From d2aca15f31f39ab1548ae8410932293504d0eb36 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sat, 30 Mar 2024 17:38:36 +0100 Subject: [PATCH] doc: remove the -- unescaping hack lowdown has an option to disable this behavior. use it. Change-Id: I06d4201b7f528021ddb8e94ac6baff385402e080 --- doc/manual/local.mk | 4 ++-- doc/manual/meson.build | 2 +- doc/manual/render-manpage.sh | 13 ++++--------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/doc/manual/local.mk b/doc/manual/local.mk index 8899a671d..955357607 100644 --- a/doc/manual/local.mk +++ b/doc/manual/local.mk @@ -41,11 +41,11 @@ nix-eval = $(dummy-env) $(doc_nix) eval --experimental-features nix-command -I n $(d)/nix-env-%.1: $(d)/src/command-ref/nix-env/%.md $(trace-gen) doc/manual/render-manpage.sh \ - --unescape-dashes "$(subst nix-env-,nix-env --,$$(basename "$@" .1))" 1 $^ $^.tmp $@ + --out-no-smarty "$(subst nix-env-,nix-env --,$$(basename "$@" .1))" 1 $^ $^.tmp $@ $(d)/nix-store-%.1: $(d)/src/command-ref/nix-store/%.md $(trace-gen) doc/manual/render-manpage.sh \ - --unescape-dashes "$(subst nix-store-,nix-store --,$$(basename "$@" .1))" 1 $^ $^.tmp $@ + --out-no-smarty "$(subst nix-store-,nix-store --,$$(basename "$@" .1))" 1 $^ $^.tmp $@ $(d)/%.1: $(d)/src/command-ref/%.md diff --git a/doc/manual/meson.build b/doc/manual/meson.build index e764ba70b..02b707ff3 100644 --- a/doc/manual/meson.build +++ b/doc/manual/meson.build @@ -112,7 +112,7 @@ foreach command : nix_nested_manpages custom_target( command : [ './render-manpage.sh', - '--unescape-dashes', + '--out-no-smarty', command[0] + ' --' + page, '1', '@INPUT@', diff --git a/doc/manual/render-manpage.sh b/doc/manual/render-manpage.sh index d89c29482..42f13911e 100755 --- a/doc/manual/render-manpage.sh +++ b/doc/manual/render-manpage.sh @@ -2,10 +2,10 @@ set -euo pipefail -unescape_dashes= +lowdown_args= -if [ "$1" = --unescape-dashes ]; then - unescape_dashes=yes +if [ "$1" = --out-no-smarty ]; then + lowdown_args=--out-no-smarty shift fi @@ -18,10 +18,5 @@ 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 +lowdown -sT man --nroff-nolinks $lowdown_args -M section="$section" "$tmpfile" -o "$outfile" rm "$tmpfile"