aboutsummaryrefslogtreecommitdiff
path: root/doc/manual/render-manpage.sh
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-29 20:06:55 +0100
committereldritch horrors <pennae@lix.systems>2024-03-30 14:26:47 +0000
commit65d544b1a631a139c369387618adbb2fe2fe9e1f (patch)
treed49ebbdbf8de003cd89e3fb97085cf1e4900725f /doc/manual/render-manpage.sh
parenta4f5bb951dbc6fa4ffa2bb56376b38f38b6e9154 (diff)
build: extract make "functions" into scripts
we'll want to use these for the meson builds, and probably eventually rewrite them in something that isn't plain shell. diffoscope confirms that out/share and doc/share are equal before and after these changes Change-Id: I49aa418fc8615cad86d67328e08c28a7405ec952
Diffstat (limited to 'doc/manual/render-manpage.sh')
-rwxr-xr-xdoc/manual/render-manpage.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/manual/render-manpage.sh b/doc/manual/render-manpage.sh
new file mode 100755
index 000000000..d89c29482
--- /dev/null
+++ b/doc/manual/render-manpage.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+set -euo pipefail
+
+unescape_dashes=
+
+if [ "$1" = --unescape-dashes ]; then
+ unescape_dashes=yes
+ shift
+fi
+
+title="$1"
+section="$2"
+infile="$3"
+tmpfile="$4"
+outfile="$5"
+
+printf "Title: %s\n\n" "$title" > "$tmpfile"
+cat "$infile" >> "$tmpfile"
+"$(dirname "$0")"/process-includes.sh "$infile" "$tmpfile"
+lowdown -sT man --nroff-nolinks -M section="$section" "$tmpfile" -o "$outfile"
+if [ -n "$unescape_dashes" ]; then
+ # fix up `lowdown`'s automatic escaping of `--`
+ # https://github.com/kristapsdz/lowdown/blob/edca6ce6d5336efb147321a43c47a698de41bb7c/entity.c#L202
+ sed -i 's/\e\[u2013\]/--/' "$outfile"
+fi
+rm "$tmpfile"