Skip to content
Merged
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ dist
pnpm-lock.yaml
.vercel
_generated.md
land-110m.json
land-110m.json
/apps/svelte.dev/content/docs
18 changes: 18 additions & 0 deletions packages/site-kit/src/lib/markdown/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading