jupyter-book / mystmd

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

Python Plugins for MyST #1298

Closed rowanc1 closed 1 month ago

rowanc1 commented 2 months ago

Currently we have plugins that work in the Javascript ecosystem, however, many of the users that we will be supporting are more familiar with Python, we ideally want to support plugins that feel easy to write for folks already familiar with Python.

In working with @agoose77 today, we put together a bit of a plan for getting python plugins for MyST transforms and directives. @agoose77 created a demo here which creates a gallery based on a collection of myst projects:

https://gist.github.com/agoose77/66700b2a172b4c11d4801f742534e4f7

The approach is to serialize the AST and pass it to a python process for transformation, and then carry on with other transformation in myst. This seems to work quite well from the first prototypes. I know @agoose77 has a lot more ideas on how to better integrate these things!

cc @jmunroe @jnywong @jukent @kafitzgerald

agoose77 commented 2 months ago

This actually would be super trivial to support out of the box with pyodide.

We just need to add support for .py plugins, and use Pyodide to load them. I won't start this yet because it's not super urgent.