From 6c526fc1f57b666f978244db9c760841318e2251 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 12 Jan 2016 05:32:10 +0000 Subject: fixed spacing issue causing parse errors & cleanup --- bbcode/src/Text/BBCode/Lexer.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'bbcode/src/Text') 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' [']'] <* "]") <|> BBStr <$> escapedText ['['] openTag :: Parser (Text, [(Text, Maybe Text)]) -openTag = (,) <$> ("[" *> escapedText' [']', ' ']) <*> (option [] attrs <* "]") +openTag = (,) <$ "[" <*> escapedText' [']', ' '] <* takeWhile isSpace <*> attrs' <* "]" attrs :: Parser [(Text, Maybe Text)] -attrs = (:) <$> (attrs' <* takeWhile isSpace) <*> (option [] $ attrs) +attrs = (:) <$> ((,) <$> escapedText ['=', ']', ' '] <*> optional ("=" *> attrArg)) <* takeWhile isSpace <*> attrs' where - attrs' = (,) <$> escapedText ['=', ']', ' '] <*> optional ("=" *> attrArg) attrArg = "\"" *> escapedText ['"'] <* "\"" <|> escapedText [']', ' '] +attrs' :: Parser [(Text, Maybe Text)] +attrs' = option [] attrs + escapedText :: [Char] -> Parser Text -- ^ @escapedText cs@ consumes 'Text' up to (not including) the first occurence of a character from @cs@ that is not escaped using @\\@ -- -- cgit v1.2.3