Skip to content

Commit 241d178

Browse files
committed
chore: update html checks
1 parent c1f5eb3 commit 241d178

File tree

3 files changed

+54
-73
lines changed

3 files changed

+54
-73
lines changed

scripts/apidoc/markdown.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ const htmlSanitizeOptions: sanitizeHtml.IOptions = {
3939

4040
function comparableSanitizedHtml(html: string): string {
4141
return html
42+
.replace(/&#x[0-9A-F]{2};/g, (x) =>
43+
String.fromCodePoint(Number.parseInt(x.slice(3, -1), 16))
44+
)
4245
.replace(/>/g, '>')
43-
.replace(/ /g, '')
46+
.replace(/&lt;/g, '<')
47+
.replace(/&amp;/g, '&')
4448
.replace(/&quot;/g, '"')
45-
.replace(/&#39;/g, "'");
49+
.replace(/=""/g, '')
50+
.replace(/ /g, '');
4651
}
4752

4853
/**

test/scripts/apidoc/__snapshots__/module.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ exports[`module > analyzeModule() > ModuleExampleTest 1`] = `
1212
{
1313
"comment": "This is a description for a module with a code example.",
1414
"deprecated": undefined,
15-
"examples": "<div class=\\"language-ts vp-adaptive-theme\\"><button title=\\"Copy Code\\" class=\\"copy\\"></button><span class=\\"lang\\">ts</span><pre v-pre class=\\"shiki github-dark vp-code-dark\\"><code><span class=\\"line\\"><span style=\\"color:#F97583\\">new</span><span style=\\"color:#E1E4E8\\"> </span><span style=\\"color:#B392F0\\">ModuleExampleTest</span><span style=\\"color:#E1E4E8\\">()</span></span></code></pre><pre v-pre class=\\"shiki github-light vp-code-light\\"><code><span class=\\"line\\"><span style=\\"color:#D73A49\\">new</span><span style=\\"color:#24292E\\"> </span><span style=\\"color:#6F42C1\\">ModuleExampleTest</span><span style=\\"color:#24292E\\">()</span></span></code></pre>
15+
"examples": "<div class=\\"language-ts vp-adaptive-theme\\"><button title=\\"Copy Code\\" class=\\"copy\\"></button><span class=\\"lang\\">ts</span><pre class=\\"shiki shiki-themes github-light github-dark vp-code\\" v-pre><code><span class=\\"line\\"><span style=\\"--shiki-light:#D73A49;--shiki-dark:#F97583\\">new</span><span style=\\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\\"> ModuleExampleTest</span><span style=\\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\\">()</span></span></code></pre>
1616
</div>",
1717
}
1818
`;

0 commit comments

Comments
 (0)