diff --git a/AGENTS.md b/AGENTS.md index b94ffe9a3..d6d8830c0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -915,7 +915,7 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for local setup and the example-app wor ### Modifying the parser 1. Token processing is in `packages/comark/src/internal/parse/token-processor.ts` -2. Test with `packages/comark/test/index.test.ts` (loads the `SPEC/` fixtures; `SPEC=SPEC/COMARK/foo.md pnpm vitest run test/index.test.ts` runs one) +2. Test with `packages/comark/test/index.test.ts` (loads the `SPEC/` fixtures; `SPEC=SPEC/COMARK/foo.md pnpm vitest run test/index.test.ts` runs one). 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`) 3. Check streaming still works with `packages/comark/test/streaming.test.ts` 4. Import from `markdown-exit/core`, never `markdown-exit`: the root entry pulls in linkify-it, which `parse.ts` loads lazily only for parsers with `linkify` on 5. Decode attribute values with `decodeHTMLAttribute` from `src/internal/entities.ts`, not `entities`: it reads the `character-entities` table markdown-exit already ships, so bundles hold one table diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b385ae522..013d6a9ab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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: diff --git a/packages/comark/SPEC/COMARK/attribute-inline-component.md b/packages/comark/SPEC/COMARK/attribute-inline-component.md index 978a6d963..24673eec9 100644 --- a/packages/comark/SPEC/COMARK/attribute-inline-component.md +++ b/packages/comark/SPEC/COMARK/attribute-inline-component.md @@ -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 +``` diff --git a/packages/comark/SPEC/COMARK/attribute-span-multiple-classes.md b/packages/comark/SPEC/COMARK/attribute-span-multiple-classes.md index 3a50b2456..285084fd4 100644 --- a/packages/comark/SPEC/COMARK/attribute-span-multiple-classes.md +++ b/packages/comark/SPEC/COMARK/attribute-span-multiple-classes.md @@ -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 site +``` diff --git a/packages/comark/SPEC/COMARK/attribute-span-tailwind-class.md b/packages/comark/SPEC/COMARK/attribute-span-tailwind-class.md index c2cfc9e74..557fa3722 100644 --- a/packages/comark/SPEC/COMARK/attribute-span-tailwind-class.md +++ b/packages/comark/SPEC/COMARK/attribute-span-tailwind-class.md @@ -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 swatch and box and el + +Theme label +``` diff --git a/packages/comark/SPEC/COMARK/attribute-span.md b/packages/comark/SPEC/COMARK/attribute-span.md index 0c14c8dda..641cf2d38 100644 --- a/packages/comark/SPEC/COMARK/attribute-span.md +++ b/packages/comark/SPEC/COMARK/attribute-span.md @@ -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 link link link link +``` diff --git a/packages/comark/SPEC/COMARK/attributes/paragraph+span.md b/packages/comark/SPEC/COMARK/attributes/paragraph+span.md index ea6a2170c..41eaf8f2d 100644 --- a/packages/comark/SPEC/COMARK/attributes/paragraph+span.md +++ b/packages/comark/SPEC/COMARK/attributes/paragraph+span.md @@ -55,3 +55,11 @@ A paragraph [span] {attr="value"} A paragraph [span]{attr="value"} ``` + +## Markdown HTML + +```md +A paragraph span {attr="value"} + +A paragraph span +``` diff --git a/packages/comark/SPEC/COMARK/codeblock-indented-content.md b/packages/comark/SPEC/COMARK/codeblock-indented-content.md index cd2642e8a..96671a634 100644 --- a/packages/comark/SPEC/COMARK/codeblock-indented-content.md +++ b/packages/comark/SPEC/COMARK/codeblock-indented-content.md @@ -56,3 +56,16 @@ ``` :: ``` + +## Markdown HTML + +```md + + +```mdc + ::accordion + :: +``` + + +``` diff --git a/packages/comark/SPEC/COMARK/component-PascalCase.md b/packages/comark/SPEC/COMARK/component-PascalCase.md index 715feccba..07b2ebcdd 100644 --- a/packages/comark/SPEC/COMARK/component-PascalCase.md +++ b/packages/comark/SPEC/COMARK/component-PascalCase.md @@ -51,3 +51,15 @@ First Paragraph Second Paragraph :: ``` + +## Markdown HTML + +```md + + +First Paragraph + +Second Paragraph + + +``` diff --git a/packages/comark/SPEC/COMARK/component-block-in-list-item.md b/packages/comark/SPEC/COMARK/component-block-in-list-item.md index 2814bb9bc..3246b3c40 100644 --- a/packages/comark/SPEC/COMARK/component-block-in-list-item.md +++ b/packages/comark/SPEC/COMARK/component-block-in-list-item.md @@ -77,3 +77,18 @@ ### Heading :: ``` + +## Markdown HTML + +```md +- *item one* + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-block-props-backtick.md b/packages/comark/SPEC/COMARK/component-block-props-backtick.md index 64d03de7d..826da60c2 100644 --- a/packages/comark/SPEC/COMARK/component-block-props-backtick.md +++ b/packages/comark/SPEC/COMARK/component-block-props-backtick.md @@ -54,3 +54,13 @@ variant: soft Content :: ``` + +## Markdown HTML + +```md + + +Content + + +``` diff --git a/packages/comark/SPEC/COMARK/component-block-props-tilde-with-code.md b/packages/comark/SPEC/COMARK/component-block-props-tilde-with-code.md index bc5894ffc..73a31eb79 100644 --- a/packages/comark/SPEC/COMARK/component-block-props-tilde-with-code.md +++ b/packages/comark/SPEC/COMARK/component-block-props-tilde-with-code.md @@ -59,3 +59,13 @@ source: |- Preview content here :: ``` + +## Markdown HTML + +```md + + +Preview content here + + +``` diff --git a/packages/comark/SPEC/COMARK/component-block-props-tilde.md b/packages/comark/SPEC/COMARK/component-block-props-tilde.md index 9ebc1686d..3b18196f1 100644 --- a/packages/comark/SPEC/COMARK/component-block-props-tilde.md +++ b/packages/comark/SPEC/COMARK/component-block-props-tilde.md @@ -54,3 +54,13 @@ variant: soft Content :: ``` + +## Markdown HTML + +```md + + +Content + + +``` diff --git a/packages/comark/SPEC/COMARK/component-block-props-types.md b/packages/comark/SPEC/COMARK/component-block-props-types.md index 7345909ab..cdd858882 100644 --- a/packages/comark/SPEC/COMARK/component-block-props-types.md +++ b/packages/comark/SPEC/COMARK/component-block-props-types.md @@ -74,3 +74,13 @@ config: Component content :: ``` + +## Markdown HTML + +```md + +``` diff --git a/packages/comark/SPEC/COMARK/component-block-tailwind-class.md b/packages/comark/SPEC/COMARK/component-block-tailwind-class.md index eea440e78..d69c6145b 100644 --- a/packages/comark/SPEC/COMARK/component-block-tailwind-class.md +++ b/packages/comark/SPEC/COMARK/component-block-tailwind-class.md @@ -39,3 +39,13 @@ Hello Hello :: ``` + +## Markdown HTML + +```md + + +Hello + + +``` diff --git a/packages/comark/SPEC/COMARK/component-empty.md b/packages/comark/SPEC/COMARK/component-empty.md index 3de9c2b1f..ac8144333 100644 --- a/packages/comark/SPEC/COMARK/component-empty.md +++ b/packages/comark/SPEC/COMARK/component-empty.md @@ -32,3 +32,9 @@ ::component :: ``` + +## Markdown HTML + +```md + +``` diff --git a/packages/comark/SPEC/COMARK/component-multiple-colons.md b/packages/comark/SPEC/COMARK/component-multiple-colons.md index 3d95ec6a4..156972c13 100644 --- a/packages/comark/SPEC/COMARK/component-multiple-colons.md +++ b/packages/comark/SPEC/COMARK/component-multiple-colons.md @@ -32,3 +32,9 @@ ::component :: ``` + +## Markdown HTML + +```md + +``` diff --git a/packages/comark/SPEC/COMARK/component-name-comment.md b/packages/comark/SPEC/COMARK/component-name-comment.md index 43fd79e59..e21e062ca 100644 --- a/packages/comark/SPEC/COMARK/component-name-comment.md +++ b/packages/comark/SPEC/COMARK/component-name-comment.md @@ -57,3 +57,15 @@ Some :comment[a note]{author="maxi"} text. body :: ``` + +## Markdown HTML + +```md +Some a note text. + + + +body + + +``` diff --git a/packages/comark/SPEC/COMARK/component-name-math.md b/packages/comark/SPEC/COMARK/component-name-math.md index cebcc0677..a546ef85b 100644 --- a/packages/comark/SPEC/COMARK/component-name-math.md +++ b/packages/comark/SPEC/COMARK/component-name-math.md @@ -57,3 +57,15 @@ Some :math[x] text. body :: ``` + +## Markdown HTML + +```md +Some x text. + + + +body + + +``` diff --git a/packages/comark/SPEC/COMARK/component-name-mermaid.md b/packages/comark/SPEC/COMARK/component-name-mermaid.md index 69c852ca6..fa34ed9fe 100644 --- a/packages/comark/SPEC/COMARK/component-name-mermaid.md +++ b/packages/comark/SPEC/COMARK/component-name-mermaid.md @@ -55,3 +55,15 @@ Some :mermaid[x] text. body :: ``` + +## Markdown HTML + +```md +Some x text. + + + +body + + +``` diff --git a/packages/comark/SPEC/COMARK/component-name-table.md b/packages/comark/SPEC/COMARK/component-name-table.md index 5b392145c..2d8d17146 100644 --- a/packages/comark/SPEC/COMARK/component-name-table.md +++ b/packages/comark/SPEC/COMARK/component-name-table.md @@ -54,3 +54,11 @@ Some :table[x] text. Some :table[x] text. ``` + +## Markdown HTML + +```md +
+ +Some x
text. +``` diff --git a/packages/comark/SPEC/COMARK/component-name-template.md b/packages/comark/SPEC/COMARK/component-name-template.md index e312e30aa..bf3b4fd2b 100644 --- a/packages/comark/SPEC/COMARK/component-name-template.md +++ b/packages/comark/SPEC/COMARK/component-name-template.md @@ -57,3 +57,15 @@ Some :template[x] text. body :: ``` + +## Markdown HTML + +```md +Some text. + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested-after-list.md b/packages/comark/SPEC/COMARK/component-nested-after-list.md index e1d70b47b..51a6dc1e3 100644 --- a/packages/comark/SPEC/COMARK/component-nested-after-list.md +++ b/packages/comark/SPEC/COMARK/component-nested-after-list.md @@ -99,3 +99,22 @@ Make sure to use an even numbered version. ::: :: ``` + +## Markdown HTML + +```md + + +### Prerequisites + +- **Node.js** - `22.x` or newer +- **Terminal** - In order to run Nuxt commands + + + +Make sure to use an even numbered version. + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested-codeblock-indented.md b/packages/comark/SPEC/COMARK/component-nested-codeblock-indented.md index e2089e859..b9d14eee7 100644 --- a/packages/comark/SPEC/COMARK/component-nested-codeblock-indented.md +++ b/packages/comark/SPEC/COMARK/component-nested-codeblock-indented.md @@ -68,3 +68,20 @@ ::: :: ``` + +## Markdown HTML + +```md + + + + +```mdc + ::accordion + :: +``` + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested-codeblock-outdented.md b/packages/comark/SPEC/COMARK/component-nested-codeblock-outdented.md index bbecf01e7..665bc52a7 100644 --- a/packages/comark/SPEC/COMARK/component-nested-codeblock-outdented.md +++ b/packages/comark/SPEC/COMARK/component-nested-codeblock-outdented.md @@ -68,3 +68,20 @@ ::: :: ``` + +## Markdown HTML + +```md + + + + +```mdc + ::accordion + :: +``` + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested-codeblock.md b/packages/comark/SPEC/COMARK/component-nested-codeblock.md index 79f073e4e..e4fff76bb 100644 --- a/packages/comark/SPEC/COMARK/component-nested-codeblock.md +++ b/packages/comark/SPEC/COMARK/component-nested-codeblock.md @@ -59,3 +59,17 @@ hello ``` :: ``` + +## Markdown HTML + +```md + + +```mdc +::alert +hello +:: +``` + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested-deep-outdented.md b/packages/comark/SPEC/COMARK/component-nested-deep-outdented.md index 3ac8de8ff..6e189267e 100644 --- a/packages/comark/SPEC/COMARK/component-nested-deep-outdented.md +++ b/packages/comark/SPEC/COMARK/component-nested-deep-outdented.md @@ -57,3 +57,21 @@ text ::: :: ``` + +## Markdown HTML + +```md + + + + + + +text + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested-in-list.md b/packages/comark/SPEC/COMARK/component-nested-in-list.md index b3f3664f2..56de060e3 100644 --- a/packages/comark/SPEC/COMARK/component-nested-in-list.md +++ b/packages/comark/SPEC/COMARK/component-nested-in-list.md @@ -103,3 +103,21 @@ ::: :: ``` + +## Markdown HTML + +```md + + +### Prerequisites + +- **Node.js** - `22.x` or newer +- **Terminal** - In order to run Nuxt commands + + + Make sure to use an even numbered version. + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested-multiline-separated.md b/packages/comark/SPEC/COMARK/component-nested-multiline-separated.md index f26d4c22c..ea56d986d 100644 --- a/packages/comark/SPEC/COMARK/component-nested-multiline-separated.md +++ b/packages/comark/SPEC/COMARK/component-nested-multiline-separated.md @@ -211,3 +211,45 @@ full-width: true ::: :: ``` + +## Markdown HTML + +```md + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested-paragraph-outdented.md b/packages/comark/SPEC/COMARK/component-nested-paragraph-outdented.md index f5557da98..c74048a7a 100644 --- a/packages/comark/SPEC/COMARK/component-nested-paragraph-outdented.md +++ b/packages/comark/SPEC/COMARK/component-nested-paragraph-outdented.md @@ -49,3 +49,17 @@ hello world ::: :: ``` + +## Markdown HTML + +```md + + + + +hello world + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested-unindented.md b/packages/comark/SPEC/COMARK/component-nested-unindented.md index 4f2a91a36..4634cb419 100644 --- a/packages/comark/SPEC/COMARK/component-nested-unindented.md +++ b/packages/comark/SPEC/COMARK/component-nested-unindented.md @@ -99,3 +99,35 @@ This is the parent ::: :: ``` + +## Markdown HTML + +```md + + +This is the parent + + + +Sibling content + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested-yaml-props-outdented.md b/packages/comark/SPEC/COMARK/component-nested-yaml-props-outdented.md index 47aebecd4..4ef5980c1 100644 --- a/packages/comark/SPEC/COMARK/component-nested-yaml-props-outdented.md +++ b/packages/comark/SPEC/COMARK/component-nested-yaml-props-outdented.md @@ -54,3 +54,17 @@ content ::: :: ``` + +## Markdown HTML + +```md + + + + +content + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested.md b/packages/comark/SPEC/COMARK/component-nested.md index b934f6b9c..a6771702e 100644 --- a/packages/comark/SPEC/COMARK/component-nested.md +++ b/packages/comark/SPEC/COMARK/component-nested.md @@ -57,3 +57,19 @@ First Paragraph ::: :: ``` + +## Markdown HTML + +```md + + +First Paragraph + + + +Second Paragraph + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested2.md b/packages/comark/SPEC/COMARK/component-nested2.md index b07f37882..e980e4697 100644 --- a/packages/comark/SPEC/COMARK/component-nested2.md +++ b/packages/comark/SPEC/COMARK/component-nested2.md @@ -57,3 +57,19 @@ First Paragraph ::: :: ``` + +## Markdown HTML + +```md + + +First Paragraph + + + +Second Paragraph + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested3.md b/packages/comark/SPEC/COMARK/component-nested3.md index 536abf369..a84bed749 100644 --- a/packages/comark/SPEC/COMARK/component-nested3.md +++ b/packages/comark/SPEC/COMARK/component-nested3.md @@ -77,3 +77,25 @@ First Paragraph ::: :: ``` + +## Markdown HTML + +```md + + +First Paragraph + + + +Second Paragraph + + + +Third Paragraph + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-nested4.md b/packages/comark/SPEC/COMARK/component-nested4.md index 8097d8529..4d5c69499 100644 --- a/packages/comark/SPEC/COMARK/component-nested4.md +++ b/packages/comark/SPEC/COMARK/component-nested4.md @@ -171,3 +171,51 @@ timeout: ::: :: ``` + +## Markdown HTML + +```md + + + + + + + + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-props-boolean-false.md b/packages/comark/SPEC/COMARK/component-props-boolean-false.md index 9b9b71eea..4d07c8f39 100644 --- a/packages/comark/SPEC/COMARK/component-props-boolean-false.md +++ b/packages/comark/SPEC/COMARK/component-props-boolean-false.md @@ -52,3 +52,13 @@ My button My button :: ``` + +## Markdown HTML + +```md + + +My button + + +``` diff --git a/packages/comark/SPEC/COMARK/component-props-boolean-inline.md b/packages/comark/SPEC/COMARK/component-props-boolean-inline.md index 7d50c421b..84cee9004 100644 --- a/packages/comark/SPEC/COMARK/component-props-boolean-inline.md +++ b/packages/comark/SPEC/COMARK/component-props-boolean-inline.md @@ -51,3 +51,13 @@ My button My button :: ``` + +## Markdown HTML + +```md + + +My button + + +``` diff --git a/packages/comark/SPEC/COMARK/component-props-boolean-yaml.md b/packages/comark/SPEC/COMARK/component-props-boolean-yaml.md index 602a406b0..dbbbd5364 100644 --- a/packages/comark/SPEC/COMARK/component-props-boolean-yaml.md +++ b/packages/comark/SPEC/COMARK/component-props-boolean-yaml.md @@ -57,3 +57,13 @@ disabled: true My button :: ``` + +## Markdown HTML + +```md + + +My button + + +``` diff --git a/packages/comark/SPEC/COMARK/component-props-four-inline-to-yaml.md b/packages/comark/SPEC/COMARK/component-props-four-inline-to-yaml.md index 58e094883..f3b13d91c 100644 --- a/packages/comark/SPEC/COMARK/component-props-four-inline-to-yaml.md +++ b/packages/comark/SPEC/COMARK/component-props-four-inline-to-yaml.md @@ -48,3 +48,13 @@ variant: soft Content :: ``` + +## Markdown HTML + +```md + + +Content + + +``` diff --git a/packages/comark/SPEC/COMARK/component-props-max-inline-zero.md b/packages/comark/SPEC/COMARK/component-props-max-inline-zero.md index 893c4a56e..888d11075 100644 --- a/packages/comark/SPEC/COMARK/component-props-max-inline-zero.md +++ b/packages/comark/SPEC/COMARK/component-props-max-inline-zero.md @@ -51,3 +51,13 @@ title: Hello Content :: ``` + +## Markdown HTML + +```md + + +Content + + +``` diff --git a/packages/comark/SPEC/COMARK/component-props-single-yaml.md b/packages/comark/SPEC/COMARK/component-props-single-yaml.md index 3118e4f9c..6eb603d34 100644 --- a/packages/comark/SPEC/COMARK/component-props-single-yaml.md +++ b/packages/comark/SPEC/COMARK/component-props-single-yaml.md @@ -42,3 +42,13 @@ Content Content :: ``` + +## Markdown HTML + +```md + + +Content + + +``` diff --git a/packages/comark/SPEC/COMARK/component-props-three-inline.md b/packages/comark/SPEC/COMARK/component-props-three-inline.md index 3aedeb50b..ebce8c371 100644 --- a/packages/comark/SPEC/COMARK/component-props-three-inline.md +++ b/packages/comark/SPEC/COMARK/component-props-three-inline.md @@ -41,3 +41,13 @@ Content Content :: ``` + +## Markdown HTML + +```md + + +Content + + +``` diff --git a/packages/comark/SPEC/COMARK/component-short+block.md b/packages/comark/SPEC/COMARK/component-short+block.md index 870a7809f..a22b68efb 100644 --- a/packages/comark/SPEC/COMARK/component-short+block.md +++ b/packages/comark/SPEC/COMARK/component-short+block.md @@ -73,3 +73,25 @@ First Paragraph Second Paragraph :: ``` + +## Markdown HTML + +```md + + + + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-slot-default-escaped.md b/packages/comark/SPEC/COMARK/component-slot-default-escaped.md new file mode 100644 index 000000000..a86d060b2 --- /dev/null +++ b/packages/comark/SPEC/COMARK/component-slot-default-escaped.md @@ -0,0 +1,58 @@ +## Input + +```md +::box +#default +\# literal +:: +``` + +## AST + +```json +{ + "frontmatter": {}, + "meta": {}, + "nodes": [ + [ + "box", + {}, + [ + "template", + { + "name": "default" + }, + "# literal" + ] + ] + ] +} +``` + +## HTML + +```html + + + +``` + +## Markdown + +```md +::box +\# literal +:: +``` + +## Markdown HTML + +```md + + +\# literal + + +``` diff --git a/packages/comark/SPEC/COMARK/component-slot-default-named.md b/packages/comark/SPEC/COMARK/component-slot-default-named.md index eec0d6f94..4a01193fa 100644 --- a/packages/comark/SPEC/COMARK/component-slot-default-named.md +++ b/packages/comark/SPEC/COMARK/component-slot-default-named.md @@ -46,3 +46,13 @@ Default slot content Default slot content :: ``` + +## Markdown HTML + +```md + + +Default slot content + + +``` diff --git a/packages/comark/SPEC/COMARK/component-slot-default.md b/packages/comark/SPEC/COMARK/component-slot-default.md index 03aa8b78e..5e373db91 100644 --- a/packages/comark/SPEC/COMARK/component-slot-default.md +++ b/packages/comark/SPEC/COMARK/component-slot-default.md @@ -37,3 +37,13 @@ Default slot content Default slot content :: ``` + +## Markdown HTML + +```md + + +Default slot content + + +``` diff --git a/packages/comark/SPEC/COMARK/component-slot-nested-after-list.md b/packages/comark/SPEC/COMARK/component-slot-nested-after-list.md index 0b9952e88..2d3baffb8 100644 --- a/packages/comark/SPEC/COMARK/component-slot-nested-after-list.md +++ b/packages/comark/SPEC/COMARK/component-slot-nested-after-list.md @@ -113,3 +113,30 @@ Make sure to use an even numbered version. ::: :: ``` + +## Markdown HTML + +```md + + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-slot-nested-codeblock.md b/packages/comark/SPEC/COMARK/component-slot-nested-codeblock.md index d567db4b0..a11920a42 100644 --- a/packages/comark/SPEC/COMARK/component-slot-nested-codeblock.md +++ b/packages/comark/SPEC/COMARK/component-slot-nested-codeblock.md @@ -69,3 +69,21 @@ hello ``` :: ``` + +## Markdown HTML + +```md + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-slot-nested-components.md b/packages/comark/SPEC/COMARK/component-slot-nested-components.md index a0f4b7947..25227e123 100644 --- a/packages/comark/SPEC/COMARK/component-slot-nested-components.md +++ b/packages/comark/SPEC/COMARK/component-slot-nested-components.md @@ -83,3 +83,29 @@ Some text ::: :: ``` + +## Markdown HTML + +```md + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-slot-with-multiple-attrs.md b/packages/comark/SPEC/COMARK/component-slot-with-multiple-attrs.md index 4452155f0..e0b27a919 100644 --- a/packages/comark/SPEC/COMARK/component-slot-with-multiple-attrs.md +++ b/packages/comark/SPEC/COMARK/component-slot-with-multiple-attrs.md @@ -49,3 +49,17 @@ Title Title :: ``` + +## Markdown HTML + +```md + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-slots-with-attrs.md b/packages/comark/SPEC/COMARK/component-slots-with-attrs.md index d4f9a28f0..7047710bc 100644 --- a/packages/comark/SPEC/COMARK/component-slots-with-attrs.md +++ b/packages/comark/SPEC/COMARK/component-slots-with-attrs.md @@ -65,3 +65,23 @@ Visual Editor Edit without code. :: ``` + +## Markdown HTML + +```md + + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-slots-with-default-named.md b/packages/comark/SPEC/COMARK/component-slots-with-default-named.md index 9fec44c81..8dca292e1 100644 --- a/packages/comark/SPEC/COMARK/component-slots-with-default-named.md +++ b/packages/comark/SPEC/COMARK/component-slots-with-default-named.md @@ -63,3 +63,23 @@ First Paragraph Second Paragraph :: ``` + +## Markdown HTML + +```md + + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-slots.md b/packages/comark/SPEC/COMARK/component-slots.md index 89d0845ed..3300c39f4 100644 --- a/packages/comark/SPEC/COMARK/component-slots.md +++ b/packages/comark/SPEC/COMARK/component-slots.md @@ -63,3 +63,23 @@ First Paragraph Second Paragraph :: ``` + +## Markdown HTML + +```md + + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-with-codeblock.md b/packages/comark/SPEC/COMARK/component-with-codeblock.md index 524986417..f7d5255a3 100644 --- a/packages/comark/SPEC/COMARK/component-with-codeblock.md +++ b/packages/comark/SPEC/COMARK/component-with-codeblock.md @@ -99,3 +99,27 @@ This is a paragraph with **bold** and _italic_ text. ``` :: ``` + +## Markdown HTML + +```md + + +```mdc [content/index.md] +--- +title: The Mountains Website +description: A website about the most iconic mountains in the world. +--- + +::my-vue-hero-component{orientation="horizontal"} +#title +Welcome to the Mountains Website. +#description +This is a description of the Mountains Website. +:: + +This is a paragraph with **bold** and _italic_ text. +``` + + +``` diff --git a/packages/comark/SPEC/COMARK/component-with-heading.md b/packages/comark/SPEC/COMARK/component-with-heading.md index 4bd6a5950..d0b111f3e 100644 --- a/packages/comark/SPEC/COMARK/component-with-heading.md +++ b/packages/comark/SPEC/COMARK/component-with-heading.md @@ -81,3 +81,19 @@ Text content Text content :: ``` + +## Markdown HTML + +```md + + +### Step 1 + +![Image](https://example.com/image.jpg) + +### Step 2 + +Text content + + +``` diff --git a/packages/comark/SPEC/COMARK/component-yaml-props-thematic-break-named-slot.md b/packages/comark/SPEC/COMARK/component-yaml-props-thematic-break-named-slot.md index d583dcf3d..a6e698276 100644 --- a/packages/comark/SPEC/COMARK/component-yaml-props-thematic-break-named-slot.md +++ b/packages/comark/SPEC/COMARK/component-yaml-props-thematic-break-named-slot.md @@ -89,3 +89,25 @@ Middle line Line three :: ``` + +## Markdown HTML + +```md + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/component-yaml-props-thematic-break.md b/packages/comark/SPEC/COMARK/component-yaml-props-thematic-break.md index e0dae7767..02b6d1db7 100644 --- a/packages/comark/SPEC/COMARK/component-yaml-props-thematic-break.md +++ b/packages/comark/SPEC/COMARK/component-yaml-props-thematic-break.md @@ -79,3 +79,21 @@ Middle text Below :: ``` + +## Markdown HTML + +```md + + +Above + +--- + +Middle text + +--- + +Below + + +``` diff --git a/packages/comark/SPEC/COMARK/component-yaml-props.md b/packages/comark/SPEC/COMARK/component-yaml-props.md index 33515be72..a74681d20 100644 --- a/packages/comark/SPEC/COMARK/component-yaml-props.md +++ b/packages/comark/SPEC/COMARK/component-yaml-props.md @@ -79,3 +79,15 @@ First Paragraph Second Paragraph :: ``` + +## Markdown HTML + +```md + + +First Paragraph + +Second Paragraph + + +``` diff --git a/packages/comark/SPEC/COMARK/component.md b/packages/comark/SPEC/COMARK/component.md index b8a319c64..77096ff5c 100644 --- a/packages/comark/SPEC/COMARK/component.md +++ b/packages/comark/SPEC/COMARK/component.md @@ -51,3 +51,15 @@ First Paragraph Second Paragraph :: ``` + +## Markdown HTML + +```md + + +First Paragraph + +Second Paragraph + + +``` diff --git a/packages/comark/SPEC/COMARK/data-binding-frontmatter.md b/packages/comark/SPEC/COMARK/data-binding-frontmatter.md index 9cffa1df7..cd2b16839 100644 --- a/packages/comark/SPEC/COMARK/data-binding-frontmatter.md +++ b/packages/comark/SPEC/COMARK/data-binding-frontmatter.md @@ -54,3 +54,18 @@ site: Hello :: ``` + +## Markdown HTML + +```md +--- +site: + name: My Blog +--- + + + +Hello + + +``` diff --git a/packages/comark/SPEC/COMARK/data-binding-inline.md b/packages/comark/SPEC/COMARK/data-binding-inline.md index a86bb1a7c..5da658f54 100644 --- a/packages/comark/SPEC/COMARK/data-binding-inline.md +++ b/packages/comark/SPEC/COMARK/data-binding-inline.md @@ -54,3 +54,14 @@ user: Hello :badge{:label="frontmatter.user.name"}! ``` + +## Markdown HTML + +```md +--- +user: + name: Ada +--- + +Hello ! +``` diff --git a/packages/comark/SPEC/COMARK/data-binding-props.md b/packages/comark/SPEC/COMARK/data-binding-props.md index 675e34c3f..2824d25c1 100644 --- a/packages/comark/SPEC/COMARK/data-binding-props.md +++ b/packages/comark/SPEC/COMARK/data-binding-props.md @@ -48,3 +48,13 @@ ::: :: ``` + +## Markdown HTML + +```md + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/data-binding-unresolved.md b/packages/comark/SPEC/COMARK/data-binding-unresolved.md index 84816db28..ec30f242d 100644 --- a/packages/comark/SPEC/COMARK/data-binding-unresolved.md +++ b/packages/comark/SPEC/COMARK/data-binding-unresolved.md @@ -34,3 +34,9 @@ ::card{:to="$doc.snippet.link"} :: ``` + +## Markdown HTML + +```md + +``` diff --git a/packages/comark/SPEC/COMARK/emoji-inside-component-autounwrap.md b/packages/comark/SPEC/COMARK/emoji-inside-component-autounwrap.md index f2311f943..b539a3203 100644 --- a/packages/comark/SPEC/COMARK/emoji-inside-component-autounwrap.md +++ b/packages/comark/SPEC/COMARK/emoji-inside-component-autounwrap.md @@ -67,3 +67,19 @@ options: ⚠️ Please backup your data before proceeding :: ``` + +## Markdown HTML + +```md + + +✅ Successfully deployed! 🚀 + + + + + +⚠️ Please backup your data before proceeding + + +``` diff --git a/packages/comark/SPEC/COMARK/emoji-inside-component.md b/packages/comark/SPEC/COMARK/emoji-inside-component.md index f2311f943..b539a3203 100644 --- a/packages/comark/SPEC/COMARK/emoji-inside-component.md +++ b/packages/comark/SPEC/COMARK/emoji-inside-component.md @@ -67,3 +67,19 @@ options: ⚠️ Please backup your data before proceeding :: ``` + +## Markdown HTML + +```md + + +✅ Successfully deployed! 🚀 + + + + + +⚠️ Please backup your data before proceeding + + +``` diff --git a/packages/comark/SPEC/COMARK/inline-component-br.md b/packages/comark/SPEC/COMARK/inline-component-br.md index e8a1e24a9..924117438 100644 --- a/packages/comark/SPEC/COMARK/inline-component-br.md +++ b/packages/comark/SPEC/COMARK/inline-component-br.md @@ -89,3 +89,18 @@ Published modules cannot leverage auto-imports. :br :br Auto-imports are not enabled for files within `node_modules`. ``` + +## Markdown HTML + +```md + + +Beware that using only `$fetch` will not provide network calls de-duplication.
+It is recommended to use `$fetch` for client-side interactions. + +
+ +Published modules cannot leverage auto-imports. +

