mystmd
mystmd copied to clipboard
Allow in-line variable insertion with an `{embed}` role and `` syntax
Currently, inserting a variable or a cell output with {embed} inserts a block-level output even if the embed syntax is written in-line with text around it.
It would be useful if users can embed variables in-line with text so that they can insert things like individual numbers, ideally with some formatting capabilities as well.
One implementation pathway
One idea would be to do the following:
- Define an
{embed}role that assumes the output is in-line rather than block-level. We'd need to figure out how to attach the breadcrumbs (maybe a footnote or margin note?) back to the original notebook. - Modify the image embed short-hand (
) to choose the role or the directive based on whether it's surrounded by text or a standalone block-level item.
Reference
{eval}docs in MyST-NB embeds in-line with execution.{glue:text}role in Sphinx accomplishes this with a role
Example
An example from https://github.com/executablebooks/mystmd/issues/800:
From @ rmnldwg
E.g., when I write a manuscript like this
## Methods We included  patients in our study. Their mean age was  years.an I have the corresponding notebook cells, then I see this:
But I would like to include these numbers like so: