summaryrefslogtreecommitdiff
path: root/pandoc.hs
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2015-02-18 19:57:30 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2015-02-18 21:09:07 +0000
commit70e0c4d41b94edcc611a652c2f02973aff667121 (patch)
treeaf7fb2ad9c11adb1abcb4bb46cadf65fd5a9dbf5 /pandoc.hs
parentbe943a561f9f718b60278def746ba4b024f3da85 (diff)
Update executable file
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 2290f750a..43d758c55 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
@@ -1262,17 +1264,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',