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

Perserve the lexer when converting from md:myst to notebook #1327

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mwouts
Copy link
Owner

@mwouts mwouts commented Feb 16, 2025

@chrisjsewell @choldgraf I am looking for a way to preserve the cell lexer when converting the notebook from MyST Markdown to a Jupyter notebook. The reasons for that are the following:

  1. I would like to preserve the lexer on round trips and solve Preserve the pygments_lexer of (unpaired) md:myst notebooks #789
  2. I would like to distinguish between cells in the kernel language (that can be converted to code cells) and those in other languages (which might need a language magic), see e.g. jupytext --to md:myst *.md should be idempotent #1317

Do you have recommendations on how to best do this? Thanks

Copy link

Thank you for making this pull request.

Did you know? You can try it on Binder: Binder:lab or Binder:notebook.

Also, the version of Jupytext developed in this PR can be installed with pip:

HATCH_BUILD_HOOKS_ENABLE=true pip install git+https://github.com/mwouts/jupytext.git@issue_789_preserve_myst_lexers

(this requires nodejs, see more at Developing Jupytext)

Copy link

codecov bot commented Feb 16, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.51%. Comparing base (9aba222) to head (f2ff837).

Files with missing lines Patch % Lines
src/jupytext/myst.py 0.00% 3 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.
❌ Your project check has failed because the head coverage (91.35%) is below the target coverage (97.00%). You can increase the head coverage or adjust the target coverage.

❗ There is a different number of reports uploaded between BASE (9aba222) and HEAD (f2ff837). Click for more details.

HEAD has 10 uploads less than BASE
Flag BASE (9aba222) HEAD (f2ff837)
11 1
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1327      +/-   ##
==========================================
- Coverage   97.04%   91.51%   -5.53%     
==========================================
  Files          29       29              
  Lines        4499     4502       +3     
==========================================
- Hits         4366     4120     -246     
- Misses        133      382     +249     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@choldgraf
Copy link
Contributor

Cc @agoose77 and @rowanc1 who might have thoughts here

@agoose77
Copy link

I will think about this more broadly, but my initial reaction to #789 (comment) is that fenced-code blocks are distinctly different to code-cells, and we should not be converting them to code-cells in the MyST target format. Let me circle back here to touch on the wider topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants