Docx writer: ensure that distArchive is the one that comes with pandoc.

Previously a `reference.docx` in `~/.pandoc` (or the user data dir)
would be used instead, and this could cause problems because a
user-modified docx sometimes lacks vital sections that we count
on the `distArchive` to supply.

Closes #4182.
This commit is contained in:
John MacFarlane 2017-12-21 21:44:13 -08:00
parent 3c10951023
commit 239cfb7f00

View file

@ -213,8 +213,12 @@ writeDocx opts doc@(Pandoc meta _) = do
let doc' = walk fixDisplayMath doc let doc' = walk fixDisplayMath doc
username <- P.lookupEnv "USERNAME" username <- P.lookupEnv "USERNAME"
utctime <- P.getCurrentTime utctime <- P.getCurrentTime
distArchive <- (toArchive . BL.fromStrict) <$> distArchive <- (toArchive . BL.fromStrict) <$> do
P.readDefaultDataFile "reference.docx" oldUserDataDir <- P.getUserDataDir
P.setUserDataDir Nothing
res <- P.readDefaultDataFile "reference.docx"
P.setUserDataDir oldUserDataDir
return res
refArchive <- case writerReferenceDoc opts of refArchive <- case writerReferenceDoc opts of
Just f -> toArchive <$> P.readFileLazy f Just f -> toArchive <$> P.readFileLazy f
Nothing -> (toArchive . BL.fromStrict) <$> Nothing -> (toArchive . BL.fromStrict) <$>