pygmentize - using Pygments to highlight source code

native_tags.contrib.pygmentize.highlight(code, lexer, **kwargs)
Returns highlighted code div tag from HtmlFormatter

Lexer is guessed by lexer name arguments are passed into the formatter

Syntax:

{% highlight [source code] [lexer name] [formatter options] %}

Example:

{% highlight 'print "Hello World"' python linenos=true %}

This is a function tag.

native_tags.contrib.pygmentize.highlight_block(context, nodelist, lexer, **kwargs)
Code is nodelist rendered in context

Returns highlighted code div tag from HtmlFormatter Lexer is guessed by lexer name arguments are passed into the formatter

Syntax:

{% highlight_block [lexer name] [formatter options] %}
    ... source code ..
{% endhighlight_block %}

Example:

{% highlight_block python linenos=true %}
    print '{{ request.path }}'
{% endhighlight_block %}

This is a block tag.

native_tags.contrib.pygmentize.highlight_style(cssclass='highlight', **kwargs)
Returns the CSS from the HtmlFormatter.

cssclass is the name of the div css class to use

Syntax:

{% highlight_style [cssclass] [formatter options] %}

Example:

{% highlight_style code linenos=true %}

This is a function tag.

Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.