From fe17c720081798175c9936d1624f428b565e310f Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 12 Jan 2016 05:21:16 +0000 Subject: Rose-Tree labels now carry attributes --- bbcode/src/Text/BBCode/Lexer.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bbcode/src/Text/BBCode') diff --git a/bbcode/src/Text/BBCode/Lexer.hs b/bbcode/src/Text/BBCode/Lexer.hs index ad26113..2eb0022 100644 --- a/bbcode/src/Text/BBCode/Lexer.hs +++ b/bbcode/src/Text/BBCode/Lexer.hs @@ -29,9 +29,12 @@ data BBToken = BBOpen Text [(Text, Maybe Text)] -- ^ Tag open with attributes token :: Parser BBToken -- ^ Tokenizer token = BBClose <$> ("[/" *> escapedText' [']'] <* "]") - <|> BBOpen <$> ("[" *> escapedText' [']', ' ']) <*> (option [] attrs <* "]") + <|> uncurry BBOpen <$> openTag <|> BBStr <$> escapedText ['['] +openTag :: Parser (Text, [(Text, Maybe Text)]) +openTag = (,) <$> ("[" *> escapedText' [']', ' ']) <*> (option [] attrs <* "]") + attrs :: Parser [(Text, Maybe Text)] attrs = (:) <$> (attrs' <* takeWhile isSpace) <*> (option [] $ attrs) where -- cgit v1.2.3