diff options
Diffstat (limited to 'bbcode/src/Text/BBCode')
| -rw-r--r-- | bbcode/src/Text/BBCode/Lexer.hs | 6 |
1 files changed, 4 insertions, 2 deletions
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' [']'] <* "]") | |||
| 33 | <|> BBStr <$> escapedText ['['] | 33 | <|> BBStr <$> escapedText ['['] |
| 34 | 34 | ||
| 35 | openTag :: Parser (Text, [(Text, Maybe Text)]) | 35 | openTag :: Parser (Text, [(Text, Maybe Text)]) |
| 36 | openTag = (,) <$ "[" <*> escapedText' [']', ' '] <* takeWhile isSpace <*> attrs' <* "]" | 36 | openTag = (,) <$ "[" <*> escapedText' [']', ' ', '='] <*> attrs' <* "]" |
| 37 | 37 | ||
| 38 | attrs :: Parser [(Text, Maybe Text)] | 38 | attrs :: Parser [(Text, Maybe Text)] |
| 39 | attrs = (:) <$> ((,) <$> escapedText ['=', ']', ' '] <*> optional ("=" *> attrArg)) <* takeWhile isSpace <*> attrs' | 39 | attrs = (:) <$> (namedAttr <|> plainValue) <* takeWhile isSpace <*> attrs' |
| 40 | where | 40 | where |
| 41 | namedAttr = (,) <$ takeWhile isSpace <*> escapedText ['=', ']', ' '] <*> optional ("=" *> attrArg) | ||
| 42 | plainValue = (,) <$> pure "" <* "=" <*> (Just <$> attrArg) | ||
| 41 | attrArg = "\"" *> escapedText ['"'] <* "\"" | 43 | attrArg = "\"" *> escapedText ['"'] <* "\"" |
| 42 | <|> escapedText [']', ' '] | 44 | <|> escapedText [']', ' '] |
| 43 | 45 | ||
