eric6/ThirdParty/Pygments/pygments/filter.py

changeset 7701
25f42e208e08
parent 7547
21b0534faebc
child 7983
54c5cfbb1e29
equal deleted inserted replaced
7700:a3cf077a8db3 7701:25f42e208e08
3 pygments.filter 3 pygments.filter
4 ~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~
5 5
6 Module that implements the default filter. 6 Module that implements the default filter.
7 7
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 12
13 def apply_filters(stream, filters, lexer=None): 13 def apply_filters(stream, filters, lexer=None):
15 Use this method to apply an iterable of filters to 15 Use this method to apply an iterable of filters to
16 a stream. If lexer is given it's forwarded to the 16 a stream. If lexer is given it's forwarded to the
17 filter, otherwise the filter receives `None`. 17 filter, otherwise the filter receives `None`.
18 """ 18 """
19 def _apply(filter_, stream): 19 def _apply(filter_, stream):
20 for token in filter_.filter(lexer, stream): 20 yield from filter_.filter(lexer, stream)
21 yield token
22 for filter_ in filters: 21 for filter_ in filters:
23 stream = _apply(filter_, stream) 22 stream = _apply(filter_, stream)
24 return stream 23 return stream
25 24
26 25
68 self.__class__.__name__) 67 self.__class__.__name__)
69 Filter.__init__(self, **options) 68 Filter.__init__(self, **options)
70 69
71 def filter(self, lexer, stream): 70 def filter(self, lexer, stream):
72 # pylint: disable=not-callable 71 # pylint: disable=not-callable
73 for ttype, value in self.function(lexer, stream, self.options): 72 yield from self.function(lexer, stream, self.options)
74 yield ttype, value

eric ide

mercurial