diff options
Diffstat (limited to 'scripts/fill_layout.lua')
-rwxr-xr-x | scripts/fill_layout.lua | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/scripts/fill_layout.lua b/scripts/fill_layout.lua index 34219858..94a0cd94 100755 --- a/scripts/fill_layout.lua +++ b/scripts/fill_layout.lua @@ -5,15 +5,13 @@ -- Filter the file through markdown using TOC generation in order to get header -- anchors, but ignore the actual TOC. -local name = arg[1] -local f = io.open(name, 'r') -local markdown = f:read('*a') -f:close() -local p = io.popen('markdown -f toc -T ' .. name) +local p = io.popen('markdown -f toc -T ' .. arg[1]) local html = p:read('*a'):match('^.-\n</ul>\n(.+)$') p:close() -- Fill in HTML layout (stdin) with markdown output and print the result. -local title, content = '{{ page.title }}', '{{ content }}' -io.write(io.stdin:read('*a'):gsub(title, html:match('<h%d.->([^<]+)')): - gsub(content, (html:gsub('%%', '%%%%')))) +local tags = { + ['page.title'] = html:match('<h%d.->([^<]+)'), + content = html:gsub('%%', '%%%%') +} +io.write(io.stdin:read('*a'):gsub('{{ (%S+) }}', tags)) |