summaryrefslogtreecommitdiff
path: root/pygments
diff options
context:
space:
mode:
Diffstat (limited to 'pygments')
-rw-r--r--pygments/filters/__init__.py12
-rw-r--r--pygments/formatters/__init__.py8
-rw-r--r--pygments/formatters/bbcode.py19
-rw-r--r--pygments/formatters/html.py131
-rw-r--r--pygments/formatters/latex.py62
-rw-r--r--pygments/formatters/other.py16
-rw-r--r--pygments/formatters/rtf.py14
-rw-r--r--pygments/formatters/terminal.py30
-rw-r--r--pygments/lexers/agile.py62
-rw-r--r--pygments/lexers/compiled.py29
-rw-r--r--pygments/lexers/dotnet.py17
-rw-r--r--pygments/lexers/other.py17
-rw-r--r--pygments/lexers/special.py11
-rw-r--r--pygments/lexers/templates.py234
-rw-r--r--pygments/lexers/text.py52
-rw-r--r--pygments/lexers/web.py50
16 files changed, 639 insertions, 125 deletions
diff --git a/pygments/filters/__init__.py b/pygments/filters/__init__.py
index 3f42741f..3bf7d79a 100644
--- a/pygments/filters/__init__.py
+++ b/pygments/filters/__init__.py
@@ -41,7 +41,10 @@ def get_all_filters():
class CodeTagFilter(Filter):
"""
- Highlights codetags in comments and docstrings.
+ Highlights special code tags in comments and docstrings. Per default, the
+ list of highlighted tags is ``XXX``, ``TODO``, ``BUG`` and ``NOTE``. You can
+ override this list by specifying a `codetags` parameter that takes a list of
+ words.
"""
def __init__(self, **options):
Filter.__init__(self)
@@ -72,8 +75,11 @@ class CodeTagFilter(Filter):
class KeywordCaseFilter(Filter):
"""
- Changes the case of keywords. (To ``lower``, ``upper`` or
- ``capitalize`` case)
+ Converts keywords to ``lower``, ``upper`` or ``capitalize`` which means
+ first letter uppercase, rest lowercase. This can be useful e.g. if you
+ highlight Pascal code and want to adapt the code to your styleguide. The
+ default is ``lower``, override that by providing the `keywordcase`
+ parameter.
"""
def __init__(self, **options):
diff --git a/pygments/formatters/__init__.py b/pygments/formatters/__init__.py
index be20c0ce..8aefe103 100644
--- a/pygments/formatters/__init__.py
+++ b/pygments/formatters/__init__.py
@@ -34,18 +34,18 @@ def _doc_desc(obj):
FORMATTERS = {
HtmlFormatter: ('HTML', ('html',), ('.htm', '.html'),
_doc_desc(HtmlFormatter)),
- TerminalFormatter: ('Terminal', ('terminal', 'console'), (),
- _doc_desc(TerminalFormatter)),
LatexFormatter: ('LaTeX', ('latex', 'tex'), ('.tex',),
_doc_desc(LatexFormatter)),
RtfFormatter: ('RTF', ('rtf',), ('.rtf',),
_doc_desc(RtfFormatter)),
+ TerminalFormatter: ('Terminal', ('terminal', 'console'), (),
+ _doc_desc(TerminalFormatter)),
+ BBCodeFormatter: ('BBcode', ('bbcode', 'bb'), (),
+ _doc_desc(BBCodeFormatter)),
RawTokenFormatter: ('Raw tokens', ('raw', 'tokens'), ('.raw',),
_doc_desc(RawTokenFormatter)),
NullFormatter: ('Text only', ('text', 'null'), ('.txt',),
_doc_desc(NullFormatter)),
- BBCodeFormatter: ('BBcode', ('bbcode', 'bb'), (),
- _doc_desc(BBCodeFormatter))
}
diff --git a/pygments/formatters/bbcode.py b/pygments/formatters/bbcode.py
index d9b96485..2f15884a 100644
--- a/pygments/formatters/bbcode.py
+++ b/pygments/formatters/bbcode.py
@@ -18,12 +18,14 @@ __all__ = ['BBCodeFormatter']
class BBCodeFormatter(Formatter):
"""
- Output BBCode tags with appropiate colors and formatting.
+ Formats tokens with BBcodes. These formatting codes are used by many
+ bulletin boards, so you can highlight your sourcecode with pygments before
+ posting it there.
- This formatter doesn't support background colors and borders, as there are
- no common BBcodes for that.
+ This formatter has no support for background colors and borders, as there
+ are no common BBcode tags for that.
- Some board systems (e.g. phpBB) don't support markup in their [code] tag,
+ Some board systems (e.g. phpBB) don't support colors in their [code] tag,
so you can't use the highlighting together with that tag.
Text in a [code] tag usually is shown with a monospace font (which this
formatter can do with the ``monofont`` option) and no spaces (which you
@@ -31,12 +33,13 @@ class BBCodeFormatter(Formatter):
Additional options accepted:
- ``codetag``
- If set to true, put the output into [code] tags (default: false).
+ `codetag`
+ If set to true, put the output into ``[code]`` tags (default:
+ ``false``)
- ``monofont``
+ `monofont`
If set to true, add a tag to show the code with a monospace font
- (default: false).
+ (default: ``false``).
"""
def __init__(self, **options):
diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py
index f72046ef..d323c781 100644
--- a/pygments/formatters/html.py
+++ b/pygments/formatters/html.py
@@ -103,43 +103,106 @@ td.linenos { background-color: #f0f0f0; padding-right: 10px; }
class HtmlFormatter(Formatter):
"""
- Output HTML <span> tags with appropriate classes.
+ Format tokens as HTML 4 ``<span>`` tags within a ``<pre>`` tag, wrapped
+ in a ``<div>`` tag. The ``<div>``'s CSS class can be set by the `cssclass`
+ option.
+
+ If the `linenos` option is given and true, the ``<pre>`` is additionally
+ wrapped inside a ``<table>`` which has one row and two cells: one
+ containing the line numbers and one containing the code. Example:
+
+ .. sourcecode:: html
+
+ <div class="highlight" >
+ <table><tr>
+ <td class="linenos" title="click to toggle"
+ onclick="with (this.firstChild.style)
+ { display = (display == '') ? 'none' : '' }">
+ <pre>1
+ 2</pre>
+ </td>
+ <td class="code">
+ <pre><span class="Ke">def </span><span class="NaFu">foo</span>(bar):
+ <span class="Ke">pass</span>
+ </pre>
+ </td>
+ </tr></table></div>
+
+ (whitespace added to improve clarity). Wrapping can be disabled using the
+ `nowrap` option.
+
+ With the `full` option, a complete HTML 4 document is output, including
+ the style definitions inside a ``<style>`` tag, or in a separate file if
+ the `cssfile` option is given.
+
+ The `get_style_defs(arg='')` method of a `HtmlFormatter` returns a string
+ containing CSS rules for the CSS classes used by the formatter. The
+ argument `arg` can be used to specify additional CSS selectors that
+ are prepended to the classes. A call `fmter.get_style_defs('td .code')`
+ would result in the following CSS classes:
+
+ .. sourcecode:: css
+
+ td .code .kw { font-weight: bold; color: #00FF00 }
+ td .code .cm { color: #999999 }
+ ...
+
+ If you have pygments 0.6 or higher you can also pass a list of tuple to the
+ `get_style_defs` method to request multiple prefixes for the tokens:
+
+ .. sourcecode:: python
+
+ formatter.get_style_defs(['div.syntax pre', 'pre.syntax'])
+
+ The output would then look like this:
+
+ .. sourcecode:: css
+
+ div.syntax pre .kw,
+ pre.syntax .kw { font-weight: bold; color: #00FF00 }
+ div.syntax pre .cm,
+ pre.syntax .cm { color: #999999 }
+ ...
Additional options accepted:
- ``nowrap``
- If set to true, don't wrap the tokens at all. This disables
- all other options (default: False).
- ``noclasses``
- If set to true, token <span>s will not use CSS classes, but
- inline styles.
- ``classprefix``
- Prefix for token CSS classes, is prepended to all token style
- classes (e.g. class="o" -> class="_o" if classprefix == '_')
- (default: '').
- ``cssclass``
- CSS class for the wrapping <div> (default: 'highlight').
- ``cssstyles``
- Inline CSS styles for the wrapping <div>. (default: '').
- ``cssfile``
- If the ``full`` option is ``True`` and this is not ``''``,
- put the CSS in a separate file whose name is given by this option
- (default: ''). New in 0.6.
- ``linenos``
- If set to ``True``, output line numbers (default: False).
- ``linenostart``
- The line number for the first line (default: 1).
- ``linenostep``
- If set to a number n > 1, only every nth line number is printed
- (default: 1).
- ``linenospecial``
- If set to a number n > 0, every nth line number is given a special
- CSS class ``special`` (default: 0).
- ``nobackground``
- If set to ``True`` the formatter won't output the background color
- for the overall element (this automatically defaults to ``False``
- when there is no overall element [eg: no argument for the
- `get_syntax_defs` method given]) (default: ``False``). New in 0.6.
+ `nowrap`
+ If set to ``True``, don't wrap the tokens at all, not even in a ``<pre>``
+ tag. This disables all other options (default: ``False``).
+
+ `noclasses`
+ If set to true, token ``<span>`` tags will not use CSS classes, but
+ inline styles. This is not recommended for larger pieces of code since
+ it increases output size by quite a bit (default: ``False``).
+
+ `classprefix`
+ Since the token types use relatively short class names, they may clash
+ with some of your own class names. In this case you can use the
+ `classprefix` option to give a string to prepend to all Pygments-generated
+ CSS class names for token types.
+ Note that this option also affects the output of `get_style_defs()`.
+
+ `cssclass`
+ CSS class for the wrapping ``<div>`` tag (default: ``'highlight'``).
+
+ `cssstyles`
+ Inline CSS styles for the wrapping ``<div>`` tag (default: ``''``).
+
+ `cssfile`
+ If the `full` option is true and this option is given, it must be the
+ name of an external file. The stylesheet is then written to this file
+ instead of the HTML file. *New in Pygments 0.6.*
+
+ `linenospecial`
+ If set to a number n > 0, every nth line number is given the CSS
+ class ``"special"`` (default: ``0``).
+
+ `nobackground`
+ If set to ``True``, the formatter won't output the background color
+ for the wrapping element (this automatically defaults to ``False``
+ when there is no wrapping element [eg: no argument for the
+ `get_syntax_defs` method given]) (default: ``False``). *New in
+ Pygments 0.6.*
"""
def __init__(self, **options):
diff --git a/pygments/formatters/latex.py b/pygments/formatters/latex.py
index d3d4f0b5..d8bdb8a3 100644
--- a/pygments/formatters/latex.py
+++ b/pygments/formatters/latex.py
@@ -46,32 +46,48 @@ DOC_TEMPLATE = r'''
class LatexFormatter(Formatter):
- """
- Output LaTeX "color" and "fancyvrb" control sequences.
+ r"""
+ Format tokens as LaTeX code. This needs the `fancyvrb` and `color`
+ standard packages.
+
+ Without the `full` option, code is formatted as one ``Verbatim``
+ environment, like this:
+
+ .. sourcecode:: latex
+
+ \begin{Verbatim}[commandchars=@\[\]]
+ @Can[def ]@Cax[foo](bar):
+ @Can[pass]
+ \end{Verbatim}
+
+ The command sequences used here (``@Can`` etc.) are generated from the given
+ `style` and can be retrieved using the `get_style_defs` method.
+
+ With the `full` option, a complete LaTeX document is output, including
+ the command definitions in the preamble.
+
+ The `get_style_defs(arg='')` method of a `LatexFormatter` returns a string
+ containing ``\newcommand`` commands defining the commands used inside the
+ ``Verbatim`` environments. If the argument `arg` is true,
+ ``\renewcommand`` is used instead.
+
+ Additional options accepted:
+
+ `docclass`
+ If the `full` option is enabled, this is the document class to use
+ (default: ``'article'``).
+
+ `preamble`
+ If the `full` option is enabled, this can be further preamble commands,
+ e.g. ``\usepackage`` (default: ``''``).
+
+ `verboptions`
+ Additional options given to the Verbatim environment (see the *fancyvrb*
+ docs for possible values) (default: ``''``).
+
"""
def __init__(self, **options):
- """
- Additional options accepted:
-
- ``docclass``
- If ``full`` is true, this is the document class to use (default: 'article').
- ``preamble``
- If ``full`` is true, this can be further preamble commands (default: '').
- ``linenos``
- If true, output line numbers (default: False).
- ``linenostart``
- The line number for the first line (default: 1).
- ``linenostep``
- If set to a number n > 1, only every nth line number is printed (default: 1).
- ``verboptions``
- Additional options given to the Verbatim environment (default: '').
- ``nobackground``
- If set to ``True`` the formatter won't output the background color
- for the overall element (default: ``False``)
- Note that light colors on dark background with this option disabled
- won't be readable very good.
- """
Formatter.__init__(self, **options)
self.docclass = options.get('docclass', 'article')
self.preamble = options.get('preamble', '')
diff --git a/pygments/formatters/other.py b/pygments/formatters/other.py
index f6101848..7ef39b4f 100644
--- a/pygments/formatters/other.py
+++ b/pygments/formatters/other.py
@@ -29,16 +29,18 @@ class NullFormatter(Formatter):
class RawTokenFormatter(Formatter):
- """
- Output a raw token representation for storing token streams.
+ r"""
+ Formats tokens as a raw representation for storing token streams.
- The format is ``tokentype<TAB>repr(tokenstring)``
+ The format is ``tokentype<TAB>repr(tokenstring)\n``. The output can later
+ be converted to a token stream with the `RawTokenLexer`, described in the
+ `lexer list <lexers.txt>`_.
- Additional options accepted:
+ Only one option is accepted:
- ``compress``
- If set to "gz" or "bz2", compress the token stream with
- the given compression algorithm (default: '').
+ `compress`
+ If set to ``'gz'`` or ``'bz2'``, compress the output with the given
+ compression algorithm after encoding (default: ``''``).
"""
unicodeoutput = False
diff --git a/pygments/formatters/rtf.py b/pygments/formatters/rtf.py
index f6764d50..9bfed9d8 100644
--- a/pygments/formatters/rtf.py
+++ b/pygments/formatters/rtf.py
@@ -16,7 +16,19 @@ __all__ = ['RtfFormatter']
class RtfFormatter(Formatter):
- """Output RTF (Rich Text Format)."""
+ """
+ Formats tokens as RTF markup. This formatter automatically outputs full RTF
+ documents with color information and other useful stuff. Perfect for Copy and
+ Paste into Microsoft® Word® documents.
+
+ *New in Pygments 0.6.*
+
+ Additional options accepted:
+
+ `fontface`
+ The used font famliy, for example ``Bitstream Vera Sans``. Defaults to
+ some generic font which is supposed to have fixed width.
+ """
unicodeoutput = False
diff --git a/pygments/formatters/terminal.py b/pygments/formatters/terminal.py
index 4d6debd9..661031e7 100644
--- a/pygments/formatters/terminal.py
+++ b/pygments/formatters/terminal.py
@@ -51,22 +51,26 @@ TERMINAL_COLORS = {
class TerminalFormatter(Formatter):
- """
- Output plain text with coloring ANSI sequences.
- """
+ r"""
+ Formats tokens with ANSI color sequences, for output in a text console.
+ Color sequences are terminated at newlines, so that paging the output
+ works correctly.
- def __init__(self, **options):
- """
- Accepted options:
+ The `get_style_defs()` method doesn't do anything special since there is
+ no support for common styles.
+
+ Options accepted:
- ``bg``
- Set to ``'light'`` or ``'dark'`` depending on the
- terminal's background.
+ `bg`
+ Set to ``"light"`` or ``"dark"`` depending on the terminal's background
+ (default: ``"light"``).
- ``colorscheme``
- ``None`` or a dictionary mapping token types to
- ``(lightbg, darkbg)`` color names.
- """
+ `colorscheme`
+ A dictionary mapping token types to (lightbg, darkbg) color names or
+ ``None`` (default: ``None`` = use builtin colorscheme).
+ """
+
+ def __init__(self, **options):
Formatter.__init__(self, **options)
self.darkbg = options.get('bg', 'light') == 'dark'
self.colorscheme = options.get('colorscheme', None) or TERMINAL_COLORS
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py
index 7337b323..7275ea28 100644
--- a/pygments/lexers/agile.py
+++ b/pygments/lexers/agile.py
@@ -3,7 +3,7 @@
pygments.lexers.agile
~~~~~~~~~~~~~~~~~~~~~
- Lexers for agile languages: Python, Ruby, Perl, Scheme.
+ Lexers for agile languages.
:copyright: 2006 by Georg Brandl, Armin Ronacher,
Lukas Meuser, Marek Kubica, Tim Hatch.
@@ -31,6 +31,10 @@ line_re = re.compile('.*?\n')
class PythonLexer(RegexLexer):
+ """
+ For `Python <http://www.python.org>`_ source code.
+ """
+
name = 'Python'
aliases = ['python', 'py']
filenames = ['*.py', '*.pyw']
@@ -156,11 +160,17 @@ class PythonLexer(RegexLexer):
class PythonConsoleLexer(Lexer):
"""
- Parses Python console output or doctests, like::
+ For Python console output or doctests, such as:
+
+ .. sourcecode:: pycon
- >>> a = 1
+ >>> a = 'foo'
>>> print a
- 1
+ foo
+ >>> 1 / 0
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ ZeroDivisionError: integer division or modulo by zero
"""
name = 'Python console session'
aliases = ['pycon']
@@ -207,6 +217,12 @@ class PythonConsoleLexer(Lexer):
class PythonTracebackLexer(RegexLexer):
+ """
+ For Python tracebacks.
+
+ *New in Pygments 0.7.*
+ """
+
name = 'PythonTraceback'
aliases = ['pytb']
filenames = ['*.pytb']
@@ -228,6 +244,10 @@ class PythonTracebackLexer(RegexLexer):
class RubyLexer(ExtendedRegexLexer):
+ """
+ For `Ruby <http://www.ruby-lang.org>`_ source code.
+ """
+
name = 'Ruby'
aliases = ['rb', 'ruby']
filenames = ['*.rb', '*.rbw', 'Rakefile', '*.rake', '*.gemspec', '*.rbx']
@@ -542,7 +562,9 @@ class RubyLexer(ExtendedRegexLexer):
class RubyConsoleLexer(Lexer):
"""
- Parses Ruby console output like::
+ For Ruby interactive console (**irb**) output like:
+
+ .. sourcecode:: rbcon
irb(main):001:0> a = 1
=> 1
@@ -583,6 +605,10 @@ class RubyConsoleLexer(Lexer):
class PerlLexer(RegexLexer):
+ """
+ For `Perl <http://www.perl.org>`_ source code.
+ """
+
name = 'Perl'
aliases = ['perl', 'pl']
filenames = ['*.pl', '*.pm']
@@ -717,6 +743,28 @@ class PerlLexer(RegexLexer):
class LuaLexer(RegexLexer):
+ """
+ For `Lua <http://www.lua.org>`_ source code.
+
+ Additional options accepted:
+
+ `func_name_highlighting`
+ If given and ``True``, highlight builtin function names
+ (default: ``True``).
+ `disabled_modules`
+ If given, must be a list of module names whose function names
+ should not be highlighted. By default all modules are highlighted.
+
+ To get a list of allowed modules have a look into the
+ `_luabuiltins` module:
+
+ .. sourcecode:: pycon
+
+ >>> from pygments.lexers._luabuiltins import MODULES
+ >>> MODULES.keys()
+ ['string', 'coroutine', 'modules', 'io', 'basic', ...]
+ """
+
name = 'Lua'
aliases = ['lua']
filenames = ['*.lua']
@@ -824,7 +872,9 @@ class SchemeLexer(RegexLexer):
This parser is checked with pastes from the LISP pastebin
at http://paste.lisp.org/ to cover as much syntax as possible.
- It should support the full Scheme syntax as defined in R5RS.
+ It supports the full Scheme syntax as defined in R5RS.
+
+ *New in Pygments 0.6.*
"""
name = 'Scheme'
aliases = ['scheme']
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py
index 5de1cf71..36d80d66 100644
--- a/pygments/lexers/compiled.py
+++ b/pygments/lexers/compiled.py
@@ -3,7 +3,7 @@
pygments.lexers.compiled
~~~~~~~~~~~~~~~~~~~~~~~~
- Lexers for compiled languages: C/C++, Delphi, Java.
+ Lexers for compiled languages.
:copyright: 2006 by Georg Brandl, Armin Ronacher, Christoph Hack.
:license: BSD, see LICENSE for more details.
@@ -28,6 +28,9 @@ __all__ = ['CLexer', 'CppLexer', 'DelphiLexer', 'JavaLexer']
class CLexer(RegexLexer):
+ """
+ For C source code with preprocessor directives.
+ """
name = 'C'
aliases = ['c']
filenames = ['*.c', '*.h']
@@ -122,6 +125,9 @@ class CLexer(RegexLexer):
class CppLexer(RegexLexer):
+ """
+ For C++ source code with preprocessor directives.
+ """
name = 'C++'
aliases = ['cpp', 'c++']
filenames = ['*.cpp', '*.hpp', '*.c++', '*.h++']
@@ -196,6 +202,23 @@ class CppLexer(RegexLexer):
class DelphiLexer(Lexer):
+ """
+ For `Delphi <http://www.borland.com/delphi/>`_ (Borland Object Pascal),
+ Turbo Pascal and Free Pascal source code.
+
+ Additional options accepted:
+
+ `turbopascal`
+ Highlight Turbo Pascal specific keywords (default: ``True``).
+ `delphi`
+ Highlight Borland Delphi specific keywords (default: ``True``).
+ `freepascal`
+ Highlight Free Pascal specific keywords (default: ``True``).
+ `units`
+ A list of units that should be considered builtin, supported are
+ ``System``, ``SysUtils``, ``Classes`` and ``Math``.
+ Default is to consider all of them builtin.
+ """
name = 'Delphi'
aliases = ['delphi', 'pas', 'pascal', 'objectpascal']
filenames = ['*.pas']
@@ -663,6 +686,10 @@ class DelphiLexer(Lexer):
class JavaLexer(RegexLexer):
+ """
+ For `Java <http://www.sun.com/java/>`_ source code.
+ """
+
name = 'Java'
aliases = ['java']
filenames = ['*.java']
diff --git a/pygments/lexers/dotnet.py b/pygments/lexers/dotnet.py
index c8b278d8..f47532ba 100644
--- a/pygments/lexers/dotnet.py
+++ b/pygments/lexers/dotnet.py
@@ -3,7 +3,7 @@
pygments.lexers.dotnet
~~~~~~~~~~~~~~~~~~~~~~
- .net languages
+ Lexers for .net languages.
:copyright: 2006 by Georg Brandl, Armin Ronacher.
:license: BSD, see LICENSE for more details.
@@ -18,6 +18,11 @@ __all__ = ['CSharpLexer', 'BooLexer', 'VbNetLexer']
class CSharpLexer(RegexLexer):
+ """
+ For `C# <http://msdn2.microsoft.com/en-us/vcsharp/default.aspx>`_
+ source code.
+ """
+
name = 'C#'
aliases = ['csharp', 'c#']
filenames = ['*.cs']
@@ -75,6 +80,10 @@ class CSharpLexer(RegexLexer):
class BooLexer(RegexLexer):
+ """
+ For `Boo <http://boo.codehaus.org/>`_ source code.
+ """
+
name = 'Boo'
aliases = ['boo']
filenames = ['*.boo']
@@ -138,6 +147,12 @@ class BooLexer(RegexLexer):
class VbNetLexer(RegexLexer):
+ """
+ For
+ `Visual Basic.NET <http://msdn2.microsoft.com/en-us/vbasic/default.aspx>`_
+ source code.
+ """
+
name = 'VB.net'
aliases = ['vb.net', 'vbnet']
filenames = ['*.vb', '*.bas']
diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py
index cede911f..cec162b4 100644
--- a/pygments/lexers/other.py
+++ b/pygments/lexers/other.py
@@ -3,7 +3,7 @@
pygments.lexers.other
~~~~~~~~~~~~~~~~~~~~~
- Lexers for other languages: SQL, BrainFuck.
+ Lexers for other languages.
:copyright: 2006 by Georg Brandl, Tim Hatch <tim@timhatch.com>.
:license: BSD, see LICENSE for more details.
@@ -21,6 +21,11 @@ __all__ = ['SqlLexer', 'BrainfuckLexer', 'BashLexer']
class SqlLexer(RegexLexer):
+ """
+ Lexer for Structured Query Language. Currently, this lexer does
+ not recognize any special syntax except ANSI SQL.
+ """
+
name = 'SQL'
aliases = ['sql']
filenames = ['*.sql']
@@ -130,6 +135,11 @@ class SqlLexer(RegexLexer):
class BrainfuckLexer(RegexLexer):
+ """
+ Lexer for the esoteric `BrainFuck <http://www.muppetlabs.com/~breadbox/bf/>`_
+ language.
+ """
+
name = 'Brainfuck'
aliases = ['brainfuck', 'bf']
filenames = ['*.bf', '*.b']
@@ -157,8 +167,11 @@ class BrainfuckLexer(RegexLexer):
class BashLexer(RegexLexer):
"""
- Lex (ba)sh source files.
+ Lexer for (ba)sh shell scripts.
+
+ *New in Pygments 0.6.*
"""
+
name = 'Bash'
aliases = ['bash', 'sh']
filenames = ['*.sh']
diff --git a/pygments/lexers/special.py b/pygments/lexers/special.py
index 5af9320a..8cd43246 100644
--- a/pygments/lexers/special.py
+++ b/pygments/lexers/special.py
@@ -20,6 +20,9 @@ __all__ = ['TextLexer', 'RawTokenLexer']
class TextLexer(Lexer):
+ """
+ "Null" lexer, doesn't highlight anything.
+ """
name = 'Text only'
aliases = ['text']
filenames = ['*.txt']
@@ -35,13 +38,13 @@ line_re = re.compile('.*?\n')
class RawTokenLexer(Lexer):
"""
- Recreate a token stream formatted with the RawTokenFormatter.
+ Recreate a token stream formatted with the `RawTokenFormatter`.
Additional options accepted:
- ``compress``
- If set to "gz" or "bz2", decompress the token stream with
- the given compression algorithm (default: '').
+ `compress`
+ If set to ``"gz"`` or ``"bz2"``, decompress the token stream with
+ the given compression algorithm before lexing (default: ``''``).
"""
name = 'Raw token data'
aliases = ['raw']
diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py
index 3efb3ba5..7c8c356d 100644
--- a/pygments/lexers/templates.py
+++ b/pygments/lexers/templates.py
@@ -3,7 +3,7 @@
pygments.lexers.templates
~~~~~~~~~~~~~~~~~~~~~~~~~
- Lexers for various template engines.
+ Lexers for various template engines' markup.
:copyright: 2006 by Armin Ronacher, Georg Brandl, Matt Good,
Ben Bangert.
@@ -40,6 +40,16 @@ __all__ = ['HtmlPhpLexer', 'XmlPhpLexer', 'CssPhpLexer',
class ErbLexer(Lexer):
+ """
+ Generic `ERB <http://ruby-doc.org/core/classes/ERB.html>`_ (Ruby Templating)
+ lexer.
+
+ Just highlights ruby code between the preprocessor directives, other data
+ is left untouched by the lexer.
+
+ All options are also forwarded to the `RubyLexer`.
+ """
+
name = 'ERB'
aliases = ['erb']
@@ -124,6 +134,13 @@ class ErbLexer(Lexer):
class SmartyLexer(RegexLexer):
+ """
+ Generic `Smarty <http://smarty.php.net/>`_ template lexer.
+
+ Just highlights smarty code between the preprocessor directives, other
+ data is left untouched by the lexer.
+ """
+
name = 'Smarty'
aliases = ['smarty']
filenames = ['*.tpl']
@@ -171,6 +188,14 @@ class SmartyLexer(RegexLexer):
class DjangoLexer(RegexLexer):
+ """
+ Generic `django <http://www.djangoproject.com/documentation/templates/>`_
+ and `jinja <http://wsgiarea.pocoo.org/jinja/>`_ template lexer.
+
+ It just highlights django/jinja code between the preprocessor directives,
+ other data is left untouched by the lexer.
+ """
+
name = 'Django/Jinja'
aliases = ['django', 'jinja']
@@ -227,6 +252,15 @@ class DjangoLexer(RegexLexer):
class MyghtyLexer(RegexLexer):
+ """
+ Generic `myghty templates`_ lexer. Code that isn't Myghty
+ markup is yielded as `Token.Other`.
+
+ *New in Pygments 0.6.*
+
+ .. _myghty templates: http://www.myghty.org/
+ """
+
name = 'Myghty'
aliases = ['myghty']
filenames = ['*.myt', 'autodelegate']
@@ -250,22 +284,28 @@ class MyghtyLexer(RegexLexer):
(r'(?<=^)\#[^\n]*(\n|\Z)', Comment),
(r'(?<=^)(\%)([^\n]*)(\n|\Z)',
bygroups(Name.Tag, using(PythonLexer), Other)),
- (r'''(?sx)
- (.+?) # anything, followed by:
- (?:
- (?<=\n)(?=[%#]) | # an eval or comment line
- (?=</?[%&]) | # a substitution or block or
- # call start or end
- # - don't consume
- (\\\n) | # an escaped newline
- \Z # end of string
- )
- ''', bygroups(Other, Operator)),
+ (r"""(?sx)
+ (.+?) # anything, followed by:
+ (?:
+ (?<=\n)(?=[%#]) | # an eval or comment line
+ (?=</?[%&]) | # a substitution or block or
+ # call start or end
+ # - don't consume
+ (\\\n) | # an escaped newline
+ \Z # end of string
+ )""", bygroups(Other, Operator)),
]
}
class MyghtyHtmlLexer(DelegatingLexer):
+ """
+ Subclass of the `MyghtyLexer` that highlights unlexer data
+ with the `HtmlLexer`.
+
+ *New in Pygments 0.6.*
+ """
+
name = 'HTML+Myghty'
aliases = ['html+myghty']
@@ -275,6 +315,13 @@ class MyghtyHtmlLexer(DelegatingLexer):
class MyghtyXmlLexer(DelegatingLexer):
+ """
+ Subclass of the `MyghtyLexer` that highlights unlexer data
+ with the `XmlLexer`.
+
+ *New in Pygments 0.6.*
+ """
+
name = 'XML+Myghty'
aliases = ['xml+myghty']
@@ -284,6 +331,13 @@ class MyghtyXmlLexer(DelegatingLexer):
class MyghtyJavascriptLexer(DelegatingLexer):
+ """
+ Subclass of the `MyghtyLexer` that highlights unlexer data
+ with the `JavascriptLexer`.
+
+ *New in Pygments 0.6.*
+ """
+
name = 'JavaScript+Myghty'
aliases = ['js+myghty', 'javascript+myghty']
@@ -293,6 +347,13 @@ class MyghtyJavascriptLexer(DelegatingLexer):
class MyghtyCssLexer(DelegatingLexer):
+ """
+ Subclass of the `MyghtyLexer` that highlights unlexer data
+ with the `CssLexer`.
+
+ *New in Pygments 0.6.*
+ """
+
name = 'CSS+Myghty'
aliases = ['css+myghty']
@@ -302,6 +363,15 @@ class MyghtyCssLexer(DelegatingLexer):
class MakoLexer(RegexLexer):
+ """
+ Generic `mako templates`_ lexer. Code that isn't Mako
+ markup is yielded as `Token.Other`.
+
+ *New in Pygments 0.7.*
+
+ .. _mako templates: http://www.makotemplates.org/
+ """
+
name = 'Mako'
aliases = ['mako']
filenames = ['*.mao']
@@ -358,6 +428,13 @@ class MakoLexer(RegexLexer):
class MakoHtmlLexer(DelegatingLexer):
+ """
+ Subclass of the `MakoLexer` that highlights unlexed data
+ with the `HtmlLexer`.
+
+ *New in Pygments 0.7.*
+ """
+
name = 'HTML+Mako'
aliases = ['html+mako']
@@ -366,6 +443,13 @@ class MakoHtmlLexer(DelegatingLexer):
**options)
class MakoXmlLexer(DelegatingLexer):
+ """
+ Subclass of the `MakoLexer` that highlights unlexer data
+ with the `XmlLexer`.
+
+ *New in Pygments 0.7.*
+ """
+
name = 'XML+Mako'
aliases = ['xml+mako']
@@ -374,6 +458,13 @@ class MakoXmlLexer(DelegatingLexer):
**options)
class MakoJavascriptLexer(DelegatingLexer):
+ """
+ Subclass of the `MakoLexer` that highlights unlexer data
+ with the `JavascriptLexer`.
+
+ *New in Pygments 0.7.*
+ """
+
name = 'JavaScript+Mako'
aliases = ['js+mako', 'javascript+mako']
@@ -382,6 +473,13 @@ class MakoJavascriptLexer(DelegatingLexer):
MakoLexer, **options)
class MakoCssLexer(DelegatingLexer):
+ """
+ Subclass of the `MakoLexer` that highlights unlexer data
+ with the `CssLexer`.
+
+ *New in Pygments 0.7.*
+ """
+
name = 'CSS+Mako'
aliases = ['css+mako']
@@ -393,6 +491,11 @@ class MakoCssLexer(DelegatingLexer):
# Genshi lexers courtesy of Matt Good.
class GenshiTextLexer(RegexLexer):
+ """
+ A lexer that highlights `genshi <http://genshi.edgewall.org/>`_ text
+ templates.
+ """
+
name = 'Genshi Text'
aliases = ['genshitext']
@@ -422,6 +525,11 @@ class GenshiTextLexer(RegexLexer):
class GenshiMarkupLexer(RegexLexer):
+ """
+ Base lexer for Genshi markup, used by `HtmlGenshiLexer` and
+ `GenshiLexer`.
+ """
+
flags = re.DOTALL
tokens = {
@@ -481,6 +589,11 @@ class GenshiMarkupLexer(RegexLexer):
class HtmlGenshiLexer(DelegatingLexer):
+ """
+ A lexer that highlights `genshi <http://genshi.edgewall.org/>`_ and
+ `kid <http://kid-templating.org/>`_ kid HTML templates.
+ """
+
name = 'HTML+Genshi'
aliases = ['html+genshi', 'html+kid']
alias_filenames = ['*.html', '*.htm', '*.xhtml']
@@ -499,6 +612,11 @@ class HtmlGenshiLexer(DelegatingLexer):
class GenshiLexer(DelegatingLexer):
+ """
+ A lexer that highlights `genshi <http://genshi.edgewall.org/>`_ and
+ `kid <http://kid-templating.org/>`_ kid XML templates.
+ """
+
name = 'Genshi'
aliases = ['genshi', 'kid', 'xml+genshi', 'xml+kid']
filenames = ['*.kid']
@@ -518,6 +636,10 @@ class GenshiLexer(DelegatingLexer):
class JavascriptGenshiLexer(DelegatingLexer):
+ """
+ A lexer that highlights javascript code in genshi text templates.
+ """
+
name = 'JavaScript+Genshi Text'
aliases = ['js+genshitext', 'js+genshi', 'javascript+genshitext',
'javascript+genshi']
@@ -533,6 +655,10 @@ class JavascriptGenshiLexer(DelegatingLexer):
class CssGenshiLexer(DelegatingLexer):
+ """
+ A lexer that highlights CSS definitions in genshi text templates.
+ """
+
name = 'CSS+Genshi Text'
aliases = ['css+genshitext', 'css+genshi']
alias_filenames = ['*.css']
@@ -546,6 +672,13 @@ class CssGenshiLexer(DelegatingLexer):
class RhtmlLexer(DelegatingLexer):
+ """
+ Subclass of the ERB lexer that highlights the unlexed data with the
+ html lexer.
+
+ Nested Javascript and CSS is highlighted too.
+ """
+
name = 'RHTML'
aliases = ['rhtml', 'html+erb', 'html+ruby']
filenames = ['*.rhtml']
@@ -563,6 +696,11 @@ class RhtmlLexer(DelegatingLexer):
class XmlErbLexer(DelegatingLexer):
+ """
+ Subclass of `ErbLexer` which highlights data outside preprocessor
+ directives with the `XmlLexer`.
+ """
+
name = 'XML+Ruby'
aliases = ['xml+erb', 'xml+ruby']
alias_filenames = ['*.xml']
@@ -578,6 +716,10 @@ class XmlErbLexer(DelegatingLexer):
class CssErbLexer(DelegatingLexer):
+ """
+ Subclass of `ErbLexer` which highlights unlexed data with the `CssLexer`.
+ """
+
name = 'CSS+Ruby'
aliases = ['css+erb', 'css+ruby']
alias_filenames = ['*.xml']
@@ -590,6 +732,11 @@ class CssErbLexer(DelegatingLexer):
class JavascriptErbLexer(DelegatingLexer):
+ """
+ Subclass of `ErbLexer` which highlights unlexed data with the
+ `JavascriptLexer`.
+ """
+
name = 'JavaScript+Ruby'
aliases = ['js+erb', 'javascript+erb', 'js+ruby', 'javascript+ruby']
alias_filenames = ['*.js']
@@ -603,6 +750,12 @@ class JavascriptErbLexer(DelegatingLexer):
class HtmlPhpLexer(DelegatingLexer):
+ """
+ Subclass of `PhpLexer` that highlights unhandled data with the `HtmlLexer`.
+
+ Nested Javascript and CSS is highlighted too.
+ """
+
name = 'HTML+PHP'
aliases = ['html+php']
filenames = ['*.phtml']
@@ -623,6 +776,10 @@ class HtmlPhpLexer(DelegatingLexer):
class XmlPhpLexer(DelegatingLexer):
+ """
+ Subclass of `PhpLexer` that higlights unhandled data with the `XmlLexer`.
+ """
+
name = 'XML+PHP'
aliases = ['xml+php']
alias_filenames = ['*.xml', '*.php', '*.php[345]']
@@ -638,6 +795,10 @@ class XmlPhpLexer(DelegatingLexer):
class CssPhpLexer(DelegatingLexer):
+ """
+ Subclass of `PhpLexer` which highlights unmatched data with the `CssLexer`.
+ """
+
name = 'CSS+PHP'
aliases = ['css+php']
alias_filenames = ['*.css']
@@ -650,6 +811,11 @@ class CssPhpLexer(DelegatingLexer):
class JavascriptPhpLexer(DelegatingLexer):
+ """
+ Subclass of `PhpLexer` which highlights unmatched data with the
+ `JavascriptLexer`.
+ """
+
name = 'JavaScript+PHP'
aliases = ['js+php', 'javascript+php']
alias_filenames = ['*.js']
@@ -663,6 +829,13 @@ class JavascriptPhpLexer(DelegatingLexer):
class HtmlSmartyLexer(DelegatingLexer):
+ """
+ Subclass of the `SmartyLexer` that highighlights unlexed data with the
+ `HtmlLexer`.
+
+ Nested Javascript and CSS is highlighted too.
+ """
+
name = 'HTML+Smarty'
aliases = ['html+smarty']
alias_filenames = ['*.html', '*.htm', '*.xhtml', '*.tpl']
@@ -678,6 +851,11 @@ class HtmlSmartyLexer(DelegatingLexer):
class XmlSmartyLexer(DelegatingLexer):
+ """
+ Subclass of the `SmartyLexer` that highlights unlexed data with the
+ `XmlLexer`.
+ """
+
name = 'XML+Smarty'
aliases = ['xml+smarty']
alias_filenames = ['*.xml', '*.tpl']
@@ -693,6 +871,11 @@ class XmlSmartyLexer(DelegatingLexer):
class CssSmartyLexer(DelegatingLexer):
+ """
+ Subclass of the `SmartyLexer` that highlights unlexed data with the
+ `CssLexer`.
+ """
+
name = 'CSS+Smarty'
aliases = ['css+smarty']
alias_filenames = ['*.css', '*.tpl']
@@ -705,6 +888,11 @@ class CssSmartyLexer(DelegatingLexer):
class JavascriptSmartyLexer(DelegatingLexer):
+ """
+ Subclass of the `SmartyLexer` that highlights unlexed data with the
+ `JavascriptLexer`.
+ """
+
name = 'JavaScript+Smarty'
aliases = ['js+smarty', 'javascript+smarty']
alias_filenames = ['*.js', '*.tpl']
@@ -718,6 +906,13 @@ class JavascriptSmartyLexer(DelegatingLexer):
class HtmlDjangoLexer(DelegatingLexer):
+ """
+ Subclass of the `DjangoLexer` that highighlights unlexed data with the
+ `HtmlLexer`.
+
+ Nested Javascript and CSS is highlighted too.
+ """
+
name = 'HTML+Django/Jinja'
aliases = ['html+django', 'html+jinja']
alias_filenames = ['*.html', '*.htm', '*.xhtml']
@@ -733,6 +928,11 @@ class HtmlDjangoLexer(DelegatingLexer):
class XmlDjangoLexer(DelegatingLexer):
+ """
+ Subclass of the `DjangoLexer` that highlights unlexed data with the
+ `XmlLexer`.
+ """
+
name = 'XML+Django/Jinja'
aliases = ['xml+django', 'xml+jinja']
alias_filenames = ['*.xml']
@@ -748,6 +948,11 @@ class XmlDjangoLexer(DelegatingLexer):
class CssDjangoLexer(DelegatingLexer):
+ """
+ Subclass of the `DjangoLexer` that highlights unlexed data with the
+ `CssLexer`.
+ """
+
name = 'CSS+Django/Jinja'
aliases = ['css+django', 'css+jinja']
alias_filenames = ['*.css']
@@ -760,6 +965,11 @@ class CssDjangoLexer(DelegatingLexer):
class JavascriptDjangoLexer(DelegatingLexer):
+ """
+ Subclass of the `DjangoLexer` that highlights unlexed data with the
+ `JavascriptLexer`.
+ """
+
name = 'JavaScript+Django/Jinja'
aliases = ['js+django', 'javascript+django',
'js+jinja', 'javascript+jinja']
diff --git a/pygments/lexers/text.py b/pygments/lexers/text.py
index adee57e4..ba03ff01 100644
--- a/pygments/lexers/text.py
+++ b/pygments/lexers/text.py
@@ -3,7 +3,7 @@
pygments.lexers.text
~~~~~~~~~~~~~~~~~~~~
- Lexers for non-source code file types: Diff, Makefiles, Ini configs etc.
+ Lexers for non-source code file types.
:copyright: 2006 by Armin Ronacher, Georg Brandl,
Tim Hatch <tim@timhatch.com>,
@@ -29,6 +29,10 @@ __all__ = ['IniLexer', 'SourcesListLexer', 'MakefileLexer', 'DiffLexer',
class IniLexer(RegexLexer):
+ """
+ Lexer for configuration files in INI style.
+ """
+
name = 'INI'
aliases = ['ini', 'cfg']
filenames = ['*.ini', '*.cfg']
@@ -52,8 +56,11 @@ class IniLexer(RegexLexer):
class SourcesListLexer(RegexLexer):
"""
- Lex debian sources.list files
+ Lexer that highlights debian sources.list files.
+
+ *New in Pygments 0.7.*
"""
+
name= 'Debian Sourcelist'
aliases = ['sourceslist', 'sources.list']
filenames = ['sources.list']
@@ -97,6 +104,10 @@ class SourcesListLexer(RegexLexer):
class MakefileLexer(RegexLexer):
+ """
+ Lexer for Makefiles.
+ """
+
name = 'Makefile'
aliases = ['make', 'makefile', 'mf']
filenames = ['*.mak', 'Makefile', 'makefile']
@@ -140,6 +151,10 @@ class MakefileLexer(RegexLexer):
class DiffLexer(RegexLexer):
+ """
+ Lexer for unified or context-style diffs or patches.
+ """
+
name = 'Diff'
aliases = ['diff']
filenames = ['*.diff', '*.patch']
@@ -168,6 +183,10 @@ class DiffLexer(RegexLexer):
class IrcLogsLexer(RegexLexer):
+ """
+ Lexer for IRC logs in **irssi** or **xchat** style.
+ """
+
name = 'IRC logs'
aliases = ['irc']
@@ -208,6 +227,12 @@ class IrcLogsLexer(RegexLexer):
class BBCodeLexer(RegexLexer):
+ """
+ A lexer that highlights BBCode(-like) syntax.
+
+ *New in Pygments 0.6.*
+ """
+
name = 'BBCode'
aliases = ['bbcode']
@@ -223,6 +248,10 @@ class BBCodeLexer(RegexLexer):
class TexLexer(RegexLexer):
+ """
+ Lexer for the TeX and LaTeX typesetting languages.
+ """
+
name = 'TeX'
aliases = ['tex', 'latex']
filenames = ['*.tex', '*.aux', '*.toc']
@@ -277,9 +306,12 @@ class TexLexer(RegexLexer):
class GroffLexer(RegexLexer):
"""
- Lexer for the roff format, supporting groff extensions. Mainly useful
- for highlighting manpages.
+ Lexer for the (g)roff typesetting language, supporting groff
+ extensions. Mainly useful for highlighting manpage sources.
+
+ *New in Pygments 0.6.*
"""
+
name = 'Groff'
aliases = ['groff', 'nroff', 'man']
filenames = ['*.[1234567]', '*.man']
@@ -329,8 +361,12 @@ class GroffLexer(RegexLexer):
class ApacheConfLexer(RegexLexer):
"""
- Lex Apache configuration like files.
+ Lexer for configuration files following the Apache config file
+ format.
+
+ *New in Pygments 0.6.*
"""
+
name = 'ApacheConf'
aliases = ['apacheconf', 'aconf', 'apache']
filenames = ['.htaccess', 'apache.conf', 'apache2.conf']
@@ -361,6 +397,12 @@ class ApacheConfLexer(RegexLexer):
class MoinWikiLexer(RegexLexer):
+ """
+ For MoinMoin (and Trac) Wiki markup.
+
+ *New in Pygments 0.7.*
+ """
+
name = 'MoinMoin/Trac Wiki markup'
aliases = ['trac-wiki', 'moin']
filenames = []
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index 9ae674cb..09374209 100644
--- a/pygments/lexers/web.py
+++ b/pygments/lexers/web.py
@@ -3,7 +3,7 @@
pygments.lexers.web
~~~~~~~~~~~~~~~~~~~
- Lexers for web-related languages: JavaScript, CSS, HTML, XML, PHP.
+ Lexers for web-related languages and markup.
:copyright: 2006 by Georg Brandl, Armin Ronacher,
Tim Hatch <tim@timhatch.com>.
@@ -28,6 +28,10 @@ __all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'CssLexer',
class JavascriptLexer(RegexLexer):
+ """
+ For JavaScript source code.
+ """
+
name = 'JavaScript'
aliases = ['js', 'javascript']
filenames = ['*.js']
@@ -61,6 +65,10 @@ class JavascriptLexer(RegexLexer):
class CssLexer(RegexLexer):
+ """
+ For CSS (Cascading Style Sheets).
+ """
+
name = 'CSS'
aliases = ['css']
filenames = ['*.css']
@@ -190,6 +198,11 @@ class CssLexer(RegexLexer):
class HtmlLexer(RegexLexer):
+ """
+ For HTML 4 and XHTML 1 markup. Nested JavaScript and CSS is highlighted
+ by the appropriate lexer.
+ """
+
name = 'HTML'
aliases = ['html']
filenames = ['*.html', '*.htm', '*.xhtml']
@@ -240,6 +253,37 @@ class HtmlLexer(RegexLexer):
class PhpLexer(RegexLexer):
+ """
+ For `PHP <http://www.php.net/>`_ source code.
+ For PHP embedded in HTML, use the `HtmlPhpLexer`.
+
+ Additional options accepted:
+
+ `startinline`
+ If given and ``True`` the lexer starts highlighting with
+ php code. (i.e.: no starting ``<?php`` required)
+ `funcnamehighlighting`
+ If given and ``True``, highlight builtin function names
+ (default: ``True``).
+ `disabledmodules`
+ If given, must be a list of module names whose function names
+ should not be highlighted. By default all modules are highlighted
+ except the special ``'unknown'`` module that includes functions
+ that are known to php but are undocumented.
+
+ To get a list of allowed modules have a look into the
+ `_phpbuiltins` module:
+
+ .. sourcecode:: pycon
+
+ >>> from pygments.lexers._phpbuiltins import MODULES
+ >>> MODULES.keys()
+ ['PHP Options/Info', 'Zip', 'dba', ...]
+
+ In fact the names of those modules match the module names from
+ the php documentation.
+ """
+
name = 'PHP'
aliases = ['php', 'php3', 'php4', 'php5']
filenames = ['*.php', '*.php[345]']
@@ -349,6 +393,10 @@ class PhpLexer(RegexLexer):
class XmlLexer(RegexLexer):
+ """
+ Generic lexer for XML (eXtensible Markup Language).
+ """
+
flags = re.MULTILINE | re.DOTALL
name = 'XML'