ref: bd34d60603cd062af02b0681c9e625b59f1893cd
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' } fn cfg { echo -n `''{sed 1q cfg/$1 >[2]/dev/null} } language = `{cfg language} site = `{cfg site} 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