Skip to content

How to use generated output as the body of an outer code block? #38

Answered by pawamoy
sisp asked this question in Q&A
Discussion options

You must be logged in to vote

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:

```python exec="1" result="vegalite"
# Imagine a real function that generates a Vega-Lite JSON document
print('{"$schema": "https://vega.github.io/schema/vega-lite/v5.json", ...}')
```

This simply tells Markdown Exe…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@sisp
Comment options

@pawamoy
Comment options

Answer selected by sisp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants