diff --git a/.changeset/odd-waves-glow.md b/.changeset/odd-waves-glow.md new file mode 100644 index 0000000..40d60d0 --- /dev/null +++ b/.changeset/odd-waves-glow.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/site-kit': patch +--- + +fix: url tokenizer to not treat package version string as email diff --git a/packages/site-kit/src/lib/markdown/utils.js b/packages/site-kit/src/lib/markdown/utils.js index 2082ea6..1900c1a 100644 --- a/packages/site-kit/src/lib/markdown/utils.js +++ b/packages/site-kit/src/lib/markdown/utils.js @@ -208,6 +208,19 @@ const default_renderer = { } }; +/** @type {import('marked').TokenizerObject} */ +const tokenizer = { + url(src) { + // if `src` is a package version string, eg: adapter-auto@1.2.3 + // do not tokenize it as email + if (/@\d+\.\d+\.\d+/.test(src)) { + return undefined; + } + // else, use the default tokenizer behavior + return false; + } +}; + /** * @param {string} markdown * @param {Partial} renderer @@ -217,7 +230,8 @@ export async function transform(markdown, renderer = {}) { renderer: { ...default_renderer, ...renderer - } + }, + tokenizer }); return (await marked.parse(markdown)) ?? '';