diff options
author | Jesse Rosenthal <jrosenthal@jhu.edu> | 2016-03-12 10:24:39 -0500 |
---|---|---|
committer | Jesse Rosenthal <jrosenthal@jhu.edu> | 2016-03-12 17:08:20 -0500 |
commit | 68fd333ec4475c5a524004bcf2e76a7959dc3afa (patch) | |
tree | 821236ac034aa7ad2bf495b65cfff066d3bfc3fa /src | |
parent | ee03e954d0d3cb76971c91001348762f55224890 (diff) | |
download | pandoc-68fd333ec4475c5a524004bcf2e76a7959dc3afa.tar.gz |
Add a general ByteStringReader with warnings.
Have docx reader use it.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index 4b2397eb9..d59ee7846 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -223,6 +223,14 @@ mkStringReaderWithWarnings r = StringReader $ \o s -> mkBSReader :: (ReaderOptions -> BL.ByteString -> Either PandocError (Pandoc, MediaBag)) -> Reader mkBSReader r = ByteStringReader (\o s -> return $ r o s) +mkBSReaderWithWarnings :: (ReaderOptions -> BL.ByteString -> Either PandocError (Pandoc, MediaBag, [String])) -> Reader +mkBSReaderWithWarnings r = ByteStringReader $ \o s -> + case r o s of + Left err -> return $ Left err + Right (doc, mediaBag, warnings) -> do + mapM_ warn warnings + return $ Right (doc, mediaBag) + -- | Association list of formats and readers. readers :: [(String, Reader)] readers = [ ("native" , StringReader $ \_ s -> return $ readNative s) @@ -243,7 +251,7 @@ readers = [ ("native" , StringReader $ \_ s -> return $ readNative s) ,("latex" , mkStringReader readLaTeX) ,("haddock" , mkStringReader readHaddock) ,("twiki" , mkStringReader readTWiki) - ,("docx" , mkBSReader readDocx) + ,("docx" , mkBSReaderWithWarnings readDocxWithWarnings) ,("odt" , mkBSReader readOdt) ,("t2t" , mkStringReader readTxt2TagsNoMacros) ,("epub" , mkBSReader readEPUB) |