Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.support.pygments.filters.NameHighlightFilter Class Reference
Inheritance diagram for MoinMoin.support.pygments.filters.NameHighlightFilter:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.support.pygments.filters.NameHighlightFilter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def filter

Public Attributes

 names
 tokentype

Detailed Description

Highlight a normal Name token with a different token type.

Example::

    filter = NameHighlightFilter(
        names=['foo', 'bar', 'baz'],
        tokentype=Name.Function,
    )

This would highlight the names "foo", "bar" and "baz"
as functions. `Name.Function` is the default token type.

Options accepted:

`names` : list of strings
  A list of names that should be given the different token type.
  There is no default.
`tokentype` : TokenType or string
  A token type or a string containing a token type name that is
  used for highlighting the strings in `names`.  The default is
  `Name.Function`.

Definition at line 133 of file __init__.py.


Constructor & Destructor Documentation

Definition at line 158 of file __init__.py.

00158 
00159     def __init__(self, **options):
00160         Filter.__init__(self, **options)
00161         self.names = set(get_list_opt(options, 'names', []))
00162         tokentype = options.get('tokentype')
00163         if tokentype:
00164             self.tokentype = string_to_tokentype(tokentype)
00165         else:
00166             self.tokentype = Name.Function


Member Function Documentation

def MoinMoin.support.pygments.filters.NameHighlightFilter.filter (   self,
  lexer,
  stream 
)

Definition at line 167 of file __init__.py.

00167 
00168     def filter(self, lexer, stream):
00169         for ttype, value in stream:
00170             if ttype is Name and value in self.names:
00171                 yield self.tokentype, value
00172             else:
00173                 yield ttype, value
00174 


Member Data Documentation

Definition at line 160 of file __init__.py.

Definition at line 163 of file __init__.py.


The documentation for this class was generated from the following file: