Skip to content
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

Not compatible with mkdocs's admonition #31

Open
TiborVoelcker opened this issue Oct 16, 2024 · 3 comments
Open

Not compatible with mkdocs's admonition #31

TiborVoelcker opened this issue Oct 16, 2024 · 3 comments

Comments

@TiborVoelcker
Copy link

A widely used mkdocs plugin is introducing admonitions. I have a lot of code examples in expandable admonitions, like so:

??? quote
    
    ```python
    x = 1
    ```

Using this syntax, the code blocks are not tested.

I believe this is because markdown_it does not recognize it. There should be a plugin available for markdown_it which introduces this syntax so it can be parsed correctly. Maybe there could be a configuration option to add plugins to markdown_it?

@freider
Copy link
Collaborator

freider commented Nov 27, 2024

Happy to accept contributions for this! :)

@TiborVoelcker
Copy link
Author

I gathered some information about this. Note that I did not test any of this yet.

The plugins can be added like this with the example of the admonition:

from markdown_it import MarkdownIt
from mdit_py_plugins.admon import admon_plugin


from mdit_py_plugins import plugin1, plugin2
md = MarkdownIt().use(admon_plugin)

This would need to be added to

mi = markdown_it.MarkdownIt(config="commonmark")

Then there is the question regarding the configuration which plugins should be loaded. As this is a pytest plugin, the possibilities are quite restricted.
It could be possible with pytest_addoption.
This might be cumbersome, but possible. One could define an option where a list of plugins are input. These are the parsed and loaded.

Things get even more complicated, as some md plugins have parameters that can be specified at initialization. Not sure how to handle this.

Another idea would be to just use ALL plugins, but this does not sound like a good idea.

@TiborVoelcker
Copy link
Author

I sadly don't have the time to try some things out or even make a PR. But I wanted to add the information I gathered if someone else wants to take a look. Or maybe even future me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants