Skip to content

Commit 3617ce1

Browse files
committed
Pass cell IDs in metadata
1 parent 752d20f commit 3617ce1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

myst_nb/core/nb_to_tokens.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def notebook_to_tokens(
4848

4949
# generate tokens
5050
tokens: list[Token]
51+
cell_id = nb_cell.get("id", None)
5152
if nb_cell["cell_type"] == "markdown":
5253
# https://nbformat.readthedocs.io/en/5.1.3/format_description.html#markdown-cells
5354
# TODO if cell has tag output-caption, then use as caption for next/preceding cell?
@@ -60,6 +61,7 @@ def notebook_to_tokens(
6061
meta={
6162
"index": cell_index,
6263
"metadata": nb_node_to_dict(nb_cell["metadata"]),
64+
"id": cell_id,
6365
},
6466
map=[0, len(nb_cell["source"].splitlines()) - 1],
6567
),
@@ -88,6 +90,7 @@ def notebook_to_tokens(
8890
meta={
8991
"index": cell_index,
9092
"metadata": nb_node_to_dict(nb_cell["metadata"]),
93+
"id": cell_id,
9194
},
9295
map=[0, 0],
9396
)
@@ -106,6 +109,7 @@ def notebook_to_tokens(
106109
meta={
107110
"index": cell_index,
108111
"metadata": nb_node_to_dict(nb_cell["metadata"]),
112+
"id": cell_id,
109113
},
110114
map=[0, 0],
111115
)

0 commit comments

Comments
 (0)