Update json styles

This commit is contained in:
Daniele Tonon
2023-09-14 08:53:19 +02:00
parent 769e06554b
commit 7940dddc3e
4 changed files with 18 additions and 5 deletions

View File

@@ -85,13 +85,17 @@ function syntaxHighlight(json) {
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
return json.replace(
/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,
function (match) {
function (match, p1) {
var cls = 'number'
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key'
} else {
cls = 'string'
if (p1.length < 100) {
cls = 'string'
} else {
cls = 'string content'
}
}
} else if (/true|false/.test(match)) {
cls = 'boolean'