fix: markdown render issues (#832)

This commit is contained in:
Jason Rasmussen
2026-09-25 17:16:25 -04:00
committed by GitHub
parent dce188a00e
commit f4ecb65652
3 changed files with 8 additions and 2 deletions
@@ -139,6 +139,12 @@ describe(svelteMarkdownPreprocess.name, () => {
it('should leave a component inside a code fence as code', async () => { it('should leave a component inside a code fence as code', async () => {
await expect(render('```svelte\n<Markdown.Image src="a.webp" />\n```')).resolves.toContain('<Markdown.Code'); await expect(render('```svelte\n<Markdown.Image src="a.webp" />\n```')).resolves.toContain('<Markdown.Code');
}); });
it('should escape template syntax inside inline code', async () => {
await expect(render('Use `${PORT}:{PORT}`')).resolves.toContain(
'<Markdown.Code code={`' + String.raw`$\{PORT\}:\{PORT\}` + '`} />',
);
});
}); });
describe('images', () => { describe('images', () => {
@@ -227,7 +227,7 @@ export const markedSvelte = (): MarkedExtension => ({
}, },
codespan({ text }) { codespan({ text }) {
return `<Markdown.Code code={\`${text}\`} />`; return `<Markdown.Code code={\`${escapeSvelteCode(text)}\`} />`;
}, },
}, },
}); });
@@ -38,4 +38,4 @@
let { size, tag, class: className } = $derived(getSizeAndTag(level)); let { size, tag, class: className } = $derived(getSizeAndTag(level));
</script> </script>
<Heading {size} {tag} class={cleanClass('flex items-center gap-1', className)} {id} {children} /> <Heading {size} {tag} class={cleanClass('flex items-center flex-wrap gap-1 ', className)} {id} {children} />