~kvik/ugh

ref: bd34d60603cd062af02b0681c9e625b59f1893cd ugh/bin/md2html -rwxr-xr-x 600 bytes
bd34d606kvik Revert accidental change 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/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