From 60e98cdfdacc7f2973e557fc6d0b28e6f9a6b139 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Tue, 8 Sep 2020 23:11:24 -0400 Subject: Changed processing pipeline for manually generating documentation. --- scripts/fill_layout.lua | 19 +++++++++++++++++++ scripts/gen_doc.lua | 23 ----------------------- 2 files changed, 19 insertions(+), 23 deletions(-) create mode 100755 scripts/fill_layout.lua delete mode 100755 scripts/gen_doc.lua (limited to 'scripts') diff --git a/scripts/fill_layout.lua b/scripts/fill_layout.lua new file mode 100755 index 00000000..34219858 --- /dev/null +++ b/scripts/fill_layout.lua @@ -0,0 +1,19 @@ +#!/usr/bin/lua +-- Filters the given file through markdown, inserts it into the template +-- specified by stdin by replacing simple {{ variable }} tags, and outputs the +-- result to stdout. + +-- 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 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('%%', '%%%%')))) diff --git a/scripts/gen_doc.lua b/scripts/gen_doc.lua deleted file mode 100755 index fff69a12..00000000 --- a/scripts/gen_doc.lua +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/lua --- Filters the given file through markdown, replaces simple {{ variable }} --- templates, and saves the result to an HTML file of the same name for offline --- documentation generation. - --- 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 html = p:read('*a'):match('^.-\n\n(.+)$') -p:close() - --- Fill in HTML layout with markdown content. -f = io.open('../docs/_layouts/default.html') -html = f:read('*a'):gsub('{{ page.title }}', html:match('([^<]+)')): - gsub('{{ content }}', (html:gsub('%%', '%%%%'))) -f:close() - --- Write to HTML file. -io.open(name:gsub('^(.+)%.md$', '%1.html'), 'wb'):write(html):close() -- cgit v1.2.3