git.iko.soy/typeable/pandoc
on master help sign in
docx writer: avoid extra copy of abstractNum and num elements...

...in numbering.xml. This caused pandoc-produced docx files to be uneditable using Word Online. The problem was that recent versions of reference.docx include samples of various kinds of text, including lists. The numering elements for these were getting copied over to the new docx, where they clashed with the autogenerated elements produced by pandoc. This didn't confuse Desktop Word, but it did confuse Word Online. Closes #5358.

commitb7cbd7b8c91915db5b4146af53f24e82d9394e1f authorJohn MacFarlane <jgm@berkeley.edu> dateMon 11 Mar 2019, 22:09 (8 years ago) parentf7ebd51
28 files changed+9−1
src/Text/Pandoc/Writers/Docx.hs+9−1 test/docx/golden/block_quotes.docx test/docx/golden/codeblock.docx test/docx/golden/comments.docx test/docx/golden/custom_style_no_reference.docx test/docx/golden/definition_list.docx test/docx/golden/document-properties-short-desc.docx test/docx/golden/document-properties.docx test/docx/golden/headers.docx test/docx/golden/image.docx test/docx/golden/inline_code.docx test/docx/golden/inline_formatting.docx test/docx/golden/inline_images.docx test/docx/golden/link_in_notes.docx test/docx/golden/links.docx test/docx/golden/lists.docx test/docx/golden/lists_continuing.docx test/docx/golden/lists_restarting.docx test/docx/golden/nested_anchors_in_header.docx test/docx/golden/notes.docx test/docx/golden/table_one_row.docx test/docx/golden/table_with_list_cell.docx test/docx/golden/tables.docx test/docx/golden/track_changes_deletion.docx test/docx/golden/track_changes_insertion.docx test/docx/golden/track_changes_move.docx test/docx/golden/unicode.docx test/docx/golden/verbatim_subsuper.docx
src/Text/Pandoc/Writers/Docx.hs+9−1
@@ -465,7 +465,15 @@ writeDocx opts doc@(Pandoc meta _) = do
465465 let numpath = "word/numbering.xml"
466466 numbering <- parseXml refArchive distArchive numpath
467467 newNumElts <- mkNumbering (stLists st)
468− let allElts = onlyElems (elContent numbering) ++ newNumElts
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
475+ let oldElts = filter (not . pandocAdded) $ onlyElems (elContent numbering)
476+ let allElts = oldElts ++ newNumElts
469477 let numEntry = toEntry numpath epochtime $ renderXml numbering{ elContent =
470478 -- we want all the abstractNums first, then the nums,
471479 -- 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.