From efceca7860188e7891b0d63db8876e98c89365be Mon Sep 17 00:00:00 2001 From: Steve Purves Date: Tue, 14 Nov 2023 17:17:45 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=B3=20Correctly=20select=20figures=20w?= =?UTF-8?q?ith=20outputs=20and=20get=20figure=20node=20(#263)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/four-forks-begin.md | 5 +++++ packages/jupyter/src/execute/provider.tsx | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .changeset/four-forks-begin.md diff --git a/.changeset/four-forks-begin.md b/.changeset/four-forks-begin.md new file mode 100644 index 000000000..57923c48b --- /dev/null +++ b/.changeset/four-forks-begin.md @@ -0,0 +1,5 @@ +--- +'@myst-theme/jupyter': patch +--- + +correctly select figures with outputs and get figure node diff --git a/packages/jupyter/src/execute/provider.tsx b/packages/jupyter/src/execute/provider.tsx index 71c1df2f1..ab6d0556b 100644 --- a/packages/jupyter/src/execute/provider.tsx +++ b/packages/jupyter/src/execute/provider.tsx @@ -91,11 +91,13 @@ function useExecutionScopeFetcher({ } function listComputables(mdast: GenericParent) { - return selectAll('container[kind=figure] > output, embed > output', mdast).map((node: any) => { - const { key, label, source } = node; - const output = selectAll('output', node); - return { embedKey: key, outputKey: (output[0] as any).key, label, source }; - }); + return selectAll('container[kind=figure]:has(output), embed:has(output)', mdast).map( + (node: any) => { + const { key, label, source } = node; + const output = selectAll('output', node); + return { embedKey: key, outputKey: (output[0] as any).key, label, source }; + }, + ); } /**