Improve Python syntax highlighting
See original GitHub issuemonaco-editor version: 0.19.2 Browser: Chrome 79 maybe OS: macOS Mojave Playground code that reproduces the issue:
monaco.editor.create(document.getElementById("container"), {
value: "from functions import sum, average",
language: "python"
});
Basically some import statements in Python aren’t highlighted properly.
How Monaco/Monarch highlights things:
How VSCode highlights things:
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Python Improved - Packages
A better Python .tmLanguage syntax highlighting definition for Sublime Text and TextMate. It includes support for both Python 2 and Python 3, and...
Read more >Python IDLE Syntax Highlighting
The IDLE editor will highlight only Python's standard . py files. To fix this issue, simply rename the file from the non-Python file...
Read more >Improve python syntax highlighting : PY-17767
Python syntax highlighting seems to be missing several syntax highlighting features available in other editors and IDEs for python.
Read more >Additional Syntax Highlighting for Python?? : r/vim
vim-python/python-syntax is the best I've used so far. I haven't seen any of the issues mentioned by u/dutch_gecko about incorrect highlighting ...
Read more >Welcome! — Pygments
Get Pygments from the Python Package Index, or install it with: ... It is a generic syntax highlighter suitable for use in code...
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
More importantly, this seems to be missing Python 3 features like recognizing
async
/await
as keywords and supporting f-strings.It should be possible to implement a Monarch tokenizer which results in a token stream similar to what the TextMate grammars result in. Right now implementing a Monarch tokenizer which approximates TextMate will result in a loss of syntax highlighting as Monaco’s default theme does not support all of the tokens.
I did extend the Monarch Python syntax highlighting to be closer to TextMate, but this required a number of customizations to the theme as well, would be great if I could make a PR to monaco-languages without it requiring theme customizations.
Python editor with my customizations: https://colab.research.google.com/gist/blois/00fa28cdb0433e62c8106a4b5812d024/syntax-highlighting.ipynb