aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-01-28 12:36:51 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-01-28 12:36:51 -0800
commit0487eae7eea436957ddbe36256e244d2fb607e7b (patch)
treef4c8344e37dbcbd98673ce92f83893a7d15222f7 /src
parentd1ded4b0260b32550ac45329d7c43a82a7e7e911 (diff)
downloadpandoc-0487eae7eea436957ddbe36256e244d2fb607e7b.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs7
1 files changed, 4 insertions, 3 deletions
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