git.iko.soy/typeable/pandoc
on master help sign in
Add readDocxWithWarnings
ee03e95Jesse Rosenthal
src/Text/Pandoc/Readers/Docx.hs+15−6
@@ -69,7 +69,8 @@ implemented, [-] means partially implemented):
69-}
69-}
70
70
71module Text.Pandoc.Readers.Docx
71module Text.Pandoc.Readers.Docx
72+ ( readDocxWithWarnings
72− ( readDocx
73+ , readDocx
73 ) where
74 ) where
74
75
75import Codec.Archive.Zip
76import Codec.Archive.Zip
@@ -96,14 +97,22 @@ import qualified Data.Sequence as Seq (null)
96import Text.Pandoc.Error
97import Text.Pandoc.Error
97import Text.Pandoc.Compat.Except
98import Text.Pandoc.Compat.Except
98
99
100+readDocxWithWarnings :: ReaderOptions
101+ -> B.ByteString
102+ -> Either PandocError (Pandoc, MediaBag, [String])
103+readDocxWithWarnings opts bytes =
104+ case archiveToDocxWithWarnings (toArchive bytes) of
105+ Right (docx, warnings) -> do
106+ (meta, blks, mediaBag) <- docxToOutput opts docx
107+ return (Pandoc meta blks, mediaBag, warnings)
108+ Left _ -> Left (ParseFailure "couldn't parse docx file")
109+
99readDocx :: ReaderOptions
110readDocx :: ReaderOptions
100 -> B.ByteString
111 -> B.ByteString
101 -> Either PandocError (Pandoc, MediaBag)
112 -> Either PandocError (Pandoc, MediaBag)
102−readDocx opts bytes =
113+readDocx opts bytes = do
103− case archiveToDocx (toArchive bytes) of
114+ (pandoc, mediaBag, _) <- readDocxWithWarnings opts bytes
104− Right docx -> (\(meta, blks, mediaBag) -> (Pandoc meta blks, mediaBag))
115+ return (pandoc, mediaBag)
105− <$> (docxToOutput opts docx)
106− Left _ -> Left (ParseFailure "couldn't parse docx file")
107
116
108data DState = DState { docxAnchorMap :: M.Map String String
117data DState = DState { docxAnchorMap :: M.Map String String
109 , docxMediaBag :: MediaBag
118 , docxMediaBag :: MediaBag