From 3bea3635d69fd61caf44fe3ab48499cbbca44b13 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 3 Jan 2013 22:55:55 -0800 Subject: Changed type of 'readers' in Text.Pandoc, so all readers are in IO. Users who want pure readers can still get them; this just affects the function getReader that looks up a reader based on the format name. The point of this change is to make it possible to print warnings from the parser. --- src/Text/Pandoc.hs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index ce2b16152..18ca069d3 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -176,17 +176,17 @@ parseFormatSpec = parse formatSpec "" _ -> Set.insert ext -- | Association list of formats and readers. -readers :: [(String, ReaderOptions -> String -> Pandoc)] -readers = [("native" , \_ -> readNative) - ,("json" , \_ -> decodeJSON) - ,("markdown_strict" , readMarkdown) - ,("markdown" , readMarkdown) - ,("rst" , readRST) - ,("mediawiki" , readMediaWiki) - ,("docbook" , readDocBook) - ,("textile" , readTextile) -- TODO : textile+lhs - ,("html" , readHtml) - ,("latex" , readLaTeX) +readers :: [(String, ReaderOptions -> String -> IO Pandoc)] +readers = [("native" , \_ s -> return $ readNative s) + ,("json" , \_ s -> return $ decodeJSON s) + ,("markdown_strict" , \o s -> return $ readMarkdown o s) + ,("markdown" , \o s -> return $ readMarkdown o s) + ,("rst" , \o s -> return $ readRST o s) + ,("mediawiki" , \o s -> return $ readMediaWiki o s) + ,("docbook" , \o s -> return $ readDocBook o s) + ,("textile" , \o s -> return $ readTextile o s) -- TODO : textile+lhs + ,("html" , \o s -> return $ readHtml o s) + ,("latex" , \o s -> return $ readLaTeX o s) ] data Writer = PureStringWriter (WriterOptions -> Pandoc -> String) @@ -240,7 +240,7 @@ getDefaultExtensions "markdown_strict" = strictExtensions getDefaultExtensions _ = pandocExtensions -- | Retrieve reader based on formatSpec (format+extensions). -getReader :: String -> Either String (ReaderOptions -> String -> Pandoc) +getReader :: String -> Either String (ReaderOptions -> String -> IO Pandoc) getReader s = case parseFormatSpec s of Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e] -- cgit v1.2.3