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

Update to Mistune v3 #1820

Merged
merged 9 commits into from Jun 16, 2023
Merged

Update to Mistune v3 #1820

merged 9 commits into from Jun 16, 2023

Conversation

TiagodePAlves
Copy link
Contributor

@TiagodePAlves TiagodePAlves commented Aug 3, 2022

Mistune v3 is already in Pre-Release on PyPi, with a few incompatibilities. Not a lot of changes on our side, besides moving regexes to new variables and updating methods to the new API.

I haven't tested on older Python versions (< 3.10) yet, just waiting for a proper release.

Highlights in Mistune Code

@kloczek
Copy link

kloczek commented Aug 13, 2022

Any plans to backport that PR for 6.5.x?

@TiagodePAlves TiagodePAlves force-pushed the mistune-v3 branch 2 times, most recently from 6871973 to bc04451 Compare August 13, 2022 20:25
@TiagodePAlves
Copy link
Contributor Author

Any plans to backport that PR for 6.5.x?

You should try discussing that in #1809. Anyway, Mistune 2.0 took a very long release cycle:

So maybe when version 3.0 lands it won't make sense to use nbconvert 6.5 anymore.

@blink1073
Copy link
Member

Any plans to backport that PR for 6.5.x?

No, while we (mainly @TiagodePAlves) did our best to preserve backward compatibility, there are just too many differences between the versions, which is what is prompting us to move to 7.0 in the first place.

@kloczek
Copy link

kloczek commented Aug 22, 2022

Just tested this PR and looks like it is not possible to apply it on top of 6.5.3

+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-nbconvert-Update-to-Mistune-v3.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
2 out of 4 hunks FAILED -- saving rejects to file nbconvert/filters/markdown_mistune.py.rej
1 out of 1 hunk FAILED -- saving rejects to file pyproject.toml.rej
6 out of 6 hunks FAILED -- saving rejects to file nbconvert/filters/markdown_mistune.py.rej
1 out of 1 hunk FAILED -- saving rejects to file nbconvert/filters/markdown_mistune.py.rej
2 out of 3 hunks FAILED -- saving rejects to file nbconvert/filters/markdown_mistune.py.rej

@TiagodePAlves
Copy link
Contributor Author

TiagodePAlves commented Aug 22, 2022

You'll probably need #1764 and #1774 too.

@lepture
Copy link
Contributor

lepture commented Nov 19, 2022

Also, there is a built-in math plugin in mistune v3. Can you review it? If there should be something required to change, please let me know.

@jarrodmillman
Copy link

https://pypi.org/project/mistune/3.0.0/ is out now!

gentoo-bot pushed a commit to gentoo/gentoo that referenced this pull request Jun 12, 2023
Incompatible w/ mistune-3, see jupyter/nbconvert#1820.

Closes: https://bugs.gentoo.org/908377
Signed-off-by: Sam James <sam@gentoo.org>
@TiagodePAlves
Copy link
Contributor Author

Just updated to Mistune v3. There are a lot of changes for markdown_mistune.py now, but they are mostly related to the type hints. The main changes in functionality are in the MathBlockParser and MathInlineParser classes to align with v3.

Now, the check_links job is not liking the changes. It can't import name 'BlockState' from 'mistune', so I suspect it may be using an older version of Mistune. Don't know what to do here.

@blink1073
Copy link
Member

Check links is failing because pytest-check-links is installing the released version of nbconvert. How much work would it be to support both mistune 2 and 3?

@TiagodePAlves
Copy link
Contributor Author

Oh, makes sense. I think it should be okay to support both, I just hadn't considered it.

@TiagodePAlves TiagodePAlves marked this pull request as ready for review June 16, 2023 19:59
@TiagodePAlves
Copy link
Contributor Author

Ok, I had to keep two versios of MathBlockParser and MathInlineParser, one for v2 and one for v3, but the rest had minimal impact. I ran the full test suite in Python 3.7 and Python 3.11 for Mistune 2.0.5 and 3.0.1 and everything passed successfully.

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thank you! I'll make a new minor release early next week.

@blink1073 blink1073 merged commit 60af6d8 into jupyter:main Jun 16, 2023
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants