diff options
Diffstat (limited to 'bbcode/src/Text/BBCode')
-rw-r--r-- | bbcode/src/Text/BBCode/Lexer.hs | 5 |
1 files changed, 4 insertions, 1 deletions
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 | |||
29 | token :: Parser BBToken | 29 | token :: Parser BBToken |
30 | -- ^ Tokenizer | 30 | -- ^ Tokenizer |
31 | token = BBClose <$> ("[/" *> escapedText' [']'] <* "]") | 31 | token = BBClose <$> ("[/" *> escapedText' [']'] <* "]") |
32 | <|> BBOpen <$> ("[" *> escapedText' [']', ' ']) <*> (option [] attrs <* "]") | 32 | <|> uncurry BBOpen <$> openTag |
33 | <|> BBStr <$> escapedText ['['] | 33 | <|> BBStr <$> escapedText ['['] |
34 | 34 | ||
35 | openTag :: Parser (Text, [(Text, Maybe Text)]) | ||
36 | openTag = (,) <$> ("[" *> escapedText' [']', ' ']) <*> (option [] attrs <* "]") | ||
37 | |||
35 | attrs :: Parser [(Text, Maybe Text)] | 38 | attrs :: Parser [(Text, Maybe Text)] |
36 | attrs = (:) <$> (attrs' <* takeWhile isSpace) <*> (option [] $ attrs) | 39 | attrs = (:) <$> (attrs' <* takeWhile isSpace) <*> (option [] $ attrs) |
37 | where | 40 | where |