diff --git a/.changeset/friendly-cooks-dream.md b/.changeset/friendly-cooks-dream.md new file mode 100644 index 000000000..eca389c05 --- /dev/null +++ b/.changeset/friendly-cooks-dream.md @@ -0,0 +1,5 @@ +--- +'@myst-theme/jupyter': patch +--- + +Patch myst-block bug diff --git a/packages/jupyter/src/providers.tsx b/packages/jupyter/src/providers.tsx index aacf503b2..15030546f 100644 --- a/packages/jupyter/src/providers.tsx +++ b/packages/jupyter/src/providers.tsx @@ -83,7 +83,7 @@ export function notebookFromMdast( //Object.assign(notebook.metadata, ipynb.metadata); notebook.cells = (mdast.children as GenericParent[]).map((block: GenericParent) => { if (block.type !== 'block') console.warn(`Unexpected block type ${block.type}`); - if (block.children.length == 2 && block.children[0].type === 'code') { + if (block.children && block.children.length == 2 && block.children[0].type === 'code') { const [codeCell, output] = block.children; // use the block.key to identify the cell but maintain a mapping @@ -105,7 +105,7 @@ export function notebookFromMdast( const cell = new core.ThebeNonExecutableCell( block.key, notebook.id, - block.children.reduce((acc, child) => acc + '\n' + (child.value ?? ''), ''), + block.children?.reduce((acc, child) => acc + '\n' + (child.value ?? ''), '') ?? '', block.data ?? {}, notebook.rendermime, );