aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/fill_layout.lua
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2020-09-09 09:39:21 -0400
committerGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2020-09-09 09:39:21 -0400
commita6143ac532127d2175d9c505a1c3915a0150ca25 (patch)
tree0b7b032dacb9919baac2095dddc7c2f548183202 /scripts/fill_layout.lua
parenta5d626b3d3f43f791ccffadf7d5ec92648deee3c (diff)
Simplified and generalized documentation generation script.
Diffstat (limited to 'scripts/fill_layout.lua')
-rwxr-xr-xscripts/fill_layout.lua14
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))