-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Missing syntax highlighting for the JSON viewer #6567
Comments
This looks interesting. Any ideas on where to get started with this? |
Can't seem to locate where this bug is originated. I can see some inline styles being generated in JupyterLab for the same viewer but don't know why they aren't doing the same in the notebook 🤔 |
Thanks @kostyafarber for looking into this. Right I guess the first step would be to check if the styles are correctly added to the page, as there could be one missing in notebook compared to lab (haven't looked more into it since) |
Can't seem to isolate why notebook is not applying the styles. I can see in JupyterLab style tags are produced with these I can't find any reference to these in the code anywhere. They look like they are to do with |
@kostyafarber for CodeMirror 6, the theme uses CSS in JS (see documentation). That way is usually combined with auto-generated class name (as you are seeing). But they are never mentioned explicitly in the code (as they should never be used and can change without notice). So if in notebook you can see the style applied have colored defined like |
@fcollonval okay, I can see these styles in the debug console on notebook. I can even see the It looks like these styles are being extracted by this function here: And being called here for example: But these styles aren't being produced on notebook. Not sure how to map that to a missing css import on the page. Is there meant to be an extra css file defined somewhere here to enable this function to work properly in notebook? https://github.com/jupyter/notebook/blob/main/packages/application/style/index.css |
Ok I think I get what is happening - the CodeMirror theme rules are not added to the page because there are no CodeMirror editor. |
What we should do is add the CodeMirror rules on the page for the JSON Renderer. You can do that by adding manually the style using StyleModule.mount(document, jupyterHighlightStyle.module) |
Ah okay , as there is no CodeMirror Editor on the JSON Renderer. Thanks for the investigation @fcollonval Should this PR be done in JupyterLab and then I can reference this issue there? |
|
Sorry if this is a silly question, but what do you mean by fixing it upstream? |
Sorry fixing it in JupyterLab itself |
All good! Thanks for the help 😄 |
We usually refer to JupyterLab as the upstream of notebook as notebook v7 is a remix of JupyterLab plugins. |
Ah okay. Thanks for that. Good to know the lingo. I'll work on it and open a PR upstream and reference this issue. |
As noticed in #6566 (comment), syntax highlighting is missing when opening JSON files with the JSON viewer:
The text was updated successfully, but these errors were encountered: