Unable to use filter with RegexLexer

Issue #1091 resolved
created an issue

My lexer resides in pascal.py, to the import list of which I added an import for a filter:

from pygments.filters import KeywordCaseFilter

My lexer is then derived from RegexLexer ...

class Modula2Lexer(RegexLexer):

In its initialisation method I try to add the keyword case filter ...

def __init__(self, **options):
    self.reserved_words = set()
    self.builtins = set()

Unfortunately, when I run the lexer, this raises an error ...

  File "/Users/#removed#/Development/pygments/pygments/lexers/pascal.py", line 813, in __init__
  File "/Users/#removed#/Development/pygments/pygments/lexer.py", line 124, in add_filter
AttributeError: 'Modula2Lexer' object has no attribute 'filters'

Either, this is a bug in the code in that RegexLexer does not inherit the ability to add filters from its superclass Lexer, or perhaps more likely, this is a bug in your online documentation which presents these steps as sufficient to add a filter.


Comments (1)

  1. Log in to comment