ThirdParty/Pygments/pygments/lexers/html.py

changeset 4697
c2e9bf425554
parent 4172
4f20dba37ab6
child 5713
6762afd9f963
equal deleted inserted replaced
4696:bf4d19a7cade 4697:c2e9bf425554
3 pygments.lexers.html 3 pygments.lexers.html
4 ~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for HTML, XML and related markup. 6 Lexers for HTML, XML and related markup.
7 7
8 :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 13
44 (r'&\S*?;', Name.Entity), 44 (r'&\S*?;', Name.Entity),
45 (r'\<\!\[CDATA\[.*?\]\]\>', Comment.Preproc), 45 (r'\<\!\[CDATA\[.*?\]\]\>', Comment.Preproc),
46 ('<!--', Comment, 'comment'), 46 ('<!--', Comment, 'comment'),
47 (r'<\?.*?\?>', Comment.Preproc), 47 (r'<\?.*?\?>', Comment.Preproc),
48 ('<![^>]*>', Comment.Preproc), 48 ('<![^>]*>', Comment.Preproc),
49 (r'<\s*script\s*', Name.Tag, ('script-content', 'tag')), 49 (r'(<)(\s*)(script)(\s*)',
50 (r'<\s*style\s*', Name.Tag, ('style-content', 'tag')), 50 bygroups(Punctuation, Text, Name.Tag, Text),
51 ('script-content', 'tag')),
52 (r'(<)(\s*)(style)(\s*)',
53 bygroups(Punctuation, Text, Name.Tag, Text),
54 ('style-content', 'tag')),
51 # note: this allows tag names not used in HTML like <x:with-dash>, 55 # note: this allows tag names not used in HTML like <x:with-dash>,
52 # this is to support yet-unknown template engines and the like 56 # this is to support yet-unknown template engines and the like
53 (r'<\s*[\w:.-]+', Name.Tag, 'tag'), 57 (r'(<)(\s*)([\w:.-]+)',
54 (r'<\s*/\s*[\w:.-]+\s*>', Name.Tag), 58 bygroups(Punctuation, Text, Name.Tag), 'tag'),
59 (r'(<)(\s*)(/)(\s*)([\w:.-]+)(\s*)(>)',
60 bygroups(Punctuation, Text, Punctuation, Text, Name.Tag, Text,
61 Punctuation)),
55 ], 62 ],
56 'comment': [ 63 'comment': [
57 ('[^-]+', Comment), 64 ('[^-]+', Comment),
58 ('-->', Comment, '#pop'), 65 ('-->', Comment, '#pop'),
59 ('-', Comment), 66 ('-', Comment),
60 ], 67 ],
61 'tag': [ 68 'tag': [
62 (r'\s+', Text), 69 (r'\s+', Text),
63 (r'([\w:-]+\s*=)(\s*)', bygroups(Name.Attribute, Text), 'attr'), 70 (r'([\w:-]+\s*)(=)(\s*)', bygroups(Name.Attribute, Operator, Text),
71 'attr'),
64 (r'[\w:-]+', Name.Attribute), 72 (r'[\w:-]+', Name.Attribute),
65 (r'/?\s*>', Name.Tag, '#pop'), 73 (r'(/?)(\s*)(>)', bygroups(Punctuation, Text, Punctuation), '#pop'),
66 ], 74 ],
67 'script-content': [ 75 'script-content': [
68 (r'<\s*/\s*script\s*>', Name.Tag, '#pop'), 76 (r'(<)(\s*)(/)(\s*)(script)(\s*)(>)',
77 bygroups(Punctuation, Text, Punctuation, Text, Name.Tag, Text,
78 Punctuation), '#pop'),
69 (r'.+?(?=<\s*/\s*script\s*>)', using(JavascriptLexer)), 79 (r'.+?(?=<\s*/\s*script\s*>)', using(JavascriptLexer)),
70 ], 80 ],
71 'style-content': [ 81 'style-content': [
72 (r'<\s*/\s*style\s*>', Name.Tag, '#pop'), 82 (r'(<)(\s*)(/)(\s*)(style)(\s*)(>)',
83 bygroups(Punctuation, Text, Punctuation, Text, Name.Tag, Text,
84 Punctuation),'#pop'),
73 (r'.+?(?=<\s*/\s*style\s*>)', using(CssLexer)), 85 (r'.+?(?=<\s*/\s*style\s*>)', using(CssLexer)),
74 ], 86 ],
75 'attr': [ 87 'attr': [
76 ('".*?"', String, '#pop'), 88 ('".*?"', String, '#pop'),
77 ("'.*?'", String, '#pop'), 89 ("'.*?'", String, '#pop'),

eric ide

mercurial