module documentation

Utility functions.

Unknown Field: copyright
Copyright 2006-2021 by the Pygments team, see AUTHORS.
Unknown Field: license
BSD, see LICENSE for details.
Class ​Option​Error Undocumented
Function get​_bool​_opt Undocumented
Function get​_choice​_opt Undocumented
Function get​_int​_opt Undocumented
Function get​_list​_opt Undocumented
Variable doctype​_lookup​_re Undocumented
Variable split​_path​_re Undocumented
Variable tag​_re Undocumented
Variable xml​_decl​_re Undocumented
Class ​Class​Not​Found Raised if one of the lookup functions didn't find a matching class.
Class ​Future Generic class to defer some work.
Class ​Unclosing​Text​IOWrapper Undocumented
Function docstring​_headline Undocumented
Function doctype​_matches Check if the doctype matches a regular expression (if present).
Function duplicates​_removed Returns a list with duplicates removed from the iterable it.
Function format​_lines Formats a sequence of strings for output.
Function guess​_decode Decode text with guessed encoding.
Function guess​_decode​_from​_terminal Decode text coming from terminal term.
Function html​_doctype​_matches Check if the file looks like it has a html doctype.
Function looks​_like​_xml Check if a doctype exists or if we have some tags.
Function make​_analysator Return a static text analyser function that returns float values.
Function shebang​_matches Check if the given regular expression matches the last part of the shebang if one exists.
Function surrogatepair Given a unicode character code with length greater than 16 bits, return the two 16 bit surrogate pair.
Function terminal​_encoding Return our best guess of encoding for the given term.
Variable ​_looks​_like​_xml​_cache Undocumented
def get_bool_opt(options, optname, default=None):

Undocumented

def get_choice_opt(options, optname, allowed, default=None, normcase=False):

Undocumented

def get_int_opt(options, optname, default=None):

Undocumented

def get_list_opt(options, optname, default=None):

Undocumented

doctype_lookup_re =

Undocumented

split_path_re =

Undocumented

tag_re =

Undocumented

xml_decl_re =

Undocumented

def docstring_headline(obj):

Undocumented

def doctype_matches(text, regex):

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"'

def duplicates_removed(it, already_seen=()):

Returns a list with duplicates removed from the iterable it.

Order is preserved.

def format_lines(var_name, seq, raw=False, indent_level=0):
Formats a sequence of strings for output.
def guess_decode(text):

Decode text with guessed encoding.

First try UTF-8; this should fail for non-UTF-8 encodings. Then try the preferred locale encoding. Fall back to latin-1, which always works.

def guess_decode_from_terminal(text, term):

Decode text coming from terminal term.

First try the terminal encoding, if given. Then try UTF-8. Then try the preferred locale encoding. Fall back to latin-1, which always works.

def html_doctype_matches(text):
Check if the file looks like it has a html doctype.
def looks_like_xml(text):
Check if a doctype exists or if we have some tags.
def make_analysator(f):
Return a static text analyser function that returns float values.
def shebang_matches(text, regex):

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 '^$')

def surrogatepair(c):
Given a unicode character code with length greater than 16 bits, return the two 16 bit surrogate pair.
def terminal_encoding(term):
Return our best guess of encoding for the given term.
_looks_like_xml_cache: dict =

Undocumented