deri pushed a commit to branch master in repository groff. commit df1d447c99b984f9fd82f46cfc2becb2475b6d6e Author: Deri James <d...@chuzzlewit.myzen.co.uk> AuthorDate: Tue Jan 30 17:05:00 2024 +0000
New pdfmom, can now be used with all macros. Previously only useful for producing documents with mom. * src/devices/gropdf/pdfmom.pl: New --roff flag allows other macros (e.g. -ms) to be given on the command line. * src/devices/gropdf/pdfmom.1.man: Document the new facility. --- src/devices/gropdf/pdfmom.1.man | 27 +++++++++++++++++++- src/devices/gropdf/pdfmom.pl | 56 +++++++++++++++++++++++++++++++++-------- 2 files changed, 72 insertions(+), 11 deletions(-) diff --git a/src/devices/gropdf/pdfmom.1.man b/src/devices/gropdf/pdfmom.1.man index 8d60047ba..77397fded 100644 --- a/src/devices/gropdf/pdfmom.1.man +++ b/src/devices/gropdf/pdfmom.1.man @@ -10,7 +10,7 @@ macro package for .\" Legal Terms .\" ==================================================================== .\" -.\" Copyright (C) 2012-2020 Free Software Foundation, Inc. +.\" Copyright (C) 2012-2023 Free Software Foundation, Inc. .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are @@ -53,6 +53,7 @@ macro package for .\" ==================================================================== . .SY pdfmom +.RB [ \-\-roff ] .RB [ \-Tpdf ] .RI [ groff-options ] .RI [ file\~ .\|.\|.] @@ -60,6 +61,7 @@ macro package for . . .SY pdfmom +.RB [ \-\-roff ] .B \-Tps .RI [ pdfroff-options ] .RI [ groff-options ] @@ -89,6 +91,25 @@ macros. . . .P +If the +.B \-\-roff +option is used, +the wrapper can be used with macro packages other than +.MR groff_mom @MAN7EXT@ . +. +This is also true if the wrapper is renamed or linked as a +pseudonym; +for example, +creating a +.I pdfms +link pointing to the +.I pdfmom +executable makes a wrapper for producing PDFs with the +.I ms +package. +. +. +.P .I pdfmom prints to the standard output, so output must usually be redirected to a destination file. @@ -173,6 +194,10 @@ options, .I pdfmom displays its version information and exits. . +Using the +.B \-\-help +option displays a usage message and exits. +. . .\" ==================================================================== .SH Authors diff --git a/src/devices/gropdf/pdfmom.pl b/src/devices/gropdf/pdfmom.pl index 89977d496..1c24d85b9 100644 --- a/src/devices/gropdf/pdfmom.pl +++ b/src/devices/gropdf/pdfmom.pl @@ -1,6 +1,6 @@ #!@PERL@ # -# pdfmom : Frontend to run groff -mom to produce PDFs +# pdfmom : Frontend to run groff to produce PDFs # Deri James : Friday 16 Mar 2012 # @@ -29,6 +29,20 @@ my @cmd; my $dev='pdf'; my $preconv=''; my $readstdin=1; +my $mom='-mom'; +my $zflg=''; +if ($0=~m/pdf(\w+)$/) +{ + my $m=$1; + if ($m=~m/^(mom|mm|ms|me|man|mandoc)$/) + { + $mom="-".$m; + } + else + { + $mom=''; + } +} my $RT_SEP='@RT_SEP@'; $ENV{PATH}=$ENV{GROFF_BIN_PATH}.$RT_SEP.$ENV{PATH} if exists($ENV{GROFF_BIN_PATH}); @@ -68,11 +82,30 @@ while (my $c=shift) $preconv=$c; next; } - elsif ($c eq '-z' or $c eq '-Z') + elsif ($c eq '-Z') { - $dev=$c; + $zflg=$c; next; } + elsif ($c eq '-z') + { + $zflg="$c -dPDF.EXPORT=1"; + next; + } + elsif ($c eq '--roff') + { + $mom=''; + } + elsif ($c eq '--help') + { + print "usage: pdfmom [--roff] [-Tpdf] [groff-option ...] [file ...]\n"; + print "usage: pdfmom [--roff] -Tps [pdfroff-option ...] [groff-option ...] [file ...]\n"; + print "usage: pdfmom {-v | --version}\n"; + print "usage: pdfmom --help\n"; + print "\nHandle forward references in PDF documents.\n" . + "See the pdfmom(1) manual page.\n"; + exit; + } elsif ($c eq '-v' or $c eq '--version') { print "GNU pdfmom (groff) version @VERSION@\n"; @@ -123,19 +156,22 @@ if ($readstdin) if ($dev eq 'pdf') { - system("groff -Tpdf -dLABEL.REFS=1 -mom -z $cmdstring 2>&1 | LC_ALL=C grep '^\\. *ds' | groff -Tpdf -dPDF.EXPORT=1 -dLABEL.REFS=1 -mom -z - $cmdstring 2>&1 | LC_ALL=C grep '^\\. *ds' | groff -Tpdf -mom $preconv - $cmdstring"); + if ($mom) + { + system("groff -Tpdf -dLABEL.REFS=1 $mom -z $cmdstring 2>&1 | LC_ALL=C grep '^\\. *ds' | groff -Tpdf -dPDF.EXPORT=1 -dLABEL.REFS=1 $mom -z - $cmdstring 2>&1 | LC_ALL=C grep '^\\. *ds' | groff -Tpdf $mom $preconv - $cmdstring $zflg"); + } + else + { + system("groff -Tpdf -dPDF.EXPORT=1 -z $cmdstring 2>&1 | LC_ALL=C grep '^\\. *ds' | groff -Tpdf $preconv - $cmdstring $zflg"); + } } elsif ($dev eq 'ps') { - system("groff -Tpdf -dLABEL.REFS=1 -mom -z $cmdstring 2>&1 | LC_ALL=C grep '^\\. *ds' | pdfroff -mpdfmark -mom --no-toc - $preconv $cmdstring"); + system("groff -Tpdf -dLABEL.REFS=1 $mom -z $cmdstring 2>&1 | LC_ALL=C grep '^\\. *ds' | pdfroff -mpdfmark $mom --no-toc - $preconv $cmdstring"); } elsif ($dev eq '-z') # pseudo dev - just compile for warnings { - system("groff -Tpdf -mom -z $cmdstring"); -} -elsif ($dev eq '-Z') # pseudo dev - produce troff output -{ - system("groff -Tpdf -mom -Z $cmdstring"); + system("groff -Tpdf $mom -z $cmdstring"); } else { _______________________________________________ Groff-commit mailing list Groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit