diff --git a/.prettierignore b/.prettierignore index a7d2383ec6..15a0a5aa82 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,4 +5,5 @@ dist pnpm-lock.yaml .vercel _generated.md -land-110m.json \ No newline at end of file +land-110m.json +/apps/svelte.dev/content/docs diff --git a/packages/site-kit/src/lib/markdown/renderer.ts b/packages/site-kit/src/lib/markdown/renderer.ts index 0072d3801c..cb3984d5ab 100644 --- a/packages/site-kit/src/lib/markdown/renderer.ts +++ b/packages/site-kit/src/lib/markdown/renderer.ts @@ -283,6 +283,24 @@ export async function render_content_markdown( // Save everything locally now snippets.save(token.text, html); } + + // ensure that `foo`/`bar` is transformed to `foo` / `bar` + // https://github.com/sveltejs/svelte.dev/pull/577 + const slash_index = + // @ts-expect-error + token.tokens?.findIndex((token) => token.type === 'text' && token.text === '/') ?? -1; + + if (slash_index !== -1) { + // @ts-expect-error + const before = token.tokens[slash_index - 1]; + // @ts-expect-error + const after = token.tokens[slash_index + 1]; + + if (before?.type === 'codespan' && after?.type === 'codespan') { + // @ts-expect-error + token.tokens[slash_index].raw = token.tokens[slash_index].text = ' / '; + } + } }, text(token) { // @ts-expect-error I think this is a bug in marked — some text tokens have children,