-
Notifications
You must be signed in to change notification settings - Fork 197
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
Move to markdown-it-py parser #123
Conversation
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_KEY }} | ||
|
||
publish: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is a publish vs. a build triggered? this seems like a useful way to automate releases, just not sure how it works :-)
|
||
Docutils |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from a dogfooding perspective I feel like these should be written in markdown :-) (not blocking this PR though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why its not is because, autodoc has to read the python docstrings as rST. I'm sure you could get it to read them as markdown (and rewrite all you doctrings as such), but I doubt its worth the hassle!
from myst_parser.sphinx_renderer import mock_sphinx_env | ||
|
||
with mock_sphinx_env(conf=conf, document=md.options["document"]): | ||
return md.render(text, env) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how simple this is 👍
This looks great - markdown-it-py is pretty readable! |
needs: build | ||
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@choldgraf, you can give conditionals to each job. In this case the 'publish' job is triggered conditional on the 'build' job passing, and if the full process was triggered by creating a release tag on the repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shit that's cool! I'm really liking github-actions (I know I know, you're not allowed to make fun of me every time I praise a microsoft product)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆
yeh well in terms of document building, its certainly something we could consider providing our own workflow/action for; something like https://github.com/ammaraskar/sphinx-action (using a Docker environment), but also making use of caching and artefacts: https://help.github.com/en/actions/configuring-and-managing-workflows/caching-and-storing-workflow-data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I am one step ahead of you on that one ;-) even have a friend that works on Microsoft Azure helping out!
Thanks for the heads up, this does indeed (at first glance) seem to be a nice change - the details you summarized in Basic Details and Testing make things seem easier to understand. I plan to take a more detailed look perhaps over the weekend (unless things are changing so rapidly that you think it would be best to hold off). Love the new features too :) |
A couple quick thoughts:
|
Yeh that's already there https://329-240151150-gh.circle-artifacts.com/0/html/using/syntax.html#math-shortcuts
Will probably have to add them to both (may be able to sub-class, bu they will still need to added to the |
There is also now a complimentary pre-release for executablebooks/MyST-NB#107: |
I just built MyST-flavored Elegant Scipy with v0.8.0a3 and the only obvious difference I noticed was that multiline footnotes work now 🎉 . FWIW I didn't see any new complaints from sphinx during the build process. |
amazing! I'd be a fan of just merging this away and spot-checking bugs as they come up. In my mind the myst-parser is in a perpetual "pre-release" state until we start advertising it as "ready for users". @chrisjsewell are you +1 to merge? |
Ok with executablebooks/myst-parser.example-project#16 now closed I'm gonna go ahead and merge. Note the only niggling issue is this executablebooks/markdown-it-py#8, |
This PR implements the move from
mistletoe
to markdown-it-py, as the underlying markdown parser. The reason for this is are discussed in executablebooks/meta#44 (comment) and executablebooks/meta#47.Basic Implementation
The basic structure of the
DocutilsRenderer
,SphinxRenderer
, andSphinxParser
remain very similar. But all the syntax specific elements have actually been removed, as they are included directly in https://github.com/ExecutableBookProject/markdown-it-py/tree/master/markdown_it/extensions (at least for now).In https://github.com/ExecutableBookProject/MyST-Parser/blob/22eb21809ce1eeddeecc52dfc392125e3e2230d3/myst_parser/main.py#L18
You can see how the parsing class instance is constructed; starting with a base commonmark compliant implementation, then iteratively applying plugins with the extended syntax features (its just soo damn "clean"!). I have also added some control of this within the actual sphinx extension, e.g. see https://github.com/ExecutableBookProject/MyST-Parser/tree/markdown-it/tests/test_sphinx/sourcedirs/conf_values
conf.py
means that this
goes to:
With this control, you can relatively easily port more of the existing markdown-it plugins, or any new ones, and allow them to be optionally enabled (assuming that a complimentary docutils render method could be derived)
Testing
I have also "cleaned" up the testing, to use "text based" test fixture files (as also used in markdown-it), that follow the structure:
If you look in https://github.com/ExecutableBookProject/MyST-Parser/tree/markdown-it/tests/test_renderers/fixtures, you'll find these files, which give a really good self-documentation of how all the different syntax elements / roles / directives are rendered.
Benchmarking
As with https://github.com/ExecutableBookProject/markdown-it-py#benchmarking
* not commonmark compliant
** rendering to
docutils AST
, rather than HTML stringDocumentation
I have not made any updates to the documentation thus far, but did make the changes for the pydata-sphinx-theme, so the documentation builds: https://circleci.com/gh/ExecutableBookProject/MyST-Parser/307#artifacts/containers/0. Errors should just be due to autodoc/intersphinx looking for obsolete API elements
Also testing has been moved from travis to GitHub actions, @choldgraf can we/shall we also move the document build to here, rather than circle-ci (from a quick google, something like https://github.com/ammaraskar/sphinx-action)
Additional Features
Some additional syntax features this has also allowed me to initially add:
CC'in @choldgraf @mmcky @rossbar @jstac @mtiley @najuzilu