You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing a code cell, there is an optional value (don't know what to properly call it)ipython3 here
```{code-cell}ipython3print("Hello!")
```
Examples in the documentation oscillate between having this and excluding it. This can become very prominent when syncing files with Jupytext because it it is converted to notebook.metadata.language_info.pygments_lexer, and often a source of VCS noise, with this being the only change.
Instead, the choice of pygments lexer seems to be fixed for all cells by the kernel as of myst-nb 18.3 (39c1bb9).
problem
This is a problem because this optional value (ipython3 above) can be quite visible, but is poorly documented and confusing. Some people may have a use-case where they want to customize the lexer and expect this behaviour based on the Jupytext conversion.
In my case, I just want to know what the purpose of this is, and if I should include or exclude it - especially for future proofing.
Here are the documents I have found discussing this value:
jupyterbook:
Provides an example, including the ipython3 and discusses the syntax highlighting, but makes no mention of the meaning of ipython3 or its relationship (or lack thereof) to syntax highlighting. I think this example should be updated to explain what the ipython3 means, as well as how the syntax highlighting is actually chosen (through the kernelspec I think).
You may also explicitly pass the kernel name after {code-cell} to make it clear which kernel you are running.... However, remember that there is only one kernel allowed per page.
This is the clearest statement I could find. If one kernel per page is true, then there should be no issue with the pygments_lexer interpretation. However, there are issues considering multiple kernels, e.g. thebe #343), and this statement does imply that maybe this value will be used sometime in the future - and hence should be kept.
The ipython3 here is purely optional, as an aide for syntax highlighting. In the round-trip, it is copied from notebook.metadata.language_info.pygments_lexer.
This is what Jupytext does. My impression is that jupytext is fairly critical to the usage of MyST-NB. If so, this behaviour should be supported, or at lease clearly documented.
Reproduce the bug
Typeset the following code or similar with Jupyter Book:
---jupytext:
formats: ipynb,md:mysttext_representation:
extension: .mdformat_name: mystformat_version: 0.13jupytext_version: 1.14.4kernelspec:
display_name: Python 3 (python3)language: pythonname: python3---# Test```{code-cell} ipython3
# This is formated as python codex = 1``````{code-cell} latex
# This is also formatted as python codex = 1``````latex% This is formated as LaTeX code# Not as python code (this line is not a latex comment)x = 1```
Describe the bug
context
When writing a code cell, there is an optional value (don't know what to properly call it)
ipython3
hereExamples in the documentation oscillate between having this and excluding it. This can become very prominent when syncing files with Jupytext because it it is converted to
notebook.metadata.language_info.pygments_lexer
, and often a source of VCS noise, with this being the only change.expectation
After finding out about this jupytext conversion, I expected that I could alter the pygment lexing of code-cells as described for myst-parser: basic code blocks.
bug
Instead, the choice of pygments lexer seems to be fixed for all cells by the kernel as of myst-nb 18.3 (39c1bb9).
problem
This is a problem because this optional value (
ipython3
above) can be quite visible, but is poorly documented and confusing. Some people may have a use-case where they want to customize the lexer and expect this behaviour based on the Jupytext conversion.In my case, I just want to know what the purpose of this is, and if I should include or exclude it - especially for future proofing.
Here are the documents I have found discussing this value:
jupyterbook:
Provides an example, including the
ipython3
and discusses the syntax highlighting, but makes no mention of the meaning ofipython3
or its relationship (or lack thereof) to syntax highlighting. I think this example should be updated to explain what theipython3
means, as well as how the syntax highlighting is actually chosen (through thekernelspec
I think).jupyterbook:
This is the clearest statement I could find. If one kernel per page is true, then there should be no issue with the
pygments_lexer
interpretation. However, there are issues considering multiple kernels, e.g. thebe #343), and this statement does imply that maybe this value will be used sometime in the future - and hence should be kept.myst-nb:
This is ambiguous.
jupytext:
This is what Jupytext does. My impression is that jupytext is fairly critical to the usage of MyST-NB. If so, this behaviour should be supported, or at lease clearly documented.
Reproduce the bug
Typeset the following code or similar with Jupyter Book:
List your environment
The text was updated successfully, but these errors were encountered: