summaryrefslogtreecommitdiff
path: root/html/gen.sh
diff options
context:
space:
mode:
Diffstat (limited to 'html/gen.sh')
-rwxr-xr-xhtml/gen.sh31
1 files changed, 18 insertions, 13 deletions
diff --git a/html/gen.sh b/html/gen.sh
index 3ed9482..df78d25 100755
--- a/html/gen.sh
+++ b/html/gen.sh
@@ -2,24 +2,29 @@
set -euo pipefail
-if [ $# -eq 0 ]
-then
- exec find . -name \*.md -exec "$0" {} +
-fi
-
-for file
-do
- if ! [ -f "$file" ]
+md2ht() {
+ src=$1
+ dst=$2
+ if ! [ -f "$src" ]
then
- echo >&2 "File not found: $file"
+ echo >&2 "File not found: $src"
continue
fi
- echo "$file"
+ echo "$src -> $dst"
{
- title=$(sed '/^# / { s/# //; q }' "$file")
+ title=$(sed 's/# //; q' "$src")
sed "s/__TITLE__/$title/" prelude.html
echo "<body>"
- markdown2 "$file" -x fenced-code-blocks,highlightjs-lang,tables
+ markdown2 "$src" -x fenced-code-blocks,highlightjs-lang,tables
echo "</body>"
- } > "${file%.md}".html
+ } > "$dst"
+}
+
+md2ht index.md index.html
+
+for note in ../notes/*.md
+do
+ name=${note#../notes/}
+ name=${name%.md}
+ md2ht "$note" "notes/$name.html"
done