git.iko.soy/typeable/pandoc
on master help sign in
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.

commit3bea3635d69fd61caf44fe3ab48499cbbca44b13 authorJohn MacFarlane <fiddlosopher@gmail.com> dateThu 3 Jan 2013, 22:55 (14 years ago) parent7ef07ea
2 files changed+15−14
pandoc.hs+3−2 src/Text/Pandoc.hs+12−12
pandoc.hs+3−2
@@ -1016,8 +1016,9 @@ main = do
10161016 then handleIncludes
10171017 else return
10181018
1019− doc <- (reader readerOpts) `fmap` (readSources sources >>=
1020− handleIncludes' . convertTabs . intercalate "\n")
1019+ doc <- readSources sources >>=
1020+ handleIncludes' . convertTabs . intercalate "\n" >>=
1021+ reader readerOpts
10211022
10221023 let doc0 = foldr ($) doc transforms
10231024
src/Text/Pandoc.hs+12−12
@@ -176,17 +176,17 @@ parseFormatSpec = parse formatSpec ""
176176 _ -> Set.insert ext
177177
178178-- | Association list of formats and readers.
179−readers :: [(String, ReaderOptions -> String -> Pandoc)]
180−readers = [("native" , \_ -> readNative)
181− ,("json" , \_ -> decodeJSON)
182− ,("markdown_strict" , readMarkdown)
183− ,("markdown" , readMarkdown)
184− ,("rst" , readRST)
185− ,("mediawiki" , readMediaWiki)
186− ,("docbook" , readDocBook)
187− ,("textile" , readTextile) -- TODO : textile+lhs
188− ,("html" , readHtml)
189− ,("latex" , readLaTeX)
179+readers :: [(String, ReaderOptions -> String -> IO Pandoc)]
180+readers = [("native" , \_ s -> return $ readNative s)
181+ ,("json" , \_ s -> return $ decodeJSON s)
182+ ,("markdown_strict" , \o s -> return $ readMarkdown o s)
183+ ,("markdown" , \o s -> return $ readMarkdown o s)
184+ ,("rst" , \o s -> return $ readRST o s)
185+ ,("mediawiki" , \o s -> return $ readMediaWiki o s)
186+ ,("docbook" , \o s -> return $ readDocBook o s)
187+ ,("textile" , \o s -> return $ readTextile o s) -- TODO : textile+lhs
188+ ,("html" , \o s -> return $ readHtml o s)
189+ ,("latex" , \o s -> return $ readLaTeX o s)
190190 ]
191191
192192data Writer = PureStringWriter (WriterOptions -> Pandoc -> String)
@@ -240,7 +240,7 @@ getDefaultExtensions "markdown_strict" = strictExtensions
240240getDefaultExtensions _ = pandocExtensions
241241
242242-- | Retrieve reader based on formatSpec (format+extensions).
243−getReader :: String -> Either String (ReaderOptions -> String -> Pandoc)
243+getReader :: String -> Either String (ReaderOptions -> String -> IO Pandoc)
244244getReader s =
245245 case parseFormatSpec s of
246246 Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e]