From 4ee8e1933e9d1dd13e3649ba4d9aec6d9d002baf Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Fri, 9 Oct 2026 12:45:15 +0200 Subject: [PATCH 1/4] feat(parse): mark incomplete block components with $.ac while streaming Auto-close (markIncomplete, on in streaming parses) writes the stage of the innermost block component it had to close on its closer: ':: '. Block closers now accept a trailing HTML comment; the components plugin reads the auto-close one into $.ac on the component and, for 'content', on its last slot. Also: close a code fence still open inside a component before the component closer, keep a typed '::' closer under dropTrailingOpeners, and add a Streaming toggle to the /play options. --- AGENTS.md | 10 +- docs/app/components/Playground.vue | 11 +- .../1.getting-started/2.document-model.md | 11 ++ docs/content/2.syntax/2.components.md | 8 ++ docs/content/5.reference/2.auto-close.md | 7 + .../SPEC/COMARK/component-closer-comment.md | 49 +++++++ .../src/internal/parse/auto-close/index.ts | 121 +++++++++++++++++- .../src/internal/parse/token-processor.ts | 3 + packages/comark/src/parse.ts | 1 + packages/comark/src/plugins/components.ts | 44 ++++++- packages/comark/src/types.ts | 10 ++ packages/comark/test/auto-close.test.ts | 50 ++++++++ packages/comark/test/streaming.test.ts | 65 ++++++++++ 13 files changed, 379 insertions(+), 11 deletions(-) create mode 100644 packages/comark/SPEC/COMARK/component-closer-comment.md diff --git a/AGENTS.md b/AGENTS.md index 595ef91e0..bcb9d69ac 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -657,8 +657,14 @@ autoCloseMarkdown('hello *', { dropTrailingOpeners: true }) // 'hello' Key options: `linkMode: 'protocol' | 'text-only'`, `math` (default false; on in parse), `dropTrailingOpeners` (default false; on when parsing with `streaming: true`), -`incompleteLinkPlaceholder`, `incompleteImagePlaceholder`, `frontmatter`, `syntax`, `attributes`. -Behavioral SPEC: `packages/comark/SPEC/auto-close.md` (run via `test/auto-close-spec.test.ts`). +`incompleteLinkPlaceholder`, `incompleteImagePlaceholder`, `frontmatter`, `syntax`, `attributes`, +`markIncomplete` (default false; on when parsing with `streaming: true`). + +`markIncomplete` writes the stage of the innermost block component auto-close had to close on +its closer: `::al` → `::al\n:: ` (`name` | `props` | `content`). The +`comark_block` rule in `src/plugins/components.ts` accepts a trailing HTML comment on any closer +(dropped), and reads an `auto-close:` one into `tokenOpen.meta.ac`; the token processor turns it +into `$.ac` on the component (and on its last slot for `content`). Behavioral SPEC: `packages/comark/SPEC/auto-close.md` (run via `test/auto-close-spec.test.ts`). ## Markdown Document Model diff --git a/docs/app/components/Playground.vue b/docs/app/components/Playground.vue index eb20cf7c7..5d89f770e 100644 --- a/docs/app/components/Playground.vue +++ b/docs/app/components/Playground.vue @@ -1,5 +1,5 @@