Replace markdown library with mistune#3767
Replace markdown library with mistune#3767iangreenleaf wants to merge 9 commits intobookwyrm-social:mainfrom
Conversation
markdown.py had parsing errors that were throwing off img srcsets.
It doesn't hugely matter one way or another, but the existing tests all expect no newline, so why rock the boat.
mouse-reeve
left a comment
There was a problem hiding this comment.
I have no objection to this change, and mistune passes the smell check of being actively maintained.
Unfortunately, you're a victim of timing on this one -- we just moved from requirements.txt to pyproject.toml. Would you be down to adjust accordingly? I'm not sure why mypy is unhappy but you should be able to run ./bw-dev ruff to resolve that failing check
|
Sure, I can merge and update! Might take me a little bit to do so--lot of other stuff going on at the moment. |
|
@mouse-reeve should be ready again. I had to cast a couple of the return values because mistune offers a weird return signature. I'm pretty sure that as called that method will only ever return a string, so hopefully casting is the appropriate solution there. |
Description
This replaces the library for parsing Markdown formatted text.
I ran into problems while working on a feature that uses media queries in the
sizesattribute onimg; markdown.py was tripping over symbols like<=and treating them like HTML even though they were in a string in an attribute and should have been passed through. In other words, I suspect the parser used by markdown.py isn't very robust.There are a couple other libraries that could work, like marko. To be honest I picked mistune without a ton of research because it seemed like it was modern, fast, and had wide adoption. Marko complains that mistune is not fully compliant with the CommonMark standard, but then mistune's own docs seem to suggest that it is. I didn't go all the way down that rabbit hole, so all that to say I'm open to using some other library instead, though I suspect whatever differences exist in adherence to spec are probably quite minor and not likely to be big deal to Bookwyrm. Mistune appears to have excellent performance as well, which is helpful.
What type of Pull Request is this?
Does this PR change settings or dependencies, or break something?
Details of breaking or configuration changes (if any of above checked)
Changes one of the library dependencies.
Documentation
Tests