documentation.js 74 KB

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