aboutsummaryrefslogtreecommitdiff
path: root/pandoc.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-03-28 12:12:48 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-03-28 12:12:48 -0700
commit6a3a04c4280817df39519bf1d73eee3b9e0b3841 (patch)
tree304a696d66d3d8cfb6f1441086947c12f2cb1cb8 /pandoc.hs
parentd744b83b61bc635419339b73b687b9280ee757fc (diff)
parentad39bc7009e320b3afb91a5683521eb1eccf0ef7 (diff)
downloadpandoc-6a3a04c4280817df39519bf1d73eee3b9e0b3841.tar.gz
Merge branch 'errortype' of https://github.com/mpickering/pandoc into mpickering-errortype
Conflicts: benchmark/benchmark-pandoc.hs src/Text/Pandoc/Readers/Markdown.hs src/Text/Pandoc/Readers/Org.hs src/Text/Pandoc/Readers/RST.hs tests/Tests/Readers/LaTeX.hs
Diffstat (limited to 'pandoc.hs')
-rw-r--r--pandoc.hs22
1 files changed, 12 insertions, 10 deletions
diff --git a/pandoc.hs b/pandoc.hs
index 804576665..9495599f0 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -72,6 +72,8 @@ import Control.Applicative ((<$>), (<|>))
import Text.Pandoc.Readers.Txt2Tags (getT2TMeta)
import Data.Monoid
+import Text.Pandoc.Error
+
type Transform = Pandoc -> Pandoc
copyrightMessage :: String
@@ -1275,17 +1277,17 @@ main = do
then 0
else tabStop)
- let handleIncludes' = if readerName' == "latex" ||
- readerName' == "latex+lhs"
+ let handleIncludes' :: String -> IO (Either PandocError String)
+ handleIncludes' = if readerName' `elem` ["latex", "latex+lhs"]
then handleIncludes
- else return
-
- (doc, media) <-
- case reader of
- StringReader r-> (, mempty) <$>
- ( readSources >=>
- handleIncludes' . convertTabs . intercalate "\n" >=>
- r readerOpts ) sources
+ else return . Right
+
+ (doc, media) <- fmap handleError $
+ case reader of
+ StringReader r-> do
+ srcs <- convertTabs . intercalate "\n" <$> readSources sources
+ doc <- handleIncludes' srcs
+ either (return . Left) (\s -> fmap (,mempty) <$> r readerOpts s) doc
ByteStringReader r -> readFiles sources >>= r readerOpts
let writerOptions = def { writerStandalone = standalone',