pawamoy/markdown-exec

Compability with snippets

TheRealVira opened this issue · 3 comments

Is your feature request related to a problem? Please describe.
Maintainability gets harder as our documentation grows. It would be great, if mkdocs exec would be compatible with snippets so that we can extract Python code to a seperate place and inject it during the build.

https://stackoverflow.com/questions/76523189/is-there-a-way-to-include-and-execute-a-python-script-and-render-the-output-in-m

Describe the solution you'd like
Adding any way of importing and executing files would be awesome! It would help with maintainability, reduce duplicate code, reduce git diffs,...

Hello! In your SO post you said you tried with snippets and it didn't work, but it should actually work. Snippets should run before Markdown-Exec, but maybe that depends on your configuration. Can I see your mkdocs.yml?

Also, check out the docs for Markdown-Exec itself, you'll see that all our Python snippets are stored in a snippets folder, and included with the Snippets extension while building 🙂

You are absolutely correct @pawamoy thank you! I think my issues were caused by using the wrong(?) snippets plugin. After removing it from my plugins list it's working as expected.

Great! Thanks for coming back and closing!
For reference and future readers: the Snippets extension I'm talking about is https://facelessuser.github.io/pymdown-extensions/extensions/snippets/