+Auto-imports are not enabled for files within `node_modules`. +``` diff --git a/packages/comark/SPEC/COMARK/inline-component-mixed.md b/packages/comark/SPEC/COMARK/inline-component-mixed.md index 8dae97a96..9c2808308 100644 --- a/packages/comark/SPEC/COMARK/inline-component-mixed.md +++ b/packages/comark/SPEC/COMARK/inline-component-mixed.md @@ -103,3 +103,15 @@ [:component[text]{.class}] ``` + +## Markdown HTML + +```md +[text](/link) + +**text** + +*text* + +text +``` diff --git a/packages/comark/SPEC/COMARK/inline-component-props-boolean.md b/packages/comark/SPEC/COMARK/inline-component-props-boolean.md index caea54ba5..6b9447bdc 100644 --- a/packages/comark/SPEC/COMARK/inline-component-props-boolean.md +++ b/packages/comark/SPEC/COMARK/inline-component-props-boolean.md @@ -35,3 +35,9 @@ ::component{reverse :square="false" disabled} :: ``` + +## Markdown HTML + +```md + +``` diff --git a/packages/comark/SPEC/COMARK/inline-component-tailwind-class.md b/packages/comark/SPEC/COMARK/inline-component-tailwind-class.md index da28a048c..f5facaacf 100644 --- a/packages/comark/SPEC/COMARK/inline-component-tailwind-class.md +++ b/packages/comark/SPEC/COMARK/inline-component-tailwind-class.md @@ -40,3 +40,9 @@ Hello :badge{.bg-[#fff].text-[12px]} world ```md Hello :badge{.bg-[#fff].text-[12px]} world ``` + +## Markdown HTML + +```md +Hello world +``` diff --git a/packages/comark/SPEC/COMARK/inline-component-text-sibling.md b/packages/comark/SPEC/COMARK/inline-component-text-sibling.md index 92e91fdeb..7629e2a13 100644 --- a/packages/comark/SPEC/COMARK/inline-component-text-sibling.md +++ b/packages/comark/SPEC/COMARK/inline-component-text-sibling.md @@ -38,3 +38,9 @@ inline :component syntax ```md inline :component syntax ``` + +## Markdown HTML + +```md +inline syntax +``` diff --git a/packages/comark/SPEC/COMARK/inline-component-with-content-atrributes.md b/packages/comark/SPEC/COMARK/inline-component-with-content-atrributes.md index be0d6c267..6ed44ed65 100644 --- a/packages/comark/SPEC/COMARK/inline-component-with-content-atrributes.md +++ b/packages/comark/SPEC/COMARK/inline-component-with-content-atrributes.md @@ -37,3 +37,13 @@ Syntax :: ``` + +## Markdown HTML + +```md + + +Syntax + + +``` diff --git a/packages/comark/SPEC/COMARK/inline-component-with-content.md b/packages/comark/SPEC/COMARK/inline-component-with-content.md index bff414685..bb905de75 100644 --- a/packages/comark/SPEC/COMARK/inline-component-with-content.md +++ b/packages/comark/SPEC/COMARK/inline-component-with-content.md @@ -35,3 +35,13 @@ Syntax :: ``` + +## Markdown HTML + +```md + + +Syntax + + +``` diff --git a/packages/comark/SPEC/COMARK/inline-component.md b/packages/comark/SPEC/COMARK/inline-component.md index a87826359..906cf1111 100644 --- a/packages/comark/SPEC/COMARK/inline-component.md +++ b/packages/comark/SPEC/COMARK/inline-component.md @@ -89,3 +89,15 @@ Paragraph with :inline-component in middle ## a :inline inside heading ``` + +## Markdown HTML + +```md +an + +Paragraph with + +Paragraph with in middle + +## a inside heading +``` diff --git a/packages/comark/SPEC/COMARK/link-with-span.md b/packages/comark/SPEC/COMARK/link-with-span.md index 92be8f436..55f0ba478 100644 --- a/packages/comark/SPEC/COMARK/link-with-span.md +++ b/packages/comark/SPEC/COMARK/link-with-span.md @@ -65,3 +65,11 @@ [[link-name]{.cls} more](https://example.com) ``` + +## Markdown HTML + +```md +[1 Document](#) + +[link-name more](https://example.com) +``` diff --git a/packages/comark/SPEC/COMARK/span.md b/packages/comark/SPEC/COMARK/span.md index a26ecca21..4f040b234 100644 --- a/packages/comark/SPEC/COMARK/span.md +++ b/packages/comark/SPEC/COMARK/span.md @@ -60,3 +60,9 @@ options: ```md [**Bold** and *italic* text]{.highlight} ``` + +## Markdown HTML + +```md +**Bold** and *italic* text +``` diff --git a/packages/comark/SPEC/COMARK/wrapped-component-nested.md b/packages/comark/SPEC/COMARK/wrapped-component-nested.md index 5d4ceea54..b71161fde 100644 --- a/packages/comark/SPEC/COMARK/wrapped-component-nested.md +++ b/packages/comark/SPEC/COMARK/wrapped-component-nested.md @@ -70,3 +70,19 @@ First Paragraph ::: :: ``` + +## Markdown HTML + +```md + + +First Paragraph + + + +Second Paragraph + + + + +``` diff --git a/packages/comark/SPEC/COMARK/wrapped-component-nested2.md b/packages/comark/SPEC/COMARK/wrapped-component-nested2.md index c64490d6f..2cfc19a41 100644 --- a/packages/comark/SPEC/COMARK/wrapped-component-nested2.md +++ b/packages/comark/SPEC/COMARK/wrapped-component-nested2.md @@ -70,3 +70,19 @@ First Paragraph ::: :: ``` + +## Markdown HTML + +```md + + +First Paragraph + + + +Second Paragraph + + + + +``` diff --git a/packages/comark/SPEC/COMARK/wrapped-component-nested3.md b/packages/comark/SPEC/COMARK/wrapped-component-nested3.md index 845e833cb..e8f8eb7bc 100644 --- a/packages/comark/SPEC/COMARK/wrapped-component-nested3.md +++ b/packages/comark/SPEC/COMARK/wrapped-component-nested3.md @@ -90,3 +90,25 @@ First Paragraph ::: :: ``` + +## Markdown HTML + +```md + + +First Paragraph + + + +Second Paragraph + + + +Third Paragraph + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/wrapped-component-short+block.md b/packages/comark/SPEC/COMARK/wrapped-component-short+block.md index 40766a113..10fc26ebc 100644 --- a/packages/comark/SPEC/COMARK/wrapped-component-short+block.md +++ b/packages/comark/SPEC/COMARK/wrapped-component-short+block.md @@ -90,3 +90,25 @@ First Paragraph Second Paragraph :: ``` + +## Markdown HTML + +```md + + + + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/wrapped-component-slot-default-named.md b/packages/comark/SPEC/COMARK/wrapped-component-slot-default-named.md index b5c69d6c6..8007c9633 100644 --- a/packages/comark/SPEC/COMARK/wrapped-component-slot-default-named.md +++ b/packages/comark/SPEC/COMARK/wrapped-component-slot-default-named.md @@ -59,3 +59,13 @@ Default slot content Default slot content :: ``` + +## Markdown HTML + +```md + + +Default slot content + + +``` diff --git a/packages/comark/SPEC/COMARK/wrapped-component-slot-default.md b/packages/comark/SPEC/COMARK/wrapped-component-slot-default.md index 4b9d7d7d8..a855f6bd5 100644 --- a/packages/comark/SPEC/COMARK/wrapped-component-slot-default.md +++ b/packages/comark/SPEC/COMARK/wrapped-component-slot-default.md @@ -50,3 +50,13 @@ Default slot content Default slot content :: ``` + +## Markdown HTML + +```md + + +Default slot content + + +``` diff --git a/packages/comark/SPEC/COMARK/wrapped-component-slots-with-default-named.md b/packages/comark/SPEC/COMARK/wrapped-component-slots-with-default-named.md index e38af3412..27b7cf444 100644 --- a/packages/comark/SPEC/COMARK/wrapped-component-slots-with-default-named.md +++ b/packages/comark/SPEC/COMARK/wrapped-component-slots-with-default-named.md @@ -80,3 +80,23 @@ First Paragraph Second Paragraph :: ``` + +## Markdown HTML + +```md + + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/wrapped-component-slots.md b/packages/comark/SPEC/COMARK/wrapped-component-slots.md index 7760e1a7d..d45a9784e 100644 --- a/packages/comark/SPEC/COMARK/wrapped-component-slots.md +++ b/packages/comark/SPEC/COMARK/wrapped-component-slots.md @@ -80,3 +80,23 @@ First Paragraph Second Paragraph :: ``` + +## Markdown HTML + +```md + + + + + + + +``` diff --git a/packages/comark/SPEC/COMARK/wrapped-emoji-inside-component.md b/packages/comark/SPEC/COMARK/wrapped-emoji-inside-component.md index c7c6a80f1..92d787edc 100644 --- a/packages/comark/SPEC/COMARK/wrapped-emoji-inside-component.md +++ b/packages/comark/SPEC/COMARK/wrapped-emoji-inside-component.md @@ -76,3 +76,19 @@ options: ⚠️ Please backup your data before proceeding :: ``` + +## Markdown HTML + +```md + + +✅ Successfully deployed! 🚀 + + + + + +⚠️ Please backup your data before proceeding + + +``` diff --git a/packages/comark/SPEC/HTML/block+component.md b/packages/comark/SPEC/HTML/block+component.md index eeb0c7dcf..5c5266ed4 100644 --- a/packages/comark/SPEC/HTML/block+component.md +++ b/packages/comark/SPEC/HTML/block+component.md @@ -54,3 +54,15 @@ Default Slot :: ``` + +## Markdown HTML + +```md + + + +Default Slot + + + +``` diff --git a/packages/comark/SPEC/markdown-directive/container-block-directive.md b/packages/comark/SPEC/markdown-directive/container-block-directive.md index 3c3ae6933..2041e2dd4 100644 --- a/packages/comark/SPEC/markdown-directive/container-block-directive.md +++ b/packages/comark/SPEC/markdown-directive/container-block-directive.md @@ -57,3 +57,15 @@ This is a **warning** message. Do not ignore it. :: ``` + +## Markdown HTML + +```md + + +This is a **warning** message. + +Do not ignore it. + + +``` diff --git a/packages/comark/SPEC/markdown-directive/container-directive-fence.md b/packages/comark/SPEC/markdown-directive/container-directive-fence.md index d53ce37e3..3eec9fae1 100644 --- a/packages/comark/SPEC/markdown-directive/container-directive-fence.md +++ b/packages/comark/SPEC/markdown-directive/container-directive-fence.md @@ -79,3 +79,25 @@ Outer content. ::: :: ``` + +## Markdown HTML + +```md + + +Outer content. + + + +Inner content. + + + +Deeply nested. + + + + + + +``` diff --git a/packages/comark/SPEC/markdown-directive/directive-attributes.md b/packages/comark/SPEC/markdown-directive/directive-attributes.md index 5a9aa7a92..4acec829d 100644 --- a/packages/comark/SPEC/markdown-directive/directive-attributes.md +++ b/packages/comark/SPEC/markdown-directive/directive-attributes.md @@ -76,3 +76,21 @@ text Content here. :: ``` + +## Markdown HTML + +```md +text world + + + +text + + + + + +Content here. + + +``` diff --git a/packages/comark/SPEC/markdown-directive/directive-id-class.md b/packages/comark/SPEC/markdown-directive/directive-id-class.md index 167f9ce1c..9bb70d815 100644 --- a/packages/comark/SPEC/markdown-directive/directive-id-class.md +++ b/packages/comark/SPEC/markdown-directive/directive-id-class.md @@ -77,3 +77,19 @@ Welcome to the site. Welcome to the site. :: ``` + +## Markdown HTML + +```md +hello + +world + +styled + +
+ +Welcome to the site. + +
+``` diff --git a/packages/comark/SPEC/markdown-directive/directive-inline-content.md b/packages/comark/SPEC/markdown-directive/directive-inline-content.md index 2749d357c..c14bb41b9 100644 --- a/packages/comark/SPEC/markdown-directive/directive-inline-content.md +++ b/packages/comark/SPEC/markdown-directive/directive-inline-content.md @@ -92,3 +92,27 @@ Important Notice The label contains inline content but the body has block content. :: ``` + +## Markdown HTML + +```md + + +it's a *happy* ending + + + + + +see **figure 1** + + + + + +Important Notice + +The label contains inline content but the body has block content. + + +``` diff --git a/packages/comark/SPEC/markdown-directive/directive-nesting.md b/packages/comark/SPEC/markdown-directive/directive-nesting.md index 0cea53238..664ca0d67 100644 --- a/packages/comark/SPEC/markdown-directive/directive-nesting.md +++ b/packages/comark/SPEC/markdown-directive/directive-nesting.md @@ -67,3 +67,21 @@ This is a spoiler. More spoiler content. :: ``` + +## Markdown HTML + +```md + + +This is a spoiler. + + + +Nested warning inside spoiler. + + + +More spoiler content. + + +``` diff --git a/packages/comark/SPEC/markdown-directive/directive-no-content.md b/packages/comark/SPEC/markdown-directive/directive-no-content.md index 6f01f9b5c..54e1c46c4 100644 --- a/packages/comark/SPEC/markdown-directive/directive-no-content.md +++ b/packages/comark/SPEC/markdown-directive/directive-no-content.md @@ -79,3 +79,15 @@ a :br with no content or attributes ::separator :: ``` + +## Markdown HTML + +```md +a :hr directive with no content + +a
with no content or attributes + + + + +``` diff --git a/packages/comark/SPEC/markdown-directive/inline-directive.md b/packages/comark/SPEC/markdown-directive/inline-directive.md index 152916cfb..0a6da6c1c 100644 --- a/packages/comark/SPEC/markdown-directive/inline-directive.md +++ b/packages/comark/SPEC/markdown-directive/inline-directive.md @@ -77,3 +77,13 @@ a :cite[smith04] reference paragraph with :abbr[HTML]{title="HyperText Markup Language"} inline ``` + +## Markdown HTML + +```md +a content directive + +a smith04 reference + +paragraph with HTML inline +``` diff --git a/packages/comark/SPEC/plugins-binding/binding-span.md b/packages/comark/SPEC/plugins-binding/binding-span.md index a23209e7d..54a80bba7 100644 --- a/packages/comark/SPEC/plugins-binding/binding-span.md +++ b/packages/comark/SPEC/plugins-binding/binding-span.md @@ -60,3 +60,13 @@ color: red [highlighted {{ frontmatter.color }} text]{.glow} ``` + +## Markdown HTML + +```md +--- +color: red +--- + +highlighted {{ frontmatter.color }} text +``` diff --git a/packages/comark/src/internal/stringify/handlers/html.ts b/packages/comark/src/internal/stringify/handlers/html.ts index 0a7dc61ae..ca104a126 100644 --- a/packages/comark/src/internal/stringify/handlers/html.ts +++ b/packages/comark/src/internal/stringify/handlers/html.ts @@ -1,5 +1,5 @@ import type { State } from 'comark/render' -import type { ElementNode } from 'comark' +import type { ElementNode, Node } from 'comark' import { htmlAttributes } from '../html-attributes.ts' import { indent, toNativeAttributes } from '../../../utils/index.ts' @@ -52,8 +52,8 @@ export async function html(node: ElementNode, state: State, parent?: ElementNode oneLiner = true } - // If parent is a paragraph, it is inline - if (parent?.[0] === 'p' || state.context.inline) { + // If parent is a paragraph or an inline element, it is inline + if (parent?.[0] === 'p' || inlineTags.has(String(parent?.[0])) || state.context.inline) { oneLiner = true } @@ -66,27 +66,39 @@ export async function html(node: ElementNode, state: State, parent?: ElementNode // Do not modify context if we are already in html mode const revert = state.applyContext({ inline: oneLiner }) + const isBlockChild = (child: Node) => + typeof child !== 'string' && + (blockTags.has(String(child?.[0])) || (!inlineTags.has(String(child?.[0])) && !hasTextSibling)) + + // A component written as a tag needs blank lines around its markdown, or CommonMark keeps it in the HTML block. + const markdownBody = !state.context.html && !oneLiner && $.html !== 1 + const childrenContent: string[] = [] - for (const child of children) { - childrenContent.push(await state.one(child, state, node)) + for (let i = 0; i < children.length; i++) { + const atLineStart = markdownBody && (i === 0 || isBlockChild(children[i - 1])) + childrenContent.push(await state.one(children[i], state, node, atLineStart)) } // A blank line inside a raw-HTML element would terminate it on reparse - const childSeparator = state.context.html ? state.context.blockSeparator : oneLiner ? '' : '\n' + const childSeparator = state.context.html + ? state.context.blockSeparator + : markdownBody + ? '\n\n' + : oneLiner + ? '' + : '\n' let content = '' let isPrevBlock = true for (let i = 0; i < children.length; i++) { const childContent = childrenContent[i] - const child = children[i] - const isBlock = - typeof child !== 'string' && - (blockTags.has(String(child?.[0])) || (!inlineTags.has(String(child?.[0])) && !hasTextSibling)) + const isBlock = isBlockChild(children[i]) if (i > 0 && !isPrevBlock && isBlock) { content += childSeparator } - content += childContent + // Block handlers end with their own separator, which `childSeparator` replaces. + content += markdownBody && isBlock ? childContent.replace(/\n+$/, '') : childContent isPrevBlock = isBlock if (isBlock && i < children.length - 1) { @@ -102,7 +114,10 @@ export async function html(node: ElementNode, state: State, parent?: ElementNode const nativeAttributes = toNativeAttributes(String(tag), node, attributes) const attrs = Object.keys(nativeAttributes).length > 0 - ? ` ${htmlAttributes(nativeAttributes, { verbatim: !state.context.html && $.html === 1 })}` + ? ` ${htmlAttributes(nativeAttributes, { + verbatim: !state.context.html && $.html === 1, + encodeNewlines: !state.context.html, + })}` : '' if (isSelfClose) { @@ -110,7 +125,8 @@ export async function html(node: ElementNode, state: State, parent?: ElementNode } if (!oneLiner && content) { - content = '\n' + paddNoneHtmlContent(content, state, String(tag)).trimEnd() + '\n' + const padding = markdownBody ? '\n\n' : '\n' + content = padding + paddNoneHtmlContent(content, state, String(tag)).trimEnd() + padding } return `<${tag}${attrs}>${content}` + (!parent && !isInline ? state.context.blockSeparator : '') diff --git a/packages/comark/src/internal/stringify/handlers/template.ts b/packages/comark/src/internal/stringify/handlers/template.ts index dc5833f6d..04ea42ccc 100644 --- a/packages/comark/src/internal/stringify/handlers/template.ts +++ b/packages/comark/src/internal/stringify/handlers/template.ts @@ -12,8 +12,6 @@ export async function template(node: ElementNode, state: State, parent?: Element return component(node, state, parent) } - const content = (await state.flow(node, state)).trimEnd() - // Omit #default marker if this is the only slot if (attrs.name === 'default') { const siblings = parent ? (parent.slice(2) as Node[]) : [] @@ -21,12 +19,28 @@ export async function template(node: ElementNode, state: State, parent?: Element (child) => Array.isArray(child) && (child as ElementNode)[0] === 'template' ).length if (templateCount === 1) { - return content + state.context.blockSeparator + return (await slotContent(node, state)) + state.context.blockSeparator } } const { name: _name, $: _$, ...rest } = attrs + + // `#name` is Comark syntax and does not parse inside an HTML tag; `name` matches the `text/html` output. + if (state.context.format !== 'markdown/comark') { + return state.handlers.html(['template', { name: attrs.name, ...rest }, ...(node.slice(2) as Node[])], state, parent) + } + + const content = await slotContent(node, state) const extraAttrs = comarkAttributes(rest) return `#${attrs.name}${extraAttrs}\n${content}` + state.context.blockSeparator } + +// `flow()` does not pass `atLineStart`, so slot text starting with `#` or `-` would lose its escape. +async function slotContent(node: ElementNode, state: State): Promise { + let content = '' + for (const child of node.slice(2) as Node[]) { + content += await state.one(child, state, node, content === '' || content.endsWith('\n')) + } + return content.trimEnd() +} diff --git a/packages/comark/src/internal/stringify/html-attributes.ts b/packages/comark/src/internal/stringify/html-attributes.ts index 2cfd4fdd8..eb9bf271b 100644 --- a/packages/comark/src/internal/stringify/html-attributes.ts +++ b/packages/comark/src/internal/stringify/html-attributes.ts @@ -122,8 +122,12 @@ const SAFE_ATTR_NAME = /^[a-zA-Z_:][a-zA-Z0-9_:.-]*$/ interface HtmlAttributesOptions { /** Keep `:` prefixes and string `"true"` values as written */ verbatim?: boolean + /** Write line breaks as ` ` / ` `, since a CommonMark HTML block needs its open tag on one line */ + encodeNewlines?: boolean } +const NEWLINE_RE = /[\n\r]/g + /** * Convert attributes to a string of HTML attributes * @@ -131,7 +135,14 @@ interface HtmlAttributesOptions { * @param options - Serialization options * @returns The stringified attributes */ -export function htmlAttributes(attributes: Record, { verbatim = false }: HtmlAttributesOptions = {}) { +export function htmlAttributes( + attributes: Record, + { verbatim = false, encodeNewlines = false }: HtmlAttributesOptions = {} +) { + const escapeValue = (value: string) => { + const escaped = escapeHtml(value) + return encodeNewlines ? escaped.replace(NEWLINE_RE, (char) => (char === '\n' ? ' ' : ' ')) : escaped + } const parts: string[] = [] for (const [rawKey, value] of Object.entries(attributes)) { const isBinding = rawKey.startsWith(':') @@ -144,10 +155,10 @@ export function htmlAttributes(attributes: Record, { verbatim = continue } if (typeof value === 'object' && value !== null) { - parts.push(`${key}="${escapeHtml(JSON.stringify(value))}"`) + parts.push(`${key}="${escapeValue(JSON.stringify(value))}"`) continue } - parts.push(`${key}="${escapeHtml(String(value))}"`) + parts.push(`${key}="${escapeValue(String(value))}"`) continue } @@ -158,11 +169,11 @@ export function htmlAttributes(attributes: Record, { verbatim = if (value === false || value === null || value === undefined) continue if (typeof value === 'object') { - parts.push(`${key}="${escapeHtml(JSON.stringify(value))}"`) + parts.push(`${key}="${escapeValue(JSON.stringify(value))}"`) continue } - parts.push(`${key}="${escapeHtml(String(value))}"`) + parts.push(`${key}="${escapeValue(String(value))}"`) } return parts.join(' ') } diff --git a/packages/comark/test/index.test.ts b/packages/comark/test/index.test.ts index 068328d2d..ed57a3fae 100644 --- a/packages/comark/test/index.test.ts +++ b/packages/comark/test/index.test.ts @@ -51,6 +51,7 @@ interface TestCase { ast: string html: string markdown: string + markdownHtml: string timeouts?: { parse?: number html?: number @@ -120,7 +121,7 @@ function extractTestCase(content: string): TestCase { const sections: Record = {} // Extract sections - find each section header and its content - const sectionHeaders = [...body.matchAll(/^## (Input|AST|HTML|Markdown)\s*\n\n```(\w+)\n/gm)] + const sectionHeaders = [...body.matchAll(/^## (Input|AST|HTML|Markdown HTML|Markdown)\s*\n\n```(\w+)\n/gm)] for (let i = 0; i < sectionHeaders.length; i++) { const match = sectionHeaders[i] @@ -170,6 +171,9 @@ function extractTestCase(content: string): TestCase { ast: sections.ast || '', html: sections.html || '', markdown: sections.markdown || '', + // `## Markdown HTML` is optional and falls back to `## Markdown`. + // Add it only when `markdown/html` output differs (components, spans, slots, `:br`). + markdownHtml: sections['markdown html'] ?? sections.markdown ?? '', timeouts, options, } @@ -299,6 +303,17 @@ describe('Comark Tests', () => { expect(result).toBe(expectedMarkdown) } ) + + it('should render AST to Markdown HTML', async () => { + const result = await renderMarkdown(document, { + ...(testCase.options || {}), + format: 'markdown/html', + components: { + binding: MarkdownBinding, + }, + }) + expect(result).toBe(testCase.markdownHtml.trim()) + }) }) }) }) diff --git a/packages/comark/test/render-markdown-html.test.ts b/packages/comark/test/render-markdown-html.test.ts new file mode 100644 index 000000000..cab7af9fc --- /dev/null +++ b/packages/comark/test/render-markdown-html.test.ts @@ -0,0 +1,31 @@ +import { describe, expect, it } from 'vitest' +import { createMarkdownExit } from 'markdown-exit/core' +import { parseMarkdown } from '../src/index' +import { render } from '../src/render' + +// `markdown/html` output is read by plain CommonMark parsers; SPEC fixtures pin the exact output. +async function reparse(markdown: string) { + const output = await render(await parseMarkdown(markdown), { format: 'markdown/html' }) + return createMarkdownExit({ html: true }).parse(output, {}) +} + +describe('render: markdown/html', () => { + it('keeps the markdown inside a component tag parseable', async () => { + const tokens = await reparse( + ['::steps', '### Create', '', 'Run:', '', '```bash', 'npx create', '```', '', '- a', '- b', '::'].join('\n') + ) + + const types = tokens.map((token) => token.type) + expect(types).toContain('heading_open') + expect(types).toContain('fence') + expect(types).toContain('bullet_list_open') + }) + + it('keeps a code block holding indented fences whole', async () => { + const code = '::tabs\n :::tabs-item\n ```mdc\n ::callout\n ::\n ```\n :::\n\n::' + const tokens = await reparse(`::code-preview\n#code\n\`\`\`\`mdc\n${code}\n\`\`\`\`\n::\n\nAfter`) + + expect(tokens.filter((token) => token.type === 'fence').map((token) => token.content)).toEqual([`${code}\n`]) + expect(tokens.at(-2)?.content).toBe('After') + }) +}) diff --git a/test/bundle.test.ts b/test/bundle.test.ts index aac8fcb86..a38666b75 100644 --- a/test/bundle.test.ts +++ b/test/bundle.test.ts @@ -77,7 +77,7 @@ describe('package bundle size', { timeout: 60_000 }, () => { "@comark/react": "42.9k (83 files)", "@comark/svelte": "50.3k (91 files)", "@comark/vue": "62.6k (89 files)", - "comark": "440k (171 files)", + "comark": "442k (171 files)", } `) })