Differences From
Artifact [a5e2ed074c]:
635 635 -- objects, including ones that users have not assigned IDs
636 636 -- to, and objects with the same name in different unlabeled
637 637 -- sections. to handle this, we provide a "namespace" mechanism,
638 638 -- where some lua table (really its address in memory) is used
639 639 -- as a handle for the object and a unique ID is attached to it.
640 640 -- if the object has an ID of its own, it is guaranteed to be
641 641 -- unique and returned; otherwise, a generic id of the form
642 --- `x-%u` is generated, where %u is an integer that incrementsfile:///home/lexi/dev/cortav/build/cortav.html
642 +-- `x-%u` is generated, where %u is an integer that increments
643 643 -- for every new object
644 644 local ids = {}
645 645 local canonicalID = {}
646 646 return function(obj,pfx)
647 647 pfx = pfx or ''
648 648 if canonicalID[obj] then
649 649 return canonicalID[obj]
................................................................................
970 970 if l:sub(1,1) == '.' then l = l:sub(2) end
971 971 return {
972 972 kind = "paragraph";
973 973 spans = ct.parse_span(l, c);
974 974 }
975 975 end)
976 976
977 -local function insert_section(skind) return function(l,c,j)
977 +local insert_subtitle = blockwrap(function(l,c)
978 + return {
979 + kind = "subtitle";
980 + spans = ct.parse_span(l:sub(3), c);
981 + }
982 +end)
983 +
984 +local function
985 +insert_section(skind) return function(l,c,j)
978 986 local depth, id, t = l:match '^([#§^]+)([^%s]*)%s*(.-)$'
979 987 if id and id ~= "" then
980 988 if c.doc.sections[id] then
981 989 c:fail('duplicate section name “%s”', id)
982 990 end
983 991 else id = nil end
984 992
................................................................................
1173 1181 ct.ctlseqs = {
1174 1182 {seq = '.', fn = insert_paragraph};
1175 1183 {seq = '¶', fn = insert_paragraph};
1176 1184 {seq = '❡', fn = insert_paragraph};
1177 1185 {seq = '#', fn = insert_section()};
1178 1186 {seq = '§', fn = insert_section()};
1179 1187 {seq = '^', fn = insert_section 'namespace'};
1188 + {seq = '--',fn = insert_subtitle};
1180 1189 {seq = '+', fn = insert_table_row};
1181 1190 {seq = '|', fn = insert_table_row};
1182 1191 {seq = '│', fn = insert_table_row};
1183 1192 {seq = '!', fn = function(l,c,j,d)
1184 1193 local last = d[#d]
1185 1194 local txt = l:match '^%s*!%s*(.-)$'
1186 1195 if (not last) or last.kind ~= 'aside' then