Description
In RMarkdown, they have a short-hand for inserting the values of r code inline into the document: `r somevariable`. Right now, we'd accomplish the same thing with {glue:}`somekey` (after glueing it into the notebook).
I wonder if it would be helpful to think up a similar short-hand for variable insertion with MyST-NB. Some random ideas:
{{ somekey }}
`j somekey` (j for jupyter)
`g somekey` (g for glue)
{g}`somekey`
Benefit
This is an extremely commonly-requested feature in the Jupyter ecosystem, so it seems there is a large community of people that want this, particularly for scientific writing. For example, see these posts on SO, shared by @matthew-brett:
and this long-standing IPython issue where it is discussed:
ipython/ipython#2958
Implementation
I think we can split this into three different questions, and each could be tackled separately:
- Given the current Glue infrastructure, define a shorthand for
glue:any. I think this could be resolved relatively quickly using MyST substitutions, as described here
- Allow for substitutions that didn't require a
glue function to be called first - this would require collecting variables when the notebooks are run somehow, and would probably be a bigger amount of work.
- More broadly, how to substitute variables at run-time from within the kernel. This would be a much more significant re-write of how the execution logic works, and would also break from how Jupyter does execution.
cc @stefanv who mentioned this earlier
Description
In RMarkdown, they have a short-hand for inserting the values of
rcode inline into the document:`r somevariable`. Right now, we'd accomplish the same thing with{glue:}`somekey`(after glueing it into the notebook).I wonder if it would be helpful to think up a similar short-hand for variable insertion with MyST-NB. Some random ideas:
{{ somekey }}`j somekey`(j for jupyter)`g somekey`(g for glue){g}`somekey`Benefit
This is an extremely commonly-requested feature in the Jupyter ecosystem, so it seems there is a large community of people that want this, particularly for scientific writing. For example, see these posts on SO, shared by @matthew-brett:
and this long-standing IPython issue where it is discussed:
ipython/ipython#2958
Implementation
I think we can split this into three different questions, and each could be tackled separately:
glue:any. I think this could be resolved relatively quickly using MyST substitutions, as described heregluefunction to be called first - this would require collecting variables when the notebooks are run somehow, and would probably be a bigger amount of work.cc @stefanv who mentioned this earlier