From 0487eae7eea436957ddbe36256e244d2fb607e7b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 28 Jan 2012 12:36:51 -0800 Subject: 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. --- src/Text/Pandoc/Readers/Markdown.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index fb04e88fe..47419defe 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -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 -- cgit v1.2.3