commit 09b77e7f5be3313091f997aa866da88b876cdb79 (patch)
parent 4d70994cc2ec8f5d731055182f315d52377d1af3
Author: Alex Karle <alex@alexkarle.com>
Date: Sun, 25 Apr 2021 12:37:53 -0400
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).
Diffstat:
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git 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#</head>#<meta name="viewport" content="width=device-width,initial-scale=1">&# ' \
- -e 's#^<html#& lang="en"#' \
- -e '/<td class="head-vol">Miscellaneous Information Manual<\/td>/d' \
- -e 's#</body># \
-<p class="foot-license"> \
- © 2019-2021 Alex Karle | <a href="/license.html">License</a> \
-</p> \
-&#' \
- > $@
+ $(HIDE)./bin/genpost.sh < $< > $@
diff --git a/bin/genpost.sh 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#</head>#<meta name="viewport" content="width=device-width,initial-scale=1">&# ' \
+ -e 's#^<html#& lang="en"#' \
+ -e '/<td class="head-vol">Miscellaneous Information Manual<\/td>/d' \
+ -e 's#</body>#<p class="foot-license">\
+ © 2019-2021 Alex Karle | <a href="/license.html">License</a>\
+</p>\
+&#'