Description
Allow ParserOptions.autoClose to accept a synchronous function. It should receive the unstable Markdown tail after incremental reuse and run before plugin preprocessing and tokenization.
Motivation
While optimizing vue-stream-markdown, I found Comark's compact document model and incremental parser architecture excellent. Our benchmarks show several-fold parsing performance improvements over the current mdast-based implementation, so I would like to adopt Comark as the parser while retaining custom completion rules for more controlled handling of incomplete Markdown.
Proposed solution
Allow autoClose to accept a boolean or a synchronous function:
autoClose?: boolean | ((markdown: string, options: AutoCloseOptions) => string)
true would keep the current behavior, false would disable auto-close, and a function would replace the built-in implementation at the same stage.
Alternatives considered
Preprocessing before parsing handles the full source and may disrupt incremental reuse. A pre plugin can work, but it is a general transform hook whose execution order may not match the built-in auto-close stage.
Additional context
PR #385 makes a pre plugin less reliable as an auto-close replacement because default hooks run first. A function would provide a stable extension point, and I would be happy to submit a PR if this approach is accepted.
Description
Allow
ParserOptions.autoCloseto accept a synchronous function. It should receive the unstable Markdown tail after incremental reuse and run before plugin preprocessing and tokenization.Motivation
While optimizing vue-stream-markdown, I found Comark's compact document model and incremental parser architecture excellent. Our benchmarks show several-fold parsing performance improvements over the current mdast-based implementation, so I would like to adopt Comark as the parser while retaining custom completion rules for more controlled handling of incomplete Markdown.
Proposed solution
Allow
autoCloseto accept a boolean or a synchronous function:autoClose?: boolean | ((markdown: string, options: AutoCloseOptions) => string)truewould keep the current behavior,falsewould disable auto-close, and a function would replace the built-in implementation at the same stage.Alternatives considered
Preprocessing before parsing handles the full source and may disrupt incremental reuse. A
preplugin can work, but it is a general transform hook whose execution order may not match the built-in auto-close stage.Additional context
PR #385 makes a
preplugin less reliable as an auto-close replacement because default hooks run first. A function would provide a stable extension point, and I would be happy to submit a PR if this approach is accepted.