git.iko.soy/typeable/pandoc
on master help sign in
docx writer: avoid extra copy of abstractNum and num elements...
b7cbd7bJohn MacFarlane
src/Text/Pandoc/Writers/Docx.hs+9−1
@@ -465,7 +465,15 @@ writeDocx opts doc@(Pandoc meta _) = do
465 let numpath = "word/numbering.xml"
465 let numpath = "word/numbering.xml"
466 numbering <- parseXml refArchive distArchive numpath
466 numbering <- parseXml refArchive distArchive numpath
467 newNumElts <- mkNumbering (stLists st)
467 newNumElts <- mkNumbering (stLists st)
468+ let pandocAdded e =
469+ case findAttrBy ((== "abstractNumId") . qName) e >>= safeRead of
470+ Just numid -> numid >= (990 :: Int)
471+ Nothing ->
472+ case findAttrBy ((== "numId") . qName) e >>= safeRead of
473+ Just numid -> numid >= (1000 :: Int)
474+ Nothing -> False
468− let allElts = onlyElems (elContent numbering) ++ newNumElts
475+ let oldElts = filter (not . pandocAdded) $ onlyElems (elContent numbering)
476+ let allElts = oldElts ++ newNumElts
469 let numEntry = toEntry numpath epochtime $ renderXml numbering{ elContent =
477 let numEntry = toEntry numpath epochtime $ renderXml numbering{ elContent =
470 -- we want all the abstractNums first, then the nums,
478 -- we want all the abstractNums first, then the nums,
471 -- otherwise things break:
479 -- otherwise things break:
test/docx/golden/block_quotes.docx

Binary file not shown.

test/docx/golden/codeblock.docx

Binary file not shown.

test/docx/golden/comments.docx

Binary file not shown.

test/docx/golden/custom_style_no_reference.docx

Binary file not shown.

test/docx/golden/definition_list.docx

Binary file not shown.

test/docx/golden/document-properties-short-desc.docx

Binary file not shown.

test/docx/golden/document-properties.docx

Binary file not shown.

test/docx/golden/headers.docx

Binary file not shown.

test/docx/golden/image.docx

Binary file not shown.

test/docx/golden/inline_code.docx

Binary file not shown.

test/docx/golden/inline_formatting.docx

Binary file not shown.

test/docx/golden/inline_images.docx

Binary file not shown.

test/docx/golden/link_in_notes.docx

Binary file not shown.

test/docx/golden/links.docx

Binary file not shown.

test/docx/golden/lists.docx

Binary file not shown.

test/docx/golden/lists_continuing.docx

Binary file not shown.

test/docx/golden/lists_restarting.docx

Binary file not shown.

test/docx/golden/nested_anchors_in_header.docx

Binary file not shown.

test/docx/golden/notes.docx

Binary file not shown.

test/docx/golden/table_one_row.docx

Binary file not shown.

test/docx/golden/table_with_list_cell.docx

Binary file not shown.

test/docx/golden/tables.docx

Binary file not shown.

test/docx/golden/track_changes_deletion.docx

Binary file not shown.

test/docx/golden/track_changes_insertion.docx

Binary file not shown.

test/docx/golden/track_changes_move.docx

Binary file not shown.

test/docx/golden/unicode.docx

Binary file not shown.

test/docx/golden/verbatim_subsuper.docx

Binary file not shown.