diff --git a/js/deps/highlight.js b/js/deps/highlight.js index c7ccd48a77..f6bda3ed52 100644 --- a/js/deps/highlight.js +++ b/js/deps/highlight.js @@ -1127,6 +1127,43 @@ hljs.registerLanguage('javascript', function(hljs) { }; }); +hljs.registerLanguage('json', function(hljs) { + var LITERALS = {literal: 'true false null'}; + var TYPES = [ + hljs.QUOTE_STRING_MODE, + hljs.C_NUMBER_MODE + ]; + var VALUE_CONTAINER = { + end: ',', endsWithParent: true, excludeEnd: true, + contains: TYPES, + keywords: LITERALS + }; + var OBJECT = { + begin: '{', end: '}', + contains: [ + { + className: 'attr', + begin: /"/, end: /"/, + contains: [hljs.BACKSLASH_ESCAPE], + illegal: '\\n', + }, + hljs.inherit(VALUE_CONTAINER, {begin: /:/}) + ], + illegal: '\\S' + }; + var ARRAY = { + begin: '\\[', end: '\\]', + contains: [hljs.inherit(VALUE_CONTAINER)], // inherit is a workaround for a bug that makes shared modes with endsWithParent compile only the ending of one of the parents + illegal: '\\S' + }; + TYPES.splice(TYPES.length, 0, OBJECT, ARRAY); + return { + contains: TYPES, + keywords: LITERALS, + illegal: '\\S' + }; +}); + hljs.registerLanguage('xml', function(hljs) { var XML_IDENT_RE = '[A-Za-z0-9\\._:-]+'; var TAG_INTERNALS = { diff --git a/package.json b/package.json index ad35399f6b..4530a46da6 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ }, "scripts": { "build": "npm run copydeps && npm run hb:build && npm run build:highlight && npm run build:respec-w3c-common", - "build:highlight": "cd node_modules/highlight.js/ && npm install && node ./tools/build.js -n xml javascript css http markdown xquery && cd ../../", + "build:highlight": "cd node_modules/highlight.js/ && npm install && node ./tools/build.js -n xml javascript css http markdown xquery json && cd ../../", "build:respec-w3c-common": "./tools/build-w3c-common.js", "jscs": "jscs --esnext tests tools js/core/markdown.js js/core/utils.js js/w3c/linter.js", "jscs:fix": "jscs --esnext --fix tests",