Skip to content

Commit

Permalink
chore: update html checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Jan 1, 2024
1 parent 67b42a6 commit 617f3a5
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 73 deletions.
9 changes: 7 additions & 2 deletions scripts/apidoc/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ const htmlSanitizeOptions: sanitizeHtml.IOptions = {

function comparableSanitizedHtml(html: string): string {
return html
.replace(/&#x[0-9A-F]{2};/g, (x) =>
String.fromCodePoint(Number.parseInt(x.slice(3, -1), 16))
)
.replace(/>/g, '>')
.replace(/ /g, '')
.replace(/&lt;/g, '<')
.replace(/&amp;/g, '&')
.replace(/&quot;/g, '"')
.replace(/&#39;/g, "'");
.replace(/=""/g, '')
.replace(/ /g, '');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/apidoc/__snapshots__/module.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`module > analyzeModule() > ModuleExampleTest 1`] = `
{
"comment": "This is a description for a module with a code example.",
"deprecated": undefined,
"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>
"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>
</div>",
}
`;
Expand Down
Loading

0 comments on commit 617f3a5

Please sign in to comment.