@@ -293,28 +293,28 @@ lineClump = do
293293
294294-- | Parse a string of characters between an open character
295295-- and a close character, including text between balanced
296−-- pairs of open and close. For example,
296+-- pairs of open and close, which must be different. For example,
297297-- @charsInBalanced '(' ')'@ will parse "(hello (there))"
298298-- and return "hello (there)". Stop if a blank line is
299299-- encountered.
300300charsInBalanced :: Char -> Char -> GenParser Char st String
301301charsInBalanced open close = try $ do
302302 char open
303− raw <- manyTill ( (do res <- charsInBalanced open close
304− return $ [open] ++ res ++ [close])
305− <|> (do notFollowedBy (blankline >> blanklines >> return '\n')
306− count 1 anyChar))
307− (char close)
303+ raw <- many $ (many1 (noneOf [open, close, '\n']))
304+ <|> (do res <- charsInBalanced open close
305+ return $ [open] ++ res ++ [close])
306+ <|> try (string "\n" >>~ notFollowedBy' blanklines)
307+ char close
308308 return $ concat raw
309309
310310-- | Like @charsInBalanced@, but allow blank lines in the content.
311311charsInBalanced' :: Char -> Char -> GenParser Char st String
312312charsInBalanced' open close = try $ do
313313 char open
314− raw <- manyTill ( (do res <- charsInBalanced open close
314+ raw <- many $ (many1 (noneOf [open, close]))
315+ <|> (do res <- charsInBalanced' open close
315316 return $ [open] ++ res ++ [close])
316− <|> count 1 anyChar)
317− (char close)
317+ char close
318318 return $ concat raw
319319
320320-- | Parses a roman numeral (uppercase or lowercase), returns number.