Syntax Highlighting Python Code on HTML in VSCode
Sep 2, 2022
If we’re talking about Python code in HTML script, we’re definitely talking about a web framework whether it’s using Flask or Django with Jinja2 templates.
Syntax highlighting in Python code will not be active when we type in the HTML script.
In order for syntax highlighting in Python code to be active, we need to do the following steps.
- Install Better Jinja plugin (https://marketplace.visualstudio.com/items?itemName=samuelcolvin.jinjahtml).
- Go to Preferences ⮞ Settings ⮞ type “File Associations” in the search settings bar, click on “edit settings.json”.
- Add this following lines of code before close curly braces, then save it.
"emmet.includeLanguages": {"jinja-html": "html"},
"files.associations": {
"*.html": "jinja-html"
} - Walaaa!