From 09b77e7f5be3313091f997aa866da88b876cdb79 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Sun, 25 Apr 2021 12:37:53 -0400 Subject: [PATCH] make: Promote mandoc|sed snippet to script This is just a small cleanup of the Makefile to make it less scary. Also, as an added benefit, it means we don't have to have the HTML depend on the Makefile, just on the generation script (reducing full rebuilds for Makefile changes). --- Makefile | 13 ++----------- bin/genpost.sh | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 11 deletions(-) create mode 100755 bin/genpost.sh diff --git a/Makefile b/Makefile index fb88819..3596299 100644 --- a/Makefile +++ b/Makefile @@ -31,19 +31,10 @@ jam-tuesday/greatest-hits: $(SETS) jam-tuesday/stats.sh bin/kiosk: src/kiosk.c $(CC) $(CFLAGS) -DMANDIR="\"`pwd`\"" src/kiosk.c -o $@ -$(HTML): Makefile +$(HTML): bin/genpost.sh .SUFFIXES: .7 .html .7.html: @echo "mandoc $<" $(HIDE)mandoc -Tlint -Werror $< - $(HIDE)mandoc -Thtml -O 'man=%N.html;https://man.openbsd.org/%N.%S,style=style.css' $< \ - | sed -e 's##&# ' \ - -e 's#^Miscellaneous Information Manual<\/td>/d' \ - -e 's## \ -

\ - © 2019-2021 Alex Karle | License \ -

\ -&#' \ - > $@ + $(HIDE)./bin/genpost.sh < $< > $@ diff --git a/bin/genpost.sh b/bin/genpost.sh new file mode 100755 index 0000000..f1d547e --- /dev/null +++ b/bin/genpost.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# genpost.sh -- reads mdoc(7) from stdin, generates HTML to stdout + + +# Command Explained +# ----------------- +# man=%N.html;man.openbsd.org -- look for files in CWD for .Xr, then link to openbsd.org +# sed: +# 1. Add a viewport tag for mobile +# 2. Add lang="en" to head for accessibility +# 3. Remove Misc Info column in header (too large on mobile) +# 4. Add a footer with license info +mandoc -Thtml -O 'man=%N.html;https://man.openbsd.org/%N.%S,style=style.css' \ + | sed \ + -e 's##&# ' \ + -e 's#^Miscellaneous Information Manual<\/td>/d' \ + -e 's##

\ + © 2019-2021 Alex Karle | License\ +

\ +&#' -- libgit2 1.1.1