Skip to content

Commit aec986b

Browse files
committed
serializing nested ntbk metadata items
1 parent e77e33c commit aec986b

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

myst_nb/parser.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def parse_block(src, start_line):
117117

118118
for cell_index, nb_cell in enumerate(ntbk.cells):
119119

120-
# if the the source_map ahs been stored (for text-based notebooks),
120+
# if the the source_map has been stored (for text-based notebooks),
121121
# we use that do define the starting line for each cell
122122
# otherwise, we set a pseudo base that represents the cell index
123123
start_line = source_map[cell_index] if source_map else (cell_index + 1) * 10000
@@ -162,21 +162,11 @@ def parse_block(src, start_line):
162162
md.core.process(state)
163163

164164
# Add the front matter.
165-
# Note that myst_parser now serialises dict/list like keys, when rendering to
166-
# docutils docinfo,
167-
# so to stay consistent with the previous code (for now) we strip this data
165+
# Note that myst_parser serialises dict/list like keys, when rendering to
166+
# docutils docinfo. These could be read back with `json.loads`.
168167
state.tokens = [
169168
Token(
170-
"front_matter",
171-
"",
172-
0,
173-
content=(
174-
{
175-
k: v
176-
for k, v in ntbk.metadata.items()
177-
if isinstance(v, (str, int, float))
178-
}
179-
),
169+
"front_matter", "", 0, content=({k: v for k, v in ntbk.metadata.items()}),
180170
)
181171
] + state.tokens
182172

0 commit comments

Comments
 (0)