/*! highlight.js v9.1.0 | BSD3 License | git.io/hljslicense */ (function(factory) { // Setup highlight.js for different environments. First is Node.js or // CommonJS. if(typeof exports !== 'undefined') { factory(exports); } else { // Export hljs globally even when using AMD for cases when this script // is loaded with others that may still expect a global hljs. self.hljs = factory({}); // Finally register the global hljs with AMD. if(typeof define === 'function' && define.amd) { define('hljs', [], function() { return self.hljs; }); } } }(function(hljs) { /* Utility functions */ function escape(value) { return value.replace(/&/gm, '&').replace(//gm, '>'); } function tag(node) { return node.nodeName.toLowerCase(); } function testRe(re, lexeme) { var match = re && re.exec(lexeme); return match && match.index == 0; } function isNotHighlighted(language) { return (/^(no-?highlight|plain|text)$/i).test(language); } function blockLanguage(block) { var i, match, length, classes = block.className + ' '; classes += block.parentNode ? block.parentNode.className : ''; // language-* takes precedence over non-prefixed class names match = (/\blang(?:uage)?-([\w-]+)\b/i).exec(classes); if (match) { return getLanguage(match[1]) ? match[1] : 'no-highlight'; } classes = classes.split(/\s+/); for (i = 0, length = classes.length; i < length; i++) { if (getLanguage(classes[i]) || isNotHighlighted(classes[i])) { return classes[i]; } } } function inherit(parent, obj) { var result = {}, key; for (key in parent) result[key] = parent[key]; if (obj) for (key in obj) result[key] = obj[key]; return result; } /* Stream merging */ function nodeStream(node) { var result = []; (function _nodeStream(node, offset) { for (var child = node.firstChild; child; child = child.nextSibling) { if (child.nodeType == 3) offset += child.nodeValue.length; else if (child.nodeType == 1) { result.push({ event: 'start', offset: offset, node: child }); offset = _nodeStream(child, offset); // Prevent void elements from having an end tag that would actually // double them in the output. There are more void elements in HTML // but we list only those realistically expected in code display. if (!tag(child).match(/br|hr|img|input/)) { result.push({ event: 'stop', offset: offset, node: child }); } } } return offset; })(node, 0); return result; } function mergeStreams(original, highlighted, value) { var processed = 0; var result = ''; var nodeStack = []; function selectStream() { if (!original.length || !highlighted.length) { return original.length ? original : highlighted; } if (original[0].offset != highlighted[0].offset) { return (original[0].offset < highlighted[0].offset) ? original : highlighted; } /* To avoid starting the stream just before it should stop the order is ensured that original always starts first and closes last: if (event1 == 'start' && event2 == 'start') return original; if (event1 == 'start' && event2 == 'stop') return highlighted; if (event1 == 'stop' && event2 == 'start') return original; if (event1 == 'stop' && event2 == 'stop') return highlighted; ... which is collapsed to: */ return highlighted[0].event == 'start' ? original : highlighted; } function open(node) { function attr_str(a) {return ' ' + a.nodeName + '="' + escape(a.value) + '"';} result += '<' + tag(node) + Array.prototype.map.call(node.attributes, attr_str).join('') + '>'; } function close(node) { result += ''; } function render(event) { (event.event == 'start' ? open : close)(event.node); } while (original.length || highlighted.length) { var stream = selectStream(); result += escape(value.substr(processed, stream[0].offset - processed)); processed = stream[0].offset; if (stream == original) { /* On any opening or closing tag of the original markup we first close the entire highlighted node stack, then render the original tag along with all the following original tags at the same offset and then reopen all the tags on the highlighted stack. */ nodeStack.reverse().forEach(close); do { render(stream.splice(0, 1)[0]); stream = selectStream(); } while (stream == original && stream.length && stream[0].offset == processed); nodeStack.reverse().forEach(open); } else { if (stream[0].event == 'start') { nodeStack.push(stream[0].node); } else { nodeStack.pop(); } render(stream.splice(0, 1)[0]); } } return result + escape(value.substr(processed)); } /* Initialization */ function compileLanguage(language) { function reStr(re) { return (re && re.source) || re; } function langRe(value, global) { return new RegExp( reStr(value), 'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : '') ); } function compileMode(mode, parent) { if (mode.compiled) return; mode.compiled = true; mode.keywords = mode.keywords || mode.beginKeywords; if (mode.keywords) { var compiled_keywords = {}; var flatten = function(className, str) { if (language.case_insensitive) { str = str.toLowerCase(); } str.split(' ').forEach(function(kw) { var pair = kw.split('|'); compiled_keywords[pair[0]] = [className, pair[1] ? Number(pair[1]) : 1]; }); }; if (typeof mode.keywords == 'string') { // string flatten('keyword', mode.keywords); } else { Object.keys(mode.keywords).forEach(function (className) { flatten(className, mode.keywords[className]); }); } mode.keywords = compiled_keywords; } mode.lexemesRe = langRe(mode.lexemes || /\b\w+\b/, true); if (parent) { if (mode.beginKeywords) { mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')\\b'; } if (!mode.begin) mode.begin = /\B|\b/; mode.beginRe = langRe(mode.begin); if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/; if (mode.end) mode.endRe = langRe(mode.end); mode.terminator_end = reStr(mode.end) || ''; if (mode.endsWithParent && parent.terminator_end) mode.terminator_end += (mode.end ? '|' : '') + parent.terminator_end; } if (mode.illegal) mode.illegalRe = langRe(mode.illegal); if (mode.relevance === undefined) mode.relevance = 1; if (!mode.contains) { mode.contains = []; } var expanded_contains = []; mode.contains.forEach(function(c) { if (c.variants) { c.variants.forEach(function(v) {expanded_contains.push(inherit(c, v));}); } else { expanded_contains.push(c == 'self' ? mode : c); } }); mode.contains = expanded_contains; mode.contains.forEach(function(c) {compileMode(c, mode);}); if (mode.starts) { compileMode(mode.starts, parent); } var terminators = mode.contains.map(function(c) { return c.beginKeywords ? '\\.?(' + c.begin + ')\\.?' : c.begin; }) .concat([mode.terminator_end, mode.illegal]) .map(reStr) .filter(Boolean); mode.terminators = terminators.length ? langRe(terminators.join('|'), true) : {exec: function(/*s*/) {return null;}}; } compileMode(language); } /* Core highlighting function. Accepts a language name, or an alias, and a string with the code to highlight. Returns an object with the following properties: - relevance (int) - value (an HTML string with highlighting markup) */ function highlight(name, value, ignore_illegals, continuation) { function subMode(lexeme, mode) { for (var i = 0; i < mode.contains.length; i++) { if (testRe(mode.contains[i].beginRe, lexeme)) { return mode.contains[i]; } } } function endOfMode(mode, lexeme) { if (testRe(mode.endRe, lexeme)) { while (mode.endsParent && mode.parent) { mode = mode.parent; } return mode; } if (mode.endsWithParent) { return endOfMode(mode.parent, lexeme); } } function isIllegal(lexeme, mode) { return !ignore_illegals && testRe(mode.illegalRe, lexeme); } function keywordMatch(mode, match) { var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0]; return mode.keywords.hasOwnProperty(match_str) && mode.keywords[match_str]; } function buildSpan(classname, insideSpan, leaveOpen, noPrefix) { var classPrefix = noPrefix ? '' : options.classPrefix, openSpan = ''; return openSpan + insideSpan + closeSpan; } function processKeywords() { if (!top.keywords) return escape(mode_buffer); var result = ''; var last_index = 0; top.lexemesRe.lastIndex = 0; var match = top.lexemesRe.exec(mode_buffer); while (match) { result += escape(mode_buffer.substr(last_index, match.index - last_index)); var keyword_match = keywordMatch(top, match); if (keyword_match) { relevance += keyword_match[1]; result += buildSpan(keyword_match[0], escape(match[0])); } else { result += escape(match[0]); } last_index = top.lexemesRe.lastIndex; match = top.lexemesRe.exec(mode_buffer); } return result + escape(mode_buffer.substr(last_index)); } function processSubLanguage() { var explicit = typeof top.subLanguage == 'string'; if (explicit && !languages[top.subLanguage]) { return escape(mode_buffer); } var result = explicit ? highlight(top.subLanguage, mode_buffer, true, continuations[top.subLanguage]) : highlightAuto(mode_buffer, top.subLanguage.length ? top.subLanguage : undefined); // Counting embedded language score towards the host language may be disabled // with zeroing the containing mode relevance. Usecase in point is Markdown that // allows XML everywhere and makes every XML snippet to have a much larger Markdown // score. if (top.relevance > 0) { relevance += result.relevance; } if (explicit) { continuations[top.subLanguage] = result.top; } return buildSpan(result.language, result.value, false, true); } function processBuffer() { return top.subLanguage !== undefined ? processSubLanguage() : processKeywords(); } function startNewMode(mode, lexeme) { var markup = mode.className? buildSpan(mode.className, '', true): ''; if (mode.returnBegin) { result += markup; mode_buffer = ''; } else if (mode.excludeBegin) { result += escape(lexeme) + markup; mode_buffer = ''; } else { result += markup; mode_buffer = lexeme; } top = Object.create(mode, {parent: {value: top}}); } function processLexeme(buffer, lexeme) { mode_buffer += buffer; if (lexeme === undefined) { result += processBuffer(); return 0; } var new_mode = subMode(lexeme, top); if (new_mode) { result += processBuffer(); startNewMode(new_mode, lexeme); return new_mode.returnBegin ? 0 : lexeme.length; } var end_mode = endOfMode(top, lexeme); if (end_mode) { var origin = top; if (!(origin.returnEnd || origin.excludeEnd)) { mode_buffer += lexeme; } result += processBuffer(); do { if (top.className) { result += ''; } relevance += top.relevance; top = top.parent; } while (top != end_mode.parent); if (origin.excludeEnd) { result += escape(lexeme); } mode_buffer = ''; if (end_mode.starts) { startNewMode(end_mode.starts, ''); } return origin.returnEnd ? 0 : lexeme.length; } if (isIllegal(lexeme, top)) throw new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || '') + '"'); /* Parser should not reach this point as all types of lexemes should be caught earlier, but if it does due to some bug make sure it advances at least one character forward to prevent infinite looping. */ mode_buffer += lexeme; return lexeme.length || 1; } var language = getLanguage(name); if (!language) { throw new Error('Unknown language: "' + name + '"'); } compileLanguage(language); var top = continuation || language; var continuations = {}; // keep continuations for sub-languages var result = '', current; for(current = top; current != language; current = current.parent) { if (current.className) { result = buildSpan(current.className, '', true) + result; } } var mode_buffer = ''; var relevance = 0; try { var match, count, index = 0; while (true) { top.terminators.lastIndex = index; match = top.terminators.exec(value); if (!match) break; count = processLexeme(value.substr(index, match.index - index), match[0]); index = match.index + count; } processLexeme(value.substr(index)); for(current = top; current.parent; current = current.parent) { // close dangling modes if (current.className) { result += ''; } } return { relevance: relevance, value: result, language: name, top: top }; } catch (e) { if (e.message.indexOf('Illegal') != -1) { return { relevance: 0, value: escape(value) }; } else { throw e; } } } /* Highlighting with language detection. Accepts a string with the code to highlight. Returns an object with the following properties: - language (detected language) - relevance (int) - value (an HTML string with highlighting markup) - second_best (object with the same structure for second-best heuristically detected language, may be absent) */ function highlightAuto(text, languageSubset) { languageSubset = languageSubset || options.languages || Object.keys(languages); var result = { relevance: 0, value: escape(text) }; var second_best = result; languageSubset.forEach(function(name) { if (!getLanguage(name)) { return; } var current = highlight(name, text, false); current.language = name; if (current.relevance > second_best.relevance) { second_best = current; } if (current.relevance > result.relevance) { second_best = result; result = current; } }); if (second_best.language) { result.second_best = second_best; } return result; } /* Post-processing of the highlighted markup: - replace TABs with something more useful - replace real line-breaks with '
' for non-pre containers */ function fixMarkup(value) { if (options.tabReplace) { value = value.replace(/^((<[^>]+>|\t)+)/gm, function(match, p1 /*..., offset, s*/) { return p1.replace(/\t/g, options.tabReplace); }); } if (options.useBR) { value = value.replace(/\n/g, '
'); } return value; } function buildClassName(prevClassName, currentLang, resultLang) { var language = currentLang ? aliases[currentLang] : resultLang, result = [prevClassName.trim()]; if (!prevClassName.match(/\bhljs\b/)) { result.push('hljs'); } if (prevClassName.indexOf(language) === -1) { result.push(language); } return result.join(' ').trim(); } /* Applies highlighting to a DOM node containing code. Accepts a DOM node and two optional parameters for fixMarkup. */ function highlightBlock(block) { var language = blockLanguage(block); if (isNotHighlighted(language)) return; var node; if (options.useBR) { node = document.createElementNS('http://www.w3.org/1999/xhtml', 'div'); node.innerHTML = block.innerHTML.replace(/\n/g, '').replace(//g, '\n'); } else { node = block; } var text = node.textContent; var result = language ? highlight(language, text, true) : highlightAuto(text); var originalStream = nodeStream(node); if (originalStream.length) { var resultNode = document.createElementNS('http://www.w3.org/1999/xhtml', 'div'); resultNode.innerHTML = result.value; result.value = mergeStreams(originalStream, nodeStream(resultNode), text); } result.value = fixMarkup(result.value); block.innerHTML = result.value; block.className = buildClassName(block.className, language, result.language); block.result = { language: result.language, re: result.relevance }; if (result.second_best) { block.second_best = { language: result.second_best.language, re: result.second_best.relevance }; } } var options = { classPrefix: 'hljs-', tabReplace: null, useBR: false, languages: undefined }; /* Updates highlight.js global options with values passed in the form of an object */ function configure(user_options) { options = inherit(options, user_options); } /* Applies highlighting to all
..
blocks on a page. */ function initHighlighting() { if (initHighlighting.called) return; initHighlighting.called = true; var blocks = document.querySelectorAll('pre code'); Array.prototype.forEach.call(blocks, highlightBlock); } /* Attaches highlighting to the page load event. */ function initHighlightingOnLoad() { addEventListener('DOMContentLoaded', initHighlighting, false); addEventListener('load', initHighlighting, false); } var languages = {}; var aliases = {}; function registerLanguage(name, language) { var lang = languages[name] = language(hljs); if (lang.aliases) { lang.aliases.forEach(function(alias) {aliases[alias] = name;}); } } function listLanguages() { return Object.keys(languages); } function getLanguage(name) { name = (name || '').toLowerCase(); return languages[name] || languages[aliases[name]]; } /* Interface definition */ hljs.highlight = highlight; hljs.highlightAuto = highlightAuto; hljs.fixMarkup = fixMarkup; hljs.highlightBlock = highlightBlock; hljs.configure = configure; hljs.initHighlighting = initHighlighting; hljs.initHighlightingOnLoad = initHighlightingOnLoad; hljs.registerLanguage = registerLanguage; hljs.listLanguages = listLanguages; hljs.getLanguage = getLanguage; hljs.inherit = inherit; // Common regexps hljs.IDENT_RE = '[a-zA-Z]\\w*'; hljs.UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*'; hljs.NUMBER_RE = '\\b\\d+(\\.\\d+)?'; hljs.C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'; // 0x..., 0..., decimal, float hljs.BINARY_NUMBER_RE = '\\b(0b[01]+)'; // 0b... hljs.RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~'; // Common modes hljs.BACKSLASH_ESCAPE = { begin: '\\\\[\\s\\S]', relevance: 0 }; hljs.APOS_STRING_MODE = { className: 'string', begin: '\'', end: '\'', illegal: '\\n', contains: [hljs.BACKSLASH_ESCAPE] }; hljs.QUOTE_STRING_MODE = { className: 'string', begin: '"', end: '"', illegal: '\\n', contains: [hljs.BACKSLASH_ESCAPE] }; hljs.PHRASAL_WORDS_MODE = { begin: /\b(a|an|the|are|I|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/ }; hljs.COMMENT = function (begin, end, inherits) { var mode = hljs.inherit( { className: 'comment', begin: begin, end: end, contains: [] }, inherits || {} ); mode.contains.push(hljs.PHRASAL_WORDS_MODE); mode.contains.push({ className: 'doctag', begin: "(?:TODO|FIXME|NOTE|BUG|XXX):", relevance: 0 }); return mode; }; hljs.C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$'); hljs.C_BLOCK_COMMENT_MODE = hljs.COMMENT('/\\*', '\\*/'); hljs.HASH_COMMENT_MODE = hljs.COMMENT('#', '$'); hljs.NUMBER_MODE = { className: 'number', begin: hljs.NUMBER_RE, relevance: 0 }; hljs.C_NUMBER_MODE = { className: 'number', begin: hljs.C_NUMBER_RE, relevance: 0 }; hljs.BINARY_NUMBER_MODE = { className: 'number', begin: hljs.BINARY_NUMBER_RE, relevance: 0 }; hljs.CSS_NUMBER_MODE = { className: 'number', begin: hljs.NUMBER_RE + '(' + '%|em|ex|ch|rem' + '|vw|vh|vmin|vmax' + '|cm|mm|in|pt|pc|px' + '|deg|grad|rad|turn' + '|s|ms' + '|Hz|kHz' + '|dpi|dpcm|dppx' + ')?', relevance: 0 }; hljs.REGEXP_MODE = { className: 'regexp', begin: /\//, end: /\/[gimuy]*/, illegal: /\n/, contains: [ hljs.BACKSLASH_ESCAPE, { begin: /\[/, end: /\]/, relevance: 0, contains: [hljs.BACKSLASH_ESCAPE] } ] }; hljs.TITLE_MODE = { className: 'title', begin: hljs.IDENT_RE, relevance: 0 }; hljs.UNDERSCORE_TITLE_MODE = { className: 'title', begin: hljs.UNDERSCORE_IDENT_RE, relevance: 0 }; hljs.registerLanguage('1c', function(hljs){ var IDENT_RE_RU = '[a-zA-Zа-яА-Я][a-zA-Z0-9_а-яА-Я]*'; var OneS_KEYWORDS = 'возврат дата для если и или иначе иначеесли исключение конецесли ' + 'конецпопытки конецпроцедуры конецфункции конеццикла константа не перейти перем ' + 'перечисление по пока попытка прервать продолжить процедура строка тогда фс функция цикл ' + 'число экспорт'; var OneS_BUILT_IN = 'ansitooem oemtoansi ввестивидсубконто ввестидату ввестизначение ' + 'ввестиперечисление ввестипериод ввестиплансчетов ввестистроку ввестичисло вопрос ' + 'восстановитьзначение врег выбранныйплансчетов вызватьисключение датагод датамесяц ' + 'датачисло добавитьмесяц завершитьработусистемы заголовоксистемы записьжурналарегистрации ' + 'запуститьприложение зафиксироватьтранзакцию значениевстроку значениевстрокувнутр ' + 'значениевфайл значениеизстроки значениеизстрокивнутр значениеизфайла имякомпьютера ' + 'имяпользователя каталогвременныхфайлов каталогиб каталогпользователя каталогпрограммы ' + 'кодсимв командасистемы конгода конецпериодаби конецрассчитанногопериодаби ' + 'конецстандартногоинтервала конквартала конмесяца коннедели лев лог лог10 макс ' + 'максимальноеколичествосубконто мин монопольныйрежим названиеинтерфейса названиенабораправ ' + 'назначитьвид назначитьсчет найти найтипомеченныенаудаление найтиссылки началопериодаби ' + 'началостандартногоинтервала начатьтранзакцию начгода начквартала начмесяца начнедели ' + 'номерднягода номерднянедели номернеделигода нрег обработкаожидания окр описаниеошибки ' + 'основнойжурналрасчетов основнойплансчетов основнойязык открытьформу открытьформумодально ' + 'отменитьтранзакцию очиститьокносообщений периодстр полноеимяпользователя получитьвремята ' + 'получитьдатута получитьдокументта получитьзначенияотбора получитьпозициюта ' + 'получитьпустоезначение получитьта прав праводоступа предупреждение префиксавтонумерации ' + 'пустаястрока пустоезначение рабочаядаттьпустоезначение рабочаядата разделительстраниц ' + 'разделительстрок разм разобратьпозициюдокумента рассчитатьрегистрына ' + 'рассчитатьрегистрыпо сигнал симв символтабуляции создатьобъект сокрл сокрлп сокрп ' + 'сообщить состояние сохранитьзначение сред статусвозврата стрдлина стрзаменить ' + 'стрколичествострок стрполучитьстроку стрчисловхождений сформироватьпозициюдокумента ' + 'счетпокоду текущаядата текущеевремя типзначения типзначениястр удалитьобъекты ' + 'установитьтана установитьтапо фиксшаблон формат цел шаблон'; var DQUOTE = {begin: '""'}; var STR_START = { className: 'string', begin: '"', end: '"|$', contains: [DQUOTE] }; var STR_CONT = { className: 'string', begin: '\\|', end: '"|$', contains: [DQUOTE] }; return { case_insensitive: true, lexemes: IDENT_RE_RU, keywords: {keyword: OneS_KEYWORDS, built_in: OneS_BUILT_IN}, contains: [ hljs.C_LINE_COMMENT_MODE, hljs.NUMBER_MODE, STR_START, STR_CONT, { className: 'function', begin: '(процедура|функция)', end: '$', lexemes: IDENT_RE_RU, keywords: 'процедура функция', contains: [ { begin: 'экспорт', endsWithParent: true, lexemes: IDENT_RE_RU, keywords: 'экспорт', contains: [hljs.C_LINE_COMMENT_MODE] }, { className: 'params', begin: '\\(', end: '\\)', lexemes: IDENT_RE_RU, keywords: 'знач', contains: [STR_START, STR_CONT] }, hljs.C_LINE_COMMENT_MODE, hljs.inherit(hljs.TITLE_MODE, {begin: IDENT_RE_RU}) ] }, {className: 'meta', begin: '#', end: '$'}, {className: 'number', begin: '\'\\d{2}\\.\\d{2}\\.(\\d{2}|\\d{4})\''} // date ] }; }); hljs.registerLanguage('accesslog', function(hljs) { return { contains: [ // IP { className: 'number', begin: '\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b' }, // Other numbers { className: 'number', begin: '\\b\\d+\\b', relevance: 0 }, // Requests { className: 'string', begin: '"(GET|POST|HEAD|PUT|DELETE|CONNECT|OPTIONS|PATCH|TRACE)', end: '"', keywords: 'GET POST HEAD PUT DELETE CONNECT OPTIONS PATCH TRACE', illegal: '\\n', relevance: 10 }, // Dates { className: 'string', begin: /\[/, end: /\]/, illegal: '\\n' }, // Strings { className: 'string', begin: '"', end: '"', illegal: '\\n' } ] }; }); hljs.registerLanguage('actionscript', function(hljs) { var IDENT_RE = '[a-zA-Z_$][a-zA-Z0-9_$]*'; var IDENT_FUNC_RETURN_TYPE_RE = '([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)'; var AS3_REST_ARG_MODE = { className: 'rest_arg', begin: '[.]{3}', end: IDENT_RE, relevance: 10 }; return { aliases: ['as'], keywords: { keyword: 'as break case catch class const continue default delete do dynamic each ' + 'else extends final finally for function get if implements import in include ' + 'instanceof interface internal is namespace native new override package private ' + 'protected public return set static super switch this throw try typeof use var void ' + 'while with', literal: 'true false null undefined' }, contains: [ hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, hljs.C_NUMBER_MODE, { className: 'class', beginKeywords: 'package', end: '{', contains: [hljs.TITLE_MODE] }, { className: 'class', beginKeywords: 'class interface', end: '{', excludeEnd: true, contains: [ { beginKeywords: 'extends implements' }, hljs.TITLE_MODE ] }, { className: 'meta', beginKeywords: 'import include', end: ';', keywords: {'meta-keyword': 'import include'} }, { className: 'function', beginKeywords: 'function', end: '[{;]', excludeEnd: true, illegal: '\\S', contains: [ hljs.TITLE_MODE, { className: 'params', begin: '\\(', end: '\\)', contains: [ hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, AS3_REST_ARG_MODE ] }, { begin: ':\\s*' + IDENT_FUNC_RETURN_TYPE_RE } ] } ], illegal: /#/ }; }); hljs.registerLanguage('apache', function(hljs) { var NUMBER = {className: 'number', begin: '[\\$%]\\d+'}; return { aliases: ['apacheconf'], case_insensitive: true, contains: [ hljs.HASH_COMMENT_MODE, {className: 'section', begin: ''}, { className: 'attribute', begin: /\w+/, relevance: 0, // keywords aren’t needed for highlighting per se, they only boost relevance // for a very generally defined mode (starts with a word, ends with line-end keywords: { nomarkup: 'order deny allow setenv rewriterule rewriteengine rewritecond documentroot ' + 'sethandler errordocument loadmodule options header listen serverroot ' + 'servername' }, starts: { end: /$/, relevance: 0, keywords: { literal: 'on off all' }, contains: [ { className: 'meta', begin: '\\s\\[', end: '\\]$' }, { className: 'variable', begin: '[\\$%]\\{', end: '\\}', contains: ['self', NUMBER] }, NUMBER, hljs.QUOTE_STRING_MODE ] } } ], illegal: /\S/ }; }); hljs.registerLanguage('applescript', function(hljs) { var STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: ''}); var PARAMS = { className: 'params', begin: '\\(', end: '\\)', contains: ['self', hljs.C_NUMBER_MODE, STRING] }; var COMMENT_MODE_1 = hljs.COMMENT('--', '$'); var COMMENT_MODE_2 = hljs.COMMENT( '\\(\\*', '\\*\\)', { contains: ['self', COMMENT_MODE_1] //allow nesting } ); var COMMENTS = [ COMMENT_MODE_1, COMMENT_MODE_2, hljs.HASH_COMMENT_MODE ]; return { aliases: ['osascript'], keywords: { keyword: 'about above after against and around as at back before beginning ' + 'behind below beneath beside between but by considering ' + 'contain contains continue copy div does eighth else end equal ' + 'equals error every exit fifth first for fourth from front ' + 'get given global if ignoring in into is it its last local me ' + 'middle mod my ninth not of on onto or over prop property put ref ' + 'reference repeat returning script second set seventh since ' + 'sixth some tell tenth that the|0 then third through thru ' + 'timeout times to transaction try until where while whose with ' + 'without', literal: 'AppleScript false linefeed return pi quote result space tab true', built_in: 'alias application boolean class constant date file integer list ' + 'number real record string text ' + 'activate beep count delay launch log offset read round ' + 'run say summarize write ' + 'character characters contents day frontmost id item length ' + 'month name paragraph paragraphs rest reverse running time version ' + 'weekday word words year' }, contains: [ STRING, hljs.C_NUMBER_MODE, { className: 'built_in', begin: '\\b(clipboard info|the clipboard|info for|list (disks|folder)|' + 'mount volume|path to|(close|open for) access|(get|set) eof|' + 'current date|do shell script|get volume settings|random number|' + 'set volume|system attribute|system info|time to GMT|' + '(load|run|store) script|scripting components|' + 'ASCII (character|number)|localized string|' + 'choose (application|color|file|file name|' + 'folder|from list|remote application|URL)|' + 'display (alert|dialog))\\b|^\\s*return\\b' }, { className: 'literal', begin: '\\b(text item delimiters|current application|missing value)\\b' }, { className: 'keyword', begin: '\\b(apart from|aside from|instead of|out of|greater than|' + "isn't|(doesn't|does not) (equal|come before|come after|contain)|" + '(greater|less) than( or equal)?|(starts?|ends|begins?) with|' + 'contained by|comes (before|after)|a (ref|reference)|POSIX file|' + 'POSIX path|(date|time) string|quoted form)\\b' }, { beginKeywords: 'on', illegal: '[${=;\\n]', contains: [hljs.UNDERSCORE_TITLE_MODE, PARAMS] } ].concat(COMMENTS), illegal: '//|->|=>|\\[\\[' }; }); hljs.registerLanguage('arduino', function(hljs) { // CPP Strings var STRINGS = { className: 'string', variants: [ hljs.inherit(hljs.QUOTE_STRING_MODE, { begin: '((u8?|U)|L)?"' }), { begin: '(u8?|U)?R"', end: '"', contains: [hljs.BACKSLASH_ESCAPE] }, { begin: '\'\\\\?.', end: '\'', illegal: '.' } ] }; // CPP preprocessor var PREPROCESSOR = { className: 'meta', begin: '#', end: '$', keywords: {'meta-keyword': 'if else elif endif define undef warning error line ' + 'pragma ifdef ifndef'}, contains: [ { begin: /\\\n/, relevance: 0 }, { beginKeywords: 'include', end: '$', keywords: {'meta-keyword': 'include'}, contains: [ hljs.inherit(STRINGS, {className: 'meta-string'}), { className: 'meta-string', begin: '<', end: '>', illegal: '\\n', } ] }, STRINGS, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE ] }; return { keywords: { function: 'setup loop while catch for if do goto try switch case else default break continue return', keyword: 'boolean byte word string String array ' + // CPP keywords 'int float private char export virtual operator sizeof uint8_t uint16_t ' + 'uint32_t uint64_t int8_t int16_t int32_t int64_t ' + 'dynamic_cast typedef const_cast const struct static_cast union namespace ' + 'unsigned long volatile static protected bool template mutable public friend ' + 'auto void enum extern using class asm typeid ' + 'short reinterpret_cast double register explicit signed typename this ' + 'inline delete alignof constexpr decltype ' + 'noexcept static_assert thread_local restrict _Bool complex _Complex _Imaginary ' + 'atomic_bool atomic_char atomic_schar ' + 'atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong ' + 'atomic_ullong', built_in: 'KeyboardController MouseController SoftwareSerial ' + 'EthernetServer EthernetClient LiquidCrystal ' + 'RobotControl GSMVoiceCall EthernetUDP EsploraTFT ' + 'HttpClient RobotMotor WiFiClient GSMScanner ' + 'FileSystem Scheduler GSMServer YunClient YunServer ' + 'IPAddress GSMClient GSMModem Keyboard Ethernet ' + 'Console GSMBand Esplora Stepper Process ' + 'WiFiUDP GSM_SMS Mailbox USBHost Firmata PImage ' + 'Client Server GSMPIN FileIO Bridge Serial ' + 'EEPROM Stream Mouse Audio Servo File Task ' + 'GPRS WiFi Wire TFT GSM SPI SD ' + 'runShellCommandAsynchronously analogWriteResolution ' + 'retrieveCallingNumber printFirmwareVersion ' + 'analogReadResolution sendDigitalPortPair ' + 'noListenOnLocalhost readJoystickButton setFirmwareVersion ' + 'readJoystickSwitch scrollDisplayRight getVoiceCallStatus ' + 'scrollDisplayLeft writeMicroseconds delayMicroseconds ' + 'beginTransmission getSignalStrength runAsynchronously ' + 'getAsynchronously listenOnLocalhost getCurrentCarrier ' + 'readAccelerometer messageAvailable sendDigitalPorts ' + 'lineFollowConfig countryNameWrite runShellCommand ' + 'readStringUntil rewindDirectory readTemperature ' + 'setClockDivider readLightSensor endTransmission ' + 'analogReference detachInterrupt countryNameRead ' + 'attachInterrupt encryptionType readBytesUntil ' + 'robotNameWrite readMicrophone robotNameRead cityNameWrite ' + 'userNameWrite readJoystickY readJoystickX mouseReleased ' + 'openNextFile scanNetworks noInterrupts digitalWrite ' + 'beginSpeaker mousePressed isActionDone mouseDragged ' + 'displayLogos noAutoscroll addParameter remoteNumber ' + 'getModifiers keyboardRead userNameRead waitContinue ' + 'processInput parseCommand printVersion readNetworks ' + 'writeMessage blinkVersion cityNameRead readMessage ' + 'setDataMode parsePacket isListening setBitOrder ' + 'beginPacket isDirectory motorsWrite drawCompass ' + 'digitalRead clearScreen serialEvent rightToLeft ' + 'setTextSize leftToRight requestFrom keyReleased ' + 'compassRead analogWrite interrupts WiFiServer ' + 'disconnect playMelody parseFloat autoscroll ' + 'getPINUsed setPINUsed setTimeout sendAnalog ' + 'readSlider analogRead beginWrite createChar ' + 'motorsStop keyPressed tempoWrite readButton ' + 'subnetMask debugPrint macAddress writeGreen ' + 'randomSeed attachGPRS readString sendString ' + 'remotePort releaseAll mouseMoved background ' + 'getXChange getYChange answerCall getResult ' + 'voiceCall endPacket constrain getSocket writeJSON ' + 'getButton available connected findUntil readBytes ' + 'exitValue readGreen writeBlue startLoop IPAddress ' + 'isPressed sendSysex pauseMode gatewayIP setCursor ' + 'getOemKey tuneWrite noDisplay loadImage switchPIN ' + 'onRequest onReceive changePIN playFile noBuffer ' + 'parseInt overflow checkPIN knobRead beginTFT ' + 'bitClear updateIR bitWrite position writeRGB ' + 'highByte writeRed setSpeed readBlue noStroke ' + 'remoteIP transfer shutdown hangCall beginSMS ' + 'endWrite attached maintain noCursor checkReg ' + 'checkPUK shiftOut isValid shiftIn pulseIn ' + 'connect println localIP pinMode getIMEI ' + 'display noBlink process getBand running beginSD ' + 'drawBMP lowByte setBand release bitRead prepare ' + 'pointTo readRed setMode noFill remove listen ' + 'stroke detach attach noTone exists buffer ' + 'height bitSet circle config cursor random ' + 'IRread setDNS endSMS getKey micros ' + 'millis begin print write ready flush width ' + 'isPIN blink clear press mkdir rmdir close ' + 'point yield image BSSID click delay ' + 'read text move peek beep rect line open ' + 'seek fill size turn stop home find ' + 'step tone sqrt RSSI SSID ' + 'end bit tan cos sin pow map abs max ' + 'min get run put', symbol: 'DIGITAL_MESSAGE FIRMATA_STRING ANALOG_MESSAGE ' + 'REPORT_DIGITAL REPORT_ANALOG INPUT_PULLUP ' + 'SET_PIN_MODE INTERNAL2V56 SYSTEM_RESET LED_BUILTIN ' + 'INTERNAL1V1 SYSEX_START INTERNAL EXTERNAL ' + 'DEFAULT OUTPUT INPUT HIGH LOW' }, contains: [ PREPROCESSOR, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, hljs.C_NUMBER_MODE ] }; }); hljs.registerLanguage('armasm', function(hljs) { //local labels: %?[FB]?[AT]?\d{1,2}\w+ return { case_insensitive: true, aliases: ['arm'], lexemes: '\\.?' + hljs.IDENT_RE, keywords: { meta: //GNU preprocs '.2byte .4byte .align .ascii .asciz .balign .byte .code .data .else .end .endif .endm .endr .equ .err .exitm .extern .global .hword .if .ifdef .ifndef .include .irp .long .macro .rept .req .section .set .skip .space .text .word .arm .thumb .code16 .code32 .force_thumb .thumb_func .ltorg '+ //ARM directives 'ALIAS ALIGN ARM AREA ASSERT ATTR CN CODE CODE16 CODE32 COMMON CP DATA DCB DCD DCDU DCDO DCFD DCFDU DCI DCQ DCQU DCW DCWU DN ELIF ELSE END ENDFUNC ENDIF ENDP ENTRY EQU EXPORT EXPORTAS EXTERN FIELD FILL FUNCTION GBLA GBLL GBLS GET GLOBAL IF IMPORT INCBIN INCLUDE INFO KEEP LCLA LCLL LCLS LTORG MACRO MAP MEND MEXIT NOFP OPT PRESERVE8 PROC QN READONLY RELOC REQUIRE REQUIRE8 RLIST FN ROUT SETA SETL SETS SN SPACE SUBT THUMB THUMBX TTL WHILE WEND ', built_in: 'r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 '+ //standard registers 'pc lr sp ip sl sb fp '+ //typical regs plus backward compatibility 'a1 a2 a3 a4 v1 v2 v3 v4 v5 v6 v7 v8 f0 f1 f2 f3 f4 f5 f6 f7 '+ //more regs and fp 'p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 '+ //coprocessor regs 'c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 '+ //more coproc 'q0 q1 q2 q3 q4 q5 q6 q7 q8 q9 q10 q11 q12 q13 q14 q15 '+ //advanced SIMD NEON regs //program status registers 'cpsr_c cpsr_x cpsr_s cpsr_f cpsr_cx cpsr_cxs cpsr_xs cpsr_xsf cpsr_sf cpsr_cxsf '+ 'spsr_c spsr_x spsr_s spsr_f spsr_cx spsr_cxs spsr_xs spsr_xsf spsr_sf spsr_cxsf '+ //NEON and VFP registers 's0 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 '+ 's16 s17 s18 s19 s20 s21 s22 s23 s24 s25 s26 s27 s28 s29 s30 s31 '+ 'd0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d12 d13 d14 d15 '+ 'd16 d17 d18 d19 d20 d21 d22 d23 d24 d25 d26 d27 d28 d29 d30 d31 ' + '{PC} {VAR} {TRUE} {FALSE} {OPT} {CONFIG} {ENDIAN} {CODESIZE} {CPU} {FPU} {ARCHITECTURE} {PCSTOREOFFSET} {ARMASM_VERSION} {INTER} {ROPI} {RWPI} {SWST} {NOSWST} . @' }, contains: [ { className: 'keyword', begin: '\\b('+ //mnemonics 'adc|'+ '(qd?|sh?|u[qh]?)?add(8|16)?|usada?8|(q|sh?|u[qh]?)?(as|sa)x|'+ 'and|adrl?|sbc|rs[bc]|asr|b[lx]?|blx|bxj|cbn?z|tb[bh]|bic|'+ 'bfc|bfi|[su]bfx|bkpt|cdp2?|clz|clrex|cmp|cmn|cpsi[ed]|cps|'+ 'setend|dbg|dmb|dsb|eor|isb|it[te]{0,3}|lsl|lsr|ror|rrx|'+ 'ldm(([id][ab])|f[ds])?|ldr((s|ex)?[bhd])?|movt?|mvn|mra|mar|'+ 'mul|[us]mull|smul[bwt][bt]|smu[as]d|smmul|smmla|'+ 'mla|umlaal|smlal?([wbt][bt]|d)|mls|smlsl?[ds]|smc|svc|sev|'+ 'mia([bt]{2}|ph)?|mrr?c2?|mcrr2?|mrs|msr|orr|orn|pkh(tb|bt)|rbit|'+ 'rev(16|sh)?|sel|[su]sat(16)?|nop|pop|push|rfe([id][ab])?|'+ 'stm([id][ab])?|str(ex)?[bhd]?|(qd?)?sub|(sh?|q|u[qh]?)?sub(8|16)|'+ '[su]xt(a?h|a?b(16)?)|srs([id][ab])?|swpb?|swi|smi|tst|teq|'+ 'wfe|wfi|yield'+ ')'+ '(eq|ne|cs|cc|mi|pl|vs|vc|hi|ls|ge|lt|gt|le|al|hs|lo)?'+ //condition codes '[sptrx]?' , //legal postfixes end: '\\s' }, hljs.COMMENT('[;@]', '$', {relevance: 0}), hljs.C_BLOCK_COMMENT_MODE, hljs.QUOTE_STRING_MODE, { className: 'string', begin: '\'', end: '[^\\\\]\'', relevance: 0 }, { className: 'title', begin: '\\|', end: '\\|', illegal: '\\n', relevance: 0 }, { className: 'number', variants: [ {begin: '[#$=]?0x[0-9a-f]+'}, //hex {begin: '[#$=]?0b[01]+'}, //bin {begin: '[#$=]\\d+'}, //literal {begin: '\\b\\d+'} //bare number ], relevance: 0 }, { className: 'symbol', variants: [ {begin: '^[a-z_\\.\\$][a-z0-9_\\.\\$]+'}, //ARM syntax {begin: '^\\s*[a-z_\\.\\$][a-z0-9_\\.\\$]+:'}, //GNU ARM syntax {begin: '[=#]\\w+' } //label reference ], relevance: 0 } ] }; }); hljs.registerLanguage('xml', function(hljs) { var XML_IDENT_RE = '[A-Za-z0-9\\._:-]+'; var PHP = { begin: /<\?(php)?(?!\w)/, end: /\?>/, subLanguage: 'php' }; var TAG_INTERNALS = { endsWithParent: true, illegal: /]+/} ] } ] } ] }; return { aliases: ['html', 'xhtml', 'rss', 'atom', 'xsl', 'plist'], case_insensitive: true, contains: [ { className: 'meta', begin: '', relevance: 10, contains: [{begin: '\\[', end: '\\]'}] }, hljs.COMMENT( '', { relevance: 10 } ), { begin: '<\\!\\[CDATA\\[', end: '\\]\\]>', relevance: 10 }, { className: 'tag', /* The lookahead pattern (?=...) ensures that 'begin' only matches '|$)', end: '>', keywords: {name: 'style'}, contains: [TAG_INTERNALS], starts: { end: '', returnEnd: true, subLanguage: ['css', 'xml'] } }, { className: 'tag', // See the comment in the