summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2015-03-08 07:24:33 +0100
committerGeorg Brandl <georg@python.org>2015-03-08 07:24:33 +0100
commit97a7b4c431784cfec8bf1779d02b9964c705e348 (patch)
tree950d945f18e24b8daaf03340a1e096ef18a7eca3
parent0064569c71402121242a09d5e5cb3eddf1ebd6d6 (diff)
parent0a78d2678371d0f00ed96dc5fa5da26be12630c4 (diff)
downloadpygments-97a7b4c431784cfec8bf1779d02b9964c705e348.tar.gz
Merged in miikkas/pygments-htmlpunctuation (pull request #453)
HTML lexer marks angle brackets etc. as punctuation, equal signs as operators
-rw-r--r--pygments/lexers/html.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/pygments/lexers/html.py b/pygments/lexers/html.py
index 1c35325f..7893952f 100644
--- a/pygments/lexers/html.py
+++ b/pygments/lexers/html.py
@@ -46,12 +46,19 @@ class HtmlLexer(RegexLexer):
('<!--', Comment, 'comment'),
(r'<\?.*?\?>', Comment.Preproc),
('<![^>]*>', Comment.Preproc),
- (r'<\s*script\s*', Name.Tag, ('script-content', 'tag')),
- (r'<\s*style\s*', Name.Tag, ('style-content', 'tag')),
+ (r'(<)(\s*)(script)(\s*)',
+ bygroups(Punctuation, Text, Name.Tag, Text),
+ ('script-content', 'tag')),
+ (r'(<)(\s*)(style)(\s*)',
+ bygroups(Punctuation, Text, Name.Tag, Text),
+ ('style-content', 'tag')),
# note: this allows tag names not used in HTML like <x:with-dash>,
# this is to support yet-unknown template engines and the like
- (r'<\s*[\w:.-]+', Name.Tag, 'tag'),
- (r'<\s*/\s*[\w:.-]+\s*>', Name.Tag),
+ (r'(<)(\s*)([\w:.-]+)',
+ bygroups(Punctuation, Text, Name.Tag), 'tag'),
+ (r'(<)(\s*)(/)(\s*)([\w:.-]+)(\s*)(>)',
+ bygroups(Punctuation, Text, Punctuation, Text, Name.Tag, Text,
+ Punctuation)),
],
'comment': [
('[^-]+', Comment),
@@ -60,16 +67,21 @@ class HtmlLexer(RegexLexer):
],
'tag': [
(r'\s+', Text),
- (r'([\w:-]+\s*=)(\s*)', bygroups(Name.Attribute, Text), 'attr'),
+ (r'([\w:-]+\s*)(=)(\s*)', bygroups(Name.Attribute, Operator, Text),
+ 'attr'),
(r'[\w:-]+', Name.Attribute),
- (r'/?\s*>', Name.Tag, '#pop'),
+ (r'(/?)(\s*)(>)', bygroups(Punctuation, Text, Punctuation), '#pop'),
],
'script-content': [
- (r'<\s*/\s*script\s*>', Name.Tag, '#pop'),
+ (r'(<)(\s*)(/)(\s*)(script)(\s*)(>)',
+ bygroups(Punctuation, Text, Punctuation, Text, Name.Tag, Text,
+ Punctuation), '#pop'),
(r'.+?(?=<\s*/\s*script\s*>)', using(JavascriptLexer)),
],
'style-content': [
- (r'<\s*/\s*style\s*>', Name.Tag, '#pop'),
+ (r'(<)(\s*)(/)(\s*)(style)(\s*)(>)',
+ bygroups(Punctuation, Text, Punctuation, Text, Name.Tag, Text,
+ Punctuation),'#pop'),
(r'.+?(?=<\s*/\s*style\s*>)', using(CssLexer)),
],
'attr': [