npm / mdsvex
mdsvex
What changed in mdsvex 0.12 to 1, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
26 breaking1 security87 new APIs and options7 behavior and defaults4 tooling19 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initmdsvex 1143 changes
Breaking changes 26
Node append and prepend can create text nodes from a string; append('text') without text now throws a TypeError.
Character references in text, link and image attributes render as written rather than being escaped a second time; bare, escaped and code-contained ampersands remain escaped.
Annotations inside block comments hide the whole comment, and fences with many annotations render in linear time.
component_mode: 'all' now replaces typed HTML elements as well as elements produced by Markdown; elements with Svelte directives remain elements and cause a warning.
A directive can have only one owner; duplicate bindings now throw DirectiveOwnerError during setup instead of silently replacing the earlier owner.
Elements with duplicate attributes retain both during compilation, allowing Svelte to report
attribute_duplicateinstead of hiding the mistake.Marks top-level brace groups in a code block as live Svelte expressions; it is enabled by default and included in default_annotations.
As a fence flag, applies [!eval] to every line of any fence, including fences without a language.
A footnote definition may put its text on the next line indented by four spaces; an empty definition now fails with FootnoteError code footnote_empty.
Heading IDs are generated as headings close, allowing parse plugins to read them in their heading handler; fixed IDs are preserved and collisions with earlier elements now raise HeadingIdError.
The editor accounts for the Vite plugin's import_images setting, enabled by default, so replaced img src values have the imported asset type rather than string.
Relative Markdown image URLs are imported relative to the document, allowing Vite to hash or inline them and fail the build when files are missing; aliases are imported as written.
HTML node attributes are now built lazily and are omitted from metadata spreads and key enumeration; read meta.attributes directly.
Code-fence open handlers receive the complete info string as node.info; node.lang retains the older name but now uses an empty string when absent.
Using a NodeView retained from a compiled document after the next document starts now errors, preventing access to that next document's nodes.
Renames the parsePlugins option to parse_plugins to follow mdsvex's snake_case option naming.
A replaced pre receives the whole pre element as children, plus code, language, metadata, title, caption, and unclaimed metadata parts as props.
Attribute values in raw HTML render as written, so entities such as
&are not escaped a second time.A run-marked code fence is displayed as code and imported as a module; a replacement pre component receives the module and decides how to run it.
In compile and compile_async, the callback receives the file path first, matching the Vite plugin; the path is the filename option or undefined.
Source mapping fields are getters, so spreading a mapping no longer copies offsets, lengths, or data; read those properties directly.
Static directives reject uses that cannot run in static output, snippets not rendered exactly once, head content, and indirect re-exports from the directives module.
List items beginning with a valid checkbox marker render a disabled checkbox; replaced li components receive a boolean checked prop instead.
Documents can be wrapped in named Svelte templates that receive frontmatter and document props plus the body as children; template selection and component replacement rules are added.
A container directive without a label contributes its text hook output in plain text before its body, so default titles appear in extracted text.
Vite 6 or later is required because Vite 5 does not call the hook needed to pick up changed component or template files in the dev server.
Security 1
Dev-server metadata requests now obey configured extensions and Vite server.fs allow, deny, and strict rules, like requests for the document itself.
New APIs and options 86
Directive child handlers can use a '*' key to handle every directly written child after its type-specific handler.
compile_async accepts an optional CompilerSession to retain plugin loads and allow hosts to invalidate paths and obtain fresh loads.
Reads files referenced by src= fences when supplied read and resolve options, and returns those files and the document template module in dependencies.
compile() accepts file contents through sources and throws a SourceError when a requested file is missing.
Compiles source to the same document text value provided by ?text, without Vite.
Invalidates cached plugin loads for the specified paths.
Hosts outside Vite can parse documents in steps, settle deferred work, and render after supplying needed inputs.
A components module can replace Markdown-produced elements with Svelte components exported under element names; only components used by a document are imported.
The highlight entry exports helpers for creating a highlighter, loading languages, and configuring annotations.
Adds values to an ordered plugin-data list; entries follow document order and are reverted when their node is revoked.
Shares a load between documents; path keys become dependencies and CompilerSession.invalidate(paths) drops cached values.
Exposes plugin data in compile results and warnings; writes are reverted when the parser revokes the node that made them.
Starts asynchronous work for a node that compile_async waits for; compile() throws PluginAsyncError if it is used.
Declares a file dependency for plugin output; compile results expose dependencies for host watching.
Gives parse plugin handlers the compile filename; it is undefined when none was supplied.
Provides parsed frontmatter to plugin handlers, parsing it on first access.
Allocates unique IDs across headings, footnotes, and plugin requests; fixed IDs preserve author-written values and can raise HeadingIdError on collision.
Reads a file through the read function supplied by the host.
Resolves a specifier through the resolve function supplied by the host.
Provides per-plugin, per-document scratch storage shared across handlers and hooks; it is not reverted and never reaches plugin_data.
Writes plugin data for a key; writes are associated with the handler's node and undone if that node is revoked.
Adds a warning to the compile, optionally located at a node.
Importing a document with ?data exports frontmatter metadata and plugin_data without its component, running plugins but rendering nothing.
A components module can declare directive components through a directives namespace export; unhandled directives are passed to parse-plugin handlers and otherwise fail compilation.
Node.svelte accepts directive components by name, with args as props and label and content as snippets.
A template can export its own directives namespace, which takes precedence over root directives for documents wrapped by that template.
Adds a plugin hook that runs after parsing, sequential passes, and deferred tasks, receiving the document root.
mdsvex/globals types the ?text import value as DocumentText.
Lets a plugin claim fence languages so the highlighter skips them and the plugin owns their rendering; duplicate claims throw FenceOwnerError.
Components modules can replace individual footnote references with a footnote export and the end section with a footnotes export.
Adds Markdown footnote references and definitions, numbered by first reference and collected at the end with backlinks; unresolved or duplicate labels error by default.
Frontmatter is parsed into metadata exported by compiled components and returned by compile(); a custom YAML parser can be supplied through frontmatter.parse.
The custom frontmatter parser receives the document path as its second argument in an object containing filename; the same parser is used for compiled documents, ?metadata imports, and ctx.frontmatter.
Enabling heading_ids adds GitHub-style text-based IDs to Markdown headings, with repeated IDs numbered; a slug function can customize the scheme.
mdsvex.config.json accepts highlight: false to disable editor code highlighting.
The Vite plugin highlights fenced code and code spans with twinkleplop by default; unknown languages render as plain twinkleplop markup with one warning per file.
compile() accepts a synchronous highlight function or false; it remains synchronous and does not highlight by default. A function may return HTML or null for plain code.
Disables Markdown image URL imports when set to false; it is enabled by default in the Vite plugin and off by default in compile().
When enhanced-img is installed and its Vite plugin is enabled, Markdown images can be imported as optimized pictures; the option can disable or require this behavior.
A code span wrapped in dollars renders as inline math through the same renderer as a math fence; plain dollar-delimited text remains text.
CursorHTMLRenderer and ComponentRenderer accept invalidate(buf, nodes) so nodes changed by deferred tasks rerender even inside cached blocks.
Sets a prefix for root URLs, using true for Vite's base, a string, or an imported function.
Names the directory whose document links can be rewritten into routes.
Selects a math renderer and its options; supports Temml by default, optional KaTeX, a custom renderer function, or false to leave math fences as code.
Adds a compiler-only entry point containing compile, CompilerSession, compiler errors, and option and result types without importing Vite, es-module-lexer, or Node builtins.
Provides TypeScript declarations for direct metadata imports when added to compilerOptions.types.
Adds a highlight entry point that exports language_loaders for loading bundled languages individually and re-exports shiki_notation.
Provides create_highlight and load_default_languages for building an asynchronous highlighter configuration for compile().
Adds a host entry for tools compiling documents without Vite, with exports for reading exports and serving metadata/data imports and editor manifests.
Adds exports for loading and using Temml, KaTeX, and source math renderers.
Components can read plugin data from Svelte context under this symbol as an object with a current property.
Imports a document's frontmatter without its component, exporting metadata as both a named and default export.
Indicates whether the parser may revoke a node; wrap_from and close are allowed only when the node is not pending.
Exposes a node's source offsets, line, and column; it may be undefined for plugin-created nodes and wire-format trees.
Removes a node and its descendants where the parser cannot revoke it; calls elsewhere throw.
Parse plugins can observe directives by name after owner handlers; observers can write plugin data and warn but cannot change nodes.
Reads the text value from a document compiled in steps.
Adds a new PFM parser and renderers.
Documents export plugin data beside metadata and pass the same object to the template; no export is added when plugins leave no data.
Adds a plugin system and an autolink plugin.
Adds a declaration-mergeable interface for plugins to type their own plugin_data keys.
Adds a type for the plugin data context obtained from Svelte context, typed by declared PluginData keys.
Notifies a listener of plugin-data writes and revocations, with the key's value after each change.
Accepts plugins that provide directives, directive handlers, parse plugins, and component replacements.
Adds a streaming renderer that applies batches, tracks plugin writes and deferred changes, and rerenders affected content through its lifecycle.
Finds the names exported by a module or Svelte module script, using a TypeScript stripper supplied by the host.
Reads an mdsvex.config.json file into the Vite plugin's manifest format and reports configuration problems, without requiring Vite or Node.
Accepts a function to rewrite links not handled by route or base rewriting.
With run=client, the component receives load, a function that imports the code block when requested, instead of module.
Allows choosing a document template from its id and metadata, as part of template selection.
Optionally converts prose quotes, dashes, and ellipses to typographic punctuation; it is off by default and leaves code and other excluded content unchanged.
compile() uses snippets to describe how running blocks are imported and can return their code; snippets: false only displays the block.
Code fences can show a file specified by src; paths resolve like document imports, optional line ranges select content, and development edits update pages that show the file.
Naming a directive component with .static.svelte renders it once at build time; its HTML is embedded without loading or hydrating the component in the browser.
Exposes plugin-written stream data as a new object after each change, so components reading it render again when it changes.
compile() accepts strict_directives: false to render an unhandled directive as its children instead of throwing, for previews and editors.
Tables support row-header columns and merged cells using || in the delimiter and header rows, and > or ^ cell markers.
An import query can override a document's template, including disabling it with ?template=false.
mdsvex/host exports template_module to combine a template and its extra replacements, with names from the extra module taking precedence.
A template can be an mdsvex document whose Markdown content reads props and renders children; a document used as a template is not wrapped in another template.
Sequential plugins may define a text handler to replace ranges in neighboring text runs with text or nodes; invalid handler configuration and overlapping replacements throw errors.
Builds the module for a document's extracted text.
Importing a document with ?text exposes reader-facing text by section without rendering its component, for uses such as search indexes and RSS bodies.
mdsvex exports the type of a text handler run for plugin authors.
When enabled, removes the paragraph wrapper around paragraphs containing only images, allowing block replacements such as figure; it is off by default.
When enabled, wraps runs of two or more top-level blocks without Svelte in display: contents divs to reduce initial hydration work; it is off by default and can affect selectors.
Behavior and default changes 7
Directive open handlers now receive the directive name immediately; block directive args are available there, while inline args remain available at close.
Directive labels accept inline Markdown; the label renders through the directive component's label snippet and is represented as a separate parse-tree node.
Footnote definitions can contain multiple blocks, with indented content continuing after a blank line and the first unindented nonblank line ending the definition.
Compiler sessions and the Vite plugin reuse their tree, dispatcher and renderer across documents when parse plugins are configured; a different array rebuilds them.
The footnotes strict: false setting turns missing-definition and duplicate-label errors into warnings for previews.
With SvelteKit 3, the mdsvex Vite plugin registers its extensions so they need not be repeated in sveltekit({ extensions }); without SvelteKit, missing Svelte extensions cause a build error.
Import statements at the top of a document are retained and placed in its instance script, creating a script when needed.
Tooling 4
The editor can read template, replacement-component, and directive information from the Vite-generated manifest or an mdsvex.config.json fallback, providing navigation, completions, and type checking.
The editor types document plugin_data exports and imports against PluginData when configured plugins may provide data; declared keys retain their types and other keys are unknown.
Vite build and development source maps point document code back to its lines in the
.svxfile.mdsvex now ships declarations for compile, CompileOptions, mdsvex and other exports; @mdsvex/render types also check under TypeScript 6.
Fixes and other changes 19
The script started by bare imports uses lang="ts" when the import is a type import or the module script uses lang="ts".
Text appended inside a code fence created by a parse plugin now becomes its code in HTML, highlighting, pre replacements, and rendered blocks.
Fence titles, playground status and height are preserved whether or not code is highlighted; an unreplaced fence renders as plain pre/code without a figure.
Code spans and HTML comments created by parse plugins now render the text those plugins put in them.
After deferred tasks or async document hooks alter images or fences, settling rebuilds Parsed.needs, snippets and math from the settled tree so imports and file reads work.
Replacement exports are discovered when declared with multiple names or destructuring in one declaration.
Braces in code, fence info strings, and backslash-escaped Markdown text render as text instead of being interpreted by Svelte as expressions.
Opening and closing frontmatter fences now allow trailing spaces and tabs in compiled documents and ?metadata imports.
Windows and old Mac line endings compile to the same HTML as LF endings, and source maps point to the correct original lines and columns.
The first document that loads the math renderer is parsed only once, so parse plugins run once while the renderer loads.
Warnings from the first render of a document that loads the math renderer are no longer reported again on its second render.
Replacing or adding a plugin in an existing plugins array takes effect on the next compile.
Replaced pre components receive title, caption, and fence metadata props when highlighting is disabled or a highlighter returns null.
Documents imported with Vite's ?raw, ?url, ?worker or ?sharedworker queries are left to Vite instead of being compiled as Markdown.
Spread and attachment attributes in typed HTML are no longer rendered as invalid attribute assignments that Svelte cannot compile.
Style blocks in documents now work; the Vite plugin no longer compiles the style request as Markdown.
A top-level script with a src attribute renders as svelte:element, preventing embedded scripts from being treated as the component script.
TreeBuilder.reset() now works with plugins and resets its dispatcher.
Content is preserved as text through the closing tag, including indentation and line breaks; Markdown markers remain literal, while Svelte expressions and elements still work.
mdsvex 0.121 changes
New APIs and options 1
Adds an option to generate Svelte 5 runes-compatible layout prop forwarding.