aboutsummaryrefslogtreecommitdiff
path: root/bbcode
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-01-12 05:32:10 +0000
committerGregor Kleen <gkleen@yggdrasil.li>2016-01-12 05:32:10 +0000
commit6c526fc1f57b666f978244db9c760841318e2251 (patch)
treec51763a957b52c397cc13887d887977aebc68321 /bbcode
parent2cb2c2c34f91a9239a547c2fa67f158a90c6652e (diff)
downloadthermoprint-6c526fc1f57b666f978244db9c760841318e2251.tar
thermoprint-6c526fc1f57b666f978244db9c760841318e2251.tar.gz
thermoprint-6c526fc1f57b666f978244db9c760841318e2251.tar.bz2
thermoprint-6c526fc1f57b666f978244db9c760841318e2251.tar.xz
thermoprint-6c526fc1f57b666f978244db9c760841318e2251.zip
fixed spacing issue causing parse errors & cleanup
Diffstat (limited to 'bbcode')
-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--