jupyter-book / mystmd

Command line tools for working with MyST Markdown.
https://mystmd.org/guide
MIT License
192 stars 61 forks source link

Refactor directive and role parsing #181

Open fwkoch opened 1 year ago

fwkoch commented 1 year ago

Context: Over the past year we have been coming up against some of the limitations of early design around the markdown-it tokenizer. There were many things that are in that library that are now either duplicated or deprecated (e.g. references and state management), there are also challenges in having errors being reported to the CLI, jupyter or web context in a consistent way. Some errors are not possible to report until much later (i.e. after transformations), and some errors need to be much more lenient (e.g. parser errors). We also need to start thinking about adding myst language extensions (e.g. tabs, diagrams) in a way that work across all serializers and are agnostic to the tokenizer being used (e.g. unified or markdown-it).

Current state:

Desired state:

rowanc1 commented 1 year ago

This has largely been completed in #184, I think to close this issue we should:

rowanc1 commented 1 year ago

This has fully landed with myst v0.1.15. 🚀

tavin commented 1 year ago

If you have to work with markdown-it and markdown-it-myst how do you cause directives (e.g. admonitions) to actually be rendered?

rowanc1 commented 1 year ago

I think the best path for now is either (1) sticking with markdown-it-docutils for now; (2) introduce a tokenizer transformer on top of the markdown-it-myst layer that modifies the token stream back to an HTML-focused export for use inside of markdown-it; or (3) if you are in control of the render process (you might not be depending on the use case), you can use something like myst-to-html after you get an AST out.

I think the best path is probably (2), but it is also probably a decent amount of work. Sticking with (1) should be mostly fine, there haven't been substantial changes at that level, mostly just allowing errors to propagate to the CLI and changing/simplifying the extension mechanism.

tavin commented 1 year ago

Sticking with (1) is already infeasible due to obsolescence :)