#!/bin/bash set -euo pipefail md2ht() { src=$1 dst=$2 if ! [ -f "$src" ] then echo >&2 "File not found: $src" continue fi echo "$src -> $dst" { title=$(sed 's/# //; q' "$src") sed "s/__TITLE__/$title/" prelude.html echo "" markdown2 "$src" -x fenced-code-blocks,highlightjs-lang,tables echo "" } > "$dst" } md2ht index.md index.html for note in ../notes/*.md do name=${note#../notes/} name=${name%.md} md2ht "$note" "notes/$name.html" done