cortav  Diff

Differences From Artifact [1054336dd5]:

To Artifact [06fed19c69]:


116
117
118
119
120
121
122

123
124
125
126
127
128
129
...
159
160
161
162
163
164
165





166
167
168
169
170
171
172
173
174





175
176
177
178
179
180
181
182
...
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
...
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
...
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977

978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
....
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027

1028

1029
1030

1031

1032
1033
1034
1035
1036
1037
1038
1039
1040

1041
1042
1043
1044
1045

1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
....
1155
1156
1157
1158
1159
1160
1161
1162
1163

1164
1165
1166
1167
1168
1169
1170
			new.generation = old.generation + 1
		else
			new.generation = 1
		end
	end;
	fns = {
		fail = function(self, msg, ...)

			ct.exns.tx(msg, self.src.file, self.line or 0, ...):throw()
		end;
		insert = function(self, block)
			block.origin = self:clone()
			table.insert(self.sec.blocks,block)
			return block
		end;
................................................................................
					if sec then
						local rid = sec.refs[id]
						if rid then
							return rid, id, sec
						end
					end






					for _, i in ipairs(sec.imports) do
						local rr, ri, rs = checkFromSec(i, doc)
						if ri then return rr, ri, rs end
					end

					if doc.sections[id] then
						return nil, id, doc.sections[id]
					end






					for _, i in ipairs(doc.globals) do
						local rr, ri, rs = checkFromSec(i, doc)
						if ri then return rr, ri, rs end
					end
				else
					local secid, ref = string.match(id, "(.-)%.(.+)")
					local s
					s = s or doc.sections[secid]
................................................................................
}

ct.sec = declare {
	ident = 'section';
	mk = function() return {
		blocks = {};
		refs = {};
		imports = {};
		depth = 0;
		kind = 'ordinary';
	} end;
	construct = function(self, id, depth)
		self.id = id
		self.depth = depth or self.depth
	end;
................................................................................
			nctx.line = ctx.line
			nctx.docDepth = (ctx.docDepth or 0) + ctx.sec.depth - 1
			return newdoc, nctx
		end;
	};
	mk = function(...) return {
		sections = {};
		globals = {};
		secorder = {};
		embed = {};
		meta = {};
		vars = {};
		parents = {...};
		ext = {
			inhibit = {};
................................................................................
	if l:sub(1,1) == '.' then l = l:sub(2) end
	return {
		kind = "paragraph";
		spans = ct.parse_span(l, c);
	}
end)

local insert_section = function(l,c,j)
	local depth, id, t = l:match '^([#§]+)([^%s]*)%s*(.-)$'
	if id and id ~= "" then
		if c.doc.sections[id] then
			c:fail('duplicate section name “%s”', id)
		end
	else id = nil end

	local s = c.doc:mksec(id, utf8.len(depth))
	s.depth = utf8.len(depth)
	s.origin = c:clone()
	s.blocks={}


	if t and t ~= "" then
		local heading = {
			kind = "label";
			spans = ct.parse_span(t,c);
			origin = s.origin;
			captions = s;
		}
		c.doc.docjob:hook('meddle_span', heading.spans, heading)
		table.insert(s.blocks, heading)
		s.heading_node = heading
	end
	c.sec = s

	j:hook('section_attach', c, s)
end

local dsetmeta = function(w,c,j)
	local key, val = w(1)
	c.doc.meta[key] = val
	j:hook('metadata_set', key, val)
end
local dextctl = function(w,c)
................................................................................
	license = dsetmeta;
	keywords = dsetmeta;
	desc = dsetmeta;
	when = dcond;
	unless = dcond;
	with = function(w,c)
		local _,str = w(2)
		local aka, name = str:match '^([^=])=(.*)$'
		if aka == nil then name=str aka=name end


		local o,id,s = c:ref(name)

		if o then -- import object
			c.sec.import.objs[aka] = o

		else -- import scope

			table.insert(c.sec.import.scope, s)
		end
	end;
	global = function(w,c)
		local _,str = w(2)
		if str ~= nil and str ~= '' then
			local aka, name = str:match '^([^=])=(.*)$'
			if aka == nil then name=str aka=name end


			local o,id,s = c:ref(name)

			if o then
				c.doc.globals.objs[aka] = name
			else

				table.insert(c.doc.globals, s)
			end
		else
			table.insert(c.doc.globals, c.sec)
		end
	end;
	pragma = function(w,c)
	end;
	lang = function(w,c)
		local _, op, l = w(2)
		local langstack = c.doc.stage.langstack
................................................................................
	end)
end

