MCPcopy Create free account
hub / github.com/enowdev/enowX-Coder / stripBgFromCode

Function stripBgFromCode

src/components/chat/HtmlPreview.tsx:16–25  ·  view source on GitHub ↗

Strip hardcoded dark backgrounds from AI-generated HTML so it blends with host

(code: string)

Source from the content-addressed store, hash-verified

14
15/** Strip hardcoded dark backgrounds from AI-generated HTML so it blends with host */
16function stripBgFromCode(code: string): string {
17 return code
18 .replace(/background\s*:\s*#1a1a1a\s*;?/gi, 'background:transparent;')
19 .replace(/background\s*:\s*#111111\s*;?/gi, 'background:transparent;')
20 .replace(/background\s*:\s*#0a0a0a\s*;?/gi, 'background:transparent;')
21 .replace(/background\s*:\s*#000000?\s*;?/gi, 'background:transparent;')
22 .replace(/background-color\s*:\s*#1a1a1a\s*;?/gi, 'background-color:transparent;')
23 .replace(/background-color\s*:\s*#111\s*;?/gi, 'background-color:transparent;')
24 .replace(/background\s*:\s*linear-gradient\([^)]*#1[a0][^)]*\)\s*;?/gi, 'background:transparent;');
25}
26
27function buildSrcdoc(code: string, colorScheme: 'light' | 'dark'): string {
28 const cleaned = stripBgFromCode(code);

Callers 1

buildSrcdocFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected