Skip to content

Commit fad80da

Browse files
authored
fix: unexpected last item in demo cols (#1499)
1 parent dd9d25e commit fad80da

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/loaders/markdown/transformer/rehypeDemo.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,13 @@ export default function rehypeDemo(
150150
node!.data ??= {};
151151
node!.data[DEMO_NODE_CONTAINER] = true;
152152

153-
// if there has no next node, it means need not to split, SKIP directly
154-
if (!nextChild) return SKIP;
155-
156153
// try to find the next demo node or br node
157154
while (nextChild) {
158-
if ((isElement(nextChild, 'code') && tryMarkDemoNode(nextChild, opts)) || isElement(nextChild, 'br')) {
155+
if (
156+
(isElement(nextChild, 'code') &&
157+
tryMarkDemoNode(nextChild, opts)) ||
158+
isElement(nextChild, 'br')
159+
) {
159160
// move to the next child index
160161
splitFrom += 1;
161162

@@ -167,6 +168,9 @@ export default function rehypeDemo(
167168
break;
168169
}
169170
}
171+
172+
// if there has no next node, it means need not to split, SKIP directly
173+
if (!nextChild) return SKIP;
170174
}
171175

172176
// split paragraph

0 commit comments

Comments
 (0)