Python syntax highlighting in a code block is inconsistent (again)
See original GitHub issueš Bug Report
Python syntax highlighting in a code block is inconsistent. If this looks familiar, itās because itās just like #2655 (regression).
To Reproduce
Add this block:
@dataclass
class MySQLConfig:
host: str = "localhost"
port: int = 3306
@dataclass
class Config:
db: MySQLConfig = MySQLConfig()
verbose: bool = True
cfg_store = ConfigStore.instance()
cfg_store.store(name="config", node=MyConfig)
@hydra.main(config_name="config")
def my_app(cfg: MyConfig) -> None:
# Python knows that the type of cfg.db is MySQLConfig without any additional hints
print(f"Host: {cfg.db.host}, port: {cfg.db.port}")
if __name__ == "__main__":
my_app()
Expected behavior
Syntax highlighting is applied consistently.
Actual Behavior
See screen shot, only the first @dataclass annotation is highlighted.
Your Environment
Ubuntu 18.
- Docusaurus version used: package.json
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9
Top Results From Across the Web
Syntax highlighting is not consistent - Meta Stack Overflow
For Python, the answer is that the lines must be indented four spaces. Then they will be picked up as code lines.
Read more >Changes to syntax highlighting - Meta Stack Exchange
code blocks are never highlighted (Super User, photo.se, bicycles.se, etc). We are now moving to a more tag-based syntax highlighting method.
Read more >Syntax highlighting : r/neovim - Reddit
I tried tree-sitter as a solution, but the highlighting is all over the place and inconsistent. On top of being inconsistent it makes...
Read more >Invalid Syntax in Python: Common Reasons for SyntaxError
The solution to this is to make all lines in the same Python code file use either tabs or spaces, but not both....
Read more >A case against syntax highlighting - Linus Ć
kesson
All other colors are used for special things like highlighting enums, classes etc. or placing a grey background behind the parts of the...
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 FreeTop 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
Top GitHub Comments
Iāve made a PR to your repo: https://github.com/facebookresearch/hydra/pull/730
And opened an issue on prism-react-render, not sure whatās happening exactly: https://github.com/FormidableLabs/prism-react-renderer/issues/87
It seems that this is no longer relevant, so Iām closing this issue.