git.iko.soy/typeable/pandoc
on master help sign in
Handle Word files generated by Microsoft Word Online.

For some reason, Word in Office 365 Online uses `document2.xml` for the content, instead of `document.xml`. This causes pandoc not to be able to parse docx. This quick fix has the parser check for both `document.xml` and `document2.xml`. Addresses #5277, but a more robust solution would be to get the name of the main document dynamically (who knows whether it might change again?).

commit2b003d4a6bc2b86f94859c43c9a16ccb6da9275c authorJohn MacFarlane <jgm@berkeley.edu> dateWed 6 Feb 2019, 09:01 (8 years ago) parent59fa4eb
1 file changed+2
src/Text/Pandoc/Readers/Docx/Parse.hs+2
src/Text/Pandoc/Readers/Docx/Parse.hs+2
@@ -364,6 +364,7 @@ archiveToDocxWithWarnings archive = do
364364archiveToDocument :: Archive -> D Document
365365archiveToDocument zf = do
366366 entry <- maybeToD $ findEntryByPath "word/document.xml" zf
367+ `mplus` findEntryByPath "word/document2.xml" zf -- see #5277
367368 docElem <- maybeToD $ (parseXMLDoc . UTF8.toStringLazy . fromEntry) entry
368369 let namespaces = elemToNameSpaces docElem
369370 bodyElem <- maybeToD $ findChildByName namespaces "w" "body" docElem
@@ -478,6 +479,7 @@ archiveToComments zf =
478479
479480filePathToRelType :: FilePath -> Maybe DocumentLocation
480481filePathToRelType "word/_rels/document.xml.rels" = Just InDocument
482+filePathToRelType "word/_rels/document2.xml.rels" = Just InDocument
481483filePathToRelType "word/_rels/footnotes.xml.rels" = Just InFootnote
482484filePathToRelType "word/_rels/endnotes.xml.rels" = Just InEndnote
483485filePathToRelType _ = Nothing