Replies: 1 comment 2 replies
-
Hii @hjakasa You can use a library like Pygments to highlight the Python code. Pygments is a Python library that can be used to highlight code in a variety of languages, including Python. You can use Pygments to highlight the Python code in your YAML document and then display the highlighted code in your text editor.
This code will highlight the Python code in the text variable and then print the highlighted code to the console. |
Beta Was this translation helpful? Give feedback.
-
I have a use case where users will be writing python code within a YAML document. There will be a tag (!Python) after which all text will be treated as python code. I've gotten python autocompletion to work based on a list of keywords and some regex with a CompletionItemProvider, but not seeing a path forward for syntax highlighting.
I have an editor instance which has setModelLanguage which I can use to switch between python and yaml syntax highlighting for the entire editor (which I'm doing currently as a work around) but ideally there is a simple way to apply text highlighting for certain line numbers in the editor. Maybe there's a way to do this through tokenizers?
Beta Was this translation helpful? Give feedback.
All reactions