summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDeri James <deri@chuzzlewit.myzen.co.uk>2023-03-09 17:39:07 +0000
committerDeri James <deri@chuzzlewit.myzen.co.uk>2023-03-09 17:39:07 +0000
commit0290924f05f823039c546f5b14422af7eef70644 (patch)
treeedb8d7b220a98d5aa9d357e947c54725da9a86b3 /src
parent5848bf3a3ee43a8be529d5d8bcef7a80c1ef3934 (diff)
downloadgroff-git-0290924f05f823039c546f5b14422af7eef70644.tar.gz
Make pdfmom more versatile.
* src/devices/gropdf/pdfmom.pl: Add flag -roff which severs hardcoded link to the mom macros. * src/devices/gropdf/pdfmom.pl: Document changes.
Diffstat (limited to 'src')
-rw-r--r--src/devices/gropdf/pdfmom.1.man16
-rw-r--r--src/devices/gropdf/pdfmom.pl34
2 files changed, 45 insertions, 5 deletions
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
{