Skip to content

Expose post-render hook for markdown-it-async so plugins can capture resolved highlight HTML #5064

@hezhengxu2018

Description

@hezhengxu2018

Is your feature request related to a problem? Please describe.

I’am maintaining a demo-block plugin that reuses VitePress’s own code highlighting so users don’t need duplicate Shiki configs. In VitePress 1.x we could call md.render inside our markdown-it rule and get final <pre><code> HTML. In 2.x, markdown-it-async replaces the highlight with placeholders during md.render and only resolves them after md.renderAsync, so any plugin capturing HTML during markdown parsing just sees or [object Promise]. To support both versions we currently inject hidden DOM nodes and let Vue read them after hydration, which breaks SSG and feels fragile.

Describe the solution you'd like

Expose a hook that runs after all async highlight promises resolve—e.g., a post-render transform callback or an API to await specific markdown-it-async placeholder IDs—so plugins can access the final highlighted HTML before the page HTML is emitted. That would let demo-blocks pass the resolved <pre> markup directly into their Vue components (or slots) without duplicating Shiki logic and while keeping SSR/SSG intact.

Describe alternatives you've considered

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions