pawamoy/markdown-exec

Feature request: default behaviour for code blocs

andynameistaken opened this issue · 2 comments

I'm using Code Emiter plugin for Obsidian which allows me to run code from code blocks, when I'm writing notes which I later publish to mkdocs with material theme.
Could you provide option for default behaviour for codeblocks?

Example:

Block with exec=on doesn't allow Code emitter to run

```python exec="on"
print("Hello Markdown!")
```

Maybe some config in mkdocs.yml allowing to execute regular codeblock might be good idea?
It would be nice, because:

  • documets will be more portable
  • person can focus more on what to write and not how to do it (most important thing I think)

Hello, thanks for the feature request!

I initially didn't want to implement such a feature, but it could be very easy with an environment variable, so why not.

Basically something like

EXEC_AUTO = [lang.strip() for lang in os.getenv("MARKDOWN_EXEC_AUTO", "").split(",")]

# and in our validator
exec_value = (language in EXEC_AUTO) | _to_bool(inputs.pop("exec", "no"))

Happy to review a PR with these changes, otherwise I'll try to get to it soon 🙂

Could you put it inside when you have time? I never did PR in my life and I don't know how to do it (yet).