From 326d7fa8f89f9a4b74042bf4cbb04931e26c8d8d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 2 Jun 2014 20:20:16 -0700 Subject: Docx writer: Improved entryFromArchive to avoid parse. No need to parse the XML if we're just going to render it right away! --- src/Text/Pandoc/Writers/Docx.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 8aaf3c1b8..1e37b5515 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -310,8 +310,9 @@ writeDocx opts doc@(Pandoc meta _) = do let relsEntry = toEntry relsPath epochtime $ renderXml rels let entryFromArchive arch path = - (toEntry path epochtime . renderXml) `fmap` - parseXml arch distArchive path + maybe (fail $ path ++ " corrupt or missing in reference docx") + return + (findEntryByPath path arch `mplus` findEntryByPath path distArchive) docPropsAppEntry <- entryFromArchive refArchive "docProps/app.xml" themeEntry <- entryFromArchive refArchive "word/theme/theme1.xml" fontTableEntry <- entryFromArchive refArchive "word/fontTable.xml" -- cgit v1.2.3