diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-03 22:55:55 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-03 22:55:55 -0800 |
commit | 3bea3635d69fd61caf44fe3ab48499cbbca44b13 (patch) | |
tree | 11c13467ddd81c31dadcc5d0fc9474b848fb649a /src/Text | |
parent | 7ef07ea3fc89a33210cbf92c6bb3a3f553a3f174 (diff) | |
download | pandoc-3bea3635d69fd61caf44fe3ab48499cbbca44b13.tar.gz |
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.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc.hs | 24 |
1 files changed, 12 insertions, 12 deletions
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] |