Skip to content

Commit 6d0320d

Browse files
fwkochstevejpurves
authored andcommitted
fix: align isCodeBlock with old PR after rebase
1 parent 3fdf705 commit 6d0320d

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

packages/myst-execute/src/execute.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import assert from 'node:assert';
99
import type { CodeBlock, ExecutionResult, ExecutableNode } from './types.js';
1010
import { executeCodeCell, evaluateInlineExpression } from './kernel.js';
1111
import {
12-
isCellBlock,
12+
isCodeBlock,
1313
codeBlockRaisesException,
1414
codeBlockSkipsExecution,
1515
isInlineExpression,
@@ -35,7 +35,7 @@ export async function computeExecutableNodes(
3535

3636
const results: ExecutionResult[] = [];
3737
for (const matchedNode of nodes) {
38-
if (isCellBlock(matchedNode)) {
38+
if (isCodeBlock(matchedNode)) {
3939
// Pull out code to execute
4040
const code = select('code', matchedNode) as Code;
4141
const { status, outputs } = await executeCodeCell(kernel, code.value);
@@ -102,7 +102,7 @@ export function applyComputedOutputsToNodes(
102102
// Pull out the result for this node
103103
const thisResult = computedResult.shift();
104104

105-
if (isCellBlock(matchedNode)) {
105+
if (isCodeBlock(matchedNode)) {
106106
const rawOutputData = (thisResult as IOutput[]) ?? [];
107107
// Pull out outputs to set data
108108
const outputs = select('outputs', matchedNode) as Outputs;
@@ -132,6 +132,6 @@ export function getExecutableNodes(tree: GenericParent) {
132132
)[]
133133
)
134134
// Filter out nodes that skip execution
135-
.filter((node) => !(isCellBlock(node) && codeBlockSkipsExecution(node)))
135+
.filter((node) => !(isCodeBlock(node) && codeBlockSkipsExecution(node)))
136136
);
137137
}

packages/myst-execute/src/transform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { Plugin } from 'unified';
1111
import { createHash } from 'node:crypto';
1212
import type { ICache } from './cache.js';
1313
import { createKernelConnection } from './kernel.js';
14-
import { isCellBlock, isInlineExpression, codeBlockRaisesException } from './utils.js';
14+
import { isCodeBlock, isInlineExpression, codeBlockRaisesException } from './utils.js';
1515
import type { ExecutableNode, ExecutionResult } from './types.js';
1616
import {
1717
getExecutableNodes,
@@ -35,7 +35,7 @@ function buildCacheKey(
3535
raisesException: boolean;
3636
}[] = [];
3737
for (const node of nodes) {
38-
if (isCellBlock(node)) {
38+
if (isCodeBlock(node)) {
3939
hashableItems.push({
4040
kind: node.type,
4141
content: (select('code', node) as Code).value,

packages/myst-execute/src/utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { select } from 'unist-util-select';
21
import type { InlineExpression } from 'myst-spec-ext';
32
import type { GenericNode } from 'myst-common';
4-
import { NotebookCellTags } from 'myst-common';
3+
import { NotebookCell, NotebookCellTags } from 'myst-common';
54
import type { CodeBlock } from './types.js';
65
/**
76
* Return true if the given node is a block over a code node and output node
87
*
98
* @param node node to test
109
*/
11-
export function isCellBlock(node: GenericNode): node is CodeBlock {
12-
return node.type === 'block' && select('code', node) !== null && select('outputs', node) !== null;
10+
export function isCodeBlock(node: GenericNode): node is CodeBlock {
11+
return node.type === 'block' && node.kind === NotebookCell.code;
1312
}
1413

1514
/**

0 commit comments

Comments
 (0)