diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-12 05:59:38 +0000 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-12 05:59:38 +0000 |
| commit | 9bc6cd27e1c4b52f46e1b210b3d560c5340d1fe4 (patch) | |
| tree | c7edccdab108fb4557e41c79502ab71cb84e9f07 /bbcode/src/Text/BBCode | |
| parent | 6c526fc1f57b666f978244db9c760841318e2251 (diff) | |
| download | thermoprint-9bc6cd27e1c4b52f46e1b210b3d560c5340d1fe4.tar thermoprint-9bc6cd27e1c4b52f46e1b210b3d560c5340d1fe4.tar.gz thermoprint-9bc6cd27e1c4b52f46e1b210b3d560c5340d1fe4.tar.bz2 thermoprint-9bc6cd27e1c4b52f46e1b210b3d560c5340d1fe4.tar.xz thermoprint-9bc6cd27e1c4b52f46e1b210b3d560c5340d1fe4.zip | |
Unnamed attributes
Diffstat (limited to 'bbcode/src/Text/BBCode')
| -rw-r--r-- | bbcode/src/Text/BBCode/Lexer.hs | 6 |
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 | ||
| 35 | openTag :: Parser (Text, [(Text, Maybe Text)]) | 35 | openTag :: Parser (Text, [(Text, Maybe Text)]) |
| 36 | openTag = (,) <$ "[" <*> escapedText' [']', ' '] <* takeWhile isSpace <*> attrs' <* "]" | 36 | openTag = (,) <$ "[" <*> escapedText' [']', ' ', '='] <*> attrs' <* "]" |
| 37 | 37 | ||
| 38 | attrs :: Parser [(Text, Maybe Text)] | 38 | attrs :: Parser [(Text, Maybe Text)] |
| 39 | attrs = (:) <$> ((,) <$> escapedText ['=', ']', ' '] <*> optional ("=" *> attrArg)) <* takeWhile isSpace <*> attrs' | 39 | attrs = (:) <$> (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 | ||
