aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Muse.hs
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-10-10 03:11:34 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-10-10 03:23:08 +0300
commit36c763a64720ccba61d3bc4f10c286cb445d52fa (patch)
tree4b7538216f0b4b3195bd7a474f3edbe5f33f5966 /src/Text/Pandoc/Readers/Muse.hs
parentd3b2161bd17c25358422f84d282f4688c345a879 (diff)
downloadpandoc-36c763a64720ccba61d3bc4f10c286cb445d52fa.tar.gz
Muse reader: rewrite code parser in applicative style
Diffstat (limited to 'src/Text/Pandoc/Readers/Muse.hs')
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index 7aef9bd6d..39c5a296e 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -873,14 +873,11 @@ nbsp = try $ pure (B.str "\160") <$ string "~~"
-- | Parse code markup, indicated by @\'=\'@ characters.
code :: PandocMonad m => MuseParser m (F Inlines)
-code = try $ do
- atStart $ char '='
- contents <- many1Till (noneOf "\n\r" <|> (newline <* notFollowedBy newline)) $ char '='
- guard $ not $ null contents
- guard $ head contents `notElem` " \t\n"
- guard $ last contents `notElem` " \t\n"
- notFollowedBy $ satisfy isAlphaNum
- return $ return $ B.code contents
+code = try $ fmap pure $ B.code . uncurry (++)
+ <$ atStart (char '=')
+ <* notFollowedBy (spaceChar <|> newline)
+ <*> manyUntil (noneOf "\n\r" <|> (newline <* notFollowedBy newline)) (try $ fmap pure $ noneOf " \t\n\r=" <* char '=')
+ <* notFollowedBy (satisfy isAlphaNum)
-- | Parse @\<code>@ tag.
codeTag :: PandocMonad m => MuseParser m (F Inlines)