@canopycanopycanopy/b-ber-markdown-renderer 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/highlightjs/highlight.js +50 -201
  2. package/dist/highlightjs/index.js +1 -1
  3. package/dist/highlightjs/languages/1c.js +91 -46
  4. package/dist/highlightjs/languages/accesslog.js +10 -5
  5. package/dist/highlightjs/languages/ada.js +26 -12
  6. package/dist/highlightjs/languages/angelscript.js +12 -5
  7. package/dist/highlightjs/languages/applescript.js +1 -4
  8. package/dist/highlightjs/languages/arcade.js +1 -4
  9. package/dist/highlightjs/languages/armasm.js +35 -16
  10. package/dist/highlightjs/languages/asciidoc.js +42 -21
  11. package/dist/highlightjs/languages/autohotkey.js +2 -2
  12. package/dist/highlightjs/languages/autoit.js +82 -82
  13. package/dist/highlightjs/languages/avrasm.js +7 -9
  14. package/dist/highlightjs/languages/bash.js +9 -5
  15. package/dist/highlightjs/languages/bnf.js +6 -3
  16. package/dist/highlightjs/languages/cal.js +0 -3
  17. package/dist/highlightjs/languages/capnproto.js +0 -2
  18. package/dist/highlightjs/languages/ceylon.js +4 -7
  19. package/dist/highlightjs/languages/clojure.js +2 -1
  20. package/dist/highlightjs/languages/cmake.js +10 -5
  21. package/dist/highlightjs/languages/coffeescript.js +10 -10
  22. package/dist/highlightjs/languages/cos.js +6 -2
  23. package/dist/highlightjs/languages/cpp.js +4 -4
  24. package/dist/highlightjs/languages/crystal.js +0 -4
  25. package/dist/highlightjs/languages/cs.js +4 -2
  26. package/dist/highlightjs/languages/d.js +34 -29
  27. package/dist/highlightjs/languages/dart.js +4 -3
  28. package/dist/highlightjs/languages/delphi.js +0 -3
  29. package/dist/highlightjs/languages/dns.js +4 -2
  30. package/dist/highlightjs/languages/dos.js +2 -1
  31. package/dist/highlightjs/languages/ebnf.js +2 -1
  32. package/dist/highlightjs/languages/elm.js +7 -2
  33. package/dist/highlightjs/languages/erlang.js +9 -6
  34. package/dist/highlightjs/languages/excel.js +2 -5
  35. package/dist/highlightjs/languages/gams.js +6 -3
  36. package/dist/highlightjs/languages/gauss.js +2 -6
  37. package/dist/highlightjs/languages/gcode.js +0 -3
  38. package/dist/highlightjs/languages/glsl.js +10 -5
  39. package/dist/highlightjs/languages/go.js +0 -1
  40. package/dist/highlightjs/languages/groovy.js +4 -2
  41. package/dist/highlightjs/languages/haml.js +4 -2
  42. package/dist/highlightjs/languages/haskell.js +9 -3
  43. package/dist/highlightjs/languages/hy.js +2 -1
  44. package/dist/highlightjs/languages/inform7.js +8 -4
  45. package/dist/highlightjs/languages/irpf90.js +4 -2
  46. package/dist/highlightjs/languages/isbl.js +292 -148
  47. package/dist/highlightjs/languages/java.js +8 -4
  48. package/dist/highlightjs/languages/javascript.js +3 -6
  49. package/dist/highlightjs/languages/json.js +0 -2
  50. package/dist/highlightjs/languages/julia.js +12 -5
  51. package/dist/highlightjs/languages/kotlin.js +15 -8
  52. package/dist/highlightjs/languages/lasso.js +0 -3
  53. package/dist/highlightjs/languages/less.js +20 -17
  54. package/dist/highlightjs/languages/livecodeserver.js +0 -3
  55. package/dist/highlightjs/languages/livescript.js +8 -9
  56. package/dist/highlightjs/languages/llvm.js +4 -2
  57. package/dist/highlightjs/languages/lua.js +6 -6
  58. package/dist/highlightjs/languages/makefile.js +0 -5
  59. package/dist/highlightjs/languages/markdown.js +18 -9
  60. package/dist/highlightjs/languages/mercury.js +4 -2
  61. package/dist/highlightjs/languages/mipsasm.js +37 -18
  62. package/dist/highlightjs/languages/mojolicious.js +4 -2
  63. package/dist/highlightjs/languages/moonscript.js +5 -8
  64. package/dist/highlightjs/languages/nginx.js +12 -6
  65. package/dist/highlightjs/languages/ocaml.js +3 -8
  66. package/dist/highlightjs/languages/openscad.js +39 -39
  67. package/dist/highlightjs/languages/perl.js +3 -3
  68. package/dist/highlightjs/languages/pgsql.js +128 -72
  69. package/dist/highlightjs/languages/php.js +0 -1
  70. package/dist/highlightjs/languages/pony.js +1 -0
  71. package/dist/highlightjs/languages/powershell.js +5 -8
  72. package/dist/highlightjs/languages/processing.js +2 -1
  73. package/dist/highlightjs/languages/prolog.js +1 -3
  74. package/dist/highlightjs/languages/properties.js +8 -5
  75. package/dist/highlightjs/languages/protobuf.js +0 -1
  76. package/dist/highlightjs/languages/puppet.js +4 -8
  77. package/dist/highlightjs/languages/purebasic.js +9 -5
  78. package/dist/highlightjs/languages/python.js +0 -1
  79. package/dist/highlightjs/languages/qml.js +15 -11
  80. package/dist/highlightjs/languages/reasonml.js +0 -6
  81. package/dist/highlightjs/languages/roboconf.js +8 -4
  82. package/dist/highlightjs/languages/routeros.js +36 -18
  83. package/dist/highlightjs/languages/ruby.js +0 -4
  84. package/dist/highlightjs/languages/ruleslanguage.js +2 -1
  85. package/dist/highlightjs/languages/rust.js +8 -4
  86. package/dist/highlightjs/languages/sas.js +4 -2
  87. package/dist/highlightjs/languages/scala.js +2 -1
  88. package/dist/highlightjs/languages/scheme.js +0 -3
  89. package/dist/highlightjs/languages/scilab.js +2 -4
  90. package/dist/highlightjs/languages/sml.js +2 -6
  91. package/dist/highlightjs/languages/sqf.js +8 -5
  92. package/dist/highlightjs/languages/stan.js +2 -1
  93. package/dist/highlightjs/languages/stylus.js +45 -24
  94. package/dist/highlightjs/languages/swift.js +4 -3
  95. package/dist/highlightjs/languages/tap.js +8 -4
  96. package/dist/highlightjs/languages/thrift.js +0 -1
  97. package/dist/highlightjs/languages/tp.js +1 -3
  98. package/dist/highlightjs/languages/twig.js +0 -3
  99. package/dist/highlightjs/languages/typescript.js +0 -3
  100. package/dist/highlightjs/languages/vala.js +12 -6
  101. package/dist/highlightjs/languages/vbnet.js +12 -27
  102. package/dist/highlightjs/languages/verilog.js +1 -2
  103. package/dist/highlightjs/languages/vhdl.js +8 -5
  104. package/dist/highlightjs/languages/vim.js +6 -3
  105. package/dist/highlightjs/languages/x86asm.js +52 -26
  106. package/dist/highlightjs/languages/xml.js +2 -2
  107. package/dist/highlightjs/languages/xquery.js +12 -7
  108. package/dist/highlightjs/languages/yaml.js +3 -1
  109. package/dist/highlightjs/languages/zephir.js +0 -1
  110. package/dist/index.js +9 -36
  111. package/package.json +17 -17
