@@ -1,10 +1,15 @@ +-- [ʞ] cli.lua +-- ~ lexi hale +-- 🄯 AGPLv3 +-- ? simple command line driver for the cortav library local ct = require 'cortav' local ss = require 'sirsem' local default_mode = { ['render:format'] = 'html'; ['html:gen-styles'] = true; + ['groff:color'] = true; } local function main(input, output, log, mode, suggestions, vars, extrule) @@ -36,19 +41,13 @@ return ss.str.begins(m, mode['render:format']..':') end)) doc.vars = vars - - -- this is kind of gross but the context object belongs to the parser, - -- not the renderer, so that's not a suitable place for this information - doc.stage = { - kind = 'render'; - format = mode['render:format']; - mode = mode; - suggestions = suggestions; - } - output:write(ct.render[mode['render:format']](doc, render_opts)) + output:write(ct.render[mode['render:format']]( + doc, render_opts, function(stage) + stage.mode = mode + end)) return 0 end local inp,outp,log = io.stdin, io.stdout, io.stderr