Skip to content

Commit 591ab49

Browse files
committed
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 <[email protected]>
1 parent 659655a commit 591ab49

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
**/*.rs.bk
33
Cargo.lock
44
.vscode
5+
**/*.html

book/Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.PHONY: all
2+
all:
3+
find src -type f -a -name '*.md' |sed 's/[.]md$$/.html/g' |xargs $(MAKE)
4+
5+
clean:
6+
find src -type f -a -name '*.html' -print0 |xargs -0 rm
7+
8+
%.html: %.md
9+
pandoc --katex --from=markdown --to=html "$<" "--output=$@"
10+
./edithtml.sh "$@" "$<"

book/edithtml.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
cat - "$1" > "$1.prefix" <<EOF
4+
<!DOCTYPE html>
5+
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
6+
<head>
7+
<meta charset="utf-8" />
8+
<meta name="generator" content="pandoc" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
10+
<title>$2</title>
11+
<style type="text/css">
12+
code{white-space: pre-wrap;}
13+
span.smallcaps{font-variant: small-caps;}
14+
span.underline{text-decoration: underline;}
15+
div.column{display: inline-block; vertical-align: top; width: 50%;}
16+
</style>
17+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">
18+
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-9Nhn55MVVN0/4OFx7EE5kpFBPsEMZxKTCnA+4fqDmg12eCTqGi6+BB2LjY8brQxJ" crossorigin="anonymous"></script>
19+
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
20+
onload="renderMathInElement(document.body);"></script>
21+
</head>
22+
<body>
23+
EOF
24+
cat "$1.prefix" - >"$1" <<EOF
25+
</body>
26+
</html>
27+
EOF
28+
rm -f "$1.prefix"

0 commit comments

Comments
 (0)