groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 17/33: [gropdf]: Make pdfmom more versatile.


From: G. Branden Robinson
Subject: [groff] 17/33: [gropdf]: Make pdfmom more versatile.
Date: Wed, 22 Mar 2023 22:11:45 -0400 (EDT)

gbranden pushed a commit to branch branden-post-1.23.0
in repository groff.

commit 6bd76e8345e591cc681ef460a1b3a4b6186a396c
Author: Deri James <deri@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 92f26036f..eedef7217 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-03-14  Deri James  <deri@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-14  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * tmac/tmac.am (tmac/stamp-wrap): Stop prepending groff's man(7)
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
 {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]