From b7cbd7b8c91915db5b4146af53f24e82d9394e1f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 11 Mar 2019 22:09:21 -0700 Subject: 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. --- src/Text/Pandoc/Writers/Docx.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 9e6c835c6..b9a3d4d7c 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -465,7 +465,15 @@ writeDocx opts doc@(Pandoc meta _) = do let numpath = "word/numbering.xml" numbering <- parseXml refArchive distArchive numpath newNumElts <- mkNumbering (stLists st) - let allElts = onlyElems (elContent numbering) ++ newNumElts + let pandocAdded e = + case findAttrBy ((== "abstractNumId") . qName) e >>= safeRead of + Just numid -> numid >= (990 :: Int) + Nothing -> + case findAttrBy ((== "numId") . qName) e >>= safeRead of + Just numid -> numid >= (1000 :: Int) + Nothing -> False + let oldElts = filter (not . pandocAdded) $ onlyElems (elContent numbering) + let allElts = oldElts ++ newNumElts let numEntry = toEntry numpath epochtime $ renderXml numbering{ elContent = -- we want all the abstractNums first, then the nums, -- otherwise things break: -- cgit v1.2.3