git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: replace setState with updateState where possible
commit84db7e492a7a7091ca366f24c21dd5d44163f0da authorAlexander Krotov <ilabdsf@gmail.com> dateWed 21 Feb 2018, 12:40 (9 years ago) parentaae362f
1 file changed+9−18
src/Text/Pandoc/Readers/Muse.hs+9−18
src/Text/Pandoc/Readers/Muse.hs+9−18
@@ -250,8 +250,7 @@ parseBlocks =
250250 rest <- parseBlocks
251251 return $ first B.<> rest
252252 listStart = do
253− st <- getState
254− setState $ st{ museInPara = False }
253+ updateState (\st -> st { museInPara = False })
255254 (first, rest) <- anyListUntil parseBlocks <|> amuseNoteBlockUntil parseBlocks
256255 return $ first B.<> rest
257256 paraStart = do
@@ -274,8 +273,7 @@ parseBlocksTill end =
274273 rest <- continuation
275274 return $ first B.<> rest
276275 listStart = do
277− st <- getState
278− setState $ st{ museInPara = False }
276+ updateState (\st -> st { museInPara = False })
279277 (first, e) <- anyListUntil ((Left <$> end) <|> (Right <$> continuation))
280278 case e of
281279 Left _ -> return first
@@ -309,8 +307,7 @@ listItemContentsUntil col pre end =
309307 (rest, e) <- parsePre <|> continuation <|> parseEnd
310308 return (first B.<> rest, e)
311309 listStart = do
312− st <- getState
313− setState $ st{ museInPara = False }
310+ updateState (\st -> st { museInPara = False })
314311 (first, e) <- anyListUntil ((Left <$> pre) <|> (Right <$> continuation) <|> (Left <$> end))
315312 case e of
316313 Left ee -> return (first, ee)
@@ -318,8 +315,7 @@ listItemContentsUntil col pre end =
318315 continuation = try $ do blank <- optionMaybe blankline
319316 skipMany blankline
320317 indentWith col
321− st <- getState
322− setState $ st{ museInPara = museInPara st && isNothing blank }
318+ updateState (\st -> st { museInPara = museInPara st && isNothing blank })
323319 listItemContentsUntil col pre end
324320
325321parseBlock :: PandocMonad m => MuseParser m (F Blocks)
@@ -331,8 +327,7 @@ parseBlock = do
331327
332328blockElements :: PandocMonad m => MuseParser m (F Blocks)
333329blockElements = do
334− st <- getState
335− setState $ st{ museInPara = False }
330+ updateState (\st -> st { museInPara = False })
336331 choice [ mempty <$ blankline
337332 , comment
338333 , separator
@@ -480,8 +475,7 @@ amuseNoteBlockUntil end = try $ do
480475 guardEnabled Ext_amuse
481476 pos <- getPosition
482477 ref <- noteMarker <* spaceChar
483− st <- getState
484− setState $ st{ museInPara = False }
478+ updateState (\st -> st { museInPara = False })
485479 (content, e) <- listItemContentsUntil (sourceColumn pos) (fail "x") end
486480 oldnotes <- museNotes <$> getState
487481 case M.lookup ref oldnotes of
@@ -541,8 +535,7 @@ bulletListItemsUntil :: PandocMonad m
541535bulletListItemsUntil indent end = try $ do
542536 char '-'
543537 void spaceChar <|> lookAhead eol
544− st <- getState
545− setState $ st{ museInPara = False }
538+ updateState (\st -> st { museInPara = False })
546539 (x, e) <- listItemContentsUntil (indent + 2) (Right <$> try (optional blankline >> indentWith indent >> bulletListItemsUntil indent end)) (Left <$> end)
547540 case e of
548541 Left ee -> return ([x], ee)
@@ -591,8 +584,7 @@ orderedListItemsUntil indent style end =
591584 continuation = try $ do
592585 pos <- getPosition
593586 void spaceChar <|> lookAhead eol
594− st <- getState
595− setState $ st{ museInPara = False }
587+ updateState (\st -> st { museInPara = False })
596588 (x, e) <- listItemContentsUntil (sourceColumn pos) (Right <$> try (optionMaybe blankline >> indentWith indent >> museOrderedListMarker style >> continuation)) (Left <$> end)
597589 case e of
598590 Left ee -> return ([x], ee)
@@ -617,8 +609,7 @@ descriptionsUntil :: PandocMonad m
617609 -> MuseParser m ([F Blocks], a)
618610descriptionsUntil indent end = do
619611 void spaceChar <|> lookAhead eol
620− st <- getState
621− setState $ st{ museInPara = False }
612+ updateState (\st -> st { museInPara = False })
622613 (x, e) <- listItemContentsUntil indent (Right <$> try (optional blankline >> indentWith indent >> manyTill spaceChar (string "::") >> descriptionsUntil indent end)) (Left <$> end)
623614 case e of
624615 Right (xs, ee) -> return (x:xs, ee)