Running pygments default lexer on the following c++ text: class foo{};
, results in this:
(Token.Keyword, 'class')
(Token.Text, ' ')
(Token.Name.Class, 'foo')
(Token.Punctuation, '{')
(Token.Punctuation, '}')
(Token.Punctuation, ';')
Note that the toke foo
has the type Token.Name.Class
.
If i change the class name to foobar
i want to be able to run the default lexer only on the touched tokens, in this case original tokens foo
and {
.
Q: How can i save the lexer state so that tokenizing foobar{
will give tokens with type Token.Name.Class
?
Having this feature would optimize syntax highlighting for large source files that suffered a change (user is typing text) right in the middle of the file for example. There seems no documented way of doing this and no information on how to do this using the default pygments lexers.
Are there any other syntax highlighting systems that have support for this behavior ?
EDIT:
Regarding performance here is an example: http://tpcg.io/ESYjiF