git.iko.soy/typeable/pandoc
on master help sign in
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).

commitd4e5fe02b0adddbe82ed00c3aabe46b2915a1ed7 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 10 Apr 2017, 22:21 (10 years ago) parent9ac9e8d
1 file changed+3−2
src/Text/Pandoc/Writers/Docx.hs+3−2
src/Text/Pandoc/Writers/Docx.hs+3−2
@@ -231,10 +231,11 @@ writeDocx opts doc@(Pandoc meta _) = do
231231 username <- P.lookupEnv "USERNAME"
232232 utctime <- P.getCurrentTime
233233 distArchive <- (toArchive . BL.fromStrict) <$>
234− P.readDataFile datadir "reference.docx"
234+ P.readDataFile Nothing "reference.docx"
235235 refArchive <- case writerReferenceDoc opts of
236236 Just f -> toArchive <$> P.readFileLazy f
237− Nothing -> return distArchive
237+ Nothing -> (toArchive . BL.fromStrict) <$>
238+ P.readDataFile datadir "reference.docx"
238239
239240 parsedDoc <- parseXml refArchive distArchive "word/document.xml"
240241 let wname f qn = qPrefix qn == Just "w" && f (qName qn)