Differences From
Artifact [05c1f2d6b4]:
620 620 } end;
621 621
622 622 catenate = function(...) return ... end;
623 623 };
624 624 toHTML = {
625 625 elt = elt;
626 626 tag = function(t,attrs,body)
627 - return f('<%s>%s</%s>', html_open(t,attrs), body, t)
627 + if t then
628 + return f('<%s>%s</%s>', html_open(t,attrs), body, t)
629 + else
630 + return tostring(body)
631 + end
628 632 end;
629 633 catenate = table.concat;
630 634 };
631 635 }
632 636 end
633 637
634 638 local function getBaseRenderers(procs, span_renderers)
................................................................................
977 981 return ''
978 982 elseif type(t) == 'string' then
979 983 return t
980 984 elseif type(t) == 'table' then
981 985 if t[1] then
982 986 return catenate(ss.map(flatten, t))
983 987 elseif t.tag then
984 - return tag(t.tag, t.attrs or {}, flatten(t.nodes))
988 + return tag(t.tag, t.attrs or {}, flatten(t.nodes), t.src)
985 989 elseif t.elt then
986 - return tag(t.elt, t.attrs or {})
990 + return elt(t.elt, t.attrs or {}, t.src)
987 991 end
988 992 end
989 993 end
990 994
991 995 function block_renderers.embed(b,s)
992 996 local obj
993 997 if b.rsrc
................................................................................
1161 1165 })
1162 1166 end
1163 1167 end
1164 1168
1165 1169 function block_renderers.macro(b,s)
1166 1170 local all = renderSubdoc(b.doc)
1167 1171 local cat = catenate(ss.map(flatten,all))
1168 - return tag('div', {}, cat)
1172 + return tag(nil, {}, cat)
1169 1173 end
1170 1174
1171 1175 function block_renderers.quote(b,s)
1172 1176 local ir = renderSubdoc(b.doc)
1173 1177 return tag('blockquote', b.id and {id=getSafeID(b)} or {}, catenate(ss.map(flatten,ir)))
1174 1178 end
1175 1179
................................................................................
1339 1343 end
1340 1344 if next(footnotes) and not opts.epub then
1341 1345 table.insert(ir, tagproc.toIR.tag('div',{id='cover'},''))
1342 1346 end
1343 1347
1344 1348 -- restructure passes
1345 1349 runhook('ir_restructure_pre', ir)
1350 +
1351 + -- flay empty containers
1352 + for _, sec in pairs(ir) do
1353 + if sec.tag == 'section' then
1354 + local i = 1 while i <= #sec.nodes do local v = sec.nodes[i]
1355 + if type(v) ~= 'string' and v.nodes and v.tag == nil then
1356 + table.remove(sec.nodes,i)
1357 + for j=1,#v.nodes do
1358 + table.insert(sec.nodes, i+j - 1, v.nodes[j])
1359 + end
1360 + end
1361 + i=i+1 end
1362 + end
1363 + end
1346 1364
1347 1365 ---- list insertion pass
1348 1366 local lists = {}
1349 1367 for _, sec in pairs(ir) do
1350 1368 if sec.tag == 'section' then
1351 1369 local i = 1 while i <= #sec.nodes do local v = sec.nodes[i]
1352 1370 if v.tag == 'li' then