Highlight.js treats Python REPL (the Python interpreter in interactive mode) as its own language separate from Python—it uses the class names python-repl
and pycon
. I checked Stack Exchange's highlight-loader.js and didn't see python-repl
loaded anywhere. Would you mind adding support?
Here's a CodePen illustrating the difference between how highlight.js handles lang-python
vs lang-python-repl
when highlighting Python interpreter interactive sessions.
Also, as @Luuklag insightfully pointed out, nearly all questions tagged "python-interactive" are also tagged "python", so if Python REPL highlight.js support is added, it would probably be best not to add default highlighting to the "python-interactive" tag, because the highlighter only adds default highlighting when there is exactly one tag with a language set used. I just want to manually make ```python-repl
code blocks.
```python-repl
code blocks.python
would be to ask Highlight.js to consider highlighting it with bothpython
andpython-repl
- and let us decide which is a better "fit" using auto-detect. But yes, first SO would need to addpython-repl
in general to it's loaded grammars.python-repl
?in
should definitely not be highlighted in tracebacks on the lines that specify files where code was found, and words likeis
,not
,for
,with
etc. should not be highlighted in exception messages (they are textual explanations of the error, and not Python code). It's debatable whether the line numbers should be highlighted. The highlighting of file names (which look like string literals to the highlighter) is accidental, but nice. It would also be nice to highlight the wordTraceback
, and>>>
and/or...
prompts.>>>
, and Python source code formatting otherwise.