Skip to content

Commit

Permalink
馃洜 fix for empty blocks in notebooks (#134)
Browse files Browse the repository at this point in the history
* 馃懡 empty markdown cells get an empty string as source

---------

Co-authored-by: Rowan Cockett <rowanc1@gmail.com>
  • Loading branch information
stevejpurves and rowanc1 committed Jun 21, 2023
1 parent fe1408b commit beee0d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-cooks-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@myst-theme/jupyter': patch
---

Patch myst-block bug
4 changes: 2 additions & 2 deletions packages/jupyter/src/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
);
Expand Down

0 comments on commit beee0d6

Please sign in to comment.