diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2015-02-02 10:38:30 +0000 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2015-03-22 21:47:28 +0000 |
commit | 4ce6471c12d779699588deb30344aa2bfe62fd41 (patch) | |
tree | 10f4add9c7ae5dfae70c4daba9bde45d7969b43e /src/Text/Pandoc/Readers | |
parent | 9e150dd7cf7c358ddeff2fa6aae574a2a1bc953f (diff) | |
download | pandoc-4ce6471c12d779699588deb30344aa2bfe62fd41.tar.gz |
Factor out "returnState" into Parsing module
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 9 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Org.hs | 9 |
2 files changed, 2 insertions, 16 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 2d7b34607..e2f2c9268 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -81,17 +81,10 @@ readMarkdownWithWarnings :: ReaderOptions -- ^ Reader options -> (Pandoc, [String]) readMarkdownWithWarnings opts s = runMarkdown opts s (returnWarnings parseMarkdown) - -retState :: MarkdownParser a -> MarkdownParser (a, ParserState) -retState p = do - r <- p - s <- getState - return (r, s) - runMarkdown :: ReaderOptions -> String -> MarkdownParser a -> a runMarkdown opts inp p = fst res where - imd = readWithM (retState p) def{ stateOptions = opts } (inp ++ "\n\n") + imd = readWithM (returnState p) def{ stateOptions = opts } (inp ++ "\n\n") res = runReader imd s s :: ParserState s = snd $ runReader imd s diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs index b21d2cc11..457db200b 100644 --- a/src/Text/Pandoc/Readers/Org.hs +++ b/src/Text/Pandoc/Readers/Org.hs @@ -74,18 +74,11 @@ type OrgParser = ParserT [Char] OrgParserState (Reader OrgParserLocal) runOrg :: ReaderOptions -> String -> OrgParser a -> a runOrg opts inp p = fst res where - imd = readWithM (retState p) def{ orgStateOptions = opts } (inp ++ "\n\n") + imd = readWithM (returnState p) def{ orgStateOptions = opts } (inp ++ "\n\n") res = runReader imd def { finalState = s } s :: OrgParserState s = snd $ runReader imd (def { finalState = s }) -retState :: OrgParser a -> OrgParser (a, OrgParserState) -retState p = do - r <- p - s <- getState - return (r, s) - - parseOrg :: OrgParser Pandoc parseOrg = do blocks' <- parseBlocks |