-
I'm trying to generate content for a fenced code block and thought I'd like to render a Vega-Lite chart in MkDocs using ````vegalite
```python exec="1"
# Imagine a real function that generates a Vega-Lite JSON document
print('{"$schema": "https://vega.github.io/schema/vega-lite/v5.json", ...}')
```
```` But
instead of the result from executing this Python code. After thinking about this problem a little, it probably wouldn't be a good idea – if technically possible at all – to always render inner code blocks with That said, is there any way to do what I'm trying to achieve, ideally in a generic way without needing to add explicit support for the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @sisp, happy to see you here 😄 So, yeah, your reasoning is correct, we can't execute inner code blocks if the outer is not also executed. We cannot even detect that the inner block should be executed: we rely on the PyMDown Superfences extension (not regular expressions or other similar approaches), so we only ever see outer code blocks: the inner code blocks are just seen as contents of the outer code blocks. Now, I believe what you want to achieve is possible. Try this:
This simply tells Markdown Exec to wrap the output of your executed code block in a |
Beta Was this translation helpful? Give feedback.
Hey @sisp, happy to see you here 😄
So, yeah, your reasoning is correct, we can't execute inner code blocks if the outer is not also executed. We cannot even detect that the inner block should be executed: we rely on the PyMDown Superfences extension (not regular expressions or other similar approaches), so we only ever see outer code blocks: the inner code blocks are just seen as contents of the outer code blocks.
Now, I believe what you want to achieve is possible. Try this:
This simply tells Markdown Exe…