Sha256: 4b3b089910c654af2c270216c1df379359ac915252dfc4ad21199d2d7914b1d1

Contents?: true

Size: 1.21 KB

Versions: 37

Compression:

Stored size: 1.21 KB

Contents

.. -*- mode: rst -*-

=======
Filters
=======

*New in Pygments 0.7.*

You can filter token streams coming from lexers to improve or annotate the
output. For example, you can highlight special words in comments, convert
keywords to upper or lowercase to enforce a style guide etc.

To apply a filter, you can use the `add_filter()` method of a lexer:

.. sourcecode:: pycon

    >>> from pygments.lexers import PythonLexer
    >>> l = PythonLexer()
    >>> # add a filter given by a string and options
    >>> l.add_filter('codetagify', case='lower')
    >>> l.filters
    [<pygments.filters.CodeTagFilter object at 0xb785decc>]
    >>> from pygments.filters import KeywordCaseFilter
    >>> # or give an instance
    >>> l.add_filter(KeywordCaseFilter(case='lower'))

The `add_filter()` method takes keyword arguments which are forwarded to
the constructor of the filter.

To get a list of all registered filters by name, you can use the
`get_all_filters()` function from the `pygments.filters` module that returns an
iterable for all known filters.

If you want to write your own filter, have a look at `Write your own filter`_.

.. _Write your own filter: filterdevelopment.txt


Builtin Filters
===============

[builtin_filter_docs]

Version data entries

37 entries across 37 versions & 4 rubygems

Version Path
mortar-pygments.rb-0.5.7 vendor/pygments-main/docs/src/filters.txt
mortar-pygments.rb-0.5.6 vendor/pygments-main/docs/src/filters.txt
mortar-pygments.rb-0.5.5 vendor/pygments-main/docs/src/filters.txt
pygments.rb-jruby-0.5.4.2 vendor/pygments-main/docs/src/filters.txt
pygments.rb-jruby-0.5.4.1 vendor/pygments-main/docs/src/filters.txt
pygments.rb-jruby-0.5.4 vendor/pygments-main/docs/src/filters.txt
gitlab-pygments.rb-0.5.4 vendor/pygments-main/docs/src/filters.txt
pygments.rb-0.5.4 vendor/pygments-main/docs/src/filters.txt
pygments.rb-0.5.2 vendor/pygments-main/docs/src/filters.txt
pygments.rb-0.5.1 vendor/pygments-main/docs/src/filters.txt
pygments.rb-0.5.0 vendor/pygments-main/docs/src/filters.txt
gitlab-pygments.rb-0.3.2 vendor/pygments-main/docs/src/filters.txt
pygments.rb-0.4.2 vendor/pygments-main/docs/src/filters.txt
pygments.rb-0.4.1 vendor/pygments-main/docs/src/filters.txt
pygments.rb-0.3.7 vendor/pygments-main/docs/src/filters.txt
pygments.rb-0.3.6 vendor/pygments-main/docs/src/filters.txt
pygments.rb-0.3.5 vendor/pygments-main/docs/src/filters.txt
pygments.rb-0.3.4 vendor/pygments-main/docs/src/filters.txt
pygments.rb-0.3.3 vendor/pygments-main/docs/src/filters.txt
pygments.rb-0.3.2 vendor/pygments-main/docs/src/filters.txt