From a6143ac532127d2175d9c505a1c3915a0150ca25 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Wed, 9 Sep 2020 09:39:21 -0400 Subject: Simplified and generalized documentation generation script. --- scripts/fill_layout.lua | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'scripts/fill_layout.lua') 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\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('([^<]+)')): - gsub(content, (html:gsub('%%', '%%%%')))) +local tags = { + ['page.title'] = html:match('([^<]+)'), + content = html:gsub('%%', '%%%%') +} +io.write(io.stdin:read('*a'):gsub('{{ (%S+) }}', tags)) -- cgit v1.2.3