Utility functions.
copyright: | Copyright 2006-2013 by the Pygments team, see AUTHORS. |
---|---|
license: | BSD, see LICENSE for details. |
If one of the get_*_by_* functions didn’t find a matching class.
Check if the doctype matches a regular expression (if present). Note that this method only checks the first part of a DOCTYPE. eg: ‘html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”’
Check if the file looks like it has a html doctype.
Return a static text analysation function that returns float values.
Check if the given regular expression matches the last part of the shebang if one exists.
>>> from pygments.util import shebang_matches
>>> shebang_matches('#!/usr/bin/env python', r'python(2\.\d)?')
True
>>> shebang_matches('#!/usr/bin/python2.4', r'python(2\.\d)?')
True
>>> shebang_matches('#!/usr/bin/python-ruby', r'python(2\.\d)?')
False
>>> shebang_matches('#!/usr/bin/python/ruby', r'python(2\.\d)?')
False
>>> shebang_matches('#!/usr/bin/startsomethingwith python',
... r'python(2\.\d)?')
True
It also checks for common windows executable file extensions:
>>> shebang_matches('#!C:\Python2.4\Python.exe', r'python(2\.\d)?')
True
Parameters ('-f' or '--foo' are ignored so 'perl' does the same as 'perl -e')
Note that this method automatically searches the whole string (eg: the regular expression is wrapped in '^$')