#!/bin/bash set -x cd $(dirname $0) git --work-tree=input --git-dir=/storage/projects/org.git checkout -f INPUTS=$(find input -name '*.org' -exec grep -l "#+PUBLISH" {} \;) readonly filter='s/#\+PUBLISH//g; ;s/\[file:([^\]]*)\.org\]/[file:$1.html]/g' mkdir -p www cp static/*.css www for input in ${INPUTS}; do output="www${input#input}" output="${output%org}html" mkdir -p $(dirname "$output") perl -pe "$filter" "$input" | pandoc -f org -s -t html5 -H static/header-ext.html -o "$output" done