{-# LANGUAGE FlexibleInstances #-}
module Text.BlogLiterately.Run
(
blogLiterately
, blogLiteratelyWith
, blogLiteratelyCustom
) where
import System.Console.CmdArgs (cmdArgs)
import Text.BlogLiterately.Options (blOpts, file')
import Text.BlogLiterately.Post (postIt)
import Text.BlogLiterately.Transform (Transform, standardTransforms,
xformDoc)
blogLiterately :: IO ()
blogLiterately :: IO ()
blogLiterately = [Transform] -> IO ()
blogLiteratelyCustom [Transform]
standardTransforms
blogLiteratelyWith :: [Transform] -> IO ()
blogLiteratelyWith :: [Transform] -> IO ()
blogLiteratelyWith = [Transform] -> IO ()
blogLiteratelyCustom forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Transform]
standardTransforms forall a. [a] -> [a] -> [a]
++)
blogLiteratelyCustom :: [Transform] -> IO ()
blogLiteratelyCustom :: [Transform] -> IO ()
blogLiteratelyCustom [Transform]
ts = do
BlogLiterately
bl <- forall a. Data a => a -> IO a
cmdArgs BlogLiterately
blOpts
String
doc <- String -> IO String
readFile (BlogLiterately -> String
file' BlogLiterately
bl)
Either PandocError (BlogLiterately, String)
res <- BlogLiterately
-> [Transform]
-> String
-> IO (Either PandocError (BlogLiterately, String))
xformDoc BlogLiterately
bl [Transform]
ts String
doc
case Either PandocError (BlogLiterately, String)
res of
Left PandocError
err -> String -> IO ()
putStrLn forall a b. (a -> b) -> a -> b
$ String
"Pandoc error: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show PandocError
err
Right (BlogLiterately
bl',String
doc') -> BlogLiterately -> String -> IO ()
postIt BlogLiterately
bl' String
doc'