970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
....
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
|
if l:sub(1,1) == '.' then l = l:sub(2) end
return {
kind = "paragraph";
spans = ct.parse_span(l, c);
}
end)
local insert_subtitle = blockwrap(function(l,c)
return {
kind = "subtitle";
spans = ct.parse_span(l:sub(3), 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
................................................................................
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_subtitle};
{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
|
|
|
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
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
1013
....
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
|
if l:sub(1,1) == '.' then l = l:sub(2) end
return {
kind = "paragraph";
spans = ct.parse_span(l, c);
}
end)
local insert_caption = blockwrap(function(l,c,j,d)
if next(d) == nil then
c:fail 'subtitle in an unlabeled section is meaningless'
end
local last = d[#d]
local me = {
kind = 'subtitle';
spans = ct.parse_span(l:sub(3):gsub("^%s+",""), c);
}
local captionable = {
quote=true, aside=true,
table=true, code=true,
embed=true, link=true,
}
if last.kind == 'label' then
me.attach = last;
elseif last.kind == 'subtitle' then
me.attach = last.attach;
elseif captionable[last.kind] then
me.kind = 'label'
me.captions = last
last.label_node = me
else
c:fail 'subtitle/attribution syntax in improper context'
end
return me
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
................................................................................
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_caption};
{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
|