From 9bc6cd27e1c4b52f46e1b210b3d560c5340d1fe4 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 12 Jan 2016 05:59:38 +0000 Subject: Unnamed attributes --- bbcode/src/Text/BBCode/Lexer.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bbcode/src') diff --git a/bbcode/src/Text/BBCode/Lexer.hs b/bbcode/src/Text/BBCode/Lexer.hs index 1c20928..7171a0e 100644 --- a/bbcode/src/Text/BBCode/Lexer.hs +++ b/bbcode/src/Text/BBCode/Lexer.hs @@ -33,11 +33,13 @@ token = BBClose <$> ("[/" *> escapedText' [']'] <* "]") <|> BBStr <$> escapedText ['['] openTag :: Parser (Text, [(Text, Maybe Text)]) -openTag = (,) <$ "[" <*> escapedText' [']', ' '] <* takeWhile isSpace <*> attrs' <* "]" +openTag = (,) <$ "[" <*> escapedText' [']', ' ', '='] <*> attrs' <* "]" attrs :: Parser [(Text, Maybe Text)] -attrs = (:) <$> ((,) <$> escapedText ['=', ']', ' '] <*> optional ("=" *> attrArg)) <* takeWhile isSpace <*> attrs' +attrs = (:) <$> (namedAttr <|> plainValue) <* takeWhile isSpace <*> attrs' where + namedAttr = (,) <$ takeWhile isSpace <*> escapedText ['=', ']', ' '] <*> optional ("=" *> attrArg) + plainValue = (,) <$> pure "" <* "=" <*> (Just <$> attrArg) attrArg = "\"" *> escapedText ['"'] <* "\"" <|> escapedText [']', ' '] -- cgit v1.2.3