git.iko.soy/typeable/pandoc
on master help sign in
Simplified inlinesInBalanced, using lookAhead.
48d67d0fiddlosopher
src/Text/Pandoc/Readers/Markdown.hs+5−5
@@ -133,13 +133,13 @@ failUnlessSmart = do
133-- between balanced pairs of @opener@ and a @closer@.
133-- between balanced pairs of @opener@ and a @closer@.
134inlinesInBalanced :: String -> String -> GenParser Char ParserState [Inline]
134inlinesInBalanced :: String -> String -> GenParser Char ParserState [Inline]
135inlinesInBalanced opener closer = try $ do
135inlinesInBalanced opener closer = try $ do
136− let nonOpenerSymbol = try $ do -- succeeds if next inline would be Str opener
136+ let openerSymbol = try $ do
137− res <- inline -- fails if next inline merely begins with opener
137+ res <- inline
138 if res == Str opener
138 if res == Str opener
139− then pzero
139+ then return res
140− else return ' '
140+ else pzero
141 try (string opener)
141 try (string opener)
142− result <- manyTill ( (do notFollowedBy nonOpenerSymbol
142+ result <- manyTill ( (do lookAhead openerSymbol
143 bal <- inlinesInBalanced opener closer
143 bal <- inlinesInBalanced opener closer
144 return $ [Str opener] ++ bal ++ [Str closer])
144 return $ [Str opener] ++ bal ++ [Str closer])
145 <|> (count 1 inline))
145 <|> (count 1 inline))