groff-commit
[Top][All Lists]
Advanced

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

[groff] 05/14: Make pdfmom more useful.


From: Deri James
Subject: [groff] 05/14: Make pdfmom more useful.
Date: Tue, 4 Jul 2023 11:22:37 -0400 (EDT)

deri pushed a commit to branch deri-gropdf-ng
in repository groff.

commit 626e2d6802b759af40b91d03ce2e0b8791fecc81
Author: Deri James <deri@chuzzlewit.myzen.co.uk>
AuthorDate: Tue Apr 25 17:05:13 2023 +0100

    Make pdfmom more useful.
---
 src/devices/gropdf/pdfmom.1.man | 33 ++++++++++++++++++++++++++++----
 src/devices/gropdf/pdfmom.pl    | 42 ++++++++++++++++++++++++++++++++++++-----
 2 files changed, 66 insertions(+), 9 deletions(-)

diff --git a/src/devices/gropdf/pdfmom.1.man b/src/devices/gropdf/pdfmom.1.man
index 08d789c54..cea77b557 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,16 +53,18 @@ macro package for
 .\" ====================================================================
 .
 .SY pdfmom
+.RB [ \-\-roff ]
 .RB [ \-Tpdf ]
-.RI [ groff-options ]
+.RI [ groff-option\~ .\|.\|.\&]
 .RI [ file\~ .\|.\|.]
 .YS
 .
 .
 .SY pdfmom
+.RB [ \-\-roff ]
 .B \-Tps
-.RI [ pdfroff-options ]
-.RI [ groff-options ]
+.RI [ pdfroff-option\~ .\|.\|.\&]
+.RI [ groff-option\~ .\|.\|.\&]
 .RI [ file\~ .\|.\|.]
 .YS
 .
@@ -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..74591e2bb 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,18 @@ while (my $c=shift)
        $dev=$c;
        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";
+       exit;
+    }
     elsif ($c eq '-v' or $c eq '--version')
     {
        print "GNU pdfmom (groff) version @VERSION@\n";
@@ -123,19 +148,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]