That looks useful to know how to do. I think that and some of the other abilities of nbconvert
were things I was missing that had me thinking this had to be more easily automated and also explained why Papermill
didn’t have that ability. Thanks.
I ended up using python to build up a string for each notebook I wanted to make from each starting markdown. I saved that as markdown with the specific code blocks to be ultimately code cells tagged specially with {.python .input}
. The other code blocks among the markdown text will ultimately be rendered as literal markdown code blocks by notedown
, which is what I needed to happen. With the markdown built up then all I needed was the following to for each markdown file to make a new notebook via notedown
and execute it via nbconvert
to get the code output to show in the resulting notebook:
!notedown --match=strict input.md > {notbeook_name}
!jupyter nbconvert --to notebook --execute {notbeook_name} --output={notbeook_name}
notedown made it easy to mix injecting code and markdown to the resulting notebook via markdown which is where I was starting from.