playable
Version:
Video player based on HTML5Video
28 lines • 964 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function syntaxHighlight(json, styleNames) {
json = json
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)/g, function (match) {
var cls = styleNames.number;
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = styleNames.key;
}
else {
cls = styleNames.string;
}
}
else if (/true|false/.test(match)) {
cls = styleNames.boolean;
}
else if (/null/.test(match)) {
cls = styleNames.null;
}
return "<span class=\"".concat(cls, "\">").concat(match, "</span>");
});
}
exports.default = syntaxHighlight;
//# sourceMappingURL=syntaxHighlight.js.map