aboutsummaryrefslogtreecommitdiff
path: root/pandoc.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-03-28 12:15:09 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-03-28 12:15:09 -0700
commitb74af6762d4a3c98be741af50fd3f3ac4344bef0 (patch)
treef7d27a6338824283957213438099b6a1269e4667 /pandoc.hs
parent6f4018f8d36ce641a5a67a6dff14de99e662a08f (diff)
parent6a3a04c4280817df39519bf1d73eee3b9e0b3841 (diff)
downloadpandoc-b74af6762d4a3c98be741af50fd3f3ac4344bef0.tar.gz
Merge branch 'mpickering-errortype'
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',