(Python) Syntax highlighting bug in Python REPL
See original GitHub issueDescribe the issue
While posting an answer on Stack Overflow, I noticed a syntax highlighting bug in the code block showing my Python program in a REPL environment. I posted the issue on Stack Exchange Meta here which shows the bug clearly.
Which language seems to have the issue?
Python.
Are you using highlight
or highlightAuto
?
I am using Stack Overflow highlighting with an explicit python
tag.
Sample Code to Reproduce
>>> class A:
... @classmethod
... def f(cls): return 'A.f'
...
>>> class B(A):
... @classmethod
... def f(cls): return 'B.f'
...
>>> b = B()
>>> b.f
<bound method B.f of <class '__main__.B'>>
>>> B.f
<bound method B.f of <class '__main__.B'>>
>>> b.f()
'B.f'
>>> B.f()
'B.f'
>>> super(B, b).f
<bound method A.f of <class '__main__.B'>>
>>> super(B, B).f
<bound method A.f of <class '__main__.B'>>
>>> super(B, b).f()
'A.f'
>>> super(B, B).f()
'A.f'
Expected behavior
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
HTML syntax highlighting bug? - Replit
html file within my linked Repl. A decent sized block of the HTML code towards the bottom of the file has the grey...
Read more >Syntax highlighting language request: Python REPL
Highlight.js treats Python REPL (the Python interpreter in interactive mode) as its own language separate from Python—it uses the class ...
Read more >Python REPL with syntax highlighting, autocomplete and ...
So I wrote a small function to just invoke the editor with the lines in the current prompt 'buffer'[1]. This gives all the...
Read more >Broken Python syntax highlighting when raw strings ... - GitLab
Summary Syntax highlighting fails after a Python raw string is encountered. All the subsequent code is wrongly displayed as a string....
Read more >strange issue for python syntax highlight in emacs
python.el highlihghts left hand side of assignment in a different color. It is known that it does not work with complex ones [1]....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think what is happening here is the quotes around the class name or the
<>
in the output is messing up the rest of the output. Compare highlight.js on SOwith the highlighter used by GitHub
All that stuff shouldn’t be orange. I just ran into what looks to be the same bug here https://stackoverflow.com/a/3560349
Our developer tool is great (and what I was snapping) but it’s not just laying around online unfortunately. Perhaps in the future.