aboutsummaryrefslogtreecommitdiff
path: root/bbcode/src
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-01-12 05:59:38 +0000
committerGregor Kleen <gkleen@yggdrasil.li>2016-01-12 05:59:38 +0000
commit9bc6cd27e1c4b52f46e1b210b3d560c5340d1fe4 (patch)
treec7edccdab108fb4557e41c79502ab71cb84e9f07 /bbcode/src
parent6c526fc1f57b666f978244db9c760841318e2251 (diff)
downloadthermoprint-9bc6cd27e1c4b52f46e1b210b3d560c5340d1fe4.tar
thermoprint-9bc6cd27e1c4b52f46e1b210b3d560c5340d1fe4.tar.gz
thermoprint-9bc6cd27e1c4b52f46e1b210b3d560c5340d1fe4.tar.bz2
thermoprint-9bc6cd27e1c4b52f46e1b210b3d560c5340d1fe4.tar.xz
thermoprint-9bc6cd27e1c4b52f46e1b210b3d560c5340d1fe4.zip
Unnamed attributes
Diffstat (limited to 'bbcode/src')
-rw-r--r--bbcode/src/Text/BBCode/Lexer.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/bbcode/src/Text/BBCode/Lexer.hs b/bbcode/src/Text/BBCode/Lexer.hs
index 1c20928..7171a0e 100644
--- a/bbcode/src/Text/BBCode/Lexer.hs
+++ b/bbcode/src/Text/BBCode/Lexer.hs
@@ -33,11 +33,13 @@ 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' [']', ' '] <* takeWhile isSpace <*> attrs' <* "]" 36openTag = (,) <$ "[" <*> escapedText' [']', ' ', '='] <*> attrs' <* "]"
37 37
38attrs :: Parser [(Text, Maybe Text)] 38attrs :: Parser [(Text, Maybe Text)]
39attrs = (:) <$> ((,) <$> escapedText ['=', ']', ' '] <*> optional ("=" *> attrArg)) <* takeWhile isSpace <*> attrs' 39attrs = (:) <$> (namedAttr <|> plainValue) <* takeWhile isSpace <*> attrs'
40 where 40 where
41 namedAttr = (,) <$ takeWhile isSpace <*> escapedText ['=', ']', ' '] <*> optional ("=" *> attrArg)
42 plainValue = (,) <$> pure "" <* "=" <*> (Just <$> attrArg)
41 attrArg = "\"" *> escapedText ['"'] <* "\"" 43 attrArg = "\"" *> escapedText ['"'] <* "\""
42 <|> escapedText [']', ' '] 44 <|> escapedText [']', ' ']
43 45