documentation.js 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // identity function for calling harmony imports with the correct context
  37. /******/ __webpack_require__.i = function(value) { return value; };
  38. /******/
  39. /******/ // define getter function for harmony exports
  40. /******/ __webpack_require__.d = function(exports, name, getter) {
  41. /******/ if(!__webpack_require__.o(exports, name)) {
  42. /******/ Object.defineProperty(exports, name, {
  43. /******/ configurable: false,
  44. /******/ enumerable: true,
  45. /******/ get: getter
  46. /******/ });
  47. /******/ }
  48. /******/ };
  49. /******/
  50. /******/ // getDefaultExport function for compatibility with non-harmony modules
  51. /******/ __webpack_require__.n = function(module) {
  52. /******/ var getter = module && module.__esModule ?
  53. /******/ function getDefault() { return module['default']; } :
  54. /******/ function getModuleExports() { return module; };
  55. /******/ __webpack_require__.d(getter, 'a', getter);
  56. /******/ return getter;
  57. /******/ };
  58. /******/
  59. /******/ // Object.prototype.hasOwnProperty.call
  60. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  61. /******/
  62. /******/ // __webpack_public_path__
  63. /******/ __webpack_require__.p = "";
  64. /******/
  65. /******/ // Load entry module and return exports
  66. /******/ return __webpack_require__(__webpack_require__.s = 39);
  67. /******/ })
  68. /************************************************************************/
  69. /******/ ({
  70. /***/ 30:
  71. /***/ (function(module, exports, __webpack_require__) {
  72. "use strict";
  73. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  74. /*! highlight.js v9.12.0 | BSD3 License | git.io/hljslicense */
  75. (function (factory) {
  76. // Find the global object for export to both the browser and web workers.
  77. var globalObject = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' && window || (typeof self === 'undefined' ? 'undefined' : _typeof(self)) === 'object' && self;
  78. // Setup highlight.js for different environments. First is Node.js or
  79. // CommonJS.
  80. if (true) {
  81. factory(exports);
  82. } else if (globalObject) {
  83. // Export hljs globally even when using AMD for cases when this script
  84. // is loaded with others that may still expect a global hljs.
  85. globalObject.hljs = factory({});
  86. // Finally register the global hljs with AMD.
  87. if (typeof define === 'function' && define.amd) {
  88. define([], function () {
  89. return globalObject.hljs;
  90. });
  91. }
  92. }
  93. })(function (hljs) {
  94. // Convenience variables for build-in objects
  95. var ArrayProto = [],
  96. objectKeys = Object.keys;
  97. // Global internal variables used within the highlight.js library.
  98. var languages = {},
  99. aliases = {};
  100. // Regular expressions used throughout the highlight.js library.
  101. var noHighlightRe = /^(no-?highlight|plain|text)$/i,
  102. languagePrefixRe = /\blang(?:uage)?-([\w-]+)\b/i,
  103. fixMarkupRe = /((^(<[^>]+>|\t|)+|(?:\n)))/gm;
  104. var spanEndTag = '</span>';
  105. // Global options used when within external APIs. This is modified when
  106. // calling the `hljs.configure` function.
  107. var options = {
  108. classPrefix: 'hljs-',
  109. tabReplace: null,
  110. useBR: false,
  111. languages: undefined
  112. };
  113. /* Utility functions */
  114. function escape(value) {
  115. return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  116. }
  117. function tag(node) {
  118. return node.nodeName.toLowerCase();
  119. }
  120. function testRe(re, lexeme) {
  121. var match = re && re.exec(lexeme);
  122. return match && match.index === 0;
  123. }
  124. function isNotHighlighted(language) {
  125. return noHighlightRe.test(language);
  126. }
  127. function blockLanguage(block) {
  128. var i, match, length, _class;
  129. var classes = block.className + ' ';
  130. classes += block.parentNode ? block.parentNode.className : '';
  131. // language-* takes precedence over non-prefixed class names.
  132. match = languagePrefixRe.exec(classes);
  133. if (match) {
  134. return getLanguage(match[1]) ? match[1] : 'no-highlight';
  135. }
  136. classes = classes.split(/\s+/);
  137. for (i = 0, length = classes.length; i < length; i++) {
  138. _class = classes[i];
  139. if (isNotHighlighted(_class) || getLanguage(_class)) {
  140. return _class;
  141. }
  142. }
  143. }
  144. function inherit(parent) {
  145. // inherit(parent, override_obj, override_obj, ...)
  146. var key;
  147. var result = {};
  148. var objects = Array.prototype.slice.call(arguments, 1);
  149. for (key in parent) {
  150. result[key] = parent[key];
  151. }objects.forEach(function (obj) {
  152. for (key in obj) {
  153. result[key] = obj[key];
  154. }
  155. });
  156. return result;
  157. }
  158. /* Stream merging */
  159. function nodeStream(node) {
  160. var result = [];
  161. (function _nodeStream(node, offset) {
  162. for (var child = node.firstChild; child; child = child.nextSibling) {
  163. if (child.nodeType === 3) offset += child.nodeValue.length;else if (child.nodeType === 1) {
  164. result.push({
  165. event: 'start',
  166. offset: offset,
  167. node: child
  168. });
  169. offset = _nodeStream(child, offset);
  170. // Prevent void elements from having an end tag that would actually
  171. // double them in the output. There are more void elements in HTML
  172. // but we list only those realistically expected in code display.
  173. if (!tag(child).match(/br|hr|img|input/)) {
  174. result.push({
  175. event: 'stop',
  176. offset: offset,
  177. node: child
  178. });
  179. }
  180. }
  181. }
  182. return offset;
  183. })(node, 0);
  184. return result;
  185. }
  186. function mergeStreams(original, highlighted, value) {
  187. var processed = 0;
  188. var result = '';
  189. var nodeStack = [];
  190. function selectStream() {
  191. if (!original.length || !highlighted.length) {
  192. return original.length ? original : highlighted;
  193. }
  194. if (original[0].offset !== highlighted[0].offset) {
  195. return original[0].offset < highlighted[0].offset ? original : highlighted;
  196. }
  197. /*
  198. To avoid starting the stream just before it should stop the order is
  199. ensured that original always starts first and closes last:
  200. if (event1 == 'start' && event2 == 'start')
  201. return original;
  202. if (event1 == 'start' && event2 == 'stop')
  203. return highlighted;
  204. if (event1 == 'stop' && event2 == 'start')
  205. return original;
  206. if (event1 == 'stop' && event2 == 'stop')
  207. return highlighted;
  208. ... which is collapsed to:
  209. */
  210. return highlighted[0].event === 'start' ? original : highlighted;
  211. }
  212. function open(node) {
  213. function attr_str(a) {
  214. return ' ' + a.nodeName + '="' + escape(a.value).replace('"', '&quot;') + '"';
  215. }
  216. result += '<' + tag(node) + ArrayProto.map.call(node.attributes, attr_str).join('') + '>';
  217. }
  218. function close(node) {
  219. result += '</' + tag(node) + '>';
  220. }
  221. function render(event) {
  222. (event.event === 'start' ? open : close)(event.node);
  223. }
  224. while (original.length || highlighted.length) {
  225. var stream = selectStream();
  226. result += escape(value.substring(processed, stream[0].offset));
  227. processed = stream[0].offset;
  228. if (stream === original) {
  229. /*
  230. On any opening or closing tag of the original markup we first close
  231. the entire highlighted node stack, then render the original tag along
  232. with all the following original tags at the same offset and then
  233. reopen all the tags on the highlighted stack.
  234. */
  235. nodeStack.reverse().forEach(close);
  236. do {
  237. render(stream.splice(0, 1)[0]);
  238. stream = selectStream();
  239. } while (stream === original && stream.length && stream[0].offset === processed);
  240. nodeStack.reverse().forEach(open);
  241. } else {
  242. if (stream[0].event === 'start') {
  243. nodeStack.push(stream[0].node);
  244. } else {
  245. nodeStack.pop();
  246. }
  247. render(stream.splice(0, 1)[0]);
  248. }
  249. }
  250. return result + escape(value.substr(processed));
  251. }
  252. /* Initialization */
  253. function expand_mode(mode) {
  254. if (mode.variants && !mode.cached_variants) {
  255. mode.cached_variants = mode.variants.map(function (variant) {
  256. return inherit(mode, { variants: null }, variant);
  257. });
  258. }
  259. return mode.cached_variants || mode.endsWithParent && [inherit(mode)] || [mode];
  260. }
  261. function compileLanguage(language) {
  262. function reStr(re) {
  263. return re && re.source || re;
  264. }
  265. function langRe(value, global) {
  266. return new RegExp(reStr(value), 'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : ''));
  267. }
  268. function compileMode(mode, parent) {
  269. if (mode.compiled) return;
  270. mode.compiled = true;
  271. mode.keywords = mode.keywords || mode.beginKeywords;
  272. if (mode.keywords) {
  273. var compiled_keywords = {};
  274. var flatten = function flatten(className, str) {
  275. if (language.case_insensitive) {
  276. str = str.toLowerCase();
  277. }
  278. str.split(' ').forEach(function (kw) {
  279. var pair = kw.split('|');
  280. compiled_keywords[pair[0]] = [className, pair[1] ? Number(pair[1]) : 1];
  281. });
  282. };
  283. if (typeof mode.keywords === 'string') {
  284. // string
  285. flatten('keyword', mode.keywords);
  286. } else {
  287. objectKeys(mode.keywords).forEach(function (className) {
  288. flatten(className, mode.keywords[className]);
  289. });
  290. }
  291. mode.keywords = compiled_keywords;
  292. }
  293. mode.lexemesRe = langRe(mode.lexemes || /\w+/, true);
  294. if (parent) {
  295. if (mode.beginKeywords) {
  296. mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')\\b';
  297. }
  298. if (!mode.begin) mode.begin = /\B|\b/;
  299. mode.beginRe = langRe(mode.begin);
  300. if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/;
  301. if (mode.end) mode.endRe = langRe(mode.end);
  302. mode.terminator_end = reStr(mode.end) || '';
  303. if (mode.endsWithParent && parent.terminator_end) mode.terminator_end += (mode.end ? '|' : '') + parent.terminator_end;
  304. }
  305. if (mode.illegal) mode.illegalRe = langRe(mode.illegal);
  306. if (mode.relevance == null) mode.relevance = 1;
  307. if (!mode.contains) {
  308. mode.contains = [];
  309. }
  310. mode.contains = Array.prototype.concat.apply([], mode.contains.map(function (c) {
  311. return expand_mode(c === 'self' ? mode : c);
  312. }));
  313. mode.contains.forEach(function (c) {
  314. compileMode(c, mode);
  315. });
  316. if (mode.starts) {
  317. compileMode(mode.starts, parent);
  318. }
  319. var terminators = mode.contains.map(function (c) {
  320. return c.beginKeywords ? '\\.?(' + c.begin + ')\\.?' : c.begin;
  321. }).concat([mode.terminator_end, mode.illegal]).map(reStr).filter(Boolean);
  322. mode.terminators = terminators.length ? langRe(terminators.join('|'), true) : { exec: function exec() /*s*/{
  323. return null;
  324. } };
  325. }
  326. compileMode(language);
  327. }
  328. /*
  329. Core highlighting function. Accepts a language name, or an alias, and a
  330. string with the code to highlight. Returns an object with the following
  331. properties:
  332. - relevance (int)
  333. - value (an HTML string with highlighting markup)
  334. */
  335. function highlight(name, value, ignore_illegals, continuation) {
  336. function subMode(lexeme, mode) {
  337. var i, length;
  338. for (i = 0, length = mode.contains.length; i < length; i++) {
  339. if (testRe(mode.contains[i].beginRe, lexeme)) {
  340. return mode.contains[i];
  341. }
  342. }
  343. }
  344. function endOfMode(mode, lexeme) {
  345. if (testRe(mode.endRe, lexeme)) {
  346. while (mode.endsParent && mode.parent) {
  347. mode = mode.parent;
  348. }
  349. return mode;
  350. }
  351. if (mode.endsWithParent) {
  352. return endOfMode(mode.parent, lexeme);
  353. }
  354. }
  355. function isIllegal(lexeme, mode) {
  356. return !ignore_illegals && testRe(mode.illegalRe, lexeme);
  357. }
  358. function keywordMatch(mode, match) {
  359. var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0];
  360. return mode.keywords.hasOwnProperty(match_str) && mode.keywords[match_str];
  361. }
  362. function buildSpan(classname, insideSpan, leaveOpen, noPrefix) {
  363. var classPrefix = noPrefix ? '' : options.classPrefix,
  364. openSpan = '<span class="' + classPrefix,
  365. closeSpan = leaveOpen ? '' : spanEndTag;
  366. openSpan += classname + '">';
  367. return openSpan + insideSpan + closeSpan;
  368. }
  369. function processKeywords() {
  370. var keyword_match, last_index, match, result;
  371. if (!top.keywords) return escape(mode_buffer);
  372. result = '';
  373. last_index = 0;
  374. top.lexemesRe.lastIndex = 0;
  375. match = top.lexemesRe.exec(mode_buffer);
  376. while (match) {
  377. result += escape(mode_buffer.substring(last_index, match.index));
  378. keyword_match = keywordMatch(top, match);
  379. if (keyword_match) {
  380. relevance += keyword_match[1];
  381. result += buildSpan(keyword_match[0], escape(match[0]));
  382. } else {
  383. result += escape(match[0]);
  384. }
  385. last_index = top.lexemesRe.lastIndex;
  386. match = top.lexemesRe.exec(mode_buffer);
  387. }
  388. return result + escape(mode_buffer.substr(last_index));
  389. }
  390. function processSubLanguage() {
  391. var explicit = typeof top.subLanguage === 'string';
  392. if (explicit && !languages[top.subLanguage]) {
  393. return escape(mode_buffer);
  394. }
  395. var result = explicit ? highlight(top.subLanguage, mode_buffer, true, continuations[top.subLanguage]) : highlightAuto(mode_buffer, top.subLanguage.length ? top.subLanguage : undefined);
  396. // Counting embedded language score towards the host language may be disabled
  397. // with zeroing the containing mode relevance. Usecase in point is Markdown that
  398. // allows XML everywhere and makes every XML snippet to have a much larger Markdown
  399. // score.
  400. if (top.relevance > 0) {
  401. relevance += result.relevance;
  402. }
  403. if (explicit) {
  404. continuations[top.subLanguage] = result.top;
  405. }
  406. return buildSpan(result.language, result.value, false, true);
  407. }
  408. function processBuffer() {
  409. result += top.subLanguage != null ? processSubLanguage() : processKeywords();
  410. mode_buffer = '';
  411. }
  412. function startNewMode(mode) {
  413. result += mode.className ? buildSpan(mode.className, '', true) : '';
  414. top = Object.create(mode, { parent: { value: top } });
  415. }
  416. function processLexeme(buffer, lexeme) {
  417. mode_buffer += buffer;
  418. if (lexeme == null) {
  419. processBuffer();
  420. return 0;
  421. }
  422. var new_mode = subMode(lexeme, top);
  423. if (new_mode) {
  424. if (new_mode.skip) {
  425. mode_buffer += lexeme;
  426. } else {
  427. if (new_mode.excludeBegin) {
  428. mode_buffer += lexeme;
  429. }
  430. processBuffer();
  431. if (!new_mode.returnBegin && !new_mode.excludeBegin) {
  432. mode_buffer = lexeme;
  433. }
  434. }
  435. startNewMode(new_mode, lexeme);
  436. return new_mode.returnBegin ? 0 : lexeme.length;
  437. }
  438. var end_mode = endOfMode(top, lexeme);
  439. if (end_mode) {
  440. var origin = top;
  441. if (origin.skip) {
  442. mode_buffer += lexeme;
  443. } else {
  444. if (!(origin.returnEnd || origin.excludeEnd)) {
  445. mode_buffer += lexeme;
  446. }
  447. processBuffer();
  448. if (origin.excludeEnd) {
  449. mode_buffer = lexeme;
  450. }
  451. }
  452. do {
  453. if (top.className) {
  454. result += spanEndTag;
  455. }
  456. if (!top.skip && !top.subLanguage) {
  457. relevance += top.relevance;
  458. }
  459. top = top.parent;
  460. } while (top !== end_mode.parent);
  461. if (end_mode.starts) {
  462. startNewMode(end_mode.starts, '');
  463. }
  464. return origin.returnEnd ? 0 : lexeme.length;
  465. }
  466. if (isIllegal(lexeme, top)) throw new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || '<unnamed>') + '"');
  467. /*
  468. Parser should not reach this point as all types of lexemes should be caught
  469. earlier, but if it does due to some bug make sure it advances at least one
  470. character forward to prevent infinite looping.
  471. */
  472. mode_buffer += lexeme;
  473. return lexeme.length || 1;
  474. }
  475. var language = getLanguage(name);
  476. if (!language) {
  477. throw new Error('Unknown language: "' + name + '"');
  478. }
  479. compileLanguage(language);
  480. var top = continuation || language;
  481. var continuations = {}; // keep continuations for sub-languages
  482. var result = '',
  483. current;
  484. for (current = top; current !== language; current = current.parent) {
  485. if (current.className) {
  486. result = buildSpan(current.className, '', true) + result;
  487. }
  488. }
  489. var mode_buffer = '';
  490. var relevance = 0;
  491. try {
  492. var match,
  493. count,
  494. index = 0;
  495. while (true) {
  496. top.terminators.lastIndex = index;
  497. match = top.terminators.exec(value);
  498. if (!match) break;
  499. count = processLexeme(value.substring(index, match.index), match[0]);
  500. index = match.index + count;
  501. }
  502. processLexeme(value.substr(index));
  503. for (current = top; current.parent; current = current.parent) {
  504. // close dangling modes
  505. if (current.className) {
  506. result += spanEndTag;
  507. }
  508. }
  509. return {
  510. relevance: relevance,
  511. value: result,
  512. language: name,
  513. top: top
  514. };
  515. } catch (e) {
  516. if (e.message && e.message.indexOf('Illegal') !== -1) {
  517. return {
  518. relevance: 0,
  519. value: escape(value)
  520. };
  521. } else {
  522. throw e;
  523. }
  524. }
  525. }
  526. /*
  527. Highlighting with language detection. Accepts a string with the code to
  528. highlight. Returns an object with the following properties:
  529. - language (detected language)
  530. - relevance (int)
  531. - value (an HTML string with highlighting markup)
  532. - second_best (object with the same structure for second-best heuristically
  533. detected language, may be absent)
  534. */
  535. function highlightAuto(text, languageSubset) {
  536. languageSubset = languageSubset || options.languages || objectKeys(languages);
  537. var result = {
  538. relevance: 0,
  539. value: escape(text)
  540. };
  541. var second_best = result;
  542. languageSubset.filter(getLanguage).forEach(function (name) {
  543. var current = highlight(name, text, false);
  544. current.language = name;
  545. if (current.relevance > second_best.relevance) {
  546. second_best = current;
  547. }
  548. if (current.relevance > result.relevance) {
  549. second_best = result;
  550. result = current;
  551. }
  552. });
  553. if (second_best.language) {
  554. result.second_best = second_best;
  555. }
  556. return result;
  557. }
  558. /*
  559. Post-processing of the highlighted markup:
  560. - replace TABs with something more useful
  561. - replace real line-breaks with '<br>' for non-pre containers
  562. */
  563. function fixMarkup(value) {
  564. return !(options.tabReplace || options.useBR) ? value : value.replace(fixMarkupRe, function (match, p1) {
  565. if (options.useBR && match === '\n') {
  566. return '<br>';
  567. } else if (options.tabReplace) {
  568. return p1.replace(/\t/g, options.tabReplace);
  569. }
  570. return '';
  571. });
  572. }
  573. function buildClassName(prevClassName, currentLang, resultLang) {
  574. var language = currentLang ? aliases[currentLang] : resultLang,
  575. result = [prevClassName.trim()];
  576. if (!prevClassName.match(/\bhljs\b/)) {
  577. result.push('hljs');
  578. }
  579. if (prevClassName.indexOf(language) === -1) {
  580. result.push(language);
  581. }
  582. return result.join(' ').trim();
  583. }
  584. /*
  585. Applies highlighting to a DOM node containing code. Accepts a DOM node and
  586. two optional parameters for fixMarkup.
  587. */
  588. function highlightBlock(block) {
  589. var node, originalStream, result, resultNode, text;
  590. var language = blockLanguage(block);
  591. if (isNotHighlighted(language)) return;
  592. if (options.useBR) {
  593. node = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
  594. node.innerHTML = block.innerHTML.replace(/\n/g, '').replace(/<br[ \/]*>/g, '\n');
  595. } else {
  596. node = block;
  597. }
  598. text = node.textContent;
  599. result = language ? highlight(language, text, true) : highlightAuto(text);
  600. originalStream = nodeStream(node);
  601. if (originalStream.length) {
  602. resultNode = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
  603. resultNode.innerHTML = result.value;
  604. result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
  605. }
  606. result.value = fixMarkup(result.value);
  607. block.innerHTML = result.value;
  608. block.className = buildClassName(block.className, language, result.language);
  609. block.result = {
  610. language: result.language,
  611. re: result.relevance
  612. };
  613. if (result.second_best) {
  614. block.second_best = {
  615. language: result.second_best.language,
  616. re: result.second_best.relevance
  617. };
  618. }
  619. }
  620. /*
  621. Updates highlight.js global options with values passed in the form of an object.
  622. */
  623. function configure(user_options) {
  624. options = inherit(options, user_options);
  625. }
  626. /*
  627. Applies highlighting to all <pre><code>..</code></pre> blocks on a page.
  628. */
  629. function initHighlighting() {
  630. if (initHighlighting.called) return;
  631. initHighlighting.called = true;
  632. var blocks = document.querySelectorAll('pre code');
  633. ArrayProto.forEach.call(blocks, highlightBlock);
  634. }
  635. /*
  636. Attaches highlighting to the page load event.
  637. */
  638. function initHighlightingOnLoad() {
  639. addEventListener('DOMContentLoaded', initHighlighting, false);
  640. addEventListener('load', initHighlighting, false);
  641. }
  642. function registerLanguage(name, language) {
  643. var lang = languages[name] = language(hljs);
  644. if (lang.aliases) {
  645. lang.aliases.forEach(function (alias) {
  646. aliases[alias] = name;
  647. });
  648. }
  649. }
  650. function listLanguages() {
  651. return objectKeys(languages);
  652. }
  653. function getLanguage(name) {
  654. name = (name || '').toLowerCase();
  655. return languages[name] || languages[aliases[name]];
  656. }
  657. /* Interface definition */
  658. hljs.highlight = highlight;
  659. hljs.highlightAuto = highlightAuto;
  660. hljs.fixMarkup = fixMarkup;
  661. hljs.highlightBlock = highlightBlock;
  662. hljs.configure = configure;
  663. hljs.initHighlighting = initHighlighting;
  664. hljs.initHighlightingOnLoad = initHighlightingOnLoad;
  665. hljs.registerLanguage = registerLanguage;
  666. hljs.listLanguages = listLanguages;
  667. hljs.getLanguage = getLanguage;
  668. hljs.inherit = inherit;
  669. // Common regexps
  670. hljs.IDENT_RE = '[a-zA-Z]\\w*';
  671. hljs.UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*';
  672. hljs.NUMBER_RE = '\\b\\d+(\\.\\d+)?';
  673. hljs.C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'; // 0x..., 0..., decimal, float
  674. hljs.BINARY_NUMBER_RE = '\\b(0b[01]+)'; // 0b...
  675. hljs.RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';
  676. // Common modes
  677. hljs.BACKSLASH_ESCAPE = {
  678. begin: '\\\\[\\s\\S]', relevance: 0
  679. };
  680. hljs.APOS_STRING_MODE = {
  681. className: 'string',
  682. begin: '\'', end: '\'',
  683. illegal: '\\n',
  684. contains: [hljs.BACKSLASH_ESCAPE]
  685. };
  686. hljs.QUOTE_STRING_MODE = {
  687. className: 'string',
  688. begin: '"', end: '"',
  689. illegal: '\\n',
  690. contains: [hljs.BACKSLASH_ESCAPE]
  691. };
  692. hljs.PHRASAL_WORDS_MODE = {
  693. 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/
  694. };
  695. hljs.COMMENT = function (begin, end, inherits) {
  696. var mode = hljs.inherit({
  697. className: 'comment',
  698. begin: begin, end: end,
  699. contains: []
  700. }, inherits || {});
  701. mode.contains.push(hljs.PHRASAL_WORDS_MODE);
  702. mode.contains.push({
  703. className: 'doctag',
  704. begin: '(?:TODO|FIXME|NOTE|BUG|XXX):',
  705. relevance: 0
  706. });
  707. return mode;
  708. };
  709. hljs.C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$');
  710. hljs.C_BLOCK_COMMENT_MODE = hljs.COMMENT('/\\*', '\\*/');
  711. hljs.HASH_COMMENT_MODE = hljs.COMMENT('#', '$');
  712. hljs.NUMBER_MODE = {
  713. className: 'number',
  714. begin: hljs.NUMBER_RE,
  715. relevance: 0
  716. };
  717. hljs.C_NUMBER_MODE = {
  718. className: 'number',
  719. begin: hljs.C_NUMBER_RE,
  720. relevance: 0
  721. };
  722. hljs.BINARY_NUMBER_MODE = {
  723. className: 'number',
  724. begin: hljs.BINARY_NUMBER_RE,
  725. relevance: 0
  726. };
  727. hljs.CSS_NUMBER_MODE = {
  728. className: 'number',
  729. 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' + ')?',
  730. relevance: 0
  731. };
  732. hljs.REGEXP_MODE = {
  733. className: 'regexp',
  734. begin: /\//, end: /\/[gimuy]*/,
  735. illegal: /\n/,
  736. contains: [hljs.BACKSLASH_ESCAPE, {
  737. begin: /\[/, end: /\]/,
  738. relevance: 0,
  739. contains: [hljs.BACKSLASH_ESCAPE]
  740. }]
  741. };
  742. hljs.TITLE_MODE = {
  743. className: 'title',
  744. begin: hljs.IDENT_RE,
  745. relevance: 0
  746. };
  747. hljs.UNDERSCORE_TITLE_MODE = {
  748. className: 'title',
  749. begin: hljs.UNDERSCORE_IDENT_RE,
  750. relevance: 0
  751. };
  752. hljs.METHOD_GUARD = {
  753. // excludes method names from keyword processing
  754. begin: '\\.\\s*' + hljs.UNDERSCORE_IDENT_RE,
  755. relevance: 0
  756. };
  757. hljs.registerLanguage('javascript', function (hljs) {
  758. var IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
  759. var KEYWORDS = {
  760. 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 ' +
  761. // ECMAScript 6 modules import
  762. 'import from as',
  763. literal: 'true false null undefined NaN Infinity',
  764. 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'
  765. };
  766. var EXPRESSIONS;
  767. var NUMBER = {
  768. className: 'number',
  769. variants: [{ begin: '\\b(0[bB][01]+)' }, { begin: '\\b(0[oO][0-7]+)' }, { begin: hljs.C_NUMBER_RE }],
  770. relevance: 0
  771. };
  772. var SUBST = {
  773. className: 'subst',
  774. begin: '\\$\\{', end: '\\}',
  775. keywords: KEYWORDS,
  776. contains: [] // defined later
  777. };
  778. var TEMPLATE_STRING = {
  779. className: 'string',
  780. begin: '`', end: '`',
  781. contains: [hljs.BACKSLASH_ESCAPE, SUBST]
  782. };
  783. SUBST.contains = [hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, TEMPLATE_STRING, NUMBER, hljs.REGEXP_MODE];
  784. var PARAMS_CONTAINS = SUBST.contains.concat([hljs.C_BLOCK_COMMENT_MODE, hljs.C_LINE_COMMENT_MODE]);
  785. return {
  786. aliases: ['js', 'jsx'],
  787. keywords: KEYWORDS,
  788. contains: [{
  789. className: 'meta',
  790. relevance: 10,
  791. begin: /^\s*['"]use (strict|asm)['"]/
  792. }, {
  793. className: 'meta',
  794. begin: /^#!/, end: /$/
  795. }, hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, TEMPLATE_STRING, hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, NUMBER, { // object attr container
  796. begin: /[{,]\s*/, relevance: 0,
  797. contains: [{
  798. begin: IDENT_RE + '\\s*:', returnBegin: true,
  799. relevance: 0,
  800. contains: [{ className: 'attr', begin: IDENT_RE, relevance: 0 }]
  801. }]
  802. }, { // "value" container
  803. begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
  804. keywords: 'return throw case',
  805. contains: [hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE, hljs.REGEXP_MODE, {
  806. className: 'function',
  807. begin: '(\\(.*?\\)|' + IDENT_RE + ')\\s*=>', returnBegin: true,
  808. end: '\\s*=>',
  809. contains: [{
  810. className: 'params',
  811. variants: [{
  812. begin: IDENT_RE
  813. }, {
  814. begin: /\(\s*\)/
  815. }, {
  816. begin: /\(/, end: /\)/,
  817. excludeBegin: true, excludeEnd: true,
  818. keywords: KEYWORDS,
  819. contains: PARAMS_CONTAINS
  820. }]
  821. }]
  822. }, { // E4X / JSX
  823. begin: /</, end: /(\/\w+|\w+\/)>/,
  824. subLanguage: 'xml',
  825. contains: [{ begin: /<\w+\s*\/>/, skip: true }, {
  826. begin: /<\w+/, end: /(\/\w+|\w+\/)>/, skip: true,
  827. contains: [{ begin: /<\w+\s*\/>/, skip: true }, 'self']
  828. }]
  829. }],
  830. relevance: 0
  831. }, {
  832. className: 'function',
  833. beginKeywords: 'function', end: /\{/, excludeEnd: true,
  834. contains: [hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE }), {
  835. className: 'params',
  836. begin: /\(/, end: /\)/,
  837. excludeBegin: true,
  838. excludeEnd: true,
  839. contains: PARAMS_CONTAINS
  840. }],
  841. illegal: /\[|%/
  842. }, {
  843. begin: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
  844. }, hljs.METHOD_GUARD, { // ES6 class
  845. className: 'class',
  846. beginKeywords: 'class', end: /[{;=]/, excludeEnd: true,
  847. illegal: /[:"\[\]]/,
  848. contains: [{ beginKeywords: 'extends' }, hljs.UNDERSCORE_TITLE_MODE]
  849. }, {
  850. beginKeywords: 'constructor', end: /\{/, excludeEnd: true
  851. }],
  852. illegal: /#(?!!)/
  853. };
  854. });
  855. hljs.registerLanguage('php', function (hljs) {
  856. var VARIABLE = {
  857. begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
  858. };
  859. var PREPROCESSOR = {
  860. className: 'meta', begin: /<\?(php)?|\?>/
  861. };
  862. var STRING = {
  863. className: 'string',
  864. contains: [hljs.BACKSLASH_ESCAPE, PREPROCESSOR],
  865. variants: [{
  866. begin: 'b"', end: '"'
  867. }, {
  868. begin: 'b\'', end: '\''
  869. }, hljs.inherit(hljs.APOS_STRING_MODE, { illegal: null }), hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null })]
  870. };
  871. var NUMBER = { variants: [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE] };
  872. return {
  873. aliases: ['php3', 'php4', 'php5', 'php6'],
  874. case_insensitive: true,
  875. keywords: 'and include_once list abstract global private echo interface as static endswitch ' + 'array null if endwhile or const for endforeach self var while isset public ' + 'protected exit foreach throw elseif include __FILE__ empty require_once do xor ' + 'return parent clone use __CLASS__ __LINE__ else break print eval new ' + 'catch __METHOD__ case exception default die require __FUNCTION__ ' + 'enddeclare final try switch continue endfor endif declare unset true false ' + 'trait goto instanceof insteadof __DIR__ __NAMESPACE__ ' + 'yield finally',
  876. contains: [hljs.HASH_COMMENT_MODE, hljs.COMMENT('//', '$', { contains: [PREPROCESSOR] }), hljs.COMMENT('/\\*', '\\*/', {
  877. contains: [{
  878. className: 'doctag',
  879. begin: '@[A-Za-z]+'
  880. }]
  881. }), hljs.COMMENT('__halt_compiler.+?;', false, {
  882. endsWithParent: true,
  883. keywords: '__halt_compiler',
  884. lexemes: hljs.UNDERSCORE_IDENT_RE
  885. }), {
  886. className: 'string',
  887. begin: /<<<['"]?\w+['"]?$/, end: /^\w+;?$/,
  888. contains: [hljs.BACKSLASH_ESCAPE, {
  889. className: 'subst',
  890. variants: [{ begin: /\$\w+/ }, { begin: /\{\$/, end: /\}/ }]
  891. }]
  892. }, PREPROCESSOR, {
  893. className: 'keyword', begin: /\$this\b/
  894. }, VARIABLE, {
  895. // swallow composed identifiers to avoid parsing them as keywords
  896. begin: /(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/
  897. }, {
  898. className: 'function',
  899. beginKeywords: 'function', end: /[;{]/, excludeEnd: true,
  900. illegal: '\\$|\\[|%',
  901. contains: [hljs.UNDERSCORE_TITLE_MODE, {
  902. className: 'params',
  903. begin: '\\(', end: '\\)',
  904. contains: ['self', VARIABLE, hljs.C_BLOCK_COMMENT_MODE, STRING, NUMBER]
  905. }]
  906. }, {
  907. className: 'class',
  908. beginKeywords: 'class interface', end: '{', excludeEnd: true,
  909. illegal: /[:\(\$"]/,
  910. contains: [{ beginKeywords: 'extends implements' }, hljs.UNDERSCORE_TITLE_MODE]
  911. }, {
  912. beginKeywords: 'namespace', end: ';',
  913. illegal: /[\.']/,
  914. contains: [hljs.UNDERSCORE_TITLE_MODE]
  915. }, {
  916. beginKeywords: 'use', end: ';',
  917. contains: [hljs.UNDERSCORE_TITLE_MODE]
  918. }, {
  919. begin: '=>' // No markup, just a relevance booster
  920. }, STRING, NUMBER]
  921. };
  922. });
  923. hljs.registerLanguage('xml', function (hljs) {
  924. var XML_IDENT_RE = '[A-Za-z0-9\\._:-]+';
  925. var TAG_INTERNALS = {
  926. endsWithParent: true,
  927. illegal: /</,
  928. relevance: 0,
  929. contains: [{
  930. className: 'attr',
  931. begin: XML_IDENT_RE,
  932. relevance: 0
  933. }, {
  934. begin: /=\s*/,
  935. relevance: 0,
  936. contains: [{
  937. className: 'string',
  938. endsParent: true,
  939. variants: [{ begin: /"/, end: /"/ }, { begin: /'/, end: /'/ }, { begin: /[^\s"'=<>`]+/ }]
  940. }]
  941. }]
  942. };
  943. return {
  944. aliases: ['html', 'xhtml', 'rss', 'atom', 'xjb', 'xsd', 'xsl', 'plist'],
  945. case_insensitive: true,
  946. contains: [{
  947. className: 'meta',
  948. begin: '<!DOCTYPE', end: '>',
  949. relevance: 10,
  950. contains: [{ begin: '\\[', end: '\\]' }]
  951. }, hljs.COMMENT('<!--', '-->', {
  952. relevance: 10
  953. }), {
  954. begin: '<\\!\\[CDATA\\[', end: '\\]\\]>',
  955. relevance: 10
  956. }, {
  957. className: 'meta',
  958. begin: /<\?xml/, end: /\?>/, relevance: 10
  959. }, {
  960. begin: /<\?(php)?/, end: /\?>/,
  961. subLanguage: 'php',
  962. contains: [{ begin: '/\\*', end: '\\*/', skip: true }]
  963. }, {
  964. className: 'tag',
  965. /*
  966. The lookahead pattern (?=...) ensures that 'begin' only matches
  967. '<style' as a single word, followed by a whitespace or an
  968. ending braket. The '$' is needed for the lexeme to be recognized
  969. by hljs.subMode() that tests lexemes outside the stream.
  970. */
  971. begin: '<style(?=\\s|>|$)', end: '>',
  972. keywords: { name: 'style' },
  973. contains: [TAG_INTERNALS],
  974. starts: {
  975. end: '</style>', returnEnd: true,
  976. subLanguage: ['css', 'xml']
  977. }
  978. }, {
  979. className: 'tag',
  980. // See the comment in the <style tag about the lookahead pattern
  981. begin: '<script(?=\\s|>|$)', end: '>',
  982. keywords: { name: 'script' },
  983. contains: [TAG_INTERNALS],
  984. starts: {
  985. end: '\<\/script\>', returnEnd: true,
  986. subLanguage: ['actionscript', 'javascript', 'handlebars', 'xml']
  987. }
  988. }, {
  989. className: 'tag',
  990. begin: '</?', end: '/?>',
  991. contains: [{
  992. className: 'name', begin: /[^\/><\s]+/, relevance: 0
  993. }, TAG_INTERNALS]
  994. }]
  995. };
  996. });
  997. return hljs;
  998. });
  999. /***/ }),
  1000. /***/ 39:
  1001. /***/ (function(module, exports, __webpack_require__) {
  1002. module.exports = __webpack_require__(6);
  1003. /***/ }),
  1004. /***/ 6:
  1005. /***/ (function(module, exports, __webpack_require__) {
  1006. "use strict";
  1007. var _highlightPack = __webpack_require__(30);
  1008. var _highlightPack2 = _interopRequireDefault(_highlightPack);
  1009. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1010. $(document).ready(function () {
  1011. $('pre code').each(function (i, block) {
  1012. _highlightPack2.default.highlightBlock(block);
  1013. });
  1014. });
  1015. /***/ })
  1016. /******/ });