#!/bin/bash set -euo pipefail if [ "$(pwd)" != "$HOME/src/zisp/html" ] then echo >&2 "Call this from within the Zisp HTML directory." 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/# //; 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 file in ../notes/*.md do name=${file#../notes/} name=${name%.md} md2ht "$file" "notes/$name.html" done shopt -s globstar for file in ../docs/**/*.md do name=${file#../docs/} name=${name%.md} dir=${file#../} dir=${dir%/*} mkdir -p "$dir" md2ht "$file" "docs/$name.html" done for file in ../docs/**/*.txt do dir=${file#../} dir=${dir%/*} mkdir -p "$dir" dest=docs/${file#../docs/} cp "$file" "$dest" done rsync -a ./ tk:/var/www/html/zisp