Skip to content

Invalid inline attribute groups silently delete brace-delimited prose #522

Open

Description

@beowulf11

Environment

  • OS: Linux x64
  • Node: 24.22.1
  • Package manager: npm (isolated installation; also observed with pnpm)
  • Framework: none required; originally encountered through the Svelte renderer

Comark version

0.8.1 (also reproduced with 0.6.2)

Reproduction

In an empty directory:

npm init -y
npm install comark@0.8.1
node --input-type=module <<'JS'
import { parseMarkdown } from 'comark';

for (const source of [
  '**Result** {a/b}',
  String.raw`**Result** {(3\,574+5\,852)\times9/44}`,
  '**Result** {title="valid"}',
]) {
  console.log(JSON.stringify({ source, nodes: (await parseMarkdown(source)).nodes }));
}
JS

Description

Brace-delimited prose that cannot form valid inline attributes is consumed and silently removed from the document. For the first two inputs above, the output contains only the bold word Result:

[["p",{},["strong",{},"Result"]]]

The third input is a control: valid attributes still work, producing:

[["p",{"title":"valid"},["strong",{},"Result"]]]

Expected: reject an invalid attribute group as attribute syntax and preserve its contents as ordinary Markdown text, rather than deleting the group. Valid attribute syntax should continue to work.

The second example is deliberately not enclosed in $ math delimiters: it represents generated prose with a bare arithmetic/TeX-like expression. It need not become typeset math, but its contents should remain visible. Enclosing supported expressions in $...$ is a separate, working math-rendering case.

Additional context

With 0.5.1, the second input instead produces an attribute named (3\,574+5\,852)\times9/44, which causes InvalidCharacterError when the Svelte renderer calls setAttribute. The newer property-name validation avoids that exception, but still consumes the invalid group and loses the expression. Returning a non-match for the entire invalid inline-attribute group would preserve the original content without forwarding an invalid attribute to a renderer.

No production message, user identity, or private application data is needed for this reproduction.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions