From f9509f8987cab39b232fad148ec4b04147932de1 Mon Sep 17 00:00:00 2001
From: Daniel Roe
+ HTML block code:
`
})
+ .replace(/`([^`\n]*)`/g, (_1, raw) => {
+ return raw ? `${code}
${htmlToText(raw).replace(//g, '>')}
` : ''
+ })
}
// Always sanitize the raw HTML data *after* it has been modified
diff --git a/tests/__snapshots__/content-rich.test.ts.snap b/tests/__snapshots__/content-rich.test.ts.snap
index 176f7587..1dde47cf 100644
--- a/tests/__snapshots__/content-rich.test.ts.snap
+++ b/tests/__snapshots__/content-rich.test.ts.snap
@@ -40,6 +40,27 @@ exports[`content-rich > custom emoji 1`] = `
exports[`content-rich > empty 1`] = `""`;
+exports[`content-rich > handles html within code blocks 1`] = `
+"
+
+<span class="icon--noto icon--noto--1st-place-medal"></span>
+<span class="icon--noto icon--noto--2nd-place-medal-medal"></span>
+
+ Inline code with link:
+ https://api.iconify.design/noto.css?icons=1st-place-medal,2nd-place-medal
+
Happy diff --git a/tests/content-rich.test.ts b/tests/content-rich.test.ts index 1f7b17f1..700fe4ff 100644 --- a/tests/content-rich.test.ts +++ b/tests/content-rich.test.ts @@ -20,6 +20,16 @@ describe('content-rich', () => { expect(formatted).toMatchSnapshot() }) + it('inline code with link', async () => { + const { formatted } = await render('
Inline code with link: `https://api.iconify.design/noto.css?icons=1st-place-medal,2nd-place-medal`
') + expect(formatted).toMatchSnapshot() + }) + + it('handles html within code blocks', async () => { + const { formatted } = await render('HTML block code:
```html
<span class="icon--noto icon--noto--1st-place-medal"></span>
<span class="icon--noto icon--noto--2nd-place-medal-medal"></span>
```