From 9823b0e19a857cde48a789555f56c6e7ea683aab Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Tue, 28 Jul 2026 15:26:49 +0200 Subject: [PATCH 1/3] fix: ignore props with invalid chars --- packages/comark/src/internal/parse/syntax/props.ts | 2 +- packages/comark/test/misc.test.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 packages/comark/test/misc.test.ts diff --git a/packages/comark/src/internal/parse/syntax/props.ts b/packages/comark/src/internal/parse/syntax/props.ts index 5551d780..ea383e8b 100644 --- a/packages/comark/src/internal/parse/syntax/props.ts +++ b/packages/comark/src/internal/parse/syntax/props.ts @@ -55,7 +55,7 @@ export function searchProps(content: string, index = 0) { if (char === '=') { index += 1 props.push([key, searchValue()]) - } else { + } else if (key.match(/^[a-z0-9_\-:]+$/gi)) { props.push([key, 'true']) } } diff --git a/packages/comark/test/misc.test.ts b/packages/comark/test/misc.test.ts new file mode 100644 index 00000000..8fb4621d --- /dev/null +++ b/packages/comark/test/misc.test.ts @@ -0,0 +1,10 @@ +import { describe, expect, it } from 'vitest' +import { parse } from '../src/parse' +import punctuation from '../src/plugins/punctuation' + +describe('misc', () => { + it('ignore props with invalid chars, only /^[a-z0-9_\-:]+$/gi', async () => { + const tree = await parse(':Alert{id="1"" }') + expect(tree.nodes).toEqual([['alert', { id: '1' }]]) + }) +}) From 2bb5da10b032abb684c6be28cdeef42422533f52 Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Tue, 28 Jul 2026 15:28:12 +0200 Subject: [PATCH 2/3] up --- packages/comark/test/misc.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/comark/test/misc.test.ts b/packages/comark/test/misc.test.ts index 8fb4621d..228bf833 100644 --- a/packages/comark/test/misc.test.ts +++ b/packages/comark/test/misc.test.ts @@ -1,9 +1,8 @@ import { describe, expect, it } from 'vitest' import { parse } from '../src/parse' -import punctuation from '../src/plugins/punctuation' describe('misc', () => { - it('ignore props with invalid chars, only /^[a-z0-9_\-:]+$/gi', async () => { + it('ignore props with invalid chars, only /^[a-z0-9_-:]+$/gi', async () => { const tree = await parse(':Alert{id="1"" }') expect(tree.nodes).toEqual([['alert', { id: '1' }]]) }) From e1ddc510a41693dd3f99617cffe957c8fa6435f8 Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Thu, 30 Jul 2026 17:30:36 +0200 Subject: [PATCH 3/3] fix: attributes can start with `[:a-z_]` --- packages/comark/src/internal/parse/syntax/props.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/comark/src/internal/parse/syntax/props.ts b/packages/comark/src/internal/parse/syntax/props.ts index ea383e8b..793c477e 100644 --- a/packages/comark/src/internal/parse/syntax/props.ts +++ b/packages/comark/src/internal/parse/syntax/props.ts @@ -52,11 +52,15 @@ export function searchProps(content: string, index = 0) { const char = content[index] if (start !== index) { const key = content.slice(start, index).trim() + let value = '' if (char === '=') { index += 1 - props.push([key, searchValue()]) - } else if (key.match(/^[a-z0-9_\-:]+$/gi)) { - props.push([key, 'true']) + value = searchValue() + } else { + value = 'true' + } + if (key.match(/^:?[a-z_][a-z0-9_-]+$/gi)) { + props.push([key, value]) } } }