##// END OF EJS Templates
Backport PR #6878: Update pygments monkeypatch for compatibility with Pygments 2.0...
Min RK -
Show More
@@ -12,6 +12,11 b" def get_tokens_unprocessed(self, text, stack=('root',)):"
12 12 """ Split ``text`` into (tokentype, text) pairs.
13 13
14 14 Monkeypatched to store the final stack on the object itself.
15
16 The `text` parameter this gets passed is only the current line, so to
17 highlight things like multiline strings correctly, we need to retrieve
18 the state from the previous line (this is done in PygmentsHighlighter,
19 below), and use it to continue processing the current line.
15 20 """
16 21 pos = 0
17 22 tokendefs = self._tokens
@@ -24,11 +29,12 b" def get_tokens_unprocessed(self, text, stack=('root',)):"
24 29 for rexmatch, action, new_state in statetokens:
25 30 m = rexmatch(text, pos)
26 31 if m:
27 if type(action) is _TokenType:
28 yield pos, action, m.group()
29 else:
30 for item in action(self, m):
31 yield item
32 if action is not None:
33 if type(action) is _TokenType:
34 yield pos, action, m.group()
35 else:
36 for item in action(self, m):
37 yield item
32 38 pos = m.end()
33 39 if new_state is not None:
34 40 # state transition
General Comments 0
You need to be logged in to leave comments. Login now