aboutsummaryrefslogtreecommitdiff
path: root/bbcode/src/Text
diff options
context:
space:
mode:
Diffstat (limited to 'bbcode/src/Text')
-rw-r--r--bbcode/src/Text/BBCode/Lexer.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/bbcode/src/Text/BBCode/Lexer.hs b/bbcode/src/Text/BBCode/Lexer.hs
index 2eb0022..1c20928 100644
--- a/bbcode/src/Text/BBCode/Lexer.hs
+++ b/bbcode/src/Text/BBCode/Lexer.hs
@@ -33,15 +33,17 @@ token = BBClose <$> ("[/" *> escapedText' [']'] <* "]")
33 <|> BBStr <$> escapedText ['['] 33 <|> BBStr <$> escapedText ['[']
34 34
35openTag :: Parser (Text, [(Text, Maybe Text)]) 35openTag :: Parser (Text, [(Text, Maybe Text)])
36openTag = (,) <$> ("[" *> escapedText' [']', ' ']) <*> (option [] attrs <* "]") 36openTag = (,) <$ "[" <*> escapedText' [']', ' '] <* takeWhile isSpace <*> attrs' <* "]"
37 37
38attrs :: Parser [(Text, Maybe Text)] 38attrs :: Parser [(Text, Maybe Text)]
39attrs = (:) <$> (attrs' <* takeWhile isSpace) <*> (option [] $ attrs) 39attrs = (:) <$> ((,) <$> escapedText ['=', ']', ' '] <*> optional ("=" *> attrArg)) <* takeWhile isSpace <*> attrs'
40 where 40 where
41 attrs' = (,) <$> escapedText ['=', ']', ' '] <*> optional ("=" *> attrArg)
42 attrArg = "\"" *> escapedText ['"'] <* "\"" 41 attrArg = "\"" *> escapedText ['"'] <* "\""
43 <|> escapedText [']', ' '] 42 <|> escapedText [']', ' ']
44 43
44attrs' :: Parser [(Text, Maybe Text)]
45attrs' = option [] attrs
46
45escapedText :: [Char] -> Parser Text 47escapedText :: [Char] -> Parser Text
46-- ^ @escapedText cs@ consumes 'Text' up to (not including) the first occurence of a character from @cs@ that is not escaped using @\\@ 48-- ^ @escapedText cs@ consumes 'Text' up to (not including) the first occurence of a character from @cs@ that is not escaped using @\\@
47-- 49--