Back to index

moin  1.9.0~rc2
Namespaces | Functions | Variables
MoinMoin.support.pygments Namespace Reference

Namespaces

namespace  cmdline
namespace  console
namespace  filter
namespace  filters
namespace  formatter
namespace  formatters
namespace  lexer
namespace  lexers
namespace  plugin
namespace  scanner
namespace  style
namespace  styles
namespace  token
namespace  unistring
namespace  util

Functions

def lex
def format
def highlight

Variables

string __version__ = '1.1.1'
string __docformat__ = 'restructuredtext'
list __all__ = ['lex', 'format', 'highlight']

Function Documentation

def MoinMoin.support.pygments.format (   tokens,
  formatter,
  outfile = None 
)
Format a tokenlist ``tokens`` with the formatter ``formatter``.

If ``outfile`` is given and a valid file object (an object
with a ``write`` method), the result will be written to it, otherwise
it is returned as a string.

Definition at line 53 of file __init__.py.

00053 
00054 def format(tokens, formatter, outfile=None):
00055     """
00056     Format a tokenlist ``tokens`` with the formatter ``formatter``.
00057 
00058     If ``outfile`` is given and a valid file object (an object
00059     with a ``write`` method), the result will be written to it, otherwise
00060     it is returned as a string.
00061     """
00062     try:
00063         if not outfile:
00064             #print formatter, 'using', formatter.encoding
00065             realoutfile = formatter.encoding and BytesIO() or StringIO()
00066             formatter.format(tokens, realoutfile)
00067             return realoutfile.getvalue()
00068         else:
00069             formatter.format(tokens, outfile)
00070     except TypeError, err:
00071         if isinstance(err.args[0], str) and \
00072            'unbound method format' in err.args[0]:
00073             raise TypeError('format() argument must be a formatter instance, '
00074                             'not a class')
00075         raise
00076 

Here is the caller graph for this function:

def MoinMoin.support.pygments.highlight (   code,
  lexer,
  formatter,
  outfile = None 
)
Lex ``code`` with ``lexer`` and format it with the formatter ``formatter``.

If ``outfile`` is given and a valid file object (an object
with a ``write`` method), the result will be written to it, otherwise
it is returned as a string.

Definition at line 77 of file __init__.py.

00077 
00078 def highlight(code, lexer, formatter, outfile=None):
00079     """
00080     Lex ``code`` with ``lexer`` and format it with the formatter ``formatter``.
00081 
00082     If ``outfile`` is given and a valid file object (an object
00083     with a ``write`` method), the result will be written to it, otherwise
00084     it is returned as a string.
00085     """
00086     return format(lex(code, lexer), formatter, outfile)
00087 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.support.pygments.lex (   code,
  lexer 
)
Lex ``code`` with ``lexer`` and return an iterable of tokens.

Definition at line 39 of file __init__.py.

00039 
00040 def lex(code, lexer):
00041     """
00042     Lex ``code`` with ``lexer`` and return an iterable of tokens.
00043     """
00044     try:
00045         return lexer.get_tokens(code)
00046     except TypeError, err:
00047         if isinstance(err.args[0], str) and \
00048            'unbound method get_tokens' in err.args[0]:
00049             raise TypeError('lex() argument must be a lexer instance, '
00050                             'not a class')
00051         raise
00052 

Here is the caller graph for this function:


Variable Documentation

Definition at line 31 of file __init__.py.

string MoinMoin.support.pygments.__docformat__ = 'restructuredtext'

Definition at line 29 of file __init__.py.

Definition at line 28 of file __init__.py.