Skip to content

Commit cd4d3c0

Browse files
committed
fix: 空のカラー指定(##|text##)をテキストとして扱う
Wikidotの挙動に合わせ、カラー指定が空の場合はカラー構文として 認識せずテキストにフォールバックするよう修正。
1 parent 316b321 commit cd4d3c0

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

packages/parser/src/parser/rules/inline/color.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export const colorRule: InlineRule = {
6363

6464
const trimmedColor = colorSpec.trim();
6565

66-
// Wikidot allows empty color (##|text##), but text must have content
67-
if (textChildren.length === 0) {
66+
// Wikidot requires non-empty color spec and non-empty content
67+
if (trimmedColor === "" || textChildren.length === 0) {
6868
return { success: false };
6969
}
7070

tests/fixtures/color/fail/expected.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,27 @@
3333
"elements": [
3434
{
3535
"element": "text",
36-
"data": "##|no spec##"
36+
"data": "##"
37+
},
38+
{
39+
"element": "text",
40+
"data": "|"
41+
},
42+
{
43+
"element": "text",
44+
"data": "no"
45+
},
46+
{
47+
"element": "text",
48+
"data": " "
49+
},
50+
{
51+
"element": "text",
52+
"data": "spec"
53+
},
54+
{
55+
"element": "text",
56+
"data": "##"
3757
}
3858
]
3959
}

0 commit comments

Comments
 (0)