MCPcopy Create free account
hub / github.com/bywwcnll/StreamPanel / syntaxHighlight

Function syntaxHighlight

devtools/modules/utils.js:62–83  ·  view source on GitHub ↗
(json)

Source from the content-addressed store, hash-verified

60}
61
62export function syntaxHighlight(json) {
63 return json.replace(
64 /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,
65 function(match) {
66 let cls = 'json-number';
67 if (/^"/.test(match)) {
68 if (/:$/.test(match)) {
69 cls = 'json-key';
70 match = match.slice(0, -1);
71 return '<span class="' + cls + '">' + escapeHtml(match) + '</span>:';
72 } else {
73 cls = 'json-string';
74 }
75 } else if (/true|false/.test(match)) {
76 cls = 'json-boolean';
77 } else if (/null/.test(match)) {
78 cls = 'json-null';
79 }
80 return '<span class="' + cls + '">' + escapeHtml(match) + '</span>';
81 }
82 );
83}
84
85export function getUrlPath(url) {
86 try {

Callers

nothing calls this directly

Calls 1

escapeHtmlFunction · 0.70

Tested by

no test coverage detected