summaryrefslogtreecommitdiff
path: root/pandoc.hs
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2016-11-30 13:55:52 -0500
committerJohn MacFarlane <jgm@berkeley.edu>2017-01-25 17:07:40 +0100
commit5a02a81b43f1081aa6fb7025428f416cfd4abaa4 (patch)
tree0239e81346fea469268138642eba5d5c29e51a78 /pandoc.hs
parent3f7b3f5fd06d46c7824f482219ffa4a461f4fef2 (diff)
Have to do some work to get the mediabag out.
Diffstat (limited to 'pandoc.hs')
-rw-r--r--pandoc.hs33
1 files changed, 20 insertions, 13 deletions
diff --git a/pandoc.hs b/pandoc.hs
index 258b0c735..646ec3a0e 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -77,7 +77,9 @@ import Text.Printf (printf)
import System.Posix.Terminal (queryTerminal)
import System.Posix.IO (stdOutput)
#endif
-import Text.Pandoc.Class (runIOorExplode, PandocIO)
+import Control.Monad.Trans
+import Text.Pandoc.Class (runIOorExplode, PandocMonad, PandocIO)
+import qualified Text.Pandoc.Class as P
type Transform = Pandoc -> Pandoc
@@ -1285,11 +1287,9 @@ convertWithOpts opts args = do
else e
Right w -> return w
- reader <- if "t2t" == readerName'
- then (mkStringReader .
- readTxt2Tags) <$>
- getT2TMeta sources outputFile
- else case getReader readerName' of
+ -- TODO: we have to get the input and the output into the state for
+ -- the sake of the text2tags reader.
+ reader <- case getReader readerName' of
Right r -> return r
Left e -> err 7 e'
where e' = case readerName' of
@@ -1374,19 +1374,26 @@ convertWithOpts opts args = do
err 5 $ "Cannot write " ++ format ++ " output to stdout.\n" ++
"Specify an output file using the -o option."
- let readSources [] = mapM readSource ["-"]
- readSources srcs = mapM readSource srcs
- readSource "-" = UTF8.getContents
+ let readSource :: MonadIO m => FilePath -> m String
+ readSource "-" = liftIO UTF8.getContents
readSource src = case parseURI src of
Just u | uriScheme u `elem` ["http:","https:"] ->
readURI src
| uriScheme u == "file:" ->
- UTF8.readFile (uriPath u)
- _ -> UTF8.readFile src
+ liftIO $ UTF8.readFile (uriPath u)
+ _ -> liftIO $ UTF8.readFile src
+
+
+
+ readSources :: MonadIO m => [FilePath] -> m [String]
+ readSources [] = mapM readSource ["-"]
+ readSources srcs = mapM readSource srcs
+
+ readURI :: MonadIO m => FilePath -> m String
readURI src = do
- res <- openURL src
+ res <- liftIO $ openURL src
case res of
- Left e -> throwIO e
+ Left e -> liftIO $ throwIO e
Right (bs,_) -> return $ UTF8.toString bs
let readFiles [] = error "Cannot read archive from stdin"