@@ -1,47 +1,38 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
-
5
4
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
6
-
7
5
  var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
8
-
9
6
  var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
10
-
11
7
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
12
-
13
8
  var _reverse = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reverse"));
14
-
15
9
  var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
16
-
17
10
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
18
-
19
11
  var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
20
-
21
12
  var _create = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/create"));
22
-
23
13
  var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
24
-
25
14
  var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
26
-
27
15
  // eslint-disable
28
16
 
29
17
  /*
30
18
  Syntax highlighting with language autodetection.
31
19
  https://highlightjs.org/
32
20
  */
21
+
33
22
  (function (factory) {
34
23
  // Find the global object for export to both the browser and web workers.
35
- var globalObject = typeof window === 'object' && window || typeof self === 'object' && self; // Setup highlight.js for different environments. First is Node.js or
36
- // CommonJS.
24
+ var globalObject = typeof window === 'object' && window || typeof self === 'object' && self;
37
25
 
26
+ // Setup highlight.js for different environments. First is Node.js or
27
+ // CommonJS.
38
28
  if (typeof exports !== 'undefined') {
39
29
  factory(exports);
40
30
  } else if (globalObject) {
41
31
  // Export hljs globally even when using AMD for cases when this script
42
32
  // is loaded with others that may still expect a global hljs.
43
- globalObject.hljs = factory({}); // Finally register the global hljs with AMD.
33
+ globalObject.hljs = factory({});
44
34
 
35
+ // Finally register the global hljs with AMD.
45
36
  if (typeof define === 'function' && define.amd) {
46
37
  define([], function () {
47
38
  return globalObject.hljs;
@@ -51,87 +42,80 @@ https://highlightjs.org/
51
42
  })(function (hljs) {
52
43
  // Convenience variables for build-in objects
53
44
  var ArrayProto = [],
54
- objectKeys = _keys.default; // Global internal variables used within the highlight.js library.
45
+ objectKeys = _keys.default;
55
46
 
47
+ // Global internal variables used within the highlight.js library.
56
48
  var languages = {},
57
- aliases = {}; // Regular expressions used throughout the highlight.js library.
49
+ aliases = {};
58
50
 
51
+ // Regular expressions used throughout the highlight.js library.
59
52
  var noHighlightRe = /^(no-?highlight|plain|text)$/i,
60
- languagePrefixRe = /\blang(?:uage)?-([\w-]+)\b/i,
61
- fixMarkupRe = /((^(<[^>]+>|\t|)+|(?:\n)))/gm; // The object will be assigned by the build tool. It used to synchronize API
62
- // of external language files with minified version of the highlight.js library.
53
+ languagePrefixRe = /\blang(?:uage)?-([\w-]+)\b/i,
54
+ fixMarkupRe = /((^(<[^>]+>|\t|)+|(?:\n)))/gm;
63
55
 
56
+ // The object will be assigned by the build tool. It used to synchronize API
57
+ // of external language files with minified version of the highlight.js library.
64
58
  var API_REPLACES;
65
- var spanEndTag = '</span>'; // Global options used when within external APIs. This is modified when
66
- // calling the `hljs.configure` function.
59
+ var spanEndTag = '</span>';
67
60
 
61
+ // Global options used when within external APIs. This is modified when
62
+ // calling the `hljs.configure` function.
68
63
  var options = {
69
64
  classPrefix: 'hljs-',
70
65
  tabReplace: null,
71
66
  useBR: false,
72
67
  languages: undefined
73
68
  };
69
+
74
70
  /* Utility functions */
75
71
 
76
72
  function escape(value) {
77
73
  return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
78
74
  }
79
-
80
75
  function tag(node) {
81
76
  return node.nodeName.toLowerCase();
82
77
  }
83
-
84
78
  function testRe(re, lexeme) {
85
79
  var match = re && re.exec(lexeme);
86
80
  return match && match.index === 0;
87
81
  }
88
-
89
82
  function isNotHighlighted(language) {
90
83
  return noHighlightRe.test(language);
91
84
  }
92
-
93
85
  function blockLanguage(block) {
94
86
  var i, match, length, _class;
95
-
96
87
  var classes = block.className + ' ';
97
- classes += block.parentNode ? block.parentNode.className : ''; // language-* takes precedence over non-prefixed class names.
88
+ classes += block.parentNode ? block.parentNode.className : '';
98
89
 
90
+ // language-* takes precedence over non-prefixed class names.
99
91
  match = languagePrefixRe.exec(classes);
100
-
101
92
  if (match) {
102
93
  return getLanguage(match[1]) ? match[1] : 'no-highlight';
103
94
  }
104
-
105
95
  classes = classes.split(/\s+/);
106
-
107
96
  for (i = 0, length = classes.length; i < length; i++) {
108
97
  _class = classes[i];
109
-
110
98
  if (isNotHighlighted(_class) || getLanguage(_class)) {
111
99
  return _class;
112
100
  }
113
101
  }
114
102
  }
115
-
116
103
  function inherit(parent) {
117
104
  // inherit(parent, override_obj, override_obj, ...)
118
105
  var key;
119
106
  var result = {};
120
107
  var objects = (0, _slice.default)(Array.prototype).call(arguments, 1);
121
-
122
108
  for (key in parent) result[key] = parent[key];
123
-
124
109
  (0, _forEach.default)(objects).call(objects, function (obj) {
125
110
  for (key in obj) result[key] = obj[key];
126
111
  });
127
112
  return result;
128
113
  }
129
- /* Stream merging */
130
114
 
115
+ /* Stream merging */
131
116
 
132
117
  function nodeStream(node) {
133
118
  var result = [];
134
-
135
119
  (function _nodeStream(node, offset) {
136
120
  for (var child = node.firstChild; child; child = child.nextSibling) {
137
121
  if (child.nodeType === 3) offset += child.nodeValue.length;else if (child.nodeType === 1) {
@@ -140,10 +124,10 @@ https://highlightjs.org/
140
124
  offset: offset,
141
125
  node: child
142
126
  });
143
- offset = _nodeStream(child, offset); // Prevent void elements from having an end tag that would actually
127
+ offset = _nodeStream(child, offset);
128
+ // Prevent void elements from having an end tag that would actually
144
129
  // double them in the output. There are more void elements in HTML
145
130
  // but we list only those realistically expected in code display.
146
-
147
131
  if (!tag(child).match(/br|hr|img|input/)) {
148
132
  result.push({
149
133
  event: 'stop',
@@ -153,26 +137,22 @@ https://highlightjs.org/
153
137
  }
154
138
  }
155
139
  }
156
-
157
140
  return offset;
158
141
  })(node, 0);
159
-
160
142
  return result;
161
143
  }
162
-
163
144
  function mergeStreams(original, highlighted, value) {
164
145
  var processed = 0;
165
146
  var result = '';
166
147
  var nodeStack = [];
167
-
168
148
  function selectStream() {
169
149
  if (!original.length || !highlighted.length) {
170
150
  return original.length ? original : highlighted;
171
151
  }
172
-
173
152
  if (original[0].offset !== highlighted[0].offset) {
174
153
  return original[0].offset < highlighted[0].offset ? original : highlighted;
175
154
  }
155
+
176
156
  /*
177
157
  To avoid starting the stream just before it should stop the order is
178
158
  ensured that original always starts first and closes last:
@@ -186,35 +166,26 @@ https://highlightjs.org/
186
166
  return highlighted;
187
167
  ... which is collapsed to:
188
168
  */
189
-
190
-
191
169
  return highlighted[0].event === 'start' ? original : highlighted;
192
170
  }
193
-
194
171
  function open(node) {
195
172
  function attr_str(a) {
196
173
  return ' ' + a.nodeName + '="' + escape(a.value).replace('"', '&quot;') + '"';
197
174
  }
198
-
199
175
  result += '<' + tag(node) + (0, _map.default)(ArrayProto).call(node.attributes, attr_str).join('') + '>';
200
176
  }
201
-
202
177
  function close(node) {
203
178
  result += '</' + tag(node) + '>';
204
179
  }
205
-
206
180
  function render(event) {
207
181
  (event.event === 'start' ? open : close)(event.node);
208
182
  }
209
-
210
183
  while (original.length || highlighted.length) {
211
184
  var stream = selectStream();
212
185
  result += escape(value.substring(processed, stream[0].offset));
213
186
  processed = stream[0].offset;
214
-
215
187
  if (stream === original) {
216
188
  var _context, _context2;
217
-
218
189
  /*
219
190
  On any opening or closing tag of the original markup we first close
220
191
  the entire highlighted node stack, then render the original tag along
@@ -222,12 +193,10 @@ https://highlightjs.org/
222
193
  reopen all the tags on the highlighted stack.
223
194
  */
224
195
  (0, _forEach.default)(_context = (0, _reverse.default)(nodeStack).call(nodeStack)).call(_context, close);
225
-
226
196
  do {
227
197
  render((0, _splice.default)(stream).call(stream, 0, 1)[0]);
228
198
  stream = selectStream();
229
199
  } while (stream === original && stream.length && stream[0].offset === processed);
230
-
231
200
  (0, _forEach.default)(_context2 = (0, _reverse.default)(nodeStack).call(nodeStack)).call(_context2, open);
232
201
  } else {
233
202
  if (stream[0].event === 'start') {
@@ -235,53 +204,43 @@ https://highlightjs.org/
235
204
  } else {
236
205
  nodeStack.pop();
237
206
  }
238
-
239
207
  render((0, _splice.default)(stream).call(stream, 0, 1)[0]);
240
208
  }
241
209
  }
242
-
243
210
  return result + escape(value.substr(processed));
244
211
  }
245
- /* Initialization */
246
212
 
213
+ /* Initialization */
247
214
 
248
215
  function expand_mode(mode) {
249
216
  if (mode.variants && !mode.cached_variants) {
250
217
  var _context3;
251
-
252
218
  mode.cached_variants = (0, _map.default)(_context3 = mode.variants).call(_context3, function (variant) {
253
219
  return inherit(mode, {
254
220
  variants: null
255
221
  }, variant);
256
222
  });
257
223
  }
258
-
259
224
  return mode.cached_variants || mode.endsWithParent && [inherit(mode)] || [mode];
260
225
  }
261
-
262
226
  function restoreLanguageApi(obj) {
263
227
  if (API_REPLACES && !obj.langApiRestored) {
264
228
  var _context4, _context5;
265
-
266
229
  obj.langApiRestored = true;
267
-
268
230
  for (var key in API_REPLACES) obj[key] && (obj[API_REPLACES[key]] = obj[key]);
269
-
270
231
  (0, _forEach.default)(_context4 = (0, _concat.default)(_context5 = obj.contains || []).call(_context5, obj.variants || [])).call(_context4, restoreLanguageApi);
271
232
  }
272
233
  }
273
-
274
234
  function compileLanguage(language) {
275
235
  function reStr(re) {
276
236
  return re && re.source || re;
277
237
  }
278
-
279
238
  function langRe(value, global) {
280
239
  return new RegExp(reStr(value), 'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : ''));
281
- } // joinRe logically computes regexps.join(separator), but fixes the
282
- // backreferences so they continue to match.
283
-
240
+ }
284
241
 
242
+ // joinRe logically computes regexps.join(separator), but fixes the
243
+ // backreferences so they continue to match.
285
244
  function joinRe(regexps, separator) {
286
245
  // backreferenceRe matches an open parenthesis or backreference. To avoid
287
246
  // an incorrect parse, it additionally matches the following:
@@ -293,86 +252,66 @@ https://highlightjs.org/
293
252
  var backreferenceRe = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
294
253
  var numCaptures = 0;
295
254
  var ret = '';
296
-
297
255
  for (var i = 0; i < regexps.length; i++) {
298
256
  var offset = numCaptures;
299
257
  var re = reStr(regexps[i]);
300
-
301
258
  if (i > 0) {
302
259
  ret += separator;
303
260
  }
304
-
305
261
  while (re.length > 0) {
306
262
  var match = backreferenceRe.exec(re);
307
-
308
263
  if (match == null) {
309
264
  ret += re;
310
265
  break;
311
266
  }
312
-
313
267
  ret += re.substring(0, match.index);
314
268
  re = re.substring(match.index + match[0].length);
315
-
316
269
  if (match[0][0] == '\\' && match[1]) {
317
270
  // Adjust the backreference.
318
271
  ret += '\\' + String(Number(match[1]) + offset);
319
272
  } else {
320
273
  ret += match[0];
321
-
322
274
  if (match[0] == '(') {
323
275
  numCaptures++;
324
276
  }
325
277
  }
326
278
  }
327
279
  }
328
-
329
280
  return ret;
330
281
  }
331
-
332
282
  function compileMode(mode, parent) {
333
283
  var _context8, _context9, _context10, _context11, _context12, _context13;
334
-
335
284
  if (mode.compiled) return;
336
285
  mode.compiled = true;
337
286
  mode.keywords = mode.keywords || mode.beginKeywords;
338
-
339
287
  if (mode.keywords) {
340
288
  var compiled_keywords = {};
341
-
342
289
  var flatten = function (className, str) {
343
290
  var _context6;
344
-
345
291
  if (language.case_insensitive) {
346
292
  str = str.toLowerCase();
347
293
  }
348
-
349
294
  (0, _forEach.default)(_context6 = str.split(' ')).call(_context6, function (kw) {
350
295
  var pair = kw.split('|');
351
296
  compiled_keywords[pair[0]] = [className, pair[1] ? Number(pair[1]) : 1];
352
297
  });
353
298
  };
354
-
355
299
  if (typeof mode.keywords === 'string') {
356
300
  // string
357
301
  flatten('keyword', mode.keywords);
358
302
  } else {
359
303
  var _context7;
360
-
361
304
  (0, _forEach.default)(_context7 = objectKeys(mode.keywords)).call(_context7, function (className) {
362
305
  flatten(className, mode.keywords[className]);
363
306
  });
364
307
  }
365
-
366
308
  mode.keywords = compiled_keywords;
367
309
  }
368
-
369
310
  mode.lexemesRe = langRe(mode.lexemes || /\w+/, true);
370
-
371
311
  if (parent) {
372
312
  if (mode.beginKeywords) {
373
313
  mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')\\b';
374
314
  }
375
-
376
315
  if (!mode.begin) mode.begin = /\B|\b/;
377
316
  mode.beginRe = langRe(mode.begin);
378
317
  if (mode.endSameAsBegin) mode.end = mode.begin;
@@ -381,39 +320,32 @@ https://highlightjs.org/
381
320
  mode.terminator_end = reStr(mode.end) || '';
382
321
  if (mode.endsWithParent && parent.terminator_end) mode.terminator_end += (mode.end ? '|' : '') + parent.terminator_end;
383
322
  }
384
-
385
323
  if (mode.illegal) mode.illegalRe = langRe(mode.illegal);
386
324
  if (mode.relevance == null) mode.relevance = 1;
387
-
388
325
  if (!mode.contains) {
389
326
  mode.contains = [];
390
327
  }
391
-
392
328
  mode.contains = (0, _concat.default)(Array.prototype).apply([], (0, _map.default)(_context8 = mode.contains).call(_context8, function (c) {
393
329
  return expand_mode(c === 'self' ? mode : c);
394
330
  }));
395
331
  (0, _forEach.default)(_context9 = mode.contains).call(_context9, function (c) {
396
332
  compileMode(c, mode);
397
333
  });
398
-
399
334
  if (mode.starts) {
400
335
  compileMode(mode.starts, parent);
401
336
  }
402
-
403
337
  var terminators = (0, _filter.default)(_context10 = (0, _map.default)(_context11 = (0, _concat.default)(_context12 = (0, _map.default)(_context13 = mode.contains).call(_context13, function (c) {
404
338
  return c.beginKeywords ? '\\.?(?:' + c.begin + ')\\.?' : c.begin;
405
339
  })).call(_context12, [mode.terminator_end, mode.illegal])).call(_context11, reStr)).call(_context10, Boolean);
406
340
  mode.terminators = terminators.length ? langRe(joinRe(terminators, '|'), true) : {
407
- exec: function
408
- /*s*/
409
- () {
341
+ exec: function /*s*/ () {
410
342
  return null;
411
343
  }
412
344
  };
413
345
  }
414
-
415
346
  compileMode(language);
416
347
  }
348
+
417
349
  /*
418
350
  Core highlighting function. Accepts a language name, or an alias, and a
419
351
  string with the code to highlight. Returns an object with the following
@@ -421,59 +353,47 @@ https://highlightjs.org/
421
353
  - relevance (int)
422
354
  - value (an HTML string with highlighting markup)
423
355
  */
424
-
425
-
426
356
  function highlight(name, value, ignore_illegals, continuation) {
427
357
  function escapeRe(value) {
428
358
  return new RegExp(value.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'm');
429
359
  }
430
-
431
360
  function subMode(lexeme, mode) {
432
361
  var i, length;
433
-
434
362
  for (i = 0, length = mode.contains.length; i < length; i++) {
435
363
  if (testRe(mode.contains[i].beginRe, lexeme)) {
436
364
  if (mode.contains[i].endSameAsBegin) {
437
365
  mode.contains[i].endRe = escapeRe(mode.contains[i].beginRe.exec(lexeme)[0]);
438
366
  }
439
-
440
367
  return mode.contains[i];
441
368
  }
442
369
  }
443
370
  }
444
-
445
371
  function endOfMode(mode, lexeme) {
446
372
  if (testRe(mode.endRe, lexeme)) {
447
373
  while (mode.endsParent && mode.parent) {
448
374
  mode = mode.parent;
449
375
  }
450
-
451
376
  return mode;
452
377
  }
453
-
454
378
  if (mode.endsWithParent) {
455
379
  return endOfMode(mode.parent, lexeme);
456
380
  }
457
381
  }
458
-
459
382
  function isIllegal(lexeme, mode) {
460
383
  return !ignore_illegals && testRe(mode.illegalRe, lexeme);
461
384
  }
462
-
463
385
  function keywordMatch(mode, match) {
464
386
  var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0];
465
387
  return mode.keywords.hasOwnProperty(match_str) && mode.keywords[match_str];
466
388
  }
467
-
468
389
  function buildSpan(classname, insideSpan, leaveOpen, noPrefix) {
469
390
  var classPrefix = noPrefix ? '' : options.classPrefix,
470
- openSpan = '<span class="' + classPrefix,
471
- closeSpan = leaveOpen ? '' : spanEndTag;
391
+ openSpan = '<span class="' + classPrefix,
392
+ closeSpan = leaveOpen ? '' : spanEndTag;
472
393
  openSpan += classname + '">';
473
394
  if (!classname) return insideSpan;
474
395
  return openSpan + insideSpan + closeSpan;
475
396
  }
476
-
477
397
  function processKeywords() {
478
398
  var keyword_match, last_index, match, result;
479
399
  if (!top.keywords) return escape(mode_buffer);
@@ -481,53 +401,43 @@ https://highlightjs.org/
481
401
  last_index = 0;
482
402
  top.lexemesRe.lastIndex = 0;
483
403
  match = top.lexemesRe.exec(mode_buffer);
484
-
485
404
  while (match) {
486
405
  result += escape(mode_buffer.substring(last_index, match.index));
487
406
  keyword_match = keywordMatch(top, match);
488
-
489
407
  if (keyword_match) {
490
408
  relevance += keyword_match[1];
491
409
  result += buildSpan(keyword_match[0], escape(match[0]));
492
410
  } else {
493
411
  result += escape(match[0]);
494
412
  }
495
-
496
413
  last_index = top.lexemesRe.lastIndex;
497
414
  match = top.lexemesRe.exec(mode_buffer);
498
415
  }
499
-
500
416
  return result + escape(mode_buffer.substr(last_index));
501
417
  }
502
-
503
418
  function processSubLanguage() {
504
419
  var explicit = typeof top.subLanguage === 'string';
505
-
506
420
  if (explicit && !languages[top.subLanguage]) {
507
421
  return escape(mode_buffer);
508
422
  }
423
+ var result = explicit ? highlight(top.subLanguage, mode_buffer, true, continuations[top.subLanguage]) : highlightAuto(mode_buffer, top.subLanguage.length ? top.subLanguage : undefined);
509
424
 
510
- 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
425
+ // Counting embedded language score towards the host language may be disabled
511
426
  // with zeroing the containing mode relevance. Usecase in point is Markdown that
512
427
  // allows XML everywhere and makes every XML snippet to have a much larger Markdown
513
428
  // score.
514
-
515
429
  if (top.relevance > 0) {
516
430
  relevance += result.relevance;
517
431
  }
518
-
519
432
  if (explicit) {
520
433
  continuations[top.subLanguage] = result.top;
521
434
  }
522
-
523
435
  return buildSpan(result.language, result.value, false, true);
524
436
  }
525
-
526
437
  function processBuffer() {
527
438
  result += top.subLanguage != null ? processSubLanguage() : processKeywords();
528
439
  mode_buffer = '';
529
440
  }
530
-
531
441
  function startNewMode(mode) {
532
442
  result += mode.className ? buildSpan(mode.className, '', true) : '';
533
443
  top = (0, _create.default)(mode, {
@@ -536,17 +446,13 @@ https://highlightjs.org/
536
446
  }
537
447
  });
538
448
  }
539
-
540
449
  function processLexeme(buffer, lexeme) {
541
450
  mode_buffer += buffer;
542
-
543
451
  if (lexeme == null) {
544
452
  processBuffer();
545
453
  return 0;
546
454
  }
547
-
548
455
  var new_mode = subMode(lexeme, top);
549
-
550
456
  if (new_mode) {
551
457
  if (new_mode.skip) {
552
458
  mode_buffer += lexeme;
@@ -554,98 +460,75 @@ https://highlightjs.org/
554
460
  if (new_mode.excludeBegin) {
555
461
  mode_buffer += lexeme;
556
462
  }
557
-
558
463
  processBuffer();
559
-
560
464
  if (!new_mode.returnBegin && !new_mode.excludeBegin) {
561
465
  mode_buffer = lexeme;
562
466
  }
563
467
  }
564
-
565
468
  startNewMode(new_mode, lexeme);
566
469
  return new_mode.returnBegin ? 0 : lexeme.length;
567
470
  }
568
-
569
471
  var end_mode = endOfMode(top, lexeme);
570
-
571
472
  if (end_mode) {
572
473
  var origin = top;
573
-
574
474
  if (origin.skip) {
575
475
  mode_buffer += lexeme;
576
476
  } else {
577
477
  if (!(origin.returnEnd || origin.excludeEnd)) {
578
478
  mode_buffer += lexeme;
579
479
  }
580
-
581
480
  processBuffer();
582
-
583
481
  if (origin.excludeEnd) {
584
482
  mode_buffer = lexeme;
585
483
  }
586
484
  }
587
-
588
485
  do {
589
486
  if (top.className) {
590
487
  result += spanEndTag;
591
488
  }
592
-
593
489
  if (!top.skip && !top.subLanguage) {
594
490
  relevance += top.relevance;
595
491
  }
596
-
597
492
  top = top.parent;
598
493
  } while (top !== end_mode.parent);
599
-
600
494
  if (end_mode.starts) {
601
495
  if (end_mode.endSameAsBegin) {
602
496
  end_mode.starts.endRe = end_mode.endRe;
603
497
  }
604
-
605
498
  startNewMode(end_mode.starts, '');
606
499
  }
607
-
608
500
  return origin.returnEnd ? 0 : lexeme.length;
609
501
  }
610
-
611
502
  if (isIllegal(lexeme, top)) throw new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || '<unnamed>') + '"');
503
+
612
504
  /*
613
505
  Parser should not reach this point as all types of lexemes should be caught
614
506
  earlier, but if it does due to some bug make sure it advances at least one
615
507
  character forward to prevent infinite looping.
616
508
  */
617
-
618
509
  mode_buffer += lexeme;
619
510
  return lexeme.length || 1;
620
511
  }
621
-
622
512
  var language = getLanguage(name);
623
-
624
513
  if (!language) {
625
514
  throw new Error('Unknown language: "' + name + '"');
626
515
  }
627
-
628
516
  compileLanguage(language);
629
517
  var top = continuation || language;
630
518
  var continuations = {}; // keep continuations for sub-languages
631
-
632
519
  var result = '',
633
- current;
634
-
520
+ current;
635
521
  for (current = top; current !== language; current = current.parent) {
636
522
  if (current.className) {
637
523
  result = buildSpan(current.className, '', true) + result;
638
524
  }
639
525
  }
640
-
641
526
  var mode_buffer = '';
642
527
  var relevance = 0;
643
-
644
528
  try {
645
529
  var match,
646
- count,
647
- index = 0;
648
-
530
+ count,
531
+ index = 0;
649
532
  while (true) {
650
533
  top.terminators.lastIndex = index;
651
534
  match = top.terminators.exec(value);
@@ -653,16 +536,13 @@ https://highlightjs.org/
653
536
  count = processLexeme(value.substring(index, match.index), match[0]);
654
537
  index = match.index + count;
655
538
  }
656
-
657
539
  processLexeme(value.substr(index));
658
-
659
540
  for (current = top; current.parent; current = current.parent) {
660
541
  // close dangling modes
661
542
  if (current.className) {
662
543
  result += spanEndTag;
663
544
  }
664
545
  }
665
-
666
546
  return {
667
547
  relevance: relevance,
668
548
  value: result,
@@ -671,7 +551,6 @@ https://highlightjs.org/
671
551
  };
672
552
  } catch (e) {
673
553
  var _context14;
674
-
675
554
  if (e.message && (0, _indexOf.default)(_context14 = e.message).call(_context14, 'Illegal') !== -1) {
676
555
  return {
677
556
  relevance: 0,
@@ -682,6 +561,7 @@ https://highlightjs.org/
682
561
  }
683
562
  }
684
563
  }
564
+
685
565
  /*
686
566
  Highlighting with language detection. Accepts a string with the code to
687
567
  highlight. Returns an object with the following properties:
@@ -691,11 +571,8 @@ https://highlightjs.org/
691
571
  - second_best (object with the same structure for second-best heuristically
692
572
  detected language, may be absent)
693
573
  */
694
-
695
-
696
574
  function highlightAuto(text, languageSubset) {
697
575
  var _context15, _context16;
698
-
699
576
  languageSubset = languageSubset || options.languages || objectKeys(languages);
700
577
  var result = {
701
578
  relevance: 0,
@@ -705,30 +582,25 @@ https://highlightjs.org/
705
582
  (0, _forEach.default)(_context15 = (0, _filter.default)(_context16 = (0, _filter.default)(languageSubset).call(languageSubset, getLanguage)).call(_context16, autoDetection)).call(_context15, function (name) {
706
583
  var current = highlight(name, text, false);
707
584
  current.language = name;
708
-
709
585
  if (current.relevance > second_best.relevance) {
710
586
  second_best = current;
711
587
  }
712
-
713
588
  if (current.relevance > result.relevance) {
714
589
  second_best = result;
715
590
  result = current;
716
591
  }
717
592
  });
718
-
719
593
  if (second_best.language) {
720
594
  result.second_best = second_best;
721
595
  }
722
-
723
596
  return result;
724
597
  }
598
+
725
599
  /*
726
600
  Post-processing of the highlighted markup:
727
601
  - replace TABs with something more useful
728
602
  - replace real line-breaks with '<br>' for non-pre containers
729
603
  */
730
-
731
-
732
604
  function fixMarkup(value) {
733
605
  return !(options.tabReplace || options.useBR) ? value : value.replace(fixMarkupRe, function (match, p1) {
734
606
  if (options.useBR && match === '\n') {
@@ -736,55 +608,44 @@ https://highlightjs.org/
736
608
  } else if (options.tabReplace) {
737
609
  return p1.replace(/\t/g, options.tabReplace);
738
610
  }
739
-
740
611
  return '';
741
612
  });
742
613
  }
743
-
744
614
  function buildClassName(prevClassName, currentLang, resultLang) {
745
615
  var _context17;
746
-
747
616
  var language = currentLang ? aliases[currentLang] : resultLang,
748
- result = [(0, _trim.default)(prevClassName).call(prevClassName)];
749
-
617
+ result = [(0, _trim.default)(prevClassName).call(prevClassName)];
750
618
  if (!prevClassName.match(/\bhljs\b/)) {
751
619
  result.push('hljs');
752
620
  }
753
-
754
621
  if ((0, _indexOf.default)(prevClassName).call(prevClassName, language) === -1) {
755
622
  result.push(language);
756
623
  }
757
-
758
624
  return (0, _trim.default)(_context17 = result.join(' ')).call(_context17);
759
625
  }
626
+
760
627
  /*
761
628
  Applies highlighting to a DOM node containing code. Accepts a DOM node and
762
629
  two optional parameters for fixMarkup.
763
630
  */
764
-
765
-
766
631
  function highlightBlock(block) {
767
632
  var node, originalStream, result, resultNode, text;
768
633
  var language = blockLanguage(block);
769
634
  if (isNotHighlighted(language)) return;
770
-
771
635
  if (options.useBR) {
772
636
  node = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
773
637
  node.innerHTML = block.innerHTML.replace(/\n/g, '').replace(/<br[ \/]*>/g, '\n');
774
638
  } else {
775
639
  node = block;
776
640
  }
777
-
778
641
  text = node.textContent;
779
642
  result = language ? highlight(language, text, true) : highlightAuto(text);
780
643
  originalStream = nodeStream(node);
781
-
782
644
  if (originalStream.length) {
783
645
  resultNode = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
784
646
  resultNode.innerHTML = result.value;
785
647
  result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
786
648
  }
787
-
788
649
  result.value = fixMarkup(result.value);
789
650
  block.innerHTML = result.value;
790
651
  block.className = buildClassName(block.className, language, result.language);
@@ -792,7 +653,6 @@ https://highlightjs.org/
792
653
  language: result.language,
793
654
  re: result.relevance
794
655
  };
795
-
796
656
  if (result.second_best) {
797
657
  block.second_best = {
798
658
  language: result.second_best.language,
@@ -800,63 +660,54 @@ https://highlightjs.org/
800
660
  };
801
661
  }
802
662
  }
663
+
803
664
  /*
804
665
  Updates highlight.js global options with values passed in the form of an object.
805
666
  */
806
-
807
-
808
667
  function configure(user_options) {
809
668
  options = inherit(options, user_options);
810
669
  }
670
+
811
671
  /*
812
672
  Applies highlighting to all <pre><code>..</code></pre> blocks on a page.
813
673
  */
814
-
815
-
816
674
  function initHighlighting() {
817
675
  if (initHighlighting.called) return;
818
676
  initHighlighting.called = true;
819
677
  var blocks = document.querySelectorAll('pre code');
820
678
  (0, _forEach.default)(ArrayProto).call(blocks, highlightBlock);
821
679
  }
680
+
822
681
  /*
823
682
  Attaches highlighting to the page load event.
824
683
  */
825
-
826
-
827
684
  function initHighlightingOnLoad() {
828
685
  addEventListener('DOMContentLoaded', initHighlighting, false);
829
686
  addEventListener('load', initHighlighting, false);
830
687
  }
831
-
832
688
  function registerLanguage(name, language) {
833
689
  var lang = languages[name] = language(hljs);
834
690
  restoreLanguageApi(lang);
835
-
836
691
  if (lang.aliases) {
837
692
  var _context18;
838
-
839
693
  (0, _forEach.default)(_context18 = lang.aliases).call(_context18, function (alias) {
840
694
  aliases[alias] = name;
841
695
  });
842
696
  }
843
697
  }
844
-
845
698
  function listLanguages() {
846
699
  return objectKeys(languages);
847
700
  }
848
-
849
701
  function getLanguage(name) {
850
702
  name = (name || '').toLowerCase();
851
703
  return languages[name] || languages[aliases[name]];
852
704
  }
853
-
854
705
  function autoDetection(name) {
855
706
  var lang = getLanguage(name);
856
707
  return lang && !lang.disableAutodetect;
857
708
  }
858
- /* Interface definition */
859
709
 
710
+ /* Interface definition */
860
711
 
861
712
  hljs.highlight = highlight;
862
713
  hljs.highlightAuto = highlightAuto;
@@ -869,17 +720,17 @@ https://highlightjs.org/
869
720
  hljs.listLanguages = listLanguages;
870
721
  hljs.getLanguage = getLanguage;
871
722
  hljs.autoDetection = autoDetection;
872
- hljs.inherit = inherit; // Common regexps
723
+ hljs.inherit = inherit;
873
724
 
725
+ // Common regexps
874
726
  hljs.IDENT_RE = '[a-zA-Z]\\w*';
875
727
  hljs.UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*';
876
728
  hljs.NUMBER_RE = '\\b\\d+(\\.\\d+)?';
877
729
  hljs.C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'; // 0x..., 0..., decimal, float
878
-
879
730
  hljs.BINARY_NUMBER_RE = '\\b(0b[01]+)'; // 0b...
731
+ hljs.RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';
880
732
 
881
- hljs.RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~'; // Common modes
882
-
733
+ // Common modes
883
734
  hljs.BACKSLASH_ESCAPE = {
884
735
  begin: '\\\\[\\s\\S]',
885
736
  relevance: 0
@@ -901,7 +752,6 @@ https://highlightjs.org/
901
752
  hljs.PHRASAL_WORDS_MODE = {
902
753
  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/
903
754
  };
904
-
905
755
  hljs.COMMENT = function (begin, end, inherits) {
906
756
  var mode = hljs.inherit({
907
757
  className: 'comment',
@@ -917,7 +767,6 @@ https://highlightjs.org/
917
767
  });
918
768
  return mode;
919
769
  };
920
-
921
770
  hljs.C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$');
922
771
  hljs.C_BLOCK_COMMENT_MODE = hljs.COMMENT('/\\*', '\\*/');
923
772
  hljs.HASH_COMMENT_MODE = hljs.COMMENT('#', '$');