summaryrefslogtreecommitdiff
path: root/pygments/lexers/text.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/text.py')
-rw-r--r--pygments/lexers/text.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/pygments/lexers/text.py b/pygments/lexers/text.py
index 24b9f6f4..efc346d5 100644
--- a/pygments/lexers/text.py
+++ b/pygments/lexers/text.py
@@ -356,12 +356,23 @@ class BBCodeLexer(RegexLexer):
mimetypes = ['text/x-bbcode']
tokens = {
- 'root' : [
- (r'[\s\w]+', Text),
- (r'(\[)(/?[^\]\n\r=]+)(\])',
- bygroups(Keyword, Keyword.Pseudo, Keyword)),
- (r'(\[)([^\]\n\r=]+)(=)([^\]\n\r]+)(\])',
- bygroups(Keyword, Keyword.Pseudo, Operator, String, Keyword)),
+ 'root': [
+ (r'[^[]+', Text),
+ # tag/end tag begin
+ (r'\[/?\w+', Keyword, 'tag'),
+ # stray bracket
+ (r'\[', Text),
+ ],
+ 'tag': [
+ (r'\s+', Text),
+ # attribute with value
+ (r'(\w+)(=)("?[^\s"\]]+"?)',
+ bygroups(Name.Attribute, Operator, String)),
+ # tag argument (a la [color=green])
+ (r'(=)("?[^\s"\]]+"?)',
+ bygroups(Operator, String)),
+ # tag end
+ (r'\]', Keyword, '#pop'),
],
}