-
Notifications
You must be signed in to change notification settings - Fork 84
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
Cell error traceback incorrectly lexed as IPython #341
Comments
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗 |
I think I agree with you about the source of the bug! Maybe there is some way to check the traceback text to see if it is Python code or not, and if not then use a generic literal block instead of the |
It seems that:
That suggests a possible approach, where the renderer would read the kernel metadata from the document, and apply the lexer depending on the kernel info. Inferring language from the traceback seems hard... |
The error "traceback" (if it is that, depending on the language) format is dependent on the kernel, not the code block -- since there is only one kernel per notebook. So @akhmerov seems on track suggesting it be based on the kernel metadata. |
Since #380, you can now set e.g. {"mystnb": {"render_error_lexer": "ipythontb"}} for a per-document setting |
Note, to turn off any lexing it would be I'm going to change this to a documentation issue, but let me know if this still does not fix things (obviously once #380 is released and integrated in jupyter-book) I guess one could debate whether the default should be "ipythontb" or "none", but I think still the majority of users are using python kernels |
Should this be working in Jupyter Book at this point? I'm running with v0.13.0. I tried adding that notebook metadata but the python lexer is still being used:
Here's how I added the metadata:
|
No, jupyter book is currently not using the latest version of myst-nb |
but if its ok, I will close this here as fixed |
I am unable to test this end-to-end because Jupyter Book is not using the latest version of MyST-NB. So I will open a corresponding issue in Jupyter Book. |
Describe the bug
I'm using Jupyter Book to produce a book with executable OCaml cells, including demoing some OCaml code that deliberately does not compile. I tag those cells with
raises-exception
of course. Some (not all) OCaml compiler error messages cause Sphinx to produce a lexer warning,Could not lex literal_block as "ipythontb"
. I think but am not sure this is because MyST-NB is assuming that the traceback field from any error is lexable as a Python error message. I conjecture that the problem is this line of code in MyST-NB.To Reproduce
Steps to reproduce the behavior:
jupyter-book build docs
. I'm happy to provide more instructions about how to do that install.Expected behavior
I expect the notebook's error output not to be lexed as Python, hence for Jupyter Book not to produce a warning.
Actual behavior
The actual output is:
Environment
jupyter-book --version
:Additional context
I conjecture the problem is this line of code in MyST-NB. It installs the IPythonTracebackLexer for the traceback field of an error output. But that is making the (to me) incorrect assumption that all error outputs are Python, rather than some other language.
Alternative explanations could include:
P.S. I am migrating my OCaml textbook from GitBook 2 to Jupyter Book and am so happy with Jupyter Book! Around 700 students/year at my university use this book, and others do elsewhere too. So I'm really grateful for the excellent upgrades that Jupyter Book is going to bring to us this fall when classes resume. Thank you so much for all your work!
The text was updated successfully, but these errors were encountered: