Skip to content

Pasting notebook cells / inputs / outputs into content #265

@choldgraf

Description

@choldgraf

I think it would be useful if authors had the ability to insert cells (optionally both/either inputs and outputs) from notebooks directly into their text.

This would let people mix-and-match their notebook content directly into their book content, might provide an easier path forward for folks that don't want to use glue, would make gluelike functionality available to all languages instead of just Python, and might provide an escape hatch for folks that want to include cells inside of admonitions (see executablebooks/meta#143).

I imagine something like a nb (for "notebook") domain that would let you reference cells/intputs/outputs, so something like:

```{nb:cell} path-to-notebook-file:{cell-#}
```

or

```{nb:cell} path-to-notebook-file
:cell: {cell-#}
```

If the notebook had a named cell according to the name cell-level metadata or the coming cell-id metadata, it might look like:

```{nb:cell} path-to-notebook-file:{cell-name}
```

By default this would grab the whole cell and include it in the doctree as a code / list of CellOutputBundles (one per output).

However, you could imagine specifying a specific output like so:

```{nb:cell} path-to-notebook-file:{cell-name}
:output: 1
```

And you could trigger "only input", "only output" etc via another option:

```{nb:cell} path-to-notebook-file:{cell-name}
:include: input,output (or just input, or up to [input,output,stdout,stderr])
```

What do folks think about this? I don't know that this is necessarily the right UX for the feature (putting it under an nb domain etc), but do folks like the general contours of this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    🏷️ glueRelated to storing/pasting variables via glueenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions