question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve Python syntax highlighting

See original GitHub issue

monaco-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:

image

How VSCode highlights things:

image

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
bolinfestcommented, Jan 24, 2020

More importantly, this seems to be missing Python 3 features like recognizing async/await as keywords and supporting f-strings.

0reactions
bloiscommented, Jan 21, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found