cortav  Diff

Differences From Artifact [76257c7c34]:

To Artifact [f6f6b80f21]:


   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 insert_subtitle = blockwrap(function(l,c)
   978         -	return {
   979         -		kind = "subtitle";
   980         -		spans = ct.parse_span(l:sub(3), c);
          977  +local insert_caption = blockwrap(function(l,c,j,d)
          978  +	if next(d) == nil then
          979  +		c:fail 'subtitle in an unlabeled section is meaningless'
          980  +	end
          981  +
          982  +	local last = d[#d]
          983  +	local me = {
          984  +		kind = 'subtitle';
          985  +		spans = ct.parse_span(l:sub(3):gsub("^%s+",""), c);
          986  +	}
          987  +
          988  +	local captionable = {
          989  +		quote=true, aside=true,
          990  +		table=true, code=true,
          991  +		embed=true, link=true,
   981    992   	}
          993  +
          994  +	if last.kind == 'label' then
          995  +		me.attach = last;
          996  +	elseif last.kind == 'subtitle' then
          997  +		me.attach = last.attach;
          998  +	elseif captionable[last.kind] then
          999  +		me.kind = 'label'
         1000  +		me.captions = last
         1001  +		last.label_node = me
         1002  +	else
         1003  +		c:fail 'subtitle/attribution syntax in improper context'
         1004  +	end
         1005  +
         1006  +	return me
   982   1007   end)
   983   1008   
   984   1009   local function
   985   1010   insert_section(skind) return function(l,c,j)
   986   1011   	local depth, id, t = l:match '^([#§^]+)([^%s]*)%s*(.-)$'
   987   1012   	if id and id ~= "" then
   988   1013   		if c.doc.sections[id] then
................................................................................
  1181   1206   ct.ctlseqs = {
  1182   1207   	{seq = '.', fn = insert_paragraph};
  1183   1208   	{seq = '¶', fn = insert_paragraph};
  1184   1209   	{seq = '❡', fn = insert_paragraph};
  1185   1210   	{seq = '#', fn = insert_section()};
  1186   1211   	{seq = '§', fn = insert_section()};
  1187   1212   	{seq = '^', fn = insert_section 'namespace'};
  1188         -	{seq = '--',fn = insert_subtitle};
         1213  +	{seq = '--',fn = insert_caption};
  1189   1214   	{seq = '+', fn = insert_table_row};
  1190   1215   	{seq = '|', fn = insert_table_row};
  1191   1216   	{seq = '│', fn = insert_table_row};
  1192   1217   	{seq = '!', fn = function(l,c,j,d)
  1193   1218   		local last = d[#d]
  1194   1219   		local txt = l:match '^%s*!%s*(.-)$'
  1195   1220   		if (not last) or last.kind ~= 'aside' then