mystmd icon indicating copy to clipboard operation
mystmd copied to clipboard

Allow in-line variable insertion with an `{embed}` role and `![](#embed)` syntax

Open choldgraf opened this issue 1 year ago • 0 comments

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:

  1. 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.
  2. Modify the image embed short-hand (![](#embed)) to choose the role or the directive based on whether it's surrounded by text or a standalone block-level item.

Reference

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 ![](#num-patients) patients in our study. Their mean age was ![](#mean-age) years.

an I have the corresponding notebook cells, then I see this:

image

But I would like to include these numbers like so:

image

choldgraf avatar Apr 16 '24 18:04 choldgraf