Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ Every renderer accepts `transformNode` (a function or array of functions returni
## Parser and plugin rules

1. Token-to-AST conversion lives in `packages/comark/src/internal/parse/tree.ts`. Run spec fixtures with `cd packages/comark && pnpm vitest run test/index.test.ts` (or `SPEC=SPEC/COMARK/foo.md pnpm vitest run test/index.test.ts`), and check `test/streaming.test.ts` after parser edits.
A fixture has `## Input`, `## AST`, `## HTML` and `## Markdown` sections, plus an optional `## Markdown HTML` for `renderMarkdown(doc, { format: 'markdown/html' })`. Every fixture runs the `markdown/html` check; when the section is missing, it falls back to `## Markdown`. Add the section only when the output differs (components, spans, slots, `:br`).
2. Always import from `markdown-exit/core`, never `markdown-exit`. Only `src/plugins/linkify.ts` imports `linkify-it`, keeping `comark/core` free of `linkify-it` and avoiding `markdown-exit`'s global fuzzy-link rule.
3. Decode HTML entities in attributes with `decodeHTMLAttribute` from `src/internal/entities.ts`, never `entities`, so bundles reuse the single `character-entities` table shipped by `markdown-exit`.
4. After adding or renaming a plugin in `packages/comark/src/plugins/`, add framework wrappers if it has a UI component, then run `pnpm sync-plugins` (also run by `pnpm build` and `pnpm stub`).
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ cd packages/comark
pnpm vitest run test/parse/sub-sup.test.ts
```

Parser fixtures live in `packages/comark/SPEC` and run through `test/index.test.ts`. Parser changes should also preserve streaming behavior in `test/streaming.test.ts`.
Parser fixtures live in `packages/comark/SPEC` and run through `test/index.test.ts`. Each fixture also checks `markdown/html` output against its `## Markdown HTML` section, or against `## Markdown` when that section is missing. Parser changes should also preserve streaming behavior in `test/streaming.test.ts`.

React and Svelte tests include a headless Chromium project. Install the browser if needed:

Expand Down
6 changes: 6 additions & 0 deletions packages/comark/SPEC/COMARK/attribute-inline-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@ Here :in{bool} :in{#id1} :in{.class1} :in{attr="value"}
```md
Here :in{bool} :in{#id1} :in{.class1} :in{attr="value"}
```

## Markdown HTML

```md
Here <in bool></in> <in id="id1"></in> <in class="class1"></in> <in attr="value"></in>
```
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ Welcome to [site]{.bg-gradient-to-r.from-primary-600.to-purple-600.bg-clip-text.
```md
Welcome to [site]{.bg-gradient-to-r.from-primary-600.to-purple-600.bg-clip-text.text-transparent}
```

## Markdown HTML

```md
Welcome to <span class="bg-gradient-to-r from-primary-600 to-purple-600 bg-clip-text text-transparent">site</span>
```
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,11 @@ Paint [swatch]{.bg-[#000]} and [box]{.text-[1.5rem]} and [el]{.w-[calc(100%-1rem

Theme [label]{.bg-[#000].text-[14px] #my-id}
```

## Markdown HTML

```md
Paint <span class="bg-[#000]">swatch</span> and <span class="text-[1.5rem]">box</span> and <span class="w-[calc(100%-1rem)]">el</span>

Theme <span class="bg-[#000] text-[14px]" id="my-id">label</span>
```
6 changes: 6 additions & 0 deletions packages/comark/SPEC/COMARK/attribute-span.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@ Here [link]{bool} [link]{#id1} [link]{.class1} [link]{attr="value"}
```md
Here [link]{bool} [link]{#id1} [link]{.class1} [link]{attr="value"}
```

## Markdown HTML

```md
Here <span bool>link</span> <span id="id1">link</span> <span class="class1">link</span> <span attr="value">link</span>
```
8 changes: 8 additions & 0 deletions packages/comark/SPEC/COMARK/attributes/paragraph+span.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,11 @@ A paragraph [span] {attr="value"}

A paragraph [span]{attr="value"}
```

## Markdown HTML

```md
A paragraph <span>span</span> {attr="value"}

A paragraph <span attr="value">span</span>
```
13 changes: 13 additions & 0 deletions packages/comark/SPEC/COMARK/codeblock-indented-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,16 @@
```
::
```

## Markdown HTML

```md
<card>

```mdc
::accordion
::
```

</card>
```
12 changes: 12 additions & 0 deletions packages/comark/SPEC/COMARK/component-PascalCase.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,15 @@ First Paragraph
Second Paragraph
::
```

## Markdown HTML

```md
<my-component>

First Paragraph

Second Paragraph

</my-component>
```
16 changes: 16 additions & 0 deletions packages/comark/SPEC/COMARK/component-block-in-list-item.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,19 @@
### Heading
::
```

## Markdown HTML

```md
- *item one*

<block>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

<template name="body">

### Heading

</template>

</block>
```
10 changes: 10 additions & 0 deletions packages/comark/SPEC/COMARK/component-block-props-backtick.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,13 @@ variant: soft
Content
::
```

## Markdown HTML

```md
<component title="Hello" color="primary" size="lg" variant="soft">

Content

</component>
```
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,13 @@ source: |-
Preview content here
::
```

## Markdown HTML

```md
<code-preview title="Quick Start" description="A code preview" lang="typescript" source="```ts&#10;const x = 1&#10;```">

Preview content here

</code-preview>
```
10 changes: 10 additions & 0 deletions packages/comark/SPEC/COMARK/component-block-props-tilde.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,13 @@ variant: soft
Content
::
```

## Markdown HTML

```md
<component title="Hello" color="primary" size="lg" variant="soft">

Content

</component>
```
10 changes: 10 additions & 0 deletions packages/comark/SPEC/COMARK/component-block-props-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,13 @@ config:
Component content
::
```

## Markdown HTML

```md
<component title="Hello World" count="42" enabled hidden="false" tags="[&quot;markdown&quot;,&quot;docs&quot;]" config="{&quot;theme&quot;:&quot;dark&quot;,&quot;debug&quot;:false}">

Component content

</component>
```
10 changes: 10 additions & 0 deletions packages/comark/SPEC/COMARK/component-block-tailwind-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@ Hello
Hello
::
```

## Markdown HTML

```md
<card class="bg-[#111] text-[1.25rem]">

Hello

</card>
```
57 changes: 57 additions & 0 deletions packages/comark/SPEC/COMARK/component-br-escaped.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
## Input

```md
::tip
before
\# literal
::
```

## AST

```json
{
"frontmatter": {},
"meta": {},
"nodes": [
[
"tip",
{},
"before",
[
"br",
{}
],
"# literal"
]
]
}
```

## HTML

```html
<tip>
before<br># literal
</tip>
```

## Markdown

```md
::tip
before
\# literal
::
```

## Markdown HTML

```md
<tip>

before
\# literal

</tip>
```
6 changes: 6 additions & 0 deletions packages/comark/SPEC/COMARK/component-empty.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@
::component
::
```

## Markdown HTML

```md
<component></component>
```
6 changes: 6 additions & 0 deletions packages/comark/SPEC/COMARK/component-multiple-colons.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@
::component
::
```

## Markdown HTML

```md
<component></component>
```
12 changes: 12 additions & 0 deletions packages/comark/SPEC/COMARK/component-name-comment.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,15 @@ Some :comment[a note]{author="maxi"} text.
body
::
```

## Markdown HTML

```md
Some <comment author="maxi">a note</comment> text.

<comment>

body

</comment>
```
12 changes: 12 additions & 0 deletions packages/comark/SPEC/COMARK/component-name-math.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,15 @@ Some :math[x] text.
body
::
```

## Markdown HTML

```md
Some <math>x</math> text.

<math k="v">

body

</math>
```
12 changes: 12 additions & 0 deletions packages/comark/SPEC/COMARK/component-name-mermaid.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,15 @@ Some :mermaid[x] text.
body
::
```

## Markdown HTML

```md
Some <mermaid>x</mermaid> text.

<mermaid>

body

</mermaid>
```
8 changes: 8 additions & 0 deletions packages/comark/SPEC/COMARK/component-name-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,11 @@ Some :table[x] text.

Some :table[x] text.
```

## Markdown HTML

```md
<table src="data.csv"></table>

Some <table>x</table> text.
```
12 changes: 12 additions & 0 deletions packages/comark/SPEC/COMARK/component-name-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,15 @@ Some :template[x] text.
body
::
```

## Markdown HTML

```md
Some <template>x</template> text.

<template k="v">

body

</template>
```
19 changes: 19 additions & 0 deletions packages/comark/SPEC/COMARK/component-nested-after-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,22 @@ Make sure to use an even numbered version.
:::
::
```

## Markdown HTML

```md
<steps>

### Prerequisites

- **Node.js** - `22.x` or newer
- **Terminal** - In order to run Nuxt commands

<callout>

Make sure to use an even numbered version.

</callout>

</steps>
```
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,20 @@
:::
::
```

## Markdown HTML

```md
<tabs>

<tabs-item label="Code">

```mdc
::accordion
::
```

</tabs-item>

</tabs>
```
Loading
Loading