ct.ctlseqs = {
	{seq = '.', fn = insert_paragraph};
	{seq = '¶', fn = insert_paragraph};
	{seq = '❡', fn = insert_paragraph};
	{seq = '#', fn = insert_section};
	{seq = '§', fn = insert_section};

	{seq = '+', fn = insert_table_row};
	{seq = '|', fn = insert_table_row};
	{seq = '│', fn = insert_table_row};
	{seq = '!', fn = function(l,c,j,d)
		local last = d[#d]
		local txt = l:match '^%s*!%s*(.-)$'
		if (not last) or last.kind ~= 'aside' then







>







 







>
>
>
>
>
|








>
>
>
>
>
|







 







|







 







|







 







|
|









|
>

|













|







 







|
<

>

>

<
>

>
|






<

>



|

>
|


|







 







|
|
>







116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
...
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
...
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
...
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
...
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
....
1030
1031
1032
1033
1034
1035
1036
1037

1038
1039
1040
1041
1042

1043
1044
1045
1046
1047
1048
1049
1050
1051
1052

1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
....
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
			new.generation = old.generation + 1
		else
			new.generation = 1
		end
	end;
	fns = {
		fail = function(self, msg, ...)
			--error(string.format(msg,...))
			ct.exns.tx(msg, self.src.file, self.line or 0, ...):throw()
		end;
		insert = function(self, block)
			block.origin = self:clone()
			table.insert(self.sec.blocks,block)
			return block
		end;
................................................................................
					if sec then
						local rid = sec.refs[id]
						if rid then
							return rid, id, sec
						end
					end

					if sec.imports.objs[id] then
						local ol = sec.imports.objs[id]
						return ol.obj, id, ol.sec
					end

					for _, i in ipairs(sec.imports.scope) do
						local rr, ri, rs = checkFromSec(i, doc)
						if ri then return rr, ri, rs end
					end

					if doc.sections[id] then
						return nil, id, doc.sections[id]
					end

					if doc.globals.objs[id] then
						local ol = doc.globals.objs[id]
						return ol.obj, id, ol.sec
					end

					for _, i in ipairs(doc.globals.scope) do
						local rr, ri, rs = checkFromSec(i, doc)
						if ri then return rr, ri, rs end
					end
				else
					local secid, ref = string.match(id, "(.-)%.(.+)")
					local s
					s = s or doc.sections[secid]
................................................................................
}

ct.sec = declare {
	ident = 'section';
	mk = function() return {
		blocks = {};
		refs = {};
		imports = {scope={}, objs={}};
		depth = 0;
		kind = 'ordinary';
	} end;
	construct = function(self, id, depth)
		self.id = id
		self.depth = depth or self.depth
	end;
................................................................................
			nctx.line = ctx.line
			nctx.docDepth = (ctx.docDepth or 0) + ctx.sec.depth - 1
			return newdoc, nctx
		end;
	};
	mk = function(...) return {
		sections = {};
		globals = {objs={},scope={}};
		secorder = {};
		embed = {};
		meta = {};
		vars = {};
		parents = {...};
		ext = {
			inhibit = {};
................................................................................
	if l:sub(1,1) == '.' then l = l:sub(2) end
	return {
		kind = "paragraph";
		spans = ct.parse_span(l, c);
	}
end)

local function insert_section(skind) return function(l,c,j)
	local depth, id, t = l:match '^([#§^]+)([^%s]*)%s*(.-)$'
	if id and id ~= "" then
		if c.doc.sections[id] then
			c:fail('duplicate section name “%s”', id)
		end
	else id = nil end

	local s = c.doc:mksec(id, utf8.len(depth))
	s.depth = utf8.len(depth)
	s.origin = c:clone()
	s.blocks = {}
	if skind then s.kind = skind end

	if skind ~= "namespace" and t and t ~= "" then
		local heading = {
			kind = "label";
			spans = ct.parse_span(t,c);
			origin = s.origin;
			captions = s;
		}
		c.doc.docjob:hook('meddle_span', heading.spans, heading)
		table.insert(s.blocks, heading)
		s.heading_node = heading
	end
	c.sec = s

	j:hook('section_attach', c, s)
end end

local dsetmeta = function(w,c,j)
	local key, val = w(1)
	c.doc.meta[key] = val
	j:hook('metadata_set', key, val)
end
local dextctl = function(w,c)
................................................................................
	license = dsetmeta;
	keywords = dsetmeta;
	desc = dsetmeta;
	when = dcond;
	unless = dcond;
	with = function(w,c)
		local _,str = w(2)
		local aka, name = str:match '^([^=]+)=(.+)$'


		if aka == nil then name=str end
		local o,id,s = c:ref(name)

		if o then -- import object

			c.sec.imports.objs[aka or name] = {obj=o, sec=s}
		else -- import scope
			if aka ~= nil then c:fail'alias is meaningless for scope import' end
			table.insert(c.sec.imports.scope, s)
		end
	end;
	global = function(w,c)
		local _,str = w(2)
		if str ~= nil and str ~= '' then
			local aka, name = str:match '^([^=])=(.*)$'


			if aka == nil then name=str end
			local o,id,s = c:ref(name)

			if o then
				c.doc.globals.objs[aka or name] = {obj=o, sec=s}
			else
				if aka ~= nil then c:fail'alias is meaningless for scope import' end
				table.insert(c.doc.globals.scope, s)
			end
		else
			table.insert(c.doc.globals.scope, c.sec)
		end
	end;
	pragma = function(w,c)
	end;
	lang = function(w,c)
		local _, op, l = w(2)
		local langstack = c.doc.stage.langstack
................................................................................
	end)
end

ct.ctlseqs = {
	{seq = '.', fn = insert_paragraph};
	{seq = '¶', fn = insert_paragraph};
	{seq = '❡', fn = insert_paragraph};
	{seq = '#', fn = insert_section()};
	{seq = '§', fn = insert_section()};
	{seq = '^', fn = insert_section 'namespace'};
	{seq = '+', fn = insert_table_row};
	{seq = '|', fn = insert_table_row};
	{seq = '│', fn = insert_table_row};
	{seq = '!', fn = function(l,c,j,d)
		local last = d[#d]
		local txt = l:match '^%s*!%s*(.-)$'
		if (not last) or last.kind ~= 'aside' then