-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Replace Markdown stdlib with CommonMark.jl #37337
Comments
I think replacing the parser would, in principle, be great (both to just get a better parser, but also to follow the CommonMark spec). However, just swapping out the parser would be breaking:
I am wondering if we'd need to create a system to support the two parsers and ASTs simultaneously? Maybe a macro + Compat.jl solution to tag a module to indicate that it should use the new parsers? And when fetching docstrings, it would fetch the existing AST by default, but could be converted to the new one? |
It currently passes all of the cm spec (https://github.com/MichaelHatherly/CommonMark.jl/blob/8706bda516a053fc55643478b1208680847c6afb/test/runtests.jl#L4-L15) so it's a fair bit more compliant, but as with all specs there's probably some untested corner cases that haven't been exercised properly. A proper public api for ast manipulations is needed prior to making this a stdlib as well, currently requires digging into internal fields to do anything useful, possibly making use of AbstractTrees.jl if it provides enough of an interface (haven't looked into that). With regards to actually replacing it, Morten is definitely right:
Definitely doable. With all that said, here's a possible multi-stage replacement plan:
|
It's used for formatting docstrings which is not on by default. It's also used to format markdown files and julia code inside those files which is also off by default. Having it on by default would probably cause a bit of confusion. |
Once you all come up with a plan, I can help with stdlib surgery which is super annoying but also very uninteresting. |
Fool me once... ;) |
Just a couple of notes on the progress here: MarkdownAST offers the API for AST manipulations, and also conversion functions between Markdown and MarkdownAST. I also started integrating it into CommonMark too (MichaelHatherly/CommonMark.jl#56; MichaelHatherly/CommonMark.jl#49). Users-wise, Documenter now uses MarkdownAST internally, and I hope to allow it to be used with CommonMark that way too. |
The Markdown stdlib has a lot of bugs (see e.g. https://github.com/JuliaLang/julia/issues?q=is%3Aopen+is%3Aissue+label%3Amarkdown where I labelled the ones I found from searching "markdown").
I wonder if we should just replace it with CommonMark.jl which seems to follow the spec better(?).
cc @MichaelHatherly @mortenpi
The text was updated successfully, but these errors were encountered: