cortav  Diff

Differences From Artifact [ad6ab18d31]:

To Artifact [2aa6072a5d]:






1
2
3
4
5
6

7
8
9
10
11
12
13
..
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50

51
52
53
54
55
56
57




local ct = require 'cortav'
local ss = require 'sirsem'

local default_mode = {
	['render:format'] = 'html';
	['html:gen-styles'] = true;

}

local function
main(input, output, log, mode, suggestions, vars, extrule)
	local doc = ct.parse(input.stream, input.src, mode, function(c)
		                     c.doc.ext = extrule
	                     end)
................................................................................
	local render_opts = ss.kmap(function(k,v)
		return k:sub(2+#mode['render:format'])
	end, ss.kfilter(mode, function(m)
		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))

	return 0
end

local inp,outp,log = io.stdin, io.stdout, io.stderr

local function entry_cli()
	local suggestions, vars, input = default_mode, {}, {
>
>
>
>






>







 







|
<
<
<
<
|
>
|
<
<
<
<
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
..
38
39
40
41
42
43
44
45




46
47
48




49
50
51
52
53
54
55
56
-- [ʞ] cli.lua
--  ~ lexi hale <lexi@hale.su>
--  🄯 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)
	local doc = ct.parse(input.stream, input.src, mode, function(c)
		                     c.doc.ext = extrule
	                     end)
................................................................................
	local render_opts = ss.kmap(function(k,v)
		return k:sub(2+#mode['render:format'])
	end, ss.kfilter(mode, function(m)
		return ss.str.begins(m, mode['render:format']..':')
	end))

	doc.vars = vars





	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

local function entry_cli()
	local suggestions, vars, input = default_mode, {}, {