ref: ee19f22be32c725ab41c27918de1e6240d1866fc
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