-
Notifications
You must be signed in to change notification settings - Fork 91
✨♻️‼️ Rewrite myst-nb #380
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
Conversation
hopefully will get fixed once executablebooks/MyST-NB#380 is merged
@bryanwweber see https://myst-nb--380.org.readthedocs.build/en/380/use/formatting_outputs.html#customise-the-render-process |
|
|
|
@chrisjsewell — I'm excited that this was merged! As someone following this project, thank you for doing this! |
|
Cheers @namurphy! |
This PR encompasses a top-to-bottom re-write of myst-nb!
It is mainly back compatible, for general users of the extension, with some more technical breaking changes listed below.
Highlights
mystnb-docutils-htmlgluerole/directives!nb_number_source_lines,nb_remove_code_source,nb_remove_code_outputs,nb_render_error_lexersphinx-build -j 4can execute four notebooks in parallel)type.subtypeto suppressglue:mdrole/directive includes nested parsing of MyST Markdown (see https://myst-nb--380.org.readthedocs.build/en/380/use/glue.html#the-glue-md-role-directive)New API Logic
The API is much clearer/cleaner (see also https://myst-nb--380.org.readthedocs.build/en/380/api/index.html)
The parsing of a notebook consists of a number of stages, with each stage separated into a separate module:
myst_nb.configuration: The configuration is set (from a file or CLI)myst_nb.docutils_/myst_nb.sphinx_: TheParseris called with an input string and sourcemyst_nb.read: The parser reads the input string to a notebook node (possibly using a custom format reader)myst_nb.execute: The notebook code outputs are potentially updated, via execution or from a cachemyst_nb.preprocess: The notebook is "pre-processed" in-place (e.g. to coalesce output streams and extract glue outputs) (this could eventually be pluggable, akin tonbconvert.preprocessors)myst_nb.parse: The notebook is converted to a Markdown-It tokens syntax treemyst_nb.render: The syntax tree is transformed to a docutils document AST (calling the renderer plugin)Breaking changes
nb_prefix.nb_render_priorityconfig is replaced bynb_mime_priority_overrides, which have different format/semanticsgluedirectives/roles are more restricted on how they work cross-document (only working on the same page by default).glue:anydirective allows for adocoption, andglue:any/glue:textallow the (relative) doc path to be added before a::.