/*! highlight.js v9.11.0 | BSD3 License | git.io/hljslicense */ (function(factory) { // Find the global object for export to both the browser and web workers. var globalObject = typeof window === 'object' && window || typeof self === 'object' && self; // Setup highlight.js for different environments. First is Node.js or // CommonJS. if(typeof exports !== 'undefined') { factory(exports); } else if(globalObject) { // Export hljs globally even when using AMD for cases when this script // is loaded with others that may still expect a global hljs. globalObject.hljs = factory({}); // Finally register the global hljs with AMD. if(typeof define === 'function' && define.amd) { define([], function() { return globalObject.hljs; }); } } }(function(hljs) { // Convenience variables for build-in objects var ArrayProto = [], objectKeys = Object.keys; // Global internal variables used within the highlight.js library. var languages = {}, aliases = {}; // Regular expressions used throughout the highlight.js library. var noHighlightRe = /^(no-?highlight|plain|text)$/i, languagePrefixRe = /\blang(?:uage)?-([\w-]+)\b/i, fixMarkupRe = /((^(<[^>]+>|\t|)+|(?:\n)))/gm; var spanEndTag = ''; // Global options used when within external APIs. This is modified when // calling the `hljs.configure` function. var options = { classPrefix: 'hljs-', tabReplace: null, useBR: false, languages: undefined }; /* Utility functions */ function escape(value) { return value.replace(/&/g, '&').replace(//g, '>'); } 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 noHighlightRe.test(language); } function blockLanguage(block) { var i, match, length, _class; var classes = block.className + ' '; classes += block.parentNode ? block.parentNode.className : ''; // language-* takes precedence over non-prefixed class names. match = languagePrefixRe.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++) { _class = classes[i] if (isNotHighlighted(_class) || getLanguage(_class)) { return _class; } } } function inherit(parent) { // inherit(parent, override_obj, override_obj, ...) var key; var result = {}; var objects = Array.prototype.slice.call(arguments, 1); for (key in parent) result[key] = parent[key]; objects.forEach(function(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).replace('"', '"') + '"';} result += '<' + tag(node) + ArrayProto.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.substring(processed, stream[0].offset)); 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 expand_mode(mode) { if (mode.variants && !mode.cached_variants) { mode.cached_variants = mode.variants.map(function(variant) { return inherit(mode, {variants: null}, variant); }); } return mode.cached_variants || (mode.endsWithParent && [inherit(mode)]) || [mode]; } 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 { objectKeys(mode.keywords).forEach(function (className) { flatten(className, mode.keywords[className]); }); } mode.keywords = compiled_keywords; } mode.lexemesRe = langRe(mode.lexemes || /\w+/, 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 == null) mode.relevance = 1; if (!mode.contains) { mode.contains = []; } mode.contains = Array.prototype.concat.apply([], mode.contains.map(function(c) { return expand_mode(c === 'self' ? mode : c) })); 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) { var i, length; for (i = 0, length = mode.contains.length; i < 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() { var keyword_match, last_index, match, result; if (!top.keywords) return escape(mode_buffer); result = ''; last_index = 0; top.lexemesRe.lastIndex = 0; match = top.lexemesRe.exec(mode_buffer); while (match) { result += escape(mode_buffer.substring(last_index, match.index)); 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() { result += (top.subLanguage != null ? processSubLanguage() : processKeywords()); mode_buffer = ''; } function startNewMode(mode) { result += mode.className? buildSpan(mode.className, '', true): ''; top = Object.create(mode, {parent: {value: top}}); } function processLexeme(buffer, lexeme) { mode_buffer += buffer; if (lexeme == null) { processBuffer(); return 0; } var new_mode = subMode(lexeme, top); if (new_mode) { if (new_mode.skip) { mode_buffer += lexeme; } else { if (new_mode.excludeBegin) { mode_buffer += lexeme; } processBuffer(); if (!new_mode.returnBegin && !new_mode.excludeBegin) { mode_buffer = lexeme; } } 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.skip) { mode_buffer += lexeme; } else { if (!(origin.returnEnd || origin.excludeEnd)) { mode_buffer += lexeme; } processBuffer(); if (origin.excludeEnd) { mode_buffer = lexeme; } } do { if (top.className) { result += spanEndTag; } if (!top.skip) { relevance += top.relevance; } top = top.parent; } while (top !== end_mode.parent); 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.substring(index, match.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 += spanEndTag; } } return { relevance: relevance, value: result, language: name, top: top }; } catch (e) { if (e.message && 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 || objectKeys(languages); var result = { relevance: 0, value: escape(text) }; var second_best = result; languageSubset.filter(getLanguage).forEach(function(name) { 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) { return !(options.tabReplace || options.useBR) ? value : value.replace(fixMarkupRe, function(match, p1) { if (options.useBR && match === '\n') { return '
'; } else if (options.tabReplace) { return p1.replace(/\t/g, options.tabReplace); } return ''; }); } 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 node, originalStream, result, resultNode, text; var language = blockLanguage(block); if (isNotHighlighted(language)) return; 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; } text = node.textContent; result = language ? highlight(language, text, true) : highlightAuto(text); originalStream = nodeStream(node); if (originalStream.length) { 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 }; } } /* 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'); ArrayProto.forEach.call(blocks, highlightBlock); } /* Attaches highlighting to the page load event. */ function initHighlightingOnLoad() { addEventListener('DOMContentLoaded', initHighlighting, false); addEventListener('load', initHighlighting, false); } function registerLanguage(name, language) { var lang = languages[name] = language(hljs); if (lang.aliases) { lang.aliases.forEach(function(alias) {aliases[alias] = name;}); } } function listLanguages() { return objectKeys(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'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\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.METHOD_GUARD = { // excludes method names from keyword processing begin: '\\.\\s*' + hljs.UNDERSCORE_IDENT_RE, relevance: 0 }; 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('bash', function(hljs) { var VAR = { className: 'variable', variants: [ {begin: /\$[\w\d#@][\w\d_]*/}, {begin: /\$\{(.*?)}/} ] }; var QUOTE_STRING = { className: 'string', begin: /"/, end: /"/, contains: [ hljs.BACKSLASH_ESCAPE, VAR, { className: 'variable', begin: /\$\(/, end: /\)/, contains: [hljs.BACKSLASH_ESCAPE] } ] }; var APOS_STRING = { className: 'string', begin: /'/, end: /'/ }; return { aliases: ['sh', 'zsh'], lexemes: /\b-?[a-z\._]+\b/, keywords: { keyword: 'if then else elif fi for while in do done case esac function', literal: 'true false', built_in: // Shell built-ins // http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html 'break cd continue eval exec exit export getopts hash pwd readonly return shift test times ' + 'trap umask unset ' + // Bash built-ins 'alias bind builtin caller command declare echo enable help let local logout mapfile printf ' + 'read readarray source type typeset ulimit unalias ' + // Shell modifiers 'set shopt ' + // Zsh built-ins 'autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles ' + 'compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate ' + 'fc fg float functions getcap getln history integer jobs kill limit log noglob popd print ' + 'pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit ' + 'unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof ' + 'zpty zregexparse zsocket zstyle ztcp', _: '-ne -eq -lt -gt -f -d -e -s -l -a' // relevance booster }, contains: [ { className: 'meta', begin: /^#![^\n]+sh\s*$/, relevance: 10 }, { className: 'function', begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/, returnBegin: true, contains: [hljs.inherit(hljs.TITLE_MODE, {begin: /\w[\w\d_]*/})], relevance: 0 }, hljs.HASH_COMMENT_MODE, QUOTE_STRING, APOS_STRING, VAR ] }; }); hljs.registerLanguage('coffeescript', function(hljs) { var KEYWORDS = { keyword: // JS keywords 'in if for while finally new do return else break catch instanceof throw try this ' + 'switch continue typeof delete debugger super yield import export from as default await ' + // Coffee keywords 'then unless until loop of by when and or is isnt not', literal: // JS literals 'true false null undefined ' + // Coffee literals 'yes no on off', built_in: 'npm require console print module global window document' }; var JS_IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; var SUBST = { className: 'subst', begin: /#\{/, end: /}/, keywords: KEYWORDS }; var EXPRESSIONS = [ hljs.BINARY_NUMBER_MODE, hljs.inherit(hljs.C_NUMBER_MODE, {starts: {end: '(\\s*/)?', relevance: 0}}), // a number tries to eat the following slash to prevent treating it as a regexp { className: 'string', variants: [ { begin: /'''/, end: /'''/, contains: [hljs.BACKSLASH_ESCAPE] }, { begin: /'/, end: /'/, contains: [hljs.BACKSLASH_ESCAPE] }, { begin: /"""/, end: /"""/, contains: [hljs.BACKSLASH_ESCAPE, SUBST] }, { begin: /"/, end: /"/, contains: [hljs.BACKSLASH_ESCAPE, SUBST] } ] }, { className: 'regexp', variants: [ { begin: '///', end: '///', contains: [SUBST, hljs.HASH_COMMENT_MODE] }, { begin: '//[gim]*', relevance: 0 }, { // regex can't start with space to parse x / 2 / 3 as two divisions // regex can't start with *, and it supports an "illegal" in the main mode begin: /\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/ } ] }, { begin: '@' + JS_IDENT_RE // relevance booster }, { subLanguage: 'javascript', excludeBegin: true, excludeEnd: true, variants: [ { begin: '```', end: '```', }, { begin: '`', end: '`', } ] } ]; SUBST.contains = EXPRESSIONS; var TITLE = hljs.inherit(hljs.TITLE_MODE, {begin: JS_IDENT_RE}); var PARAMS_RE = '(\\(.*\\))?\\s*\\B[-=]>'; var PARAMS = { className: 'params', begin: '\\([^\\(]', returnBegin: true, /* We need another contained nameless mode to not have every nested pair of parens to be called "params" */ contains: [{ begin: /\(/, end: /\)/, keywords: KEYWORDS, contains: ['self'].concat(EXPRESSIONS) }] }; return { aliases: ['coffee', 'cson', 'iced'], keywords: KEYWORDS, illegal: /\/\*/, contains: EXPRESSIONS.concat([ hljs.COMMENT('###', '###'), hljs.HASH_COMMENT_MODE, { className: 'function', begin: '^\\s*' + JS_IDENT_RE + '\\s*=\\s*' + PARAMS_RE, end: '[-=]>', returnBegin: true, contains: [TITLE, PARAMS] }, { // anonymous function start begin: /[:\(,=]\s*/, relevance: 0, contains: [ { className: 'function', begin: PARAMS_RE, end: '[-=]>', returnBegin: true, contains: [PARAMS] } ] }, { className: 'class', beginKeywords: 'class', end: '$', illegal: /[:="\[\]]/, contains: [ { beginKeywords: 'extends', endsWithParent: true, illegal: /[:="\[\]]/, contains: [TITLE] }, TITLE ] }, { begin: JS_IDENT_RE + ':', end: ':', returnBegin: true, returnEnd: true, relevance: 0 } ]) }; }); hljs.registerLanguage('cpp', function(hljs) { var CPP_PRIMITIVE_TYPES = { className: 'keyword', begin: '\\b[a-z\\d_]*_t\\b' }; var STRINGS = { className: 'string', variants: [ { begin: '(u8?|U)?L?"', end: '"', illegal: '\\n', contains: [hljs.BACKSLASH_ESCAPE] }, { begin: '(u8?|U)?R"', end: '"', contains: [hljs.BACKSLASH_ESCAPE] }, { begin: '\'\\\\?.', end: '\'', illegal: '.' } ] }; var NUMBERS = { className: 'number', variants: [ { begin: '\\b(0b[01\']+)' }, { begin: '(-?)\\b([\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)(u|U|l|L|ul|UL|f|F|b|B)' }, { begin: '(-?)(\\b0[xX][a-fA-F0-9\']+|(\\b[\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)([eE][-+]?[\\d\']+)?)' } ], relevance: 0 }; var PREPROCESSOR = { className: 'meta', begin: /#\s*[a-z]+\b/, end: /$/, keywords: { 'meta-keyword': 'if else elif endif define undef warning error line ' + 'pragma ifdef ifndef include' }, contains: [ { begin: /\\\n/, relevance: 0 }, hljs.inherit(STRINGS, {className: 'meta-string'}), { className: 'meta-string', begin: /<[^\n>]*>/, end: /$/, illegal: '\\n', }, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE ] }; var FUNCTION_TITLE = hljs.IDENT_RE + '\\s*\\('; var CPP_KEYWORDS = { keyword: 'int float while private char catch import module export virtual operator sizeof ' + 'dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace ' + 'unsigned long volatile static protected bool template mutable if public friend ' + 'do goto auto void enum else break extern using asm case typeid ' + 'short reinterpret_cast|10 default double register explicit signed typename try this ' + 'switch continue 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 new throw return ' + 'and or not', built_in: 'std string cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream ' + 'auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set ' + 'unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos ' + 'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp ' + 'fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper ' + 'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow ' + 'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp ' + 'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan ' + 'vfprintf vprintf vsprintf endl initializer_list unique_ptr', literal: 'true false nullptr NULL' }; var EXPRESSION_CONTAINS = [ CPP_PRIMITIVE_TYPES, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, NUMBERS, STRINGS ]; return { aliases: ['c', 'cc', 'h', 'c++', 'h++', 'hpp'], keywords: CPP_KEYWORDS, illegal: '', keywords: CPP_KEYWORDS, contains: ['self', CPP_PRIMITIVE_TYPES] }, { begin: hljs.IDENT_RE + '::', keywords: CPP_KEYWORDS }, { // This mode covers expression context where we can't expect a function // definition and shouldn't highlight anything that looks like one: // `return some()`, `else if()`, `(x*sum(1, 2))` variants: [ {begin: /=/, end: /;/}, {begin: /\(/, end: /\)/}, {beginKeywords: 'new throw return else', end: /;/} ], keywords: CPP_KEYWORDS, contains: EXPRESSION_CONTAINS.concat([ { begin: /\(/, end: /\)/, keywords: CPP_KEYWORDS, contains: EXPRESSION_CONTAINS.concat(['self']), relevance: 0 } ]), relevance: 0 }, { className: 'function', begin: '(' + hljs.IDENT_RE + '[\\*&\\s]+)+' + FUNCTION_TITLE, returnBegin: true, end: /[{;=]/, excludeEnd: true, keywords: CPP_KEYWORDS, illegal: /[^\w\s\*&]/, contains: [ { begin: FUNCTION_TITLE, returnBegin: true, contains: [hljs.TITLE_MODE], relevance: 0 }, { className: 'params', begin: /\(/, end: /\)/, keywords: CPP_KEYWORDS, relevance: 0, contains: [ hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, STRINGS, NUMBERS, CPP_PRIMITIVE_TYPES ] }, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, PREPROCESSOR ] }, { className: 'class', beginKeywords: 'class struct', end: /[{;:]/, contains: [ {begin: //, contains: ['self']}, // skip generic stuff hljs.TITLE_MODE ] } ]), exports: { preprocessor: PREPROCESSOR, strings: STRINGS, keywords: CPP_KEYWORDS } }; }); hljs.registerLanguage('cs', function(hljs) { var KEYWORDS = { keyword: // Normal keywords. 'abstract as base bool break byte case catch char checked const continue decimal ' + 'default delegate do double else enum event explicit extern finally fixed float ' + 'for foreach goto if implicit in int interface internal is lock long ' + 'object operator out override params private protected public readonly ref sbyte ' + 'sealed short sizeof stackalloc static string struct switch this try typeof ' + 'uint ulong unchecked unsafe ushort using virtual void volatile while ' + 'nameof ' + // Contextual keywords. 'add alias ascending async await by descending dynamic equals from get global group into join ' + 'let on orderby partial remove select set value var where yield', literal: 'null false true' }; var VERBATIM_STRING = { className: 'string', begin: '@"', end: '"', contains: [{begin: '""'}] }; var VERBATIM_STRING_NO_LF = hljs.inherit(VERBATIM_STRING, {illegal: /\n/}); var SUBST = { className: 'subst', begin: '{', end: '}', keywords: KEYWORDS }; var SUBST_NO_LF = hljs.inherit(SUBST, {illegal: /\n/}); var INTERPOLATED_STRING = { className: 'string', begin: /\$"/, end: '"', illegal: /\n/, contains: [{begin: '{{'}, {begin: '}}'}, hljs.BACKSLASH_ESCAPE, SUBST_NO_LF] }; var INTERPOLATED_VERBATIM_STRING = { className: 'string', begin: /\$@"/, end: '"', contains: [{begin: '{{'}, {begin: '}}'}, {begin: '""'}, SUBST] }; var INTERPOLATED_VERBATIM_STRING_NO_LF = hljs.inherit(INTERPOLATED_VERBATIM_STRING, { illegal: /\n/, contains: [{begin: '{{'}, {begin: '}}'}, {begin: '""'}, SUBST_NO_LF] }); SUBST.contains = [ INTERPOLATED_VERBATIM_STRING, INTERPOLATED_STRING, VERBATIM_STRING, hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, hljs.C_NUMBER_MODE, hljs.C_BLOCK_COMMENT_MODE ]; SUBST_NO_LF.contains = [ INTERPOLATED_VERBATIM_STRING_NO_LF, INTERPOLATED_STRING, VERBATIM_STRING_NO_LF, hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, hljs.C_NUMBER_MODE, hljs.inherit(hljs.C_BLOCK_COMMENT_MODE, {illegal: /\n/}) ]; var STRING = { variants: [ INTERPOLATED_VERBATIM_STRING, INTERPOLATED_STRING, VERBATIM_STRING, hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE ] }; var TYPE_IDENT_RE = hljs.IDENT_RE + '(<' + hljs.IDENT_RE + '(\\s*,\\s*' + hljs.IDENT_RE + ')*>)?(\\[\\])?'; return { aliases: ['csharp'], keywords: KEYWORDS, illegal: /::/, contains: [ hljs.COMMENT( '///', '$', { returnBegin: true, contains: [ { className: 'doctag', variants: [ { begin: '///', relevance: 0 }, { begin: '' }, { begin: '' } ] } ] } ), hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, { className: 'meta', begin: '#', end: '$', keywords: {'meta-keyword': 'if else elif endif define undef warning error line region endregion pragma checksum'} }, STRING, hljs.C_NUMBER_MODE, { beginKeywords: 'class interface', end: /[{;=]/, illegal: /[^\s:]/, contains: [ hljs.TITLE_MODE, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE ] }, { beginKeywords: 'namespace', end: /[{;=]/, illegal: /[^\s:]/, contains: [ hljs.inherit(hljs.TITLE_MODE, {begin: '[a-zA-Z](\\.?\\w)*'}), hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE ] }, { // Expression keywords prevent 'keyword Name(...)' from being // recognized as a function definition beginKeywords: 'new return throw await', relevance: 0 }, { className: 'function', begin: '(' + TYPE_IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*\\(', returnBegin: true, end: /[{;=]/, excludeEnd: true, keywords: KEYWORDS, contains: [ { begin: hljs.IDENT_RE + '\\s*\\(', returnBegin: true, contains: [hljs.TITLE_MODE], relevance: 0 }, { className: 'params', begin: /\(/, end: /\)/, excludeBegin: true, excludeEnd: true, keywords: KEYWORDS, relevance: 0, contains: [ STRING, hljs.C_NUMBER_MODE, hljs.C_BLOCK_COMMENT_MODE ] }, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE ] } ] }; }); hljs.registerLanguage('css', function(hljs) { var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*'; var RULE = { begin: /[A-Z\_\.\-]+\s*:/, returnBegin: true, end: ';', endsWithParent: true, contains: [ { className: 'attribute', begin: /\S/, end: ':', excludeEnd: true, starts: { endsWithParent: true, excludeEnd: true, contains: [ { begin: /[\w-]+\(/, returnBegin: true, contains: [ { className: 'built_in', begin: /[\w-]+/ }, { begin: /\(/, end: /\)/, contains: [ hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE ] } ] }, hljs.CSS_NUMBER_MODE, hljs.QUOTE_STRING_MODE, hljs.APOS_STRING_MODE, hljs.C_BLOCK_COMMENT_MODE, { className: 'number', begin: '#[0-9A-Fa-f]+' }, { className: 'meta', begin: '!important' } ] } } ] }; return { case_insensitive: true, illegal: /[=\/|'\$]/, contains: [ hljs.C_BLOCK_COMMENT_MODE, { className: 'selector-id', begin: /#[A-Za-z0-9_-]+/ }, { className: 'selector-class', begin: /\.[A-Za-z0-9_-]+/ }, { className: 'selector-attr', begin: /\[/, end: /\]/, illegal: '$' }, { className: 'selector-pseudo', begin: /:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/ }, { begin: '@(font-face|page)', lexemes: '[a-z-]+', keywords: 'font-face page' }, { begin: '@', end: '[{;]', // at_rule eating first "{" is a good thing // because it doesn’t let it to be parsed as // a rule set but instead drops parser into // the default mode which is how it should be. illegal: /:/, // break on Less variables @var: ... contains: [ { className: 'keyword', begin: /\w+/ }, { begin: /\s/, endsWithParent: true, excludeEnd: true, relevance: 0, contains: [ hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, hljs.CSS_NUMBER_MODE ] } ] }, { className: 'selector-tag', begin: IDENT_RE, relevance: 0 }, { begin: '{', end: '}', illegal: /\S/, contains: [ hljs.C_BLOCK_COMMENT_MODE, RULE, ] } ] }; }); hljs.registerLanguage('diff', function(hljs) { return { aliases: ['patch'], contains: [ { className: 'meta', relevance: 10, variants: [ {begin: /^@@ +\-\d+,\d+ +\+\d+,\d+ +@@$/}, {begin: /^\*\*\* +\d+,\d+ +\*\*\*\*$/}, {begin: /^\-\-\- +\d+,\d+ +\-\-\-\-$/} ] }, { className: 'comment', variants: [ {begin: /Index: /, end: /$/}, {begin: /={3,}/, end: /$/}, {begin: /^\-{3}/, end: /$/}, {begin: /^\*{3} /, end: /$/}, {begin: /^\+{3}/, end: /$/}, {begin: /\*{5}/, end: /\*{5}$/} ] }, { className: 'addition', begin: '^\\+', end: '$' }, { className: 'deletion', begin: '^\\-', end: '$' }, { className: 'addition', begin: '^\\!', end: '$' } ] }; }); hljs.registerLanguage('http', function(hljs) { var VERSION = 'HTTP/[0-9\\.]+'; return { aliases: ['https'], illegal: '\\S', contains: [ { begin: '^' + VERSION, end: '$', contains: [{className: 'number', begin: '\\b\\d{3}\\b'}] }, { begin: '^[A-Z]+ (.*?) ' + VERSION + '$', returnBegin: true, end: '$', contains: [ { className: 'string', begin: ' ', end: ' ', excludeBegin: true, excludeEnd: true }, { begin: VERSION }, { className: 'keyword', begin: '[A-Z]+' } ] }, { className: 'attribute', begin: '^\\w', end: ': ', excludeEnd: true, illegal: '\\n|\\s|=', starts: {end: '$', relevance: 0} }, { begin: '\\n\\n', starts: {subLanguage: [], endsWithParent: true} } ] }; }); hljs.registerLanguage('ini', function(hljs) { var STRING = { className: "string", contains: [hljs.BACKSLASH_ESCAPE], variants: [ { begin: "'''", end: "'''", relevance: 10 }, { begin: '"""', end: '"""', relevance: 10 }, { begin: '"', end: '"' }, { begin: "'", end: "'" } ] }; return { aliases: ['toml'], case_insensitive: true, illegal: /\S/, contains: [ hljs.COMMENT(';', '$'), hljs.HASH_COMMENT_MODE, { className: 'section', begin: /^\s*\[+/, end: /\]+/ }, { begin: /^[a-z0-9\[\]_-]+\s*=\s*/, end: '$', returnBegin: true, contains: [ { className: 'attr', begin: /[a-z0-9\[\]_-]+/ }, { begin: /=/, endsWithParent: true, relevance: 0, contains: [ { className: 'literal', begin: /\bon|off|true|false|yes|no\b/ }, { className: 'variable', variants: [ {begin: /\$[\w\d"][\w\d_]*/}, {begin: /\$\{(.*?)}/} ] }, STRING, { className: 'number', begin: /([\+\-]+)?[\d]+_[\d_]+/ }, hljs.NUMBER_MODE ] } ] } ] }; }); hljs.registerLanguage('java', function(hljs) { var JAVA_IDENT_RE = '[\u00C0-\u02B8a-zA-Z_$][\u00C0-\u02B8a-zA-Z_$0-9]*'; var GENERIC_IDENT_RE = JAVA_IDENT_RE + '(<' + JAVA_IDENT_RE + '(\\s*,\\s*' + JAVA_IDENT_RE + ')*>)?'; var KEYWORDS = 'false synchronized int abstract float private char boolean static null if const ' + 'for true while long strictfp finally protected import native final void ' + 'enum else break transient catch instanceof byte super volatile case assert short ' + 'package default double public try this switch continue throws protected public private ' + 'module requires exports do'; // https://docs.oracle.com/javase/7/docs/technotes/guides/language/underscores-literals.html var JAVA_NUMBER_RE = '\\b' + '(' + '0[bB]([01]+[01_]+[01]+|[01]+)' + // 0b... '|' + '0[xX]([a-fA-F0-9]+[a-fA-F0-9_]+[a-fA-F0-9]+|[a-fA-F0-9]+)' + // 0x... '|' + '(' + '([\\d]+[\\d_]+[\\d]+|[\\d]+)(\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))?' + '|' + '\\.([\\d]+[\\d_]+[\\d]+|[\\d]+)' + ')' + '([eE][-+]?\\d+)?' + // octal, decimal, float ')' + '[lLfF]?'; var JAVA_NUMBER_MODE = { className: 'number', begin: JAVA_NUMBER_RE, relevance: 0 }; return { aliases: ['jsp'], keywords: KEYWORDS, illegal: /<\/|#/, contains: [ hljs.COMMENT( '/\\*\\*', '\\*/', { relevance : 0, contains : [ { // eat up @'s in emails to prevent them to be recognized as doctags begin: /\w+@/, relevance: 0 }, { className : 'doctag', begin : '@[A-Za-z]+' } ] } ), hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, { className: 'class', beginKeywords: 'class interface', end: /[{;=]/, excludeEnd: true, keywords: 'class interface', illegal: /[:"\[\]]/, contains: [ {beginKeywords: 'extends implements'}, hljs.UNDERSCORE_TITLE_MODE ] }, { // Expression keywords prevent 'keyword Name(...)' from being // recognized as a function definition beginKeywords: 'new throw return else', relevance: 0 }, { className: 'function', begin: '(' + GENERIC_IDENT_RE + '\\s+)+' + hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true, end: /[{;=]/, excludeEnd: true, keywords: KEYWORDS, contains: [ { begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true, relevance: 0, contains: [hljs.UNDERSCORE_TITLE_MODE] }, { className: 'params', begin: /\(/, end: /\)/, keywords: KEYWORDS, relevance: 0, contains: [ hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, hljs.C_NUMBER_MODE, hljs.C_BLOCK_COMMENT_MODE ] }, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE ] }, JAVA_NUMBER_MODE, { className: 'meta', begin: '@[A-Za-z]+' } ] }; }); hljs.registerLanguage('javascript', 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: //, 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: /#(?!!)/ }; }); 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('julia', function(hljs) { // Since there are numerous special names in Julia, it is too much trouble // to maintain them by hand. Hence these names (i.e. keywords, literals and // built-ins) are automatically generated from Julia v0.6 itself through // the following scripts for each. var KEYWORDS = { // # keyword generator, multi-word keywords handled manually below // foreach(println, ["in", "isa", "where"]) // for kw in Base.REPLCompletions.complete_keyword("") // if !(contains(kw, " ") || kw == "struct") // println(kw) // end // end keyword: 'in isa where ' + 'baremodule begin break catch ccall const continue do else elseif end export false finally for function ' + 'global if import importall let local macro module quote return true try using while ' + // legacy, to be deprecated in the next release 'type immutable abstract bitstype typealias ', // # literal generator // println("true") // println("false") // for name in Base.REPLCompletions.completions("", 0)[1] // try // v = eval(Symbol(name)) // if !(v isa Function || v isa Type || v isa TypeVar || v isa Module || v isa Colon) // println(name) // end // end // end literal: 'true false ' + 'ARGS C_NULL DevNull ENDIAN_BOM ENV I Inf Inf16 Inf32 Inf64 InsertionSort JULIA_HOME LOAD_PATH MergeSort ' + 'NaN NaN16 NaN32 NaN64 PROGRAM_FILE QuickSort RoundDown RoundFromZero RoundNearest RoundNearestTiesAway ' + 'RoundNearestTiesUp RoundToZero RoundUp STDERR STDIN STDOUT VERSION catalan e|0 eu|0 eulergamma golden im ' + 'nothing pi γ π φ ', // # built_in generator: // for name in Base.REPLCompletions.completions("", 0)[1] // try // v = eval(Symbol(name)) // if v isa Type || v isa TypeVar // println(name) // end // end // end built_in: 'ANY AbstractArray AbstractChannel AbstractFloat AbstractMatrix AbstractRNG AbstractSerializer AbstractSet ' + 'AbstractSparseArray AbstractSparseMatrix AbstractSparseVector AbstractString AbstractUnitRange AbstractVecOrMat ' + 'AbstractVector Any ArgumentError Array AssertionError Associative Base64DecodePipe Base64EncodePipe Bidiagonal '+ 'BigFloat BigInt BitArray BitMatrix BitVector Bool BoundsError BufferStream CachingPool CapturedException ' + 'CartesianIndex CartesianRange Cchar Cdouble Cfloat Channel Char Cint Cintmax_t Clong Clonglong ClusterManager ' + 'Cmd CodeInfo Colon Complex Complex128 Complex32 Complex64 CompositeException Condition ConjArray ConjMatrix ' + 'ConjVector Cptrdiff_t Cshort Csize_t Cssize_t Cstring Cuchar Cuint Cuintmax_t Culong Culonglong Cushort Cwchar_t ' + 'Cwstring DataType Date DateFormat DateTime DenseArray DenseMatrix DenseVecOrMat DenseVector Diagonal Dict ' + 'DimensionMismatch Dims DirectIndexString Display DivideError DomainError EOFError EachLine Enum Enumerate ' + 'ErrorException Exception ExponentialBackOff Expr Factorization FileMonitor Float16 Float32 Float64 Function ' + 'Future GlobalRef GotoNode HTML Hermitian IO IOBuffer IOContext IOStream IPAddr IPv4 IPv6 IndexCartesian IndexLinear ' + 'IndexStyle InexactError InitError Int Int128 Int16 Int32 Int64 Int8 IntSet Integer InterruptException ' + 'InvalidStateException Irrational KeyError LabelNode LinSpace LineNumberNode LoadError LowerTriangular MIME Matrix ' + 'MersenneTwister Method MethodError MethodTable Module NTuple NewvarNode NullException Nullable Number ObjectIdDict ' + 'OrdinalRange OutOfMemoryError OverflowError Pair ParseError PartialQuickSort PermutedDimsArray Pipe ' + 'PollingFileWatcher ProcessExitedException Ptr QuoteNode RandomDevice Range RangeIndex Rational RawFD ' + 'ReadOnlyMemoryError Real ReentrantLock Ref Regex RegexMatch RemoteChannel RemoteException RevString RoundingMode ' + 'RowVector SSAValue SegmentationFault SerializationState Set SharedArray SharedMatrix SharedVector Signed ' + 'SimpleVector Slot SlotNumber SparseMatrixCSC SparseVector StackFrame StackOverflowError StackTrace StepRange ' + 'StepRangeLen StridedArray StridedMatrix StridedVecOrMat StridedVector String SubArray SubString SymTridiagonal ' + 'Symbol Symmetric SystemError TCPSocket Task Text TextDisplay Timer Tridiagonal Tuple Type TypeError TypeMapEntry ' + 'TypeMapLevel TypeName TypeVar TypedSlot UDPSocket UInt UInt128 UInt16 UInt32 UInt64 UInt8 UndefRefError UndefVarError ' + 'UnicodeError UniformScaling Union UnionAll UnitRange Unsigned UpperTriangular Val Vararg VecElement VecOrMat Vector ' + 'VersionNumber Void WeakKeyDict WeakRef WorkerConfig WorkerPool ' }; // ref: http://julia.readthedocs.org/en/latest/manual/variables/#allowed-variable-names var VARIABLE_NAME_RE = '[A-Za-z_\\u00A1-\\uFFFF][A-Za-z_0-9\\u00A1-\\uFFFF]*'; // placeholder for recursive self-reference var DEFAULT = { lexemes: VARIABLE_NAME_RE, keywords: KEYWORDS, illegal: /<\// }; // ref: http://julia.readthedocs.org/en/latest/manual/integers-and-floating-point-numbers/ var NUMBER = { className: 'number', // supported numeric literals: // * binary literal (e.g. 0x10) // * octal literal (e.g. 0o76543210) // * hexadecimal literal (e.g. 0xfedcba876543210) // * hexadecimal floating point literal (e.g. 0x1p0, 0x1.2p2) // * decimal literal (e.g. 9876543210, 100_000_000) // * floating pointe literal (e.g. 1.2, 1.2f, .2, 1., 1.2e10, 1.2e-10) begin: /(\b0x[\d_]*(\.[\d_]*)?|0x\.\d[\d_]*)p[-+]?\d+|\b0[box][a-fA-F0-9][a-fA-F0-9_]*|(\b\d[\d_]*(\.[\d_]*)?|\.\d[\d_]*)([eEfF][-+]?\d+)?/, relevance: 0 }; var CHAR = { className: 'string', begin: /'(.|\\[xXuU][a-zA-Z0-9]+)'/ }; var INTERPOLATION = { className: 'subst', begin: /\$\(/, end: /\)/, keywords: KEYWORDS }; var INTERPOLATED_VARIABLE = { className: 'variable', begin: '\\$' + VARIABLE_NAME_RE }; // TODO: neatly escape normal code in string literal var STRING = { className: 'string', contains: [hljs.BACKSLASH_ESCAPE, INTERPOLATION, INTERPOLATED_VARIABLE], variants: [ { begin: /\w*"""/, end: /"""\w*/, relevance: 10 }, { begin: /\w*"/, end: /"\w*/ } ] }; var COMMAND = { className: 'string', contains: [hljs.BACKSLASH_ESCAPE, INTERPOLATION, INTERPOLATED_VARIABLE], begin: '`', end: '`' }; var MACROCALL = { className: 'meta', begin: '@' + VARIABLE_NAME_RE }; var COMMENT = { className: 'comment', variants: [ { begin: '#=', end: '=#', relevance: 10 }, { begin: '#', end: '$' } ] }; DEFAULT.contains = [ NUMBER, CHAR, STRING, COMMAND, MACROCALL, COMMENT, hljs.HASH_COMMENT_MODE, { className: 'keyword', begin: '\\b(((abstract|primitive)\\s+)type|(mutable\\s+)?struct)\\b' }, {begin: /<:/} // relevance booster ]; INTERPOLATION.contains = DEFAULT.contains; return DEFAULT; }); hljs.registerLanguage('julia-repl', function(hljs) { return { contains: [ { className: 'meta', begin: /^julia>/, relevance: 10, starts: { // end the highlighting if we are on a new line and the line does not have at // least six spaces in the beginning end: /^(?![ ]{6})/, subLanguage: 'julia' }, // jldoctest Markdown blocks are used in the Julia manual and package docs indicate // code snippets that should be verified when the documentation is built. They can be // either REPL-like or script-like, but are usually REPL-like and therefore we apply // julia-repl highlighting to them. More information can be found in Documenter's // manual: https://juliadocs.github.io/Documenter.jl/latest/man/doctests.html aliases: ['jldoctest'] } ] } }); hljs.registerLanguage('makefile', function(hljs) { /* Variables: simple (eg $(var)) and special (eg $@) */ var VARIABLE = { className: 'variable', variants: [ { begin: '\\$\\(' + hljs.UNDERSCORE_IDENT_RE + '\\)', contains: [hljs.BACKSLASH_ESCAPE], }, { begin: /\$[@%`]+/} ] } ] } ] }; return { aliases: ['html', 'xhtml', 'rss', 'atom', 'xjb', 'xsd', 'xsl', 'plist'], case_insensitive: true, contains: [ { className: 'meta', begin: '', relevance: 10, contains: [{begin: '\\[', end: '\\]'}] }, hljs.COMMENT( '', { relevance: 10 } ), { begin: '<\\!\\[CDATA\\[', end: '\\]\\]>', relevance: 10 }, { begin: /<\?(php)?/, end: /\?>/, subLanguage: 'php', contains: [{begin: '/\\*', end: '\\*/', skip: true}] }, { 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