summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-02-21 12:40:37 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-02-21 12:40:37 +0300
commit84db7e492a7a7091ca366f24c21dd5d44163f0da (patch)
tree841778cc7980a84db48e3fd58fb5ed3aa80218c7 /src/Text/Pandoc
parentaae362f634cd4c9aed310ca9c437ba85de730b38 (diff)
Muse reader: replace setState with updateState where possible
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index c19b42503..e89a89b8f 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -250,8 +250,7 @@ parseBlocks =
rest <- parseBlocks
return $ first B.<> rest
listStart = do
- st <- getState
- setState $ st{ museInPara = False }
+ updateState (\st -> st { museInPara = False })
(first, rest) <- anyListUntil parseBlocks <|> amuseNoteBlockUntil parseBlocks
return $ first B.<> rest
paraStart = do
@@ -274,8 +273,7 @@ parseBlocksTill end =
rest <- continuation
return $ first B.<> rest
listStart = do
- st <- getState
- setState $ st{ museInPara = False }
+ updateState (\st -> st { museInPara = False })
(first, e) <- anyListUntil ((Left <$> end) <|> (Right <$> continuation))
case e of
Left _ -> return first
@@ -309,8 +307,7 @@ listItemContentsUntil col pre end =
(rest, e) <- parsePre <|> continuation <|> parseEnd
return (first B.<> rest, e)
listStart = do
- st <- getState
- setState $ st{ museInPara = False }
+ updateState (\st -> st { museInPara = False })
(first, e) <- anyListUntil ((Left <$> pre) <|> (Right <$> continuation) <|> (Left <$> end))
case e of
Left ee -> return (first, ee)
@@ -318,8 +315,7 @@ listItemContentsUntil col pre end =
continuation = try $ do blank <- optionMaybe blankline
skipMany blankline
indentWith col
- st <- getState
- setState $ st{ museInPara = museInPara st && isNothing blank }
+ updateState (\st -> st { museInPara = museInPara st && isNothing blank })
listItemContentsUntil col pre end
parseBlock :: PandocMonad m => MuseParser m (F Blocks)
@@ -331,8 +327,7 @@ parseBlock = do
blockElements :: PandocMonad m => MuseParser m (F Blocks)
blockElements = do
- st <- getState
- setState $ st{ museInPara = False }
+ updateState (\st -> st { museInPara = False })
choice [ mempty <$ blankline
, comment
, separator
@@ -480,8 +475,7 @@ amuseNoteBlockUntil end = try $ do
guardEnabled Ext_amuse
pos <- getPosition
ref <- noteMarker <* spaceChar
- st <- getState
- setState $ st{ museInPara = False }
+ updateState (\st -> st { museInPara = False })
(content, e) <- listItemContentsUntil (sourceColumn pos) (fail "x") end
oldnotes <- museNotes <$> getState
case M.lookup ref oldnotes of
@@ -541,8 +535,7 @@ bulletListItemsUntil :: PandocMonad m
bulletListItemsUntil indent end = try $ do
char '-'
void spaceChar <|> lookAhead eol
- st <- getState
- setState $ st{ museInPara = False }
+ updateState (\st -> st { museInPara = False })
(x, e) <- listItemContentsUntil (indent + 2) (Right <$> try (optional blankline >> indentWith indent >> bulletListItemsUntil indent end)) (Left <$> end)
case e of
Left ee -> return ([x], ee)
@@ -591,8 +584,7 @@ orderedListItemsUntil indent style end =
continuation = try $ do
pos <- getPosition
void spaceChar <|> lookAhead eol
- st <- getState
- setState $ st{ museInPara = False }
+ updateState (\st -> st { museInPara = False })
(x, e) <- listItemContentsUntil (sourceColumn pos) (Right <$> try (optionMaybe blankline >> indentWith indent >> museOrderedListMarker style >> continuation)) (Left <$> end)
case e of
Left ee -> return ([x], ee)
@@ -617,8 +609,7 @@ descriptionsUntil :: PandocMonad m
-> MuseParser m ([F Blocks], a)
descriptionsUntil indent end = do
void spaceChar <|> lookAhead eol
- st <- getState
- setState $ st{ museInPara = False }
+ updateState (\st -> st { museInPara = False })
(x, e) <- listItemContentsUntil indent (Right <$> try (optional blankline >> indentWith indent >> manyTill spaceChar (string "::") >> descriptionsUntil indent end)) (Left <$> end)
case e of
Right (xs, ee) -> return (x:xs, ee)