@canopycanopycanopy/b-ber-markdown-renderer 3.0.8-next.61 → 3.0.8-next.96

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