Skip to content

Commit d78cb7f

Browse files
committed
Remove JSON syntax highlighter
1 parent 93cc5c7 commit d78cb7f

File tree

1 file changed

+0
-45
lines changed

1 file changed

+0
-45
lines changed

assets/js/scripts.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -230,51 +230,6 @@ document.addEventListener('DOMContentLoaded', function () {
230230
}
231231
});
232232

233-
/**
234-
* JSON syntax highlighter
235-
*/
236-
const json_syntax_highlight = (json) => {
237-
if (typeof json !== 'string') {
238-
json = JSON.stringify(json, null, 2);
239-
}
240-
241-
json = json.replace(/&/g, '&')
242-
.replace(/</g, '&lt;')
243-
.replace(/>/g, '&gt;');
244-
245-
return json.replace(
246-
/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?|[{}\[\],:])/g,
247-
match => {
248-
let cls = '';
249-
if (/^"/.test(match)) {
250-
if (/:$/.test(match)) {
251-
cls = 'json-key';
252-
} else {
253-
cls = 'json-string';
254-
}
255-
} else if (/true|false/.test(match)) {
256-
cls = 'json-boolean';
257-
} else if (/null/.test(match)) {
258-
cls = 'json-null';
259-
} else if (/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(match)) {
260-
cls = 'json-number';
261-
} else if (/[\[\]{}]/.test(match)) {
262-
cls = 'json-bracket';
263-
} else if (match === ',') {
264-
cls = 'json-comma';
265-
} else if (match === ':') {
266-
cls = 'json-colon';
267-
}
268-
269-
return cls ? `<span class="${cls}">${match}</span>` : match;
270-
}
271-
);
272-
};
273-
274-
document.querySelectorAll('.json-code').forEach(value => {
275-
value.innerHTML = json_syntax_highlight(value.textContent);
276-
});
277-
278233
/**
279234
* Redirects
280235
*/

0 commit comments

Comments
 (0)