summaryrefslogtreecommitdiffstats
path: root/build-aux/manconv.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 03:10:08 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 03:10:08 +0000
commit5262a872f308b3b584c97d621992fb3877e392b8 (patch)
treeb956c322376141abeafe639bd72cfecdf16954b5 /build-aux/manconv.sh
parentInitial commit. (diff)
downloadxz-utils-5262a872f308b3b584c97d621992fb3877e392b8.tar.xz
xz-utils-5262a872f308b3b584c97d621992fb3877e392b8.zip
Adding upstream version 5.6.1+really5.4.5.upstream/5.6.1+really5.4.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'build-aux/manconv.sh')
-rw-r--r--build-aux/manconv.sh58
1 files changed, 58 insertions, 0 deletions
diff --git a/build-aux/manconv.sh b/build-aux/manconv.sh
new file mode 100644
index 0000000..73e8e3b
--- /dev/null
+++ b/build-aux/manconv.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+#
+###############################################################################
+#
+# Wrapper for GNU groff to convert man pages to a few formats
+#
+# Usage: manconv.sh FORMAT [PAPER_SIZE] < in.1 > out.suffix
+#
+# FORMAT can be ascii, utf8, ps, or pdf. PAPER_SIZE can be anything that
+# groff accepts, e.g. a4 or letter. See groff_font(5). PAPER_SIZE defaults
+# to a4 and is used only when FORMAT is ps (PostScript) or pdf.
+#
+# Multiple man pages can be given at once e.g. to create a single PDF file
+# with continuous page numbering.
+#
+###############################################################################
+#
+# Author: Lasse Collin
+#
+# This file has been put into the public domain.
+# You can do whatever you want with this file.
+#
+###############################################################################
+
+FORMAT=$1
+PAPER=${2-a4}
+
+# Make PostScript and PDF output more readable:
+# - Use 11 pt font instead of the default 10 pt.
+# - Use larger paragraph spacing than the default 0.4v (man(7) only).
+FONT=11
+PD=0.8
+
+SED_PD="
+/^\\.TH /s/\$/\\
+.PD $PD/
+s/^\\.PD\$/.PD $PD/"
+
+case $FORMAT in
+ ascii)
+ groff -t -mandoc -Tascii -P-c | col -bx
+ ;;
+ utf8)
+ groff -t -mandoc -Tutf8 -P-c | col -bx
+ ;;
+ ps)
+ sed "$SED_PD" | groff -dpaper=$PAPER -t -mandoc \
+ -rC1 -rS$FONT -Tps -P-p$PAPER
+ ;;
+ pdf)
+ sed "$SED_PD" | groff -dpaper=$PAPER -t -mandoc \
+ -rC1 -rS$FONT -Tps -P-p$PAPER | ps2pdf - -
+ ;;
+ *)
+ echo 'Invalid arguments' >&2
+ exit 1
+ ;;
+esac