fix: support interpolation in MDSVEX link and image destinations #45

Merged
corneliusio merged 2 commits from fix/mdsvex-link-destination-interpolation into master 2026-08-15 05:09:41 +00:00
corneliusio commented 2026-08-15 05:04:58 +00:00 (Migrated from github.com)

Svelte interpolations in markdown link/image destinations — [text](/path/{slug}) — were left under plain markdown URL scopes (found during the adversarial review of #41; {label} in the description worked, {slug} in the URL did not).

Fix: one override of Markdown's link-url-common context, which is included by every destination form (unquoted and angle-bracketed, links and images) and is identical across default packages v4143 through master.

Leak guard: the interpolation rule only fires when the brace provably closes before the destination can end (whitespace, ), >). Without this, a literal unmatched { — valid in a CommonMark destination — would start an interpolation that never closes and corrupt highlighting for the rest of the document. Trade-off: interpolations containing spaces or )/> (e.g. {fn(a, b)}) fall back to plain URL highlighting rather than risking a leak.

Inside the interpolation, markup.underline.link is cleared by the Svelte package's existing clear_scopes design, matching interpolation behavior in HTML attribute strings.

Regression tests cover the happy path and unmatched braces in both destination forms, with following-line sentinels. Validated locally against ST 4143 and 4207.

Svelte interpolations in markdown link/image destinations — `[text](/path/{slug})` — were left under plain markdown URL scopes (found during the adversarial review of #41; `{label}` in the description worked, `{slug}` in the URL did not). **Fix:** one override of Markdown's `link-url-common` context, which is included by every destination form (unquoted and angle-bracketed, links and images) and is identical across default packages v4143 through master. **Leak guard:** the interpolation rule only fires when the brace provably closes before the destination can end (whitespace, `)`, `>`). Without this, a literal unmatched `{` — valid in a CommonMark destination — would start an interpolation that never closes and corrupt highlighting for the rest of the document. Trade-off: interpolations containing spaces or `)`/`>` (e.g. `{fn(a, b)}`) fall back to plain URL highlighting rather than risking a leak. Inside the interpolation, `markup.underline.link` is cleared by the Svelte package's existing `clear_scopes` design, matching interpolation behavior in HTML attribute strings. Regression tests cover the happy path and unmatched braces in both destination forms, with following-line sentinels. Validated locally against ST 4143 and 4207.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
repos/svelte-sublime!45
No description provided.