Skip to content

Commit

Permalink
fix: unexpected last item in demo cols (#1499)
Browse files Browse the repository at this point in the history
  • Loading branch information
shunyue1320 authored Feb 22, 2023
1 parent dd9d25e commit fad80da
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/loaders/markdown/transformer/rehypeDemo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,13 @@ export default function rehypeDemo(
node!.data ??= {};
node!.data[DEMO_NODE_CONTAINER] = true;

// if there has no next node, it means need not to split, SKIP directly
if (!nextChild) return SKIP;

// try to find the next demo node or br node
while (nextChild) {
if ((isElement(nextChild, 'code') && tryMarkDemoNode(nextChild, opts)) || isElement(nextChild, 'br')) {
if (
(isElement(nextChild, 'code') &&
tryMarkDemoNode(nextChild, opts)) ||
isElement(nextChild, 'br')
) {
// move to the next child index
splitFrom += 1;

Expand All @@ -167,6 +168,9 @@ export default function rehypeDemo(
break;
}
}

// if there has no next node, it means need not to split, SKIP directly
if (!nextChild) return SKIP;
}

// split paragraph
Expand Down

0 comments on commit fad80da

Please sign in to comment.