Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛠 fix for empty blocks in notebooks #134

Merged
merged 4 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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