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
|
#!/usr/bin/env moon
import layout, subnav, autoref from require 'docs.gen.layout'
import compile from require 'discount'
export OUT, ESCAPE
slurp = (file) ->
file = io.open file, 'r'
with file\read '*all'
file\close!
spit = (file, str) ->
file = io.open file, 'w'
file\write str
file\close!
ESCAPE = (str) ->
(str\gsub '([*`])', '\\%1')
{ OUT, file } = arg
content = compile (autoref slurp file), 'githubtags', 'fencedcode'
if #arg > 2
sub = subnav [a for a in *arg[3,]]
content.body = table.concat { sub, content.body }, '\n\n'
spit OUT, layout content
|