diff options
author | blackbird <devnull@localhost> | 2006-10-27 23:59:07 +0200 |
---|---|---|
committer | blackbird <devnull@localhost> | 2006-10-27 23:59:07 +0200 |
commit | 0b4ae9ab3fa6057dce2833a3e34ba01511c10e44 (patch) | |
tree | f4afa530b3b9aae10144448d0aaa25bc990fb482 /pygments/lexers/web.py | |
parent | a400243228ed76501b820f2a6d0e7f924d5f9882 (diff) | |
download | pygments-0b4ae9ab3fa6057dce2833a3e34ba01511c10e44.tar.gz |
[svn] checked in changes from the last days. including:
- text in logo
- documentation update
- new `guess_lexer` method
Diffstat (limited to 'pygments/lexers/web.py')
-rw-r--r-- | pygments/lexers/web.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py index 0b90e6cd..939144dd 100644 --- a/pygments/lexers/web.py +++ b/pygments/lexers/web.py @@ -18,7 +18,8 @@ except NameError: from pygments.lexer import Lexer, RegexLexer, do_insertions, bygroups, using from pygments.token import \ Text, Comment, Operator, Keyword, Name, String, Number, Other -from pygments.util import get_bool_opt, get_list_opt +from pygments.util import get_bool_opt, get_list_opt, looks_like_xml, \ + html_doctype_matches __all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'CssLexer', @@ -217,6 +218,10 @@ class HtmlLexer(RegexLexer): ], } + def analyse_text(text): + if html_doctype_matches(text): + return 0.5 + class PhpLexer(RegexLexer): name = 'PHP' @@ -296,6 +301,13 @@ class PhpLexer(RegexLexer): continue yield index, token, value + def analyse_text(text): + rv = 0.0 + for tag in '<?php', '?>': + if tag in text: + rv += 0.2 + return rv + class XmlLexer(RegexLexer): flags = re.MULTILINE | re.DOTALL @@ -332,3 +344,7 @@ class XmlLexer(RegexLexer): (r'[^\s>]+', String, '#pop'), ], } + + def analyse_text(text): + if looks_like_xml(text): + return 0.5 |