Replies: 1 comment 1 reply
-
Hey! For parser plugins, those are inline, here. That has to do with the language. Not that extendable compared to JS. And also bundle size often matters less. For renderer, I think that’s just rehype/hast. No need to be here. For the remaining one, ASTs. That’s here, indeed. But most AST stuff you mention is more about HTML (heading IDs). What do you mean with link normalization? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Motivation
As the number of plugins grows, the Rust↔JS round-trip cost starts to dominate and both throughput and stability become shaky. To reduce round-trips, we’d like to add a thin abstraction layer in
markdown-rs
so that popular transforms (slug, autolink, smartypants, GFM, etc.) can run natively in Rust while any remaining JS runs in a single batched pass.Background context: see the Astro-side discussion about these tradeoffs in
Purpose
Under
cfg(feature = "experimental_plugins")
, introduce minimal traits and a light registry across three stages—Syntax, AST, and Render—so the “Host” (the runtime side) can manage registration order, priority, interop policy (GFM/MDX/Math/Frontmatter), and execution mode (Rust/WASM/JS-IPC). With the feature disabled, behavior is identical to today. We’ll start with AST hooks, then enable Syntax/Render as needed.Summary
Core focuses on the minimal path
Parser → MDAST → Renderer
, and hooks connect across the Host/Core boundary as an optional layer. The Host supplies deterministic behavior via ordering and policy; on plugin failure we fall back to literal text so processing continues safely. This design minimizes round-trips, centralizes conflict resolution, and keeps production behavior predictable. We’ll demonstrate with small AST-first wins (e.g., heading ID, internal link normalization) before expanding to Syntax/Render.Related: #52
Beta Was this translation helpful? Give feedback.
All reactions