Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt console doesn't work with pygments 2.0rc1 #6877

Closed
ccordoba12 opened this issue Nov 7, 2014 · 11 comments · Fixed by #6878
Closed

Qt console doesn't work with pygments 2.0rc1 #6877

ccordoba12 opened this issue Nov 7, 2014 · 11 comments · Fixed by #6878
Milestone

Comments

@ccordoba12
Copy link
Member

We have received two reports about this in Spyder already :-) This is the one I'll maintain open until it's fixed here:

https://code.google.com/p/spyderlib/issues/detail?id=2042

I'll see if I can solve this one given that you're busy with 3.0

@takluyver
Copy link
Member

Oh dear, it looks like we're monkeypatching pygments. Let's try to eliminate said monkeypatch if it's at all possible.

@ccordoba12
Copy link
Member Author

Where is that monkeypatch?

@ccordoba12
Copy link
Member Author

Removing the patch works. I'll investigate what other effects this change has.

@takluyver
Copy link
Member

Thanks! I'm reading code trying to work out why it was monkeypatched in the first place.

@ccordoba12
Copy link
Member Author

Ok, thanks!

@ccordoba12
Copy link
Member Author

After reading pygments sources, it seems that changing this if/else block:

https://github.com/ipython/ipython/blob/master/IPython/qt/console/pygments_highlighter.py#L27

to

if action is not None:
    if type(action) is _TokenType:
        yield pos, action, m.group()
    else:
        for item in action(self, m):
            yield item

solves the problem without further efforts ;-)

@takluyver
Copy link
Member

Hmmm. I'd really like to get rid of the monkeypatch properly, rather than just updating it to work with pygments at the moment.

@ccordoba12
Copy link
Member Author

I understand. It's your call then.

@takluyver
Copy link
Member

I have at least discovered what it's there for - highlighting inside multi-line strings goes wrong if I remove the monkeypatch. Now to find a better way to do it.

@takluyver
Copy link
Member

I couldn't think of a good way to do this, so #6878 keeps the monkeypatch alive, as @ccordoba12 suggested.

@minrk minrk modified the milestone: 3.0 Nov 14, 2014
@takluyver takluyver modified the milestones: 2.4, 3.0 Jan 12, 2015
minrk added a commit that referenced this issue Feb 9, 2015
… Pygments 2.0

Closes gh-6877

I spent a while looking for a better way to achive this, to get rid of the monkeypatch, but none occurred to me, so I went with Carlos' suggestion of just updating it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants