diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-24 15:10:37 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-24 15:11:17 +0200 |
commit | 7a3df06eb573d36142bd1a8e03c5ce8752d300b3 (patch) | |
tree | 70bfaea8884c374876f607774850a3a51c0cb381 /node_modules/highlight.js/lib/languages/javascript.js | |
parent | aca1143cb9eed16cf37f04e475e4257418dd18ac (diff) |
fix build issues and add typedoc
Diffstat (limited to 'node_modules/highlight.js/lib/languages/javascript.js')
-rw-r--r-- | node_modules/highlight.js/lib/languages/javascript.js | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/node_modules/highlight.js/lib/languages/javascript.js b/node_modules/highlight.js/lib/languages/javascript.js new file mode 100644 index 000000000..6bb59f042 --- /dev/null +++ b/node_modules/highlight.js/lib/languages/javascript.js @@ -0,0 +1,170 @@ +module.exports = function(hljs) { + var IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; + var KEYWORDS = { + keyword: + 'in of if for while finally var new function do return void else break catch ' + + 'instanceof with throw case default try this switch continue typeof delete ' + + 'let yield const export super debugger as async await static ' + + // ECMAScript 6 modules import + 'import from as' + , + literal: + 'true false null undefined NaN Infinity', + built_in: + 'eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent ' + + 'encodeURI encodeURIComponent escape unescape Object Function Boolean Error ' + + 'EvalError InternalError RangeError ReferenceError StopIteration SyntaxError ' + + 'TypeError URIError Number Math Date String RegExp Array Float32Array ' + + 'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array ' + + 'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require ' + + 'module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect ' + + 'Promise' + }; + var EXPRESSIONS; + var NUMBER = { + className: 'number', + variants: [ + { begin: '\\b(0[bB][01]+)' }, + { begin: '\\b(0[oO][0-7]+)' }, + { begin: hljs.C_NUMBER_RE } + ], + relevance: 0 + }; + var SUBST = { + className: 'subst', + begin: '\\$\\{', end: '\\}', + keywords: KEYWORDS, + contains: [] // defined later + }; + var TEMPLATE_STRING = { + className: 'string', + begin: '`', end: '`', + contains: [ + hljs.BACKSLASH_ESCAPE, + SUBST + ] + }; + SUBST.contains = [ + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE, + TEMPLATE_STRING, + NUMBER, + hljs.REGEXP_MODE + ] + var PARAMS_CONTAINS = SUBST.contains.concat([ + hljs.C_BLOCK_COMMENT_MODE, + hljs.C_LINE_COMMENT_MODE + ]); + + return { + aliases: ['js', 'jsx'], + keywords: KEYWORDS, + contains: [ + { + className: 'meta', + relevance: 10, + begin: /^\s*['"]use (strict|asm)['"]/ + }, + { + className: 'meta', + begin: /^#!/, end: /$/ + }, + hljs.APOS_STRING_MODE, + hljs.QUOTE_STRING_MODE, + TEMPLATE_STRING, + hljs.C_LINE_COMMENT_MODE, + hljs.C_BLOCK_COMMENT_MODE, + NUMBER, + { // object attr container + begin: /[{,]\s*/, relevance: 0, + contains: [ + { + begin: IDENT_RE + '\\s*:', returnBegin: true, + relevance: 0, + contains: [{className: 'attr', begin: IDENT_RE, relevance: 0}] + } + ] + }, + { // "value" container + begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*', + keywords: 'return throw case', + contains: [ + hljs.C_LINE_COMMENT_MODE, + hljs.C_BLOCK_COMMENT_MODE, + hljs.REGEXP_MODE, + { + className: 'function', + begin: '(\\(.*?\\)|' + IDENT_RE + ')\\s*=>', returnBegin: true, + end: '\\s*=>', + contains: [ + { + className: 'params', + variants: [ + { + begin: IDENT_RE + }, + { + begin: /\(\s*\)/, + }, + { + begin: /\(/, end: /\)/, + excludeBegin: true, excludeEnd: true, + keywords: KEYWORDS, + contains: PARAMS_CONTAINS + } + ] + } + ] + }, + { // E4X / JSX + begin: /</, end: /(\/\w+|\w+\/)>/, + subLanguage: 'xml', + contains: [ + {begin: /<\w+\s*\/>/, skip: true}, + { + begin: /<\w+/, end: /(\/\w+|\w+\/)>/, skip: true, + contains: [ + {begin: /<\w+\s*\/>/, skip: true}, + 'self' + ] + } + ] + } + ], + relevance: 0 + }, + { + className: 'function', + beginKeywords: 'function', end: /\{/, excludeEnd: true, + contains: [ + hljs.inherit(hljs.TITLE_MODE, {begin: IDENT_RE}), + { + className: 'params', + begin: /\(/, end: /\)/, + excludeBegin: true, + excludeEnd: true, + contains: PARAMS_CONTAINS + } + ], + illegal: /\[|%/ + }, + { + begin: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something` + }, + hljs.METHOD_GUARD, + { // ES6 class + className: 'class', + beginKeywords: 'class', end: /[{;=]/, excludeEnd: true, + illegal: /[:"\[\]]/, + contains: [ + {beginKeywords: 'extends'}, + hljs.UNDERSCORE_TITLE_MODE + ] + }, + { + beginKeywords: 'constructor', end: /\{/, excludeEnd: true + } + ], + illegal: /#(?!!)/ + }; +};
\ No newline at end of file |