git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: rewrite code parser in applicative style
36c763aAlexander Krotov
src/Text/Pandoc/Readers/Muse.hs+5−8
@@ -873,14 +873,11 @@ nbsp = try $ pure (B.str "\160") <$ string "~~"
873
873
874-- | Parse code markup, indicated by @\'=\'@ characters.
874-- | Parse code markup, indicated by @\'=\'@ characters.
875code :: PandocMonad m => MuseParser m (F Inlines)
875code :: PandocMonad m => MuseParser m (F Inlines)
876−code = try $ do
876+code = try $ fmap pure $ B.code . uncurry (++)
877− atStart $ char '='
877+ <$ atStart (char '=')
878+ <* notFollowedBy (spaceChar <|> newline)
878− contents <- many1Till (noneOf "\n\r" <|> (newline <* notFollowedBy newline)) $ char '='
879+ <*> manyUntil (noneOf "\n\r" <|> (newline <* notFollowedBy newline)) (try $ fmap pure $ noneOf " \t\n\r=" <* char '=')
879− guard $ not $ null contents
880− guard $ head contents `notElem` " \t\n"
881− guard $ last contents `notElem` " \t\n"
882− notFollowedBy $ satisfy isAlphaNum
880+ <* notFollowedBy (satisfy isAlphaNum)
883− return $ return $ B.code contents
884
881
885-- | Parse @\<code>@ tag.
882-- | Parse @\<code>@ tag.
886codeTag :: PandocMonad m => MuseParser m (F Inlines)
883codeTag :: PandocMonad m => MuseParser m (F Inlines)