summaryrefslogtreecommitdiff
path: root/update-html.sh
diff options
context:
space:
mode:
Diffstat (limited to 'update-html.sh')
-rwxr-xr-xupdate-html.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/update-html.sh b/update-html.sh
new file mode 100755
index 0000000..ad27933
--- /dev/null
+++ b/update-html.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+set -euo pipefail
+
+if [ "$(pwd)" != "$HOME/src/zisp" ]
+then
+ echo >&2 "Call this from within the Zisp source root."
+ exit 1
+fi
+
+md2ht() {
+ src=$1
+ dst=$2
+ if ! [ -f "$src" ]
+ then
+ echo >&2 "File not found: $src"
+ continue
+ fi
+ echo "$src -> $dst"
+ {
+ title=$(sed 's/# //; s/&/\\&/; q' "$src")
+ sed "s/__TITLE__/$title/" html/prelude.html
+ echo "<body>"
+ markdown2 "$src" -x fenced-code-blocks,highlightjs-lang,tables
+ echo "</body>"
+ } > "$dst"
+}
+
+md2ht html/index.md html/zisp/index.html
+
+cp html/style.css html/zisp/
+
+shopt -s globstar
+
+for file in notes/*.md docs/**/*.md
+do
+ dest=html/zisp/${file%.md}.html
+ mkdir -p "${dest%/*}"
+ md2ht "$file" "$dest"
+done
+
+for file in docs/**/*.txt
+do
+ dest=html/zisp/$file
+ mkdir -p "${dest%/*}"
+ cp "$file" "$dest"
+done
+
+rsync -a html/zisp tk:/var/www/html