aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-03-11 22:09:21 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-03-11 22:09:21 -0700
commitb7cbd7b8c91915db5b4146af53f24e82d9394e1f (patch)
tree3f9c6d6a04e3784ab72d3140fd124a82c9272978 /src
parentf7ebd5107dde7e22f1a2829f19ee72d7ffa9d14c (diff)
downloadpandoc-b7cbd7b8c91915db5b4146af53f24e82d9394e1f.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs10
1 files changed, 9 insertions, 1 deletions
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: