Experiment with mdoc formatting for torreas man page
Potentially more projects to follow.
This commit is contained in:
parent
4c6e5346e7
commit
b9f55ade45
3 changed files with 24 additions and 5 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -25,7 +25,7 @@ dat/nginx-confgen/man.pod
|
||||||
dat/torreas/changes.log
|
dat/torreas/changes.log
|
||||||
dat/torreas/changes.md
|
dat/torreas/changes.md
|
||||||
dat/torreas/man.md
|
dat/torreas/man.md
|
||||||
dat/torreas/man.pod
|
dat/torreas/man.mdoc
|
||||||
dat/tuwf/changes.log
|
dat/tuwf/changes.log
|
||||||
dat/tuwf/changes.md
|
dat/tuwf/changes.md
|
||||||
dat/tuwf/man.md
|
dat/tuwf/man.md
|
||||||
|
|
|
||||||
24
Makefile
24
Makefile
|
|
@ -70,7 +70,7 @@ PAGES=\
|
||||||
"yxml/man.md https://g.blicky.net/yxml.git/plain/yxml.md"\
|
"yxml/man.md https://g.blicky.net/yxml.git/plain/yxml.md"\
|
||||||
"torreas.md"\
|
"torreas.md"\
|
||||||
"torreas/changes.log https://g.blicky.net/torreas.git/plain/ChangeLog Torreas Release History"\
|
"torreas/changes.log https://g.blicky.net/torreas.git/plain/ChangeLog Torreas Release History"\
|
||||||
"torreas/man.pod https://g.blicky.net/torreas.git/plain/torreas.pod Torreas Manual"
|
"torreas/man.mdoc https://g.blicky.net/torreas.git/plain/torreas.1 Torreas Manual"
|
||||||
|
|
||||||
|
|
||||||
# Files generated by mkfeed.pl
|
# Files generated by mkfeed.pl
|
||||||
|
|
@ -97,8 +97,11 @@ POD_MD := $(shell for i in ${PAGES}; do echo "$$i" | grep -Eo '^[^ ]+\.pod'
|
||||||
# List of .md files generated from .log files
|
# List of .md files generated from .log files
|
||||||
CHANGES_MD := $(shell for i in ${PAGES}; do echo "$$i" | grep -Eo '^[^ ]+\.log' | sed -E 's/(.+)\.log$$/dat\/\1.md/'; done)
|
CHANGES_MD := $(shell for i in ${PAGES}; do echo "$$i" | grep -Eo '^[^ ]+\.log' | sed -E 's/(.+)\.log$$/dat\/\1.md/'; done)
|
||||||
|
|
||||||
|
# List of .md files generated from .mdoc files
|
||||||
|
MDOC_MD := $(shell for i in ${PAGES}; do echo "$$i" | grep -Eo '^[^ ]+\.mdoc' | sed -E 's/(.+)\.mdoc$$/dat\/\1.md/'; done)
|
||||||
|
|
||||||
# All fetched & generated files
|
# All fetched & generated files
|
||||||
CLEAN := ${FETCH} ${POD_MD} ${CHANGES_MD} ${HTML_OUT} ${FEEDS}
|
CLEAN := ${FETCH} ${POD_MD} ${CHANGES_MD} ${MDOC_MD} ${HTML_OUT} ${FEEDS}
|
||||||
|
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
@ -136,13 +139,26 @@ ${CHANGES_MD}: dat/%.md: dat/%.log mkchangelog.pl
|
||||||
@./mkchangelog.pl "$*" "${shell for i in ${PAGES}; do case "$$i" in "$*.log "*) echo "$$i" | sed -E 's/[^ ]+ +[^ ]+ +//';; esac; done}" <"$<" >"$@"
|
@./mkchangelog.pl "$*" "${shell for i in ${PAGES}; do case "$$i" in "$*.log "*) echo "$$i" | sed -E 's/[^ ]+ +[^ ]+ +//';; esac; done}" <"$<" >"$@"
|
||||||
|
|
||||||
|
|
||||||
# TODO: Add --strip-comments to pandoc when I have a version that supports it.
|
# 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.
|
||||||
|
${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/--/\\--/g' -e 's/-/-/g' -e 's/(^|[ ,.])([a-zA-Z0-9-]+)\(([1-8])\)/\1[\2(\3)](https:\/\/manned.org\/man\/\2.\3)/g' \
|
||||||
|
) >"$@"
|
||||||
|
|
||||||
|
|
||||||
${HTML_OUT}: pub/%.html: dat/%.md template.html
|
${HTML_OUT}: pub/%.html: dat/%.md template.html
|
||||||
@echo "HTML $*"
|
@echo "HTML $*"
|
||||||
@mkdir -p $$(dirname "$@")
|
@mkdir -p $$(dirname "$@")
|
||||||
@cat "$<" |\
|
@cat "$<" |\
|
||||||
./dllink.pl |\
|
./dllink.pl |\
|
||||||
pandoc -f markdown -t html5 --template template.html \
|
pandoc -f markdown -t html5 --strip-comments --template template.html \
|
||||||
--metadata path1=$$(echo "$*" | sed 's/\/.*//') \
|
--metadata path1=$$(echo "$*" | sed 's/\/.*//') \
|
||||||
--metadata path2=$$(echo "$*" | sed 's/\//-/' | sed 's/\/.*//') \
|
--metadata path2=$$(echo "$*" | sed 's/\//-/' | sed 's/\/.*//') \
|
||||||
--metadata path3=$$(echo "$*" | sed 's/\//-/g') \
|
--metadata path3=$$(echo "$*" | sed 's/\//-/g') \
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
This is the source code of the site running at [dev.yorhel.nl](https://dev.yorhel.nl/).
|
||||||
|
|
||||||
# Requirements
|
# Requirements
|
||||||
|
|
||||||
Build-time:
|
Build-time:
|
||||||
|
|
@ -7,3 +9,4 @@ Build-time:
|
||||||
- Perl (+ Pod::Simple)
|
- Perl (+ Pod::Simple)
|
||||||
- TUWF
|
- TUWF
|
||||||
- pandoc
|
- pandoc
|
||||||
|
- mandoc
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue