gbranden pushed a commit to branch branden-2023-03-31 in repository groff. commit 04eedeb5192d8a07345c9ce1cf7bda82f718f019 Author: Deri James <d...@chuzzlewit.myzen.co.uk> AuthorDate: Thu Mar 9 17:39:07 2023 +0000
[gropdf]: Make pdfmom more versatile. * src/devices/gropdf/pdfmom.pl: Add flag --roff which severs hardcoded link to the mom macros. * src/devices/gropdf/pdfmom.1.man: Document changes. --- ChangeLog | 8 ++++++++ src/devices/gropdf/pdfmom.1.man | 16 ++++++++++++++++ src/devices/gropdf/pdfmom.pl | 34 +++++++++++++++++++++++++++++----- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e06d54ec..0a7993a0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2023-03-14 Deri James <d...@chuzzlewit.myzen.co.uk> + + [gropdf]: Make pdfmom more versatile. + + * src/devices/gropdf/pdfmom.pl: Add flag --roff which severs + hardcoded link to the mom macros. + * src/devices/gropdf/pdfmom.1.man: Document changes. + 2023-03-13 G. Branden Robinson <g.branden.robin...@gmail.com> m4/groff.m4 (GROFF_TMAC): Eliminate garbage leading space from diff --git a/src/devices/gropdf/pdfmom.1.man b/src/devices/gropdf/pdfmom.1.man index 1b3dc014a..64176cd03 100644 --- a/src/devices/gropdf/pdfmom.1.man +++ b/src/devices/gropdf/pdfmom.1.man @@ -54,6 +54,7 @@ macro package for . .SY pdfmom .RB [ \-Tpdf ] +.RB [ \-roff ] .RI [ groff-options ] .RI [ file\~ .\|.\|.] .YS @@ -89,6 +90,21 @@ macros. . . .P +If the +.B \-roff +option is used the link to +.I mom +is severed and the wrapper can be used with other macro sets. +This is also true if the wrapper is renamed or linked as a +pseudonym, so creating a link called +.I pdfms +which targets pdfmom will create a wrapper for creating pdfs +with the +.I ms +macro. +. +. +.P .I pdfmom prints to the standard output, so output must usually be redirected to a destination file. diff --git a/src/devices/gropdf/pdfmom.pl b/src/devices/gropdf/pdfmom.pl index 89977d496..3a410d8ad 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,19 @@ my @cmd; my $dev='pdf'; my $preconv=''; my $readstdin=1; +my $mom='-mom'; +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}); @@ -73,6 +86,10 @@ while (my $c=shift) $dev=$c; next; } + elsif ($c eq '-roff' or $c eq '--roff') + { + $mom=''; + } elsif ($c eq '-v' or $c eq '--version') { print "GNU pdfmom (groff) version @VERSION@\n"; @@ -123,19 +140,26 @@ 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"); + } + else + { + system("groff -Tpdf -dPDF.EXPORT=1 -z $cmdstring 2>&1 | LC_ALL=C grep '^\\. *ds' | groff -Tpdf $preconv - $cmdstring"); + } } 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"); + 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