aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-01-07 09:01:32 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-01-07 09:01:32 -0800
commit002c8ce14ca15bfbc800e9628cf09babf3d96acd (patch)
treedb86407778cf9010b11de46e36de4b2ad94e0ee6 /src/Text
parent9bd7ed7225c669b6744fbbe3e8d52cccf7f814a1 (diff)
downloadpandoc-002c8ce14ca15bfbc800e9628cf09babf3d96acd.tar.gz
Fixed small regression in docx writer.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index 25739f7c8..2a834c2da 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -30,7 +30,7 @@ Conversion of 'Pandoc' documents to docx.
-}
module Text.Pandoc.Writers.Docx ( writeDocx ) where
import Data.Maybe (fromMaybe)
-import Data.List ( intercalate, isPrefixOf )
+import Data.List ( intercalate, isPrefixOf, isSuffixOf )
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL
import qualified Data.ByteString.Lazy.Char8 as BL8
@@ -265,6 +265,7 @@ writeDocx opts doc@(Pandoc meta _) = do
webSettingsEntry <- entryFromArchive "word/webSettings.xml"
let miscRels = [ f | f <- filesInArchive refArchive
, "word/_rels/" `isPrefixOf` f
+ , ".xml.rels" `isSuffixOf` f
, f /= "word/_rels/document.xml.rels"
, f /= "word/_rels/footnotes.xml.rels" ]
miscRelEntries <- mapM entryFromArchive miscRels
@@ -815,6 +816,8 @@ br = mknode "w:r" [] [mknode "w:br" [("w:type","textWrapping")] () ]
parseXml :: Archive -> String -> IO Element
parseXml refArchive relpath =
- case (findEntryByPath relpath refArchive >>= parseXMLDoc . UTF8.toStringLazy . fromEntry) of
- Just d -> return d
+ case findEntryByPath relpath refArchive of
+ Just e -> case parseXMLDoc $ UTF8.toStringLazy $ fromEntry e of
+ Just d -> return d
+ Nothing -> fail $ relpath ++ " corrupt in reference docx"
Nothing -> fail $ relpath ++ " missing in reference docx"