pawamoy / markdown-exec

Utilities to execute code blocks in Markdown files.
https://pawamoy.github.io/markdown-exec
ISC License
111 stars 8 forks source link

Compability with snippets #22

Closed TheRealVira closed 1 year ago

TheRealVira commented 1 year ago

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,...

pawamoy commented 1 year ago

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 :slightly_smiling_face:

TheRealVira commented 1 year ago

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.

pawamoy commented 1 year ago

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/