#!/bin/env bash set -e mkdir -p pub/priv rm -f res/diag/* mkdir -p res/diag cp index.md pub/index.md cp index.md pub/priv/index.md printf "\n\n" >>pub/index.md printf "\n\n" >>pub/priv/index.md export MERMAID_FILTER_FORMAT="svg" export MERMAID_FILTER_THEME="dark" export MERMAID_FILTER_BACKGROUND="transparent" export MERMAID_FILTER_LOC="res/diag" export MERMAID_FILTER_IMAGE_CLASS="mermaid" ARGS="-A common.html -F mermaid-filter --toc --css style.css -t html -s --citeproc --bibliography=bib.bib --biblatex -L ./server-katex/filter.lua" NHEAD=13 function generate_index() { pandoc --css index.css --css style.css -A common.html -t html "$1" -s -L ./server-katex/filter.lua -o "$2" & } # public declare -A all_tags declare -A all_posts for file in $(ls -1 md/*.md | sort -r); do EXTRA="-A append.html" plot="$(head -n$NHEAD "$file" | grep -m 1 plot | cut -c 7-)" [[ "$plot" = "true" ]] && EXTRA="$EXTRA -A plot.html" name="$(basename $file | cut -f 1 -d '.')" title="$(head -n$NHEAD "$file" | grep -m 1 ^title | cut -c 8-)" tags="$(head -n$NHEAD "$file" | grep -m 1 ^tags | cut -c 7-)" date="$(echo $name | rev | cut -c 4- | rev)" pubdate="$(head -n$NHEAD "$file" | grep -m 1 ^date | cut -c 6-)" author="$(head -n$NHEAD "$file" | grep -m 1 ^author | cut -c 8-)" count="$(pandoc --lua-filter wordcount.lua "$file")" if [[ "$tags" == *"essay"* ]]; then EXTRA="" fi pandoc $ARGS $EXTRA "$file" -o "pub/$name".html & post="- [$title]($name.html)" # post="$post