Add book/Makefile for local HTML generation.

This is mainly useful for syntax checking rather than to produce good-quality output.
It assumes that pandoc is installed.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2020-12-26 15:32:09 +00:00
parent 659655a4de
commit 591ab49266
3 changed files with 39 additions and 0 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
**/*.rs.bk
Cargo.lock
.vscode
**/*.html

10
book/Makefile Normal file
View File

@ -0,0 +1,10 @@
.PHONY: all
all:
find src -type f -a -name '*.md' |sed 's/[.]md$$/.html/g' |xargs $(MAKE)
clean:
find src -type f -a -name '*.html' -print0 |xargs -0 rm
%.html: %.md
pandoc --katex --from=markdown --to=html "$<" "--output=$@"
./edithtml.sh "$@" "$<"

28
book/edithtml.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
cat - "$1" > "$1.prefix" <<EOF
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>$2</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.js" integrity="sha384-9Nhn55MVVN0/4OFx7EE5kpFBPsEMZxKTCnA+4fqDmg12eCTqGi6+BB2LjY8brQxJ" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>
</head>
<body>
EOF
cat "$1.prefix" - >"$1" <<EOF
</body>
</html>
EOF
rm -f "$1.prefix"