##// 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 """ Split ``text`` into (tokentype, text) pairs.
12 """ Split ``text`` into (tokentype, text) pairs.
13
13
14 Monkeypatched to store the final stack on the object itself.
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 pos = 0
21 pos = 0
17 tokendefs = self._tokens
22 tokendefs = self._tokens
@@ -24,11 +29,12 b" def get_tokens_unprocessed(self, text, stack=('root',)):"
24 for rexmatch, action, new_state in statetokens:
29 for rexmatch, action, new_state in statetokens:
25 m = rexmatch(text, pos)
30 m = rexmatch(text, pos)
26 if m:
31 if m:
27 if type(action) is _TokenType:
32 if action is not None:
28 yield pos, action, m.group()
33 if type(action) is _TokenType:
29 else:
34 yield pos, action, m.group()
30 for item in action(self, m):
35 else:
31 yield item
36 for item in action(self, m):
37 yield item
32 pos = m.end()
38 pos = m.end()
33 if new_state is not None:
39 if new_state is not None:
34 # state transition
40 # state transition
General Comments 0
You need to be logged in to leave comments. Login now