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