aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-04-10 22:21:11 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-04-10 23:59:32 +0200
commitd4e5fe02b0adddbe82ed00c3aabe46b2915a1ed7 (patch)
tree7014315e387ccf035de9af34ddcf632623e516c9 /src/Text
parent9ac9e8d278d073ec63aa5ee6e9cb0d8830219cc9 (diff)
downloadpandoc-d4e5fe02b0adddbe82ed00c3aabe46b2915a1ed7.tar.gz
Docx writer: don't take "distArchive" from datadir.
The docx writer takes components from the distribution's version of reference.docx when it can't find them in a user's custom reference.docx. (This sometimes happens because Word will sometimes omit components needed for larger documents when saving a simple one.) Previously, we allowed a reference.docx in the data directory (e.g. `~/.pandoc`) to be used as the distribution's reference.docx. This led to a bizarre situation where pandoc would produce a good docx using `--template ~/.pandoc/ref.docx`, but if `ref.docx` were moved to `~/.pandoc/reference.docx`, it would then produce a corrupted docx. Closes #3322 (I think).
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index fcc8551a4..fddec91cc 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -231,10 +231,11 @@ writeDocx opts doc@(Pandoc meta _) = do
username <- P.lookupEnv "USERNAME"
utctime <- P.getCurrentTime
distArchive <- (toArchive . BL.fromStrict) <$>
- P.readDataFile datadir "reference.docx"
+ P.readDataFile Nothing "reference.docx"
refArchive <- case writerReferenceDoc opts of
Just f -> toArchive <$> P.readFileLazy f
- Nothing -> return distArchive
+ Nothing -> (toArchive . BL.fromStrict) <$>
+ P.readDataFile datadir "reference.docx"
parsedDoc <- parseXml refArchive distArchive "word/document.xml"
let wname f qn = qPrefix qn == Just "w" && f (qName qn)