MCPcopy Create free account
hub / github.com/webdriverio/webdriverio / sanitizeHtmlForMdx

Function sanitizeHtmlForMdx

scripts/docs-generation/docsUtils.ts:17–32  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

15 * Normalize void HTML tags for MDX compilation (e.g. `<img>` → `<img />`).
16 */
17export function sanitizeHtmlForMdx (content: string): string {
18 let result = content
19
20 for (const tag of VOID_HTML_ELEMENTS) {
21 result = result.replace(new RegExp(`</${tag}\\s*>`, 'gi'), '')
22 }
23
24 for (const tag of VOID_HTML_ELEMENTS) {
25 result = result.replace(
26 new RegExp(`<${tag}(\\s[^>]*?)?(?<!/)>`, 'gi'),
27 (_match, attrs: string | undefined) => `<${tag}${attrs ?? ''} />`
28 )
29 }
30
31 return result
32}
33
34/**
35 * Build a regex/replace function that turns the monorepo's relative markdown

Callers 1

normalizeDocFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…