fix(comark): run default plugin hooks before user plugin hooks - #385
Merged
Conversation
User plugin post hooks previously ran before the default plugins' post
hooks, so tree-consuming plugins saw an un-normalized tree (e.g. GFM
alerts were still plain blockquotes because `alert` had not rewritten
them into `['blockquote', { as }]` yet).
Post hooks now run defaults first, then user plugins. Registration
order is unchanged: user plugins still come first so same-name entries
override defaults via dedupePlugins, and a user override keeps the
default's execution slot. `pre` hooks and `markdownItPlugins` keep
their existing order.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
comark
@comark/angular
@comark/ansi
@comark/html
@comark/nuxt
@comark/react
@comark/svelte
@comark/vue
commit: |
Contributor
✅ Bundle snapshot updatedCommitted the new snapshot as 42d1d04, verified by re-running the bundle check against it. GitHub suppresses the events a workflow commit would normally raise, so the Produced by this run. |
Deriving the hoisted names from the registered defaultPlugins array instead of a hardcoded set removes the duplicated list and makes the hoisting a natural no-op with registerDefaultPlugins: false, where the user's explicit registration order rules. Adds a test for that case.
Same rationale as the post-hook ordering: among the defaults only frontmatter has a pre hook, and running it first gives user pre hooks a normalized contract — state.markdown without the frontmatter block, state.frontmatter and state.frontmatterText already populated — instead of raw text a rewriting plugin could corrupt. One partitioned list now drives both lifecycle phases; markdownItPlugins keep registration order.
Contributor
Documentation previews |
farnabaz
approved these changes
Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Comark now resolves plugins into one canonical order for MarkdownExit registration and
preandposthooks: unchanged defaults first, followed by explicit plugins in user-defined order. An explicit plugin replaces a same-name default at its listed position, and duplicate explicit names keep their first instance; tests and public documentation cover these semantics.Why
The previous registration and lifecycle orders differed, so a plugin could run in a different position depending on which part of its interface Comark invoked. Using one resolved order makes overrides predictable while ensuring user plugins receive the transformations from defaults they did not replace.