diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-12 05:32:10 +0000 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-12 05:32:10 +0000 |
| commit | 6c526fc1f57b666f978244db9c760841318e2251 (patch) | |
| tree | c51763a957b52c397cc13887d887977aebc68321 | |
| parent | 2cb2c2c34f91a9239a547c2fa67f158a90c6652e (diff) | |
| download | thermoprint-6c526fc1f57b666f978244db9c760841318e2251.tar thermoprint-6c526fc1f57b666f978244db9c760841318e2251.tar.gz thermoprint-6c526fc1f57b666f978244db9c760841318e2251.tar.bz2 thermoprint-6c526fc1f57b666f978244db9c760841318e2251.tar.xz thermoprint-6c526fc1f57b666f978244db9c760841318e2251.zip | |
fixed spacing issue causing parse errors & cleanup
| -rw-r--r-- | bbcode/src/Text/BBCode/Lexer.hs | 8 |
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 | ||
| 35 | openTag :: Parser (Text, [(Text, Maybe Text)]) | 35 | openTag :: Parser (Text, [(Text, Maybe Text)]) |
| 36 | openTag = (,) <$> ("[" *> escapedText' [']', ' ']) <*> (option [] attrs <* "]") | 36 | openTag = (,) <$ "[" <*> escapedText' [']', ' '] <* takeWhile isSpace <*> attrs' <* "]" |
| 37 | 37 | ||
| 38 | attrs :: Parser [(Text, Maybe Text)] | 38 | attrs :: Parser [(Text, Maybe Text)] |
| 39 | attrs = (:) <$> (attrs' <* takeWhile isSpace) <*> (option [] $ attrs) | 39 | attrs = (:) <$> ((,) <$> 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 | ||
| 44 | attrs' :: Parser [(Text, Maybe Text)] | ||
| 45 | attrs' = option [] attrs | ||
| 46 | |||
| 45 | escapedText :: [Char] -> Parser Text | 47 | escapedText :: [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 | -- |
