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

Code/syntax highlighting broken on Jupyter Lab #750

Open
jaanli opened this issue Apr 26, 2024 · 4 comments
Open

Code/syntax highlighting broken on Jupyter Lab #750

jaanli opened this issue Apr 26, 2024 · 4 comments
Labels
bug Something isn't working status:Blocked Requires another task to be completed

Comments

@jaanli
Copy link

jaanli commented Apr 26, 2024

Description

In this example notebook I made yesterday:

https://colab.research.google.com/github/jaanli/language-model-notebooks/blob/main/notebooks/getting-started.ipynb

The prompts render correctly:

image

But in Jupyter lab if I run jupyter lab notebooks/getting-started.ipynb from the root of the repo (https://github.com/jaanli/language-model-notebooks/) then the prompt cells don't render correctly:

image

(Note the red highlighting after the single quote, not sure what is happening)

Reproduce

Create a code cell and use the %%ai cell magic, then add a prompt using and or ' or other such characters/operators.

Expected behavior

Syntax highlighting works.

This is really cool! Thank you for an awesome jupyter feature.

@jaanli jaanli added the bug Something isn't working label Apr 26, 2024
@JasonWeill
Copy link
Collaborator

See jupyterlab/jupyterlab#3869 and jupyterlab/jupyterlab#15324. In JupyterLab 4, magic commands are treated as code with the current kernel's language; for example, if you're using a Python kernel, all magic commands are highlighted as if they were Python code, so any apostrophe is treated as the start or end of a string.

Fixing this bug will require upstream changes in JupyterLab; it is not necessarily a bug in Jupyter AI, but it is evident to people using Jupyter AI magic commands with JupyterLab.

@JasonWeill JasonWeill added the status:Blocked Requires another task to be completed label Apr 26, 2024
@krassowski
Copy link
Member

💯 if someone is interested in contributing to JupyterLab a PR which modifies the IPython language mode so that cell magics get an overlay with proper syntax highlighting (or plain formatting in case of %%ai) I am happy to review the PR (or help in other ways).

@dlqqq
Copy link
Collaborator

dlqqq commented Apr 29, 2024

Yes, I think plain formatting would work best here; otherwise we would somehow need to declare the syntax of the magics back up to the highlighter, which seems too complex at this time.

@jaanli
Copy link
Author

jaanli commented Apr 29, 2024

Sounds good, thank you @dlqqq - would it be easy to remove all formatting and switch it to plain text? I'm happy to give this a shot just not sure where to start :S

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status:Blocked Requires another task to be completed
Projects
None yet
Development

No branches or pull requests

4 participants