1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | var hljs = {};
|
11 |
|
12 | var objectKeys = Object.keys;
|
13 |
|
14 | var languages = {}, aliases = {};
|
15 | var spanEndTag = '</span>';
|
16 |
|
17 |
|
18 | var options = {
|
19 | classPrefix: 'hljs-',
|
20 | tabReplace: null,
|
21 | useBR: false,
|
22 | languages: undefined
|
23 | };
|
24 |
|
25 | var escapeRegexMap = {
|
26 | '&': '&',
|
27 | '<': '<',
|
28 | '>': '>'
|
29 | };
|
30 |
|
31 | function escape(value) {
|
32 | return value.replace(/[&<>]/gm, function (character) {
|
33 | return escapeRegexMap[character];
|
34 | });
|
35 | }
|
36 | function testRe(re, lexeme) {
|
37 | var match = re && re.exec(lexeme);
|
38 | return match && match.index === 0;
|
39 | }
|
40 | function inherit(parent, obj) {
|
41 | var key;
|
42 | var result = {};
|
43 | for (key in parent)
|
44 | result[key] = parent[key];
|
45 | if (obj)
|
46 | for (key in obj)
|
47 | result[key] = obj[key];
|
48 | return result;
|
49 | }
|
50 |
|
51 | function compileLanguage(language) {
|
52 | function reStr(re) {
|
53 | return (re && re.source) || re;
|
54 | }
|
55 | function langRe(value, global) {
|
56 | return new RegExp(reStr(value), 'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : ''));
|
57 | }
|
58 | function compileMode(mode, parent) {
|
59 | if (mode.compiled)
|
60 | return;
|
61 | mode.compiled = true;
|
62 | mode.keywords = mode.keywords || mode.beginKeywords;
|
63 | if (mode.keywords) {
|
64 | var compiled_keywords = {};
|
65 | var flatten = function (className, str) {
|
66 | if (language.case_insensitive) {
|
67 | str = str.toLowerCase();
|
68 | }
|
69 | str.split(' ').forEach(function (kw) {
|
70 | var pair = kw.split('|');
|
71 | compiled_keywords[pair[0]] = [className, pair[1] ? Number(pair[1]) : 1];
|
72 | });
|
73 | };
|
74 | if (typeof mode.keywords === 'string') {
|
75 | flatten('keyword', mode.keywords);
|
76 | }
|
77 | else {
|
78 | objectKeys(mode.keywords).forEach(function (className) {
|
79 | flatten(className, mode.keywords[className]);
|
80 | });
|
81 | }
|
82 | mode.keywords = compiled_keywords;
|
83 | }
|
84 | mode.lexemesRe = langRe(mode.lexemes || /\w+/, true);
|
85 | if (parent) {
|
86 | if (mode.beginKeywords) {
|
87 | mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')\\b';
|
88 | }
|
89 | if (!mode.begin)
|
90 | mode.begin = /\B|\b/;
|
91 | mode.beginRe = langRe(mode.begin);
|
92 | if (!mode.end && !mode.endsWithParent)
|
93 | mode.end = /\B|\b/;
|
94 | if (mode.end)
|
95 | mode.endRe = langRe(mode.end);
|
96 | mode.terminator_end = reStr(mode.end) || '';
|
97 | if (mode.endsWithParent && parent.terminator_end)
|
98 | mode.terminator_end += (mode.end ? '|' : '') + parent.terminator_end;
|
99 | }
|
100 | if (mode.illegal)
|
101 | mode.illegalRe = langRe(mode.illegal);
|
102 | if (mode.relevance == null)
|
103 | mode.relevance = 1;
|
104 | if (!mode.contains) {
|
105 | mode.contains = [];
|
106 | }
|
107 | var expanded_contains = [];
|
108 | mode.contains.forEach(function (c) {
|
109 | if (c.variants) {
|
110 | c.variants.forEach(function (v) { expanded_contains.push(inherit(c, v)); });
|
111 | }
|
112 | else {
|
113 | expanded_contains.push(c === 'self' ? mode : c);
|
114 | }
|
115 | });
|
116 | mode.contains = expanded_contains;
|
117 | mode.contains.forEach(function (c) { compileMode(c, mode); });
|
118 | if (mode.starts) {
|
119 | compileMode(mode.starts, parent);
|
120 | }
|
121 | var terminators = mode.contains.map(function (c) {
|
122 | return c.beginKeywords ? '\\.?(' + c.begin + ')\\.?' : c.begin;
|
123 | })
|
124 | .concat([mode.terminator_end, mode.illegal])
|
125 | .map(reStr)
|
126 | .filter(Boolean);
|
127 | mode.terminators = terminators.length ? langRe(terminators.join('|'), true) : { exec: function () { return null; } };
|
128 | }
|
129 | compileMode(language);
|
130 | }
|
131 | function highlightError(htmlInput, errorCharStart, errorLength) {
|
132 | if (errorCharStart < 0 || errorLength < 1 || !htmlInput)
|
133 | return htmlInput;
|
134 | var chars = htmlInput.split('');
|
135 | var inTag = false;
|
136 | var textIndex = -1;
|
137 | for (var htmlIndex = 0; htmlIndex < chars.length; htmlIndex++) {
|
138 | if (chars[htmlIndex] === '<') {
|
139 | inTag = true;
|
140 | continue;
|
141 | }
|
142 | else if (chars[htmlIndex] === '>') {
|
143 | inTag = false;
|
144 | continue;
|
145 | }
|
146 | else if (inTag) {
|
147 | continue;
|
148 | }
|
149 | else if (chars[htmlIndex] === '&') {
|
150 | var isValidEscape = true;
|
151 | var escapeChars = '&';
|
152 | for (var i = htmlIndex + 1; i < chars.length; i++) {
|
153 | if (!chars[i] || chars[i] === ' ') {
|
154 | isValidEscape = false;
|
155 | break;
|
156 | }
|
157 | else if (chars[i] === ';') {
|
158 | escapeChars += ';';
|
159 | break;
|
160 | }
|
161 | else {
|
162 | escapeChars += chars[i];
|
163 | }
|
164 | }
|
165 | isValidEscape = (isValidEscape && escapeChars.length > 1 && escapeChars.length < 9 && escapeChars[escapeChars.length - 1] === ';');
|
166 | if (isValidEscape) {
|
167 | chars[htmlIndex] = escapeChars;
|
168 | for (var i_1 = 0; i_1 < escapeChars.length - 1; i_1++) {
|
169 | chars.splice(htmlIndex + 1, 1);
|
170 | }
|
171 | }
|
172 | }
|
173 | textIndex++;
|
174 | if (textIndex < errorCharStart || textIndex >= errorCharStart + errorLength) {
|
175 | continue;
|
176 | }
|
177 | chars[htmlIndex] = "<span class=\"ion-diagnostics-error-chr\">" + chars[htmlIndex] + "</span>";
|
178 | }
|
179 | return chars.join('');
|
180 | }
|
181 | exports.highlightError = highlightError;
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 | function highlight(name, value, ignore_illegals, continuation) {
|
192 | function subMode(lexeme, mode) {
|
193 | var i, length;
|
194 | for (i = 0, length = mode.contains.length; i < length; i++) {
|
195 | if (testRe(mode.contains[i].beginRe, lexeme)) {
|
196 | return mode.contains[i];
|
197 | }
|
198 | }
|
199 | }
|
200 | function endOfMode(mode, lexeme) {
|
201 | if (testRe(mode.endRe, lexeme)) {
|
202 | while (mode.endsParent && mode.parent) {
|
203 | mode = mode.parent;
|
204 | }
|
205 | return mode;
|
206 | }
|
207 | if (mode.endsWithParent) {
|
208 | return endOfMode(mode.parent, lexeme);
|
209 | }
|
210 | }
|
211 | function isIllegal(lexeme, mode) {
|
212 | return !ignore_illegals && testRe(mode.illegalRe, lexeme);
|
213 | }
|
214 | function keywordMatch(mode, match) {
|
215 | var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0];
|
216 | return mode.keywords.hasOwnProperty(match_str) && mode.keywords[match_str];
|
217 | }
|
218 | function buildSpan(classname, insideSpan, leaveOpen, noPrefix) {
|
219 | var classPrefix = noPrefix ? '' : options.classPrefix, openSpan = '<span class="' + classPrefix, closeSpan = leaveOpen ? '' : spanEndTag;
|
220 | openSpan += classname + '">';
|
221 | return openSpan + insideSpan + closeSpan;
|
222 | }
|
223 | function processKeywords() {
|
224 | var keyword_match, last_index, match, result;
|
225 | if (!top.keywords)
|
226 | return escape(mode_buffer);
|
227 | result = '';
|
228 | last_index = 0;
|
229 | top.lexemesRe.lastIndex = 0;
|
230 | match = top.lexemesRe.exec(mode_buffer);
|
231 | while (match) {
|
232 | result += escape(mode_buffer.substr(last_index, match.index - last_index));
|
233 | keyword_match = keywordMatch(top, match);
|
234 | if (keyword_match) {
|
235 | relevance += keyword_match[1];
|
236 | result += buildSpan(keyword_match[0], escape(match[0]));
|
237 | }
|
238 | else {
|
239 | result += escape(match[0]);
|
240 | }
|
241 | last_index = top.lexemesRe.lastIndex;
|
242 | match = top.lexemesRe.exec(mode_buffer);
|
243 | }
|
244 | return result + escape(mode_buffer.substr(last_index));
|
245 | }
|
246 | function processSubLanguage() {
|
247 | var explicit = typeof top.subLanguage === 'string';
|
248 | if (explicit && !languages[top.subLanguage]) {
|
249 | return escape(mode_buffer);
|
250 | }
|
251 | var result = explicit ?
|
252 | highlight(top.subLanguage, mode_buffer, true, continuations[top.subLanguage]) :
|
253 | highlightAuto(mode_buffer, top.subLanguage.length ? top.subLanguage : undefined);
|
254 |
|
255 |
|
256 |
|
257 |
|
258 | if (top.relevance > 0) {
|
259 | relevance += result.relevance;
|
260 | }
|
261 | if (explicit) {
|
262 | continuations[top.subLanguage] = result.top;
|
263 | }
|
264 | return buildSpan(result.language, result.value, false, true);
|
265 | }
|
266 | function processBuffer() {
|
267 | result += (top.subLanguage != null ? processSubLanguage() : processKeywords());
|
268 | mode_buffer = '';
|
269 | }
|
270 | function startNewMode(mode, asdf) {
|
271 | result += mode.className ? buildSpan(mode.className, '', true) : '';
|
272 | top = Object.create(mode, { parent: { value: top } });
|
273 | }
|
274 | function processLexeme(buffer, lexeme) {
|
275 | mode_buffer += buffer;
|
276 | if (lexeme == null) {
|
277 | processBuffer();
|
278 | return 0;
|
279 | }
|
280 | var new_mode = subMode(lexeme, top);
|
281 | if (new_mode) {
|
282 | if (new_mode.skip) {
|
283 | mode_buffer += lexeme;
|
284 | }
|
285 | else {
|
286 | if (new_mode.excludeBegin) {
|
287 | mode_buffer += lexeme;
|
288 | }
|
289 | processBuffer();
|
290 | if (!new_mode.returnBegin && !new_mode.excludeBegin) {
|
291 | mode_buffer = lexeme;
|
292 | }
|
293 | }
|
294 | startNewMode(new_mode, lexeme);
|
295 | return new_mode.returnBegin ? 0 : lexeme.length;
|
296 | }
|
297 | var end_mode = endOfMode(top, lexeme);
|
298 | if (end_mode) {
|
299 | var origin = top;
|
300 | if (origin.skip) {
|
301 | mode_buffer += lexeme;
|
302 | }
|
303 | else {
|
304 | if (!(origin.returnEnd || origin.excludeEnd)) {
|
305 | mode_buffer += lexeme;
|
306 | }
|
307 | processBuffer();
|
308 | if (origin.excludeEnd) {
|
309 | mode_buffer = lexeme;
|
310 | }
|
311 | }
|
312 | do {
|
313 | if (top.className) {
|
314 | result += spanEndTag;
|
315 | }
|
316 | if (!top.skip) {
|
317 | relevance += top.relevance;
|
318 | }
|
319 | top = top.parent;
|
320 | } while (top !== end_mode.parent);
|
321 | if (end_mode.starts) {
|
322 | startNewMode(end_mode.starts, '');
|
323 | }
|
324 | return origin.returnEnd ? 0 : lexeme.length;
|
325 | }
|
326 | if (isIllegal(lexeme, top))
|
327 | throw new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || '<unnamed>') + '"');
|
328 | |
329 |
|
330 |
|
331 |
|
332 |
|
333 | mode_buffer += lexeme;
|
334 | return lexeme.length || 1;
|
335 | }
|
336 | var language = getLanguage(name);
|
337 | if (!language) {
|
338 | throw new Error('Unknown language: "' + name + '"');
|
339 | }
|
340 | compileLanguage(language);
|
341 | var top = continuation || language;
|
342 | var continuations = {};
|
343 | var result = '', current;
|
344 | for (current = top; current !== language; current = current.parent) {
|
345 | if (current.className) {
|
346 | result = buildSpan(current.className, '', true) + result;
|
347 | }
|
348 | }
|
349 | var mode_buffer = '';
|
350 | var relevance = 0;
|
351 | try {
|
352 | var match, count, index = 0;
|
353 | while (true) {
|
354 | top.terminators.lastIndex = index;
|
355 | match = top.terminators.exec(value);
|
356 | if (!match)
|
357 | break;
|
358 | count = processLexeme(value.substr(index, match.index - index), match[0]);
|
359 | index = match.index + count;
|
360 | }
|
361 | processLexeme(value.substr(index));
|
362 | for (current = top; current.parent; current = current.parent) {
|
363 | if (current.className) {
|
364 | result += spanEndTag;
|
365 | }
|
366 | }
|
367 | return {
|
368 | relevance: relevance,
|
369 | value: result,
|
370 | language: name,
|
371 | top: top
|
372 | };
|
373 | }
|
374 | catch (e) {
|
375 | if (e.message && e.message.indexOf('Illegal') !== -1) {
|
376 | return {
|
377 | relevance: 0,
|
378 | value: escape(value)
|
379 | };
|
380 | }
|
381 | else {
|
382 | throw e;
|
383 | }
|
384 | }
|
385 | }
|
386 | exports.highlight = highlight;
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 | function highlightAuto(text, languageSubset) {
|
399 | languageSubset = languageSubset || options.languages || objectKeys(languages);
|
400 | var result = {
|
401 | relevance: 0,
|
402 | value: escape(text)
|
403 | };
|
404 | var second_best = result;
|
405 | languageSubset.filter(getLanguage).forEach(function (name) {
|
406 | var current = highlight(name, text, false);
|
407 | current.language = name;
|
408 | if (current.relevance > second_best.relevance) {
|
409 | second_best = current;
|
410 | }
|
411 | if (current.relevance > result.relevance) {
|
412 | second_best = result;
|
413 | result = current;
|
414 | }
|
415 | });
|
416 | if (second_best.language) {
|
417 | result.second_best = second_best;
|
418 | }
|
419 | return result;
|
420 | }
|
421 |
|
422 |
|
423 |
|
424 | function configure(user_options) {
|
425 | options = inherit(options, user_options);
|
426 | }
|
427 | function registerLanguage(name, language) {
|
428 | var lang = languages[name] = language(hljs);
|
429 | if (lang.aliases) {
|
430 | lang.aliases.forEach(function (alias) { aliases[alias] = name; });
|
431 | }
|
432 | }
|
433 | function listLanguages() {
|
434 | return objectKeys(languages);
|
435 | }
|
436 | function getLanguage(name) {
|
437 | name = (name || '').toLowerCase();
|
438 | return languages[name] || languages[aliases[name]];
|
439 | }
|
440 |
|
441 | hljs.highlight = highlight;
|
442 | hljs.highlightAuto = highlightAuto;
|
443 | hljs.configure = configure;
|
444 | hljs.registerLanguage = registerLanguage;
|
445 | hljs.listLanguages = listLanguages;
|
446 | hljs.getLanguage = getLanguage;
|
447 | hljs.inherit = inherit;
|
448 |
|
449 | hljs.IDENT_RE = '[a-zA-Z]\\w*';
|
450 | hljs.UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*';
|
451 | hljs.NUMBER_RE = '\\b\\d+(\\.\\d+)?';
|
452 | hljs.C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)';
|
453 | hljs.BINARY_NUMBER_RE = '\\b(0b[01]+)';
|
454 | hljs.RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';
|
455 |
|
456 | hljs.BACKSLASH_ESCAPE = {
|
457 | begin: '\\\\[\\s\\S]', relevance: 0
|
458 | };
|
459 | hljs.APOS_STRING_MODE = {
|
460 | className: 'string',
|
461 | begin: '\'', end: '\'',
|
462 | illegal: '\\n',
|
463 | contains: [hljs.BACKSLASH_ESCAPE]
|
464 | };
|
465 | hljs.QUOTE_STRING_MODE = {
|
466 | className: 'string',
|
467 | begin: '"', end: '"',
|
468 | illegal: '\\n',
|
469 | contains: [hljs.BACKSLASH_ESCAPE]
|
470 | };
|
471 | hljs.PHRASAL_WORDS_MODE = {
|
472 | begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|like)\b/
|
473 | };
|
474 | hljs.COMMENT = function (begin, end, inherits) {
|
475 | var mode = hljs.inherit({
|
476 | className: 'comment',
|
477 | begin: begin, end: end,
|
478 | contains: []
|
479 | }, inherits || {});
|
480 | mode.contains.push(hljs.PHRASAL_WORDS_MODE);
|
481 | mode.contains.push({
|
482 | className: 'doctag',
|
483 | begin: '(?:TODO|FIXME|NOTE|BUG|XXX):',
|
484 | relevance: 0
|
485 | });
|
486 | return mode;
|
487 | };
|
488 | hljs.C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$');
|
489 | hljs.C_BLOCK_COMMENT_MODE = hljs.COMMENT('/\\*', '\\*/');
|
490 | hljs.HASH_COMMENT_MODE = hljs.COMMENT('#', '$');
|
491 | hljs.NUMBER_MODE = {
|
492 | className: 'number',
|
493 | begin: hljs.NUMBER_RE,
|
494 | relevance: 0
|
495 | };
|
496 | hljs.C_NUMBER_MODE = {
|
497 | className: 'number',
|
498 | begin: hljs.C_NUMBER_RE,
|
499 | relevance: 0
|
500 | };
|
501 | hljs.BINARY_NUMBER_MODE = {
|
502 | className: 'number',
|
503 | begin: hljs.BINARY_NUMBER_RE,
|
504 | relevance: 0
|
505 | };
|
506 | hljs.CSS_NUMBER_MODE = {
|
507 | className: 'number',
|
508 | begin: hljs.NUMBER_RE + '(' +
|
509 | '%|em|ex|ch|rem' +
|
510 | '|vw|vh|vmin|vmax' +
|
511 | '|cm|mm|in|pt|pc|px' +
|
512 | '|deg|grad|rad|turn' +
|
513 | '|s|ms' +
|
514 | '|Hz|kHz' +
|
515 | '|dpi|dpcm|dppx' +
|
516 | ')?',
|
517 | relevance: 0
|
518 | };
|
519 | hljs.REGEXP_MODE = {
|
520 | className: 'regexp',
|
521 | begin: /\//, end: /\/[gimuy]*/,
|
522 | illegal: /\n/,
|
523 | contains: [
|
524 | hljs.BACKSLASH_ESCAPE,
|
525 | {
|
526 | begin: /\[/, end: /\]/,
|
527 | relevance: 0,
|
528 | contains: [hljs.BACKSLASH_ESCAPE]
|
529 | }
|
530 | ]
|
531 | };
|
532 | hljs.TITLE_MODE = {
|
533 | className: 'title',
|
534 | begin: hljs.IDENT_RE,
|
535 | relevance: 0
|
536 | };
|
537 | hljs.UNDERSCORE_TITLE_MODE = {
|
538 | className: 'title',
|
539 | begin: hljs.UNDERSCORE_IDENT_RE,
|
540 | relevance: 0
|
541 | };
|
542 | hljs.METHOD_GUARD = {
|
543 |
|
544 | begin: '\\.\\s*' + hljs.UNDERSCORE_IDENT_RE,
|
545 | relevance: 0
|
546 | };
|
547 | hljs.registerLanguage('typescript', typescript);
|
548 | function typescript(hljs) {
|
549 | var KEYWORDS = {
|
550 | keyword: 'in if for while finally var new function do return void else break catch ' +
|
551 | 'instanceof with throw case default try this switch continue typeof delete ' +
|
552 | 'let yield const class public private protected get set super ' +
|
553 | 'static implements enum export import declare type namespace abstract',
|
554 | literal: 'true false null undefined NaN Infinity',
|
555 | built_in: 'eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent ' +
|
556 | 'encodeURI encodeURIComponent escape unescape Object Function Boolean Error ' +
|
557 | 'EvalError InternalError RangeError ReferenceError StopIteration SyntaxError ' +
|
558 | 'TypeError URIError Number Math Date String RegExp Array Float32Array ' +
|
559 | 'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array ' +
|
560 | 'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require ' +
|
561 | 'module console window document any number boolean string void'
|
562 | };
|
563 | return {
|
564 | aliases: ['ts'],
|
565 | keywords: KEYWORDS,
|
566 | contains: [
|
567 | {
|
568 | className: 'meta',
|
569 | begin: /^\s*['"]use strict['"]/
|
570 | },
|
571 | hljs.APOS_STRING_MODE,
|
572 | hljs.QUOTE_STRING_MODE,
|
573 | {
|
574 | className: 'string',
|
575 | begin: '`', end: '`',
|
576 | contains: [
|
577 | hljs.BACKSLASH_ESCAPE,
|
578 | {
|
579 | className: 'subst',
|
580 | begin: '\\$\\{', end: '\\}'
|
581 | }
|
582 | ]
|
583 | },
|
584 | hljs.C_LINE_COMMENT_MODE,
|
585 | hljs.C_BLOCK_COMMENT_MODE,
|
586 | {
|
587 | className: 'number',
|
588 | variants: [
|
589 | { begin: '\\b(0[bB][01]+)' },
|
590 | { begin: '\\b(0[oO][0-7]+)' },
|
591 | { begin: hljs.C_NUMBER_RE }
|
592 | ],
|
593 | relevance: 0
|
594 | },
|
595 | {
|
596 | begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
|
597 | keywords: 'return throw case',
|
598 | contains: [
|
599 | hljs.C_LINE_COMMENT_MODE,
|
600 | hljs.C_BLOCK_COMMENT_MODE,
|
601 | hljs.REGEXP_MODE
|
602 | ],
|
603 | relevance: 0
|
604 | },
|
605 | {
|
606 | className: 'function',
|
607 | begin: 'function', end: /[\{;]/, excludeEnd: true,
|
608 | keywords: KEYWORDS,
|
609 | contains: [
|
610 | 'self',
|
611 | hljs.inherit(hljs.TITLE_MODE, { begin: /[A-Za-z$_][0-9A-Za-z$_]*/ }),
|
612 | {
|
613 | className: 'params',
|
614 | begin: /\(/, end: /\)/,
|
615 | excludeBegin: true,
|
616 | excludeEnd: true,
|
617 | keywords: KEYWORDS,
|
618 | contains: [
|
619 | hljs.C_LINE_COMMENT_MODE,
|
620 | hljs.C_BLOCK_COMMENT_MODE
|
621 | ],
|
622 | illegal: /["'\(]/
|
623 | }
|
624 | ],
|
625 | illegal: /%/,
|
626 | relevance: 0
|
627 | },
|
628 | {
|
629 | beginKeywords: 'constructor', end: /\{/, excludeEnd: true
|
630 | },
|
631 | {
|
632 | begin: /module\./,
|
633 | keywords: { built_in: 'module' },
|
634 | relevance: 0
|
635 | },
|
636 | {
|
637 | beginKeywords: 'module', end: /\{/, excludeEnd: true
|
638 | },
|
639 | {
|
640 | beginKeywords: 'interface', end: /\{/, excludeEnd: true,
|
641 | keywords: 'interface extends'
|
642 | },
|
643 | {
|
644 | begin: /\$[(.]/
|
645 | },
|
646 | {
|
647 | begin: '\\.' + hljs.IDENT_RE, relevance: 0
|
648 | }
|
649 | ]
|
650 | };
|
651 | }
|
652 | hljs.registerLanguage('scss', scss);
|
653 | function scss(hljs) {
|
654 | var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
|
655 | var VARIABLE = {
|
656 | className: 'variable',
|
657 | begin: '(\\$' + IDENT_RE + ')\\b'
|
658 | };
|
659 | var HEXCOLOR = {
|
660 | className: 'number', begin: '#[0-9A-Fa-f]+'
|
661 | };
|
662 |
|
663 |
|
664 |
|
665 |
|
666 |
|
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 | return {
|
682 | case_insensitive: true,
|
683 | illegal: '[=/|\']',
|
684 | contains: [
|
685 | hljs.C_LINE_COMMENT_MODE,
|
686 | hljs.C_BLOCK_COMMENT_MODE,
|
687 | {
|
688 | className: 'selector-id', begin: '\\#[A-Za-z0-9_-]+',
|
689 | relevance: 0
|
690 | },
|
691 | {
|
692 | className: 'selector-class', begin: '\\.[A-Za-z0-9_-]+',
|
693 | relevance: 0
|
694 | },
|
695 | {
|
696 | className: 'selector-attr', begin: '\\[', end: '\\]',
|
697 | illegal: '$'
|
698 | },
|
699 | {
|
700 | className: 'selector-tag',
|
701 | begin: '\\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|div|dl|dt|em|embed|fieldset|figcaption|figure|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|samp|script|section|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\\b',
|
702 | relevance: 0
|
703 | },
|
704 | {
|
705 | begin: ':(visited|valid|root|right|required|read-write|read-only|out-range|optional|only-of-type|only-child|nth-of-type|nth-last-of-type|nth-last-child|nth-child|not|link|left|last-of-type|last-child|lang|invalid|indeterminate|in-range|hover|focus|first-of-type|first-line|first-letter|first-child|first|enabled|empty|disabled|default|checked|before|after|active)'
|
706 | },
|
707 | {
|
708 | begin: '::(after|before|choices|first-letter|first-line|repeat-index|repeat-item|selection|value)'
|
709 | },
|
710 | VARIABLE,
|
711 | {
|
712 | className: 'attribute',
|
713 | begin: '\\b(z-index|word-wrap|word-spacing|word-break|width|widows|white-space|visibility|vertical-align|unicode-bidi|transition-timing-function|transition-property|transition-duration|transition-delay|transition|transform-style|transform-origin|transform|top|text-underline-position|text-transform|text-shadow|text-rendering|text-overflow|text-indent|text-decoration-style|text-decoration-line|text-decoration-color|text-decoration|text-align-last|text-align|tab-size|table-layout|right|resize|quotes|position|pointer-events|perspective-origin|perspective|page-break-inside|page-break-before|page-break-after|padding-top|padding-right|padding-left|padding-bottom|padding|overflow-y|overflow-x|overflow-wrap|overflow|outline-width|outline-style|outline-offset|outline-color|outline|orphans|order|opacity|object-position|object-fit|normal|none|nav-up|nav-right|nav-left|nav-index|nav-down|min-width|min-height|max-width|max-height|mask|marks|margin-top|margin-right|margin-left|margin-bottom|margin|list-style-type|list-style-position|list-style-image|list-style|line-height|letter-spacing|left|justify-content|initial|inherit|ime-mode|image-orientation|image-resolution|image-rendering|icon|hyphens|height|font-weight|font-variant-ligatures|font-variant|font-style|font-stretch|font-size-adjust|font-size|font-language-override|font-kerning|font-feature-settings|font-family|font|float|flex-wrap|flex-shrink|flex-grow|flex-flow|flex-direction|flex-basis|flex|filter|empty-cells|display|direction|cursor|counter-reset|counter-increment|content|column-width|column-span|column-rule-width|column-rule-style|column-rule-color|column-rule|column-gap|column-fill|column-count|columns|color|clip-path|clip|clear|caption-side|break-inside|break-before|break-after|box-sizing|box-shadow|box-decoration-break|bottom|border-width|border-top-width|border-top-style|border-top-right-radius|border-top-left-radius|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-radius|border-left-width|border-left-style|border-left-color|border-left|border-image-width|border-image-source|border-image-slice|border-image-repeat|border-image-outset|border-image|border-color|border-collapse|border-bottom-width|border-bottom-style|border-bottom-right-radius|border-bottom-left-radius|border-bottom-color|border-bottom|border|background-size|background-repeat|background-position|background-origin|background-image|background-color|background-clip|background-attachment|background-blend-mode|background|backface-visibility|auto|animation-timing-function|animation-play-state|animation-name|animation-iteration-count|animation-fill-mode|animation-duration|animation-direction|animation-delay|animation|align-self|align-items|align-content)\\b',
|
714 | illegal: '[^\\s]'
|
715 | },
|
716 | {
|
717 | begin: '\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b'
|
718 | },
|
719 | {
|
720 | begin: ':', end: ';',
|
721 | contains: [
|
722 | VARIABLE,
|
723 | HEXCOLOR,
|
724 | hljs.CSS_NUMBER_MODE,
|
725 | hljs.QUOTE_STRING_MODE,
|
726 | hljs.APOS_STRING_MODE,
|
727 | {
|
728 | className: 'meta', begin: '!important'
|
729 | }
|
730 | ]
|
731 | },
|
732 | {
|
733 | begin: '@', end: '[{;]',
|
734 | keywords: 'mixin include extend for if else each while charset import debug media page content font-face namespace warn',
|
735 | contains: [
|
736 | VARIABLE,
|
737 | hljs.QUOTE_STRING_MODE,
|
738 | hljs.APOS_STRING_MODE,
|
739 | HEXCOLOR,
|
740 | hljs.CSS_NUMBER_MODE,
|
741 | {
|
742 | begin: '\\s[A-Za-z0-9_.-]+',
|
743 | relevance: 0
|
744 | }
|
745 | ]
|
746 | }
|
747 | ]
|
748 | };
|
749 | }
|
750 | hljs.registerLanguage('xml', xml);
|
751 | function xml(hljs) {
|
752 | var XML_IDENT_RE = '[A-Za-z0-9\\._:-]+';
|
753 | var TAG_INTERNALS = {
|
754 | endsWithParent: true,
|
755 | illegal: /</,
|
756 | relevance: 0,
|
757 | contains: [
|
758 | {
|
759 | className: 'attr',
|
760 | begin: XML_IDENT_RE,
|
761 | relevance: 0
|
762 | },
|
763 | {
|
764 | begin: /=\s*/,
|
765 | relevance: 0,
|
766 | contains: [
|
767 | {
|
768 | className: 'string',
|
769 | endsParent: true,
|
770 | variants: [
|
771 | { begin: /"/, end: /"/ },
|
772 | { begin: /'/, end: /'/ },
|
773 | { begin: /[^\s"'=<>`]+/ }
|
774 | ]
|
775 | }
|
776 | ]
|
777 | }
|
778 | ]
|
779 | };
|
780 | return {
|
781 | aliases: ['html', 'xhtml', 'rss', 'atom', 'xjb', 'xsd', 'xsl', 'plist'],
|
782 | case_insensitive: true,
|
783 | contains: [
|
784 | {
|
785 | className: 'meta',
|
786 | begin: '<!DOCTYPE', end: '>',
|
787 | relevance: 10,
|
788 | contains: [{ begin: '\\[', end: '\\]' }]
|
789 | },
|
790 | hljs.COMMENT('<!--', '-->', {
|
791 | relevance: 10
|
792 | }),
|
793 | {
|
794 | begin: '<\\!\\[CDATA\\[', end: '\\]\\]>',
|
795 | relevance: 10
|
796 | },
|
797 | {
|
798 | begin: /<\?(php)?/, end: /\?>/,
|
799 | subLanguage: 'php',
|
800 | contains: [{ begin: '/\\*', end: '\\*/', skip: true }]
|
801 | },
|
802 | {
|
803 | className: 'tag',
|
804 | |
805 |
|
806 |
|
807 |
|
808 |
|
809 |
|
810 | begin: '<style(?=\\s|>|$)', end: '>',
|
811 | keywords: { name: 'style' },
|
812 | contains: [TAG_INTERNALS],
|
813 | starts: {
|
814 | end: '</style>', returnEnd: true,
|
815 | subLanguage: ['css', 'xml']
|
816 | }
|
817 | },
|
818 | {
|
819 | className: 'tag',
|
820 |
|
821 | begin: '<script(?=\\s|>|$)', end: '>',
|
822 | keywords: { name: 'script' },
|
823 | contains: [TAG_INTERNALS],
|
824 | starts: {
|
825 | end: '\<\/script\>', returnEnd: true,
|
826 | subLanguage: ['actionscript', 'javascript', 'handlebars', 'xml']
|
827 | }
|
828 | },
|
829 | {
|
830 | className: 'meta',
|
831 | variants: [
|
832 | { begin: /<\?xml/, end: /\?>/, relevance: 10 },
|
833 | { begin: /<\?\w+/, end: /\?>/ }
|
834 | ]
|
835 | },
|
836 | {
|
837 | className: 'tag',
|
838 | begin: '</?', end: '/?>',
|
839 | contains: [
|
840 | {
|
841 | className: 'name', begin: /[^\/><\s]+/, relevance: 0
|
842 | },
|
843 | TAG_INTERNALS
|
844 | ]
|
845 | }
|
846 | ]
|
847 | };
|
848 | }
|