ref: 0e2998444cd1ae8a2e5af0c7642927bbe9d98e03
dir: /bin/md2html/
#!/bin/rc -e rfork e flagfmt = ''; args = 'a.md a.html' eval `''{aux/getflags $*} || exec aux/usage if(! ~ $#* 2) exec aux/usage md = $1 html = $2 fn expand { template = $1 eval 'cat <<ENDOFTEMPLATE ' ^ `''{cat $template} ^ ' ENDOFTEMPLATE' } # Template variables # TODO: Source these from templates/env or something. language = 'en' stub = `{echo $md | sed 's@\..*$@@'} title = `{sed 's@^# @@; 1q' $stub.md} head = `''{expand templates/head.html} body = `''{bin/filter-markdown $stub.md} body = `''{expand templates/body.html} expand templates/page.html >$html.tmp mv $html.tmp $html