From 87eb8be14348354473f7a209be91189480f29d8a Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Thu, 15 Feb 2007 01:43:12 +0000 Subject: Got rid of two unneeded 'getState's. Note that lookAhead automatically saves and restores the state. git-svn-id: https://pandoc.googlecode.com/svn/trunk@538 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/Markdown.hs | 3 +-- src/Text/Pandoc/Readers/RST.hs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 91f437372..3b2cdcdf5 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -170,12 +170,11 @@ parseMarkdown = do updateState (\state -> state { stateParseRaw = True }) -- need to parse raw HTML, since markdown allows it (title, author, date) <- option ([],[],"") titleBlock - oldState <- getState -- go through once just to get list of reference keys keysUsed <- lookAhead $ (do {manyTill (referenceKey <|> (do{anyLine; return Null})) eof; newState <- getState; return $ stateKeysUsed newState}) - setState (oldState { stateKeysUsed = keysUsed }) + updateState (\st -> st { stateKeysUsed = keysUsed }) blocks <- parseBlocks -- go through again, for real let blocks' = filter (/= Null) blocks state <- getState diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 876a7ef75..b42deb44c 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -100,12 +100,12 @@ titleTransform ((Header 1 head1):rest) = -- title, no subtitle titleTransform blocks = (blocks, []) parseRST = do - state <- getState -- first pass: get anonymous keys keyBlocks <- lookAhead $ manyTill (anonymousKey <|> (do{anyLine; return Null})) eof let anonymousKeys = filter (/= Null) keyBlocks -- run parser again to fill in anonymous links... - setState (state { stateKeyBlocks = anonymousKeys }) + updateState (\st -> st { stateKeyBlocks = anonymousKeys }) + state <- getState blocks <- parseBlocks let blocks' = filter isNotAnonKeyBlock blocks let (blocks'', title) = if stateStandalone state -- cgit v1.2.3