Skip to content

Commit 4a1d41a

Browse files
committed
Cleaner diff in getPlainCodeBlockLine
1 parent 25ae078 commit 4a1d41a

File tree

1 file changed

+12
-12
lines changed
  • packages/gitbook/src/components/DocumentView/CodeBlock

1 file changed

+12
-12
lines changed

packages/gitbook/src/components/DocumentView/CodeBlock/highlight.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,15 @@ function getPlainCodeBlockLine(
294294
content += cleanupLine(node.leaves.map((leaf) => leaf.text).join(''));
295295
} else {
296296
switch (node.type) {
297-
case 'expression': {
297+
case 'annotation': {
298298
const start = index + content.length;
299-
const exprValue = String(
300-
options?.evaluateInlineExpression?.(node.data.expression) ?? ''
299+
content += getPlainCodeBlockLine(
300+
node,
301+
index + content.length,
302+
inlines,
303+
options
301304
);
302-
content += exprValue;
303-
const end = start + exprValue.length;
305+
const end = index + content.length;
304306

305307
if (inlines) {
306308
inlines.push({
@@ -311,15 +313,13 @@ function getPlainCodeBlockLine(
311313
}
312314
break;
313315
}
314-
case 'annotation': {
316+
case 'expression': {
315317
const start = index + content.length;
316-
content += getPlainCodeBlockLine(
317-
node,
318-
index + content.length,
319-
inlines,
320-
options
318+
const exprValue = String(
319+
options?.evaluateInlineExpression?.(node.data.expression) ?? ''
321320
);
322-
const end = index + content.length;
321+
content += exprValue;
322+
const end = start + exprValue.length;
323323

324324
if (inlines) {
325325
inlines.push({

0 commit comments

Comments
 (0)