Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python syntax highlighting in a code block is inconsistent #2655

Closed
omry opened this issue Apr 24, 2020 · 4 comments · Fixed by #2666
Closed

Python syntax highlighting in a code block is inconsistent #2655

omry opened this issue Apr 24, 2020 · 4 comments · Fixed by #2666
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers

Comments

@omry
Copy link

omry commented Apr 24, 2020

🐛 Bug Report

Python syntax highlighting in a code block is inconsistent

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.

image

Your Environment

Ubuntu 18.

@omry omry added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Apr 24, 2020
@lex111
Copy link
Contributor

lex111 commented Apr 24, 2020

This is probably because prism-react-renderer uses an older version of prismjs, in which decorator syntax highlighting has not yet been fixed.

https://github.com/PrismJS/prism/pull/2018/files#diff-e99f677a9aaad5549db82df4b410cb1fR47
https://github.com/PrismJS/prism/blob/master/CHANGELOG.md#1180-2020-01-04

@omry
Copy link
Author

omry commented Apr 25, 2020

cool, what is the path to get this dependency upgraded?

@lex111
Copy link
Contributor

lex111 commented Apr 25, 2020

If I understand correctly, then we need to bump to latest version of prismjs in prism-react-renderer, however that dependency seems to be abandoned (its author @kitten does not accept PRs very well 😞).

@omry
Copy link
Author

omry commented Jun 14, 2020

Did this break again?
I tried to upgrade prism-react-renderer with yarn upgrade prism-react-renderer but I am still on 1.10.0 for some reason.

$ rg prism 
yarn.lock
1143:    prism-react-renderer "^1.1.0"
1144:    prismjs "^1.20.0"
7386:prism-react-renderer@^1.1.0:
7388:  resolved "https://registry.yarnpkg.com/prism-react-renderer/-/prism-react-renderer-1.1.1.tgz#1c1be61b1eb9446a146ca7a50b7bcf36f2a70a44"
7391:prismjs@^1.20.0:
7393:  resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.20.0.tgz#9b685fc480a3514ee7198eac6a3bf5024319ff03"

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants