MCPcopy Create free account
hub / github.com/F12FLASH/CTF / highlightSyntax

Function highlightSyntax

7.GraphQL Apocalypse/client/src/components/code-editor.tsx:34–43  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

32 };
33
34 const highlightSyntax = (code: string) => {
35 const escaped = escapeHtml(code);
36 return escaped
37 .replace(/\b(query|mutation|subscription|fragment|type|input|interface|enum|scalar|union|schema|extend|implements)\b/g, '<span class="text-primary">$1</span>')
38 .replace(/\b(String|Int|Float|Boolean|ID|true|false|null)\b/g, '<span class="text-secondary">$1</span>')
39 .replace(/&quot;([^&quot;]*)&quot;/g, '<span class="text-chart-1">&quot;$1&quot;</span>')
40 .replace(/#.*/g, '<span class="text-muted-foreground">$&</span>')
41 .replace(/\{|\}/g, '<span class="text-accent-foreground">$&</span>')
42 .replace(/\(|\)/g, '<span class="text-chart-2">$&</span>');
43 };
44
45 return (
46 <div className={`relative ${className}`}>

Callers 1

CodeEditorFunction · 0.85

Calls 1

escapeHtmlFunction · 0.85

Tested by

no test coverage detected