Improve formatting of mdoc

https://github.com/jgm/pandoc/issues/9201 has been fixed, so we can now
go through 'man' instead.
This commit is contained in:
Yorhel 2023-12-15 10:12:22 +01:00
parent c39079c121
commit 660466e13b
2 changed files with 8 additions and 8 deletions

View file

@ -141,16 +141,16 @@ ${CHANGES_MD}: dat/%.md: dat/%.log mkchangelog.pl
# pandoc doesn't support mdoc directly. Going through a `mandoc -T man` tends
# to generate nicer formatting, but runs into another issue:
# https://github.com/jgm/pandoc/issues/9201
# We'll have to settle for the quote-abusing `mandoc -T markdown` with some
# post-processing and fixups.
# to generate nicer formatting than `mandoc -T markdown`, though any links
# appear to get lost. Going through `mandoc -T html` is also an option, but
# pandoc makes quite a mess of that.
${MDOC_MD}: dat/%.md: dat/%.mdoc
@echo "MDOC $*"
@(echo "% ${shell for i in ${PAGES}; do case "$$i" in "$*.mdoc "*) echo "$$i" | sed -E 's/[^ ]+ +[^ ]+ +//';; esac; done}";\
mandoc -T markdown "$<" | \
tail -n +2 | head -n -2 | \
sed -E -e 's/-&#45;/\\--/g' -e 's/&#45;/-/g' -e 's/(^|[ ,.])([a-zA-Z0-9-]+)\(([1-8])\)/\1[\2(\3)](https:\/\/manned.org\/man\/\2.\3)/g' \
mandoc -T man "$<" |\
pandoc -f man -t markdown |\
sed -E -e 's/(^|[ ,.])([a-zA-Z0-9-]+)\(([1-8])\)/\1[\2(\3)](https:\/\/manned.org\/man\/\2.\3)/g' \
-e 's/\*\*(https:[^[:space:]]+)\*\*/[\1](\1)/g' \
) >"$@"