Markdown reader: Fixed bug in code block attribute parser.

Previously the ID attribute got lost if it didn't come first.
Now attributes can come in any order.
This commit is contained in:
John MacFarlane 2012-01-28 12:36:51 -08:00
parent d1ded4b026
commit 0487eae7ee

View file

@ -394,13 +394,14 @@ attributes = try $ do
attrs <- many (attribute >>~ many spaceChar)
char '}'
let (ids, classes, keyvals) = unzip3 attrs
let id' = if null ids then "" else head ids
return (id', concat classes, concat keyvals)
let firstNonNull [] = ""
firstNonNull (x:xs) | not (null x) = x
| otherwise = firstNonNull xs
return (firstNonNull $ reverse ids, concat classes, concat keyvals)
attribute :: GenParser Char st ([Char], [[Char]], [([Char], [Char])])
attribute = identifierAttr <|> classAttr <|> keyValAttr
identifier :: GenParser Char st [Char]
identifier = do
first <- letter