Also use pandoc to convert POD files

Turns out it now supports that as well. Yay.
This commit is contained in:
Yorhel 2025-02-12 14:20:13 +01:00
parent af1f4c0dd2
commit 5acc8eee92
5 changed files with 74 additions and 91 deletions

View file

@ -9,11 +9,12 @@
# .md files because those already have a title embedded in the file.
#
# Supported file types:
# .md: Converted directly into .html with pandoc.
# .pod: Perl's Plain Old Documentation, converted through HTML into a .md
# file which is then converted into .html again with the proper template.
# .log: A ChangeLog-formatted file, converted through .md into .html.
# .mdoc / .man: manual page, converted through .md into .html.
# .md: Converted directly into .html with pandoc.
# (the types below are first converted into .md and then into .html)
# .log: A ChangeLog-style file
# .pod: Perl's Plain Old Documentation
# .mdoc: Mandoc page
# .man: Manual page
PAGES=\
"contributing.md"\
"doc.md"\
@ -165,18 +166,10 @@ ${FETCH}: dat/%:
@curl --user-agent 'YHDEV' -s ${shell for i in ${PAGES}; do case "$$i" in "$* "*) echo "$$i" | awk '{print$$2}';; esac; done} -o "$@"
# There is a 'pod2markdown' program, but going through HTML with a little bit
# of Perl magic tends to give better results, if only because definition lists
# are properly converted this way and I have more control over links.
# The final pass through perl is to fix a pandoc bug where a code block as the
# first thing inside a definition does not survive a round-trip.
${POD_MD}: dat/%.md: dat/%.pod mkpod.pl
${POD_MD}: dat/%.md: dat/%.pod
@echo "POD $*"
@cat "$<" | ./mkpod.pl |\
pandoc -f html -t markdown -s \
--metadata title="${shell for i in ${PAGES}; do case "$$i" in "$*.pod "*) echo "$$i" | sed -E 's/[^ ]+ +[^ ]+ +//';; esac; done}" |\
perl -e '$$/=undef; print (scalar(<>) =~ s/: ([^\s].*)\n ([^\s].*)/: $$1\n $$2/gr)' >"$@"
@(echo "% ${shell for i in ${PAGES}; do case "$$i" in "$*.pod "*) echo "$$i" | sed -E 's/[^ ]+ +[^ ]+ +//';; esac; done}";\
sed -E -e 's/^=encoding.+//' $< | pandoc -f pod -t markdown | ./manproc.pl pod ) >"$@"
${CHANGES_MD}: dat/%.md: dat/%.log mkchangelog.pl
@echo "MD $*"
@ -186,12 +179,12 @@ ${CHANGES_MD}: dat/%.md: dat/%.log mkchangelog.pl
${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}";\
pandoc -f mdoc -t markdown $< | ./mdocproc.pl ) >"$@"
pandoc -f mdoc -t markdown $< | ./manproc.pl mdoc ) >"$@"
${MAN_MD}: dat/%.md: dat/%.man
@echo "MAN $*"
@(echo "% ${shell for i in ${PAGES}; do case "$$i" in "$*.man "*) echo "$$i" | sed -E 's/[^ ]+ +[^ ]+ +//';; esac; done}";\
pandoc -f man -t markdown $< | ./mdocproc.pl ) >"$@"
pandoc -f man -t markdown $< | ./manproc.pl man ) >"$@"
dat/download.md: mkdlpage.pl pub/download/*.sha256