ref: 0f2ddfa2e4d8bbc1200fbb35e5006b375c4dbd56
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} if(! ~ $#site 0) title = $site — $title 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