Skip to content

Commit 2d554a6

Browse files
committed
fix: BLOCK_END_OPEN([[/)による不正な段落分割もマージ対象に追加
1 parent 2bf5ddc commit 2d554a6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/parser/src/parser/rules/block/collapsible.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ function consumeCloseTag(ctx: ParseContext, pos: number): number {
143143
*
144144
* When a `[[collapsible]]` token appears inside a collapsible body (the rule
145145
* is filtered out to prevent nesting), the paragraph parser treats the
146-
* `BLOCK_OPEN` as a paragraph boundary, splitting content that Wikidot keeps
147-
* in a single paragraph. This function detects those artificial splits —
148-
* paragraphs whose first text element is `"[["` — and merges them back,
149-
* inserting a line-break between runs.
146+
* `BLOCK_OPEN` or `BLOCK_END_OPEN` as a paragraph boundary, splitting content
147+
* that Wikidot keeps in a single paragraph. This function detects those
148+
* artificial splits — paragraphs whose first text element is `"[["` or
149+
* `"[[/"` — and merges them back, inserting a line-break between runs.
150150
*
151151
* Paragraphs separated by blank lines (double newline) do NOT start with
152-
* `"[["` and are therefore left as separate paragraphs.
152+
* block-open text and are therefore left as separate paragraphs.
153153
*/
154154
function mergeSplitParagraphs(elements: Element[]): Element[] {
155155
const result: Element[] = [];
@@ -168,12 +168,12 @@ function mergeSplitParagraphs(elements: Element[]): Element[] {
168168
continue;
169169
}
170170

171-
// Check if this paragraph starts with "[[" (unrecognised block token)
171+
// Check if this paragraph starts with "[[" or "[[/" (unrecognised block token)
172172
const firstElem = elem.data.elements[0];
173173
const startsWithBlockOpen =
174174
firstElem?.element === "text" &&
175175
typeof firstElem.data === "string" &&
176-
firstElem.data === "[[";
176+
(firstElem.data === "[[" || firstElem.data === "[[/");
177177

178178
if (!startsWithBlockOpen) {
179179
result.push(elem);

0 commit comments

Comments
 (0)