fix: preserve nested Word structures and synchronize valid font families

This commit is contained in:
2026-11-05 21:54:52 +08:00
parent 0e072eed3b
commit 7f81c2015e
12 changed files with 292 additions and 28 deletions
+5 -2
View File
@@ -50,7 +50,9 @@ local function list_paragraphs(list)
for _, item in ipairs(list.content) do
-- Word numbers paragraphs, not tables. Give a table-first item its own
-- empty numbered paragraph; its following text remains a continuation.
if item[1] and item[1].t == 'Table' then
local first = item[1]
while first and (first.t == 'BlockQuote' or first.t == 'Div') do first = first.content[1] end
if first and first.t == 'Table' then
item:insert(1, pandoc.Div({pandoc.Para({pandoc.Str('\u{200b}')})},
pandoc.Attr('', {}, {['custom-style']='MDHelperSourceTableMarker'})))
end
@@ -98,7 +100,8 @@ local function contexts(blocks, target, level, depth, item_state)
elseif block.t == 'Div' then
block.content = contexts(block.content, target, level, depth, item_state)
else
if block.t == 'Header' or block.t == 'CodeBlock' or block.t == 'Table' then
if block.t == 'Header' or block.t == 'CodeBlock' or block.t == 'Table' or
(depth > 0 and (block.t == 'Para' or block.t == 'Plain')) then
local continuation = item_state and not item_state.pending and '1' or '0'
output:insert(pandoc.RawBlock('openxml', '<mdh:context xmlns:mdh="urn:mdhelper:source"' ..
' mdh:list-target="' .. target .. '" mdh:list-level="' .. math.max(0,level) ..