git.iko.soy/typeable/pandoc
on master help sign in
Fixed small regression in docx writer.
commit002c8ce14ca15bfbc800e9628cf09babf3d96acd authorJohn MacFarlane <jgm@berkeley.edu> dateTue 7 Jan 2014, 09:01 (13 years ago) parent9bd7ed7
1 file changed+6−3
src/Text/Pandoc/Writers/Docx.hs+6−3
src/Text/Pandoc/Writers/Docx.hs+6−3
@@ -30,7 +30,7 @@ Conversion of 'Pandoc' documents to docx.
3030-}
3131module Text.Pandoc.Writers.Docx ( writeDocx ) where
3232import Data.Maybe (fromMaybe)
33−import Data.List ( intercalate, isPrefixOf )
33+import Data.List ( intercalate, isPrefixOf, isSuffixOf )
3434import qualified Data.ByteString as B
3535import qualified Data.ByteString.Lazy as BL
3636import qualified Data.ByteString.Lazy.Char8 as BL8
@@ -265,6 +265,7 @@ writeDocx opts doc@(Pandoc meta _) = do
265265 webSettingsEntry <- entryFromArchive "word/webSettings.xml"
266266 let miscRels = [ f | f <- filesInArchive refArchive
267267 , "word/_rels/" `isPrefixOf` f
268+ , ".xml.rels" `isSuffixOf` f
268269 , f /= "word/_rels/document.xml.rels"
269270 , f /= "word/_rels/footnotes.xml.rels" ]
270271 miscRelEntries <- mapM entryFromArchive miscRels
@@ -815,6 +816,8 @@ br = mknode "w:r" [] [mknode "w:br" [("w:type","textWrapping")] () ]
815816
816817parseXml :: Archive -> String -> IO Element
817818parseXml refArchive relpath =
818− case (findEntryByPath relpath refArchive >>= parseXMLDoc . UTF8.toStringLazy . fromEntry) of
819− Just d -> return d
819+ case findEntryByPath relpath refArchive of
820+ Just e -> case parseXMLDoc $ UTF8.toStringLazy $ fromEntry e of
821+ Just d -> return d
822+ Nothing -> fail $ relpath ++ " corrupt in reference docx"
820823 Nothing -> fail $ relpath ++ " missing in reference docx"