marked 5.1.2 → 6.0.0
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.
- package/README.md +0 -1
- package/bin/marked.js +0 -0
- package/lib/marked.cjs +1115 -1697
- package/lib/marked.cjs.map +1 -0
- package/lib/marked.d.ts +624 -0
- package/lib/marked.esm.js +693 -1398
- package/lib/marked.esm.js.map +1 -0
- package/lib/marked.umd.js +1097 -1705
- package/lib/marked.umd.js.map +1 -0
- package/marked.min.js +11 -2
- package/package.json +15 -9
- package/src/Hooks.ts +29 -0
- package/src/{Instance.js → Instance.ts} +74 -67
- package/src/{Lexer.js → Lexer.ts} +39 -23
- package/src/MarkedOptions.ts +212 -0
- package/src/{Parser.js → Parser.ts} +40 -34
- package/src/{Renderer.js → Renderer.ts} +34 -70
- package/src/{Slugger.js → Slugger.ts} +8 -12
- package/src/{TextRenderer.js → TextRenderer.ts} +9 -9
- package/src/{Tokenizer.js → Tokenizer.ts} +63 -49
- package/src/Tokens.ts +199 -0
- package/src/{defaults.js → defaults.ts} +9 -4
- package/src/{helpers.js → helpers.ts} +29 -36
- package/src/marked.ts +144 -0
- package/src/{rules.js → rules.ts} +76 -13
- package/src/Hooks.js +0 -26
- package/src/marked.js +0 -91
package/lib/marked.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* marked
|
|
2
|
+
* marked v6.0.0 - a markdown parser
|
|
3
3
|
* Copyright (c) 2011-2023, Christopher Jeffrey. (MIT Licensed)
|
|
4
4
|
* https://github.com/markedjs/marked
|
|
5
5
|
*/
|
|
@@ -9,96 +9,65 @@
|
|
|
9
9
|
* The code in this file is generated from files in ./src/
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
27
|
-
writable: false
|
|
28
|
-
});
|
|
29
|
-
return Constructor;
|
|
30
|
-
}
|
|
31
|
-
function _extends() {
|
|
32
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
33
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
34
|
-
var source = arguments[i];
|
|
35
|
-
for (var key in source) {
|
|
36
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
37
|
-
target[key] = source[key];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return target;
|
|
42
|
-
};
|
|
43
|
-
return _extends.apply(this, arguments);
|
|
44
|
-
}
|
|
45
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
46
|
-
if (!o) return;
|
|
47
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
48
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
49
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
50
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
51
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
52
|
-
}
|
|
53
|
-
function _arrayLikeToArray(arr, len) {
|
|
54
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
55
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
56
|
-
return arr2;
|
|
57
|
-
}
|
|
58
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
59
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
60
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
61
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
62
|
-
if (it) o = it;
|
|
63
|
-
var i = 0;
|
|
64
|
-
return function () {
|
|
65
|
-
if (i >= o.length) return {
|
|
66
|
-
done: true
|
|
67
|
-
};
|
|
68
|
-
return {
|
|
69
|
-
done: false,
|
|
70
|
-
value: o[i++]
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
75
|
-
}
|
|
76
|
-
function _toPrimitive(input, hint) {
|
|
77
|
-
if (typeof input !== "object" || input === null) return input;
|
|
78
|
-
var prim = input[Symbol.toPrimitive];
|
|
79
|
-
if (prim !== undefined) {
|
|
80
|
-
var res = prim.call(input, hint || "default");
|
|
81
|
-
if (typeof res !== "object") return res;
|
|
82
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
83
|
-
}
|
|
84
|
-
return (hint === "string" ? String : Number)(input);
|
|
85
|
-
}
|
|
86
|
-
function _toPropertyKey(arg) {
|
|
87
|
-
var key = _toPrimitive(arg, "string");
|
|
88
|
-
return typeof key === "symbol" ? key : String(key);
|
|
89
|
-
}
|
|
90
|
-
var id = 0;
|
|
91
|
-
function _classPrivateFieldLooseKey(name) {
|
|
92
|
-
return "__private_" + id++ + "_" + name;
|
|
93
|
-
}
|
|
94
|
-
function _classPrivateFieldLooseBase(receiver, privateKey) {
|
|
95
|
-
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
|
|
96
|
-
throw new TypeError("attempted to use private field on non-instance");
|
|
12
|
+
"use strict";
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
97
26
|
}
|
|
98
|
-
return
|
|
99
|
-
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __accessCheck = (obj, member, msg) => {
|
|
31
|
+
if (!member.has(obj))
|
|
32
|
+
throw TypeError("Cannot " + msg);
|
|
33
|
+
};
|
|
34
|
+
var __privateAdd = (obj, member, value) => {
|
|
35
|
+
if (member.has(obj))
|
|
36
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
37
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
38
|
+
};
|
|
39
|
+
var __privateMethod = (obj, member, method) => {
|
|
40
|
+
__accessCheck(obj, member, "access private method");
|
|
41
|
+
return method;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// src/marked.ts
|
|
45
|
+
var marked_exports = {};
|
|
46
|
+
__export(marked_exports, {
|
|
47
|
+
Hooks: () => _Hooks,
|
|
48
|
+
Lexer: () => _Lexer,
|
|
49
|
+
Marked: () => Marked,
|
|
50
|
+
Parser: () => _Parser,
|
|
51
|
+
Renderer: () => _Renderer,
|
|
52
|
+
Slugger: () => _Slugger,
|
|
53
|
+
TextRenderer: () => _TextRenderer,
|
|
54
|
+
Tokenizer: () => _Tokenizer,
|
|
55
|
+
defaults: () => _defaults,
|
|
56
|
+
getDefaults: () => _getDefaults,
|
|
57
|
+
lexer: () => lexer,
|
|
58
|
+
marked: () => marked,
|
|
59
|
+
options: () => options,
|
|
60
|
+
parse: () => parse,
|
|
61
|
+
parseInline: () => parseInline,
|
|
62
|
+
parser: () => parser,
|
|
63
|
+
setOptions: () => setOptions,
|
|
64
|
+
use: () => use,
|
|
65
|
+
walkTokens: () => walkTokens
|
|
66
|
+
});
|
|
67
|
+
module.exports = __toCommonJS(marked_exports);
|
|
100
68
|
|
|
101
|
-
|
|
69
|
+
// src/defaults.ts
|
|
70
|
+
function _getDefaults() {
|
|
102
71
|
return {
|
|
103
72
|
async: false,
|
|
104
73
|
baseUrl: null,
|
|
@@ -106,10 +75,10 @@ function getDefaults() {
|
|
|
106
75
|
extensions: null,
|
|
107
76
|
gfm: true,
|
|
108
77
|
headerIds: true,
|
|
109
|
-
headerPrefix:
|
|
78
|
+
headerPrefix: "",
|
|
110
79
|
highlight: null,
|
|
111
80
|
hooks: null,
|
|
112
|
-
langPrefix:
|
|
81
|
+
langPrefix: "language-",
|
|
113
82
|
mangle: true,
|
|
114
83
|
pedantic: false,
|
|
115
84
|
renderer: null,
|
|
@@ -122,28 +91,24 @@ function getDefaults() {
|
|
|
122
91
|
xhtml: false
|
|
123
92
|
};
|
|
124
93
|
}
|
|
125
|
-
|
|
94
|
+
var _defaults = _getDefaults();
|
|
126
95
|
function changeDefaults(newDefaults) {
|
|
127
|
-
|
|
96
|
+
_defaults = newDefaults;
|
|
128
97
|
}
|
|
129
98
|
|
|
130
|
-
|
|
131
|
-
* Helpers
|
|
132
|
-
*/
|
|
99
|
+
// src/helpers.ts
|
|
133
100
|
var escapeTest = /[&<>"']/;
|
|
134
|
-
var escapeReplace = new RegExp(escapeTest.source,
|
|
101
|
+
var escapeReplace = new RegExp(escapeTest.source, "g");
|
|
135
102
|
var escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
|
|
136
|
-
var escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source,
|
|
103
|
+
var escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, "g");
|
|
137
104
|
var escapeReplacements = {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
'"':
|
|
142
|
-
"'":
|
|
143
|
-
};
|
|
144
|
-
var getEscapeReplacement = function getEscapeReplacement(ch) {
|
|
145
|
-
return escapeReplacements[ch];
|
|
105
|
+
"&": "&",
|
|
106
|
+
"<": "<",
|
|
107
|
+
">": ">",
|
|
108
|
+
'"': """,
|
|
109
|
+
"'": "'"
|
|
146
110
|
};
|
|
111
|
+
var getEscapeReplacement = (ch) => escapeReplacements[ch];
|
|
147
112
|
function escape(html, encode) {
|
|
148
113
|
if (encode) {
|
|
149
114
|
if (escapeTest.test(html)) {
|
|
@@ -157,38 +122,29 @@ function escape(html, encode) {
|
|
|
157
122
|
return html;
|
|
158
123
|
}
|
|
159
124
|
var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* @param {string} html
|
|
163
|
-
*/
|
|
164
125
|
function unescape(html) {
|
|
165
|
-
|
|
166
|
-
return html.replace(unescapeTest, function (_, n) {
|
|
126
|
+
return html.replace(unescapeTest, (_, n) => {
|
|
167
127
|
n = n.toLowerCase();
|
|
168
|
-
if (n ===
|
|
169
|
-
|
|
170
|
-
|
|
128
|
+
if (n === "colon")
|
|
129
|
+
return ":";
|
|
130
|
+
if (n.charAt(0) === "#") {
|
|
131
|
+
return n.charAt(1) === "x" ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
|
|
171
132
|
}
|
|
172
|
-
return
|
|
133
|
+
return "";
|
|
173
134
|
});
|
|
174
135
|
}
|
|
175
136
|
var caret = /(^|[^\[])\^/g;
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* @param {string | RegExp} regex
|
|
179
|
-
* @param {string} opt
|
|
180
|
-
*/
|
|
181
137
|
function edit(regex, opt) {
|
|
182
|
-
regex = typeof regex ===
|
|
183
|
-
opt = opt ||
|
|
184
|
-
|
|
185
|
-
replace:
|
|
186
|
-
val = val.source
|
|
187
|
-
val = val.replace(caret,
|
|
138
|
+
regex = typeof regex === "string" ? regex : regex.source;
|
|
139
|
+
opt = opt || "";
|
|
140
|
+
const obj = {
|
|
141
|
+
replace: (name, val) => {
|
|
142
|
+
val = typeof val === "object" && "source" in val ? val.source : val;
|
|
143
|
+
val = val.replace(caret, "$1");
|
|
188
144
|
regex = regex.replace(name, val);
|
|
189
145
|
return obj;
|
|
190
146
|
},
|
|
191
|
-
getRegex:
|
|
147
|
+
getRegex: () => {
|
|
192
148
|
return new RegExp(regex, opt);
|
|
193
149
|
}
|
|
194
150
|
};
|
|
@@ -196,21 +152,15 @@ function edit(regex, opt) {
|
|
|
196
152
|
}
|
|
197
153
|
var nonWordAndColonTest = /[^\w:]/g;
|
|
198
154
|
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* @param {boolean} sanitize
|
|
202
|
-
* @param {string} base
|
|
203
|
-
* @param {string} href
|
|
204
|
-
*/
|
|
205
155
|
function cleanUrl(sanitize, base, href) {
|
|
206
156
|
if (sanitize) {
|
|
207
|
-
|
|
157
|
+
let prot;
|
|
208
158
|
try {
|
|
209
|
-
prot = decodeURIComponent(unescape(href)).replace(nonWordAndColonTest,
|
|
159
|
+
prot = decodeURIComponent(unescape(href)).replace(nonWordAndColonTest, "").toLowerCase();
|
|
210
160
|
} catch (e) {
|
|
211
161
|
return null;
|
|
212
162
|
}
|
|
213
|
-
if (prot.indexOf(
|
|
163
|
+
if (prot.indexOf("javascript:") === 0 || prot.indexOf("vbscript:") === 0 || prot.indexOf("data:") === 0) {
|
|
214
164
|
return null;
|
|
215
165
|
}
|
|
216
166
|
}
|
|
@@ -218,7 +168,7 @@ function cleanUrl(sanitize, base, href) {
|
|
|
218
168
|
href = resolveUrl(base, href);
|
|
219
169
|
}
|
|
220
170
|
try {
|
|
221
|
-
href = encodeURI(href).replace(/%25/g,
|
|
171
|
+
href = encodeURI(href).replace(/%25/g, "%");
|
|
222
172
|
} catch (e) {
|
|
223
173
|
return null;
|
|
224
174
|
}
|
|
@@ -228,61 +178,43 @@ var baseUrls = {};
|
|
|
228
178
|
var justDomain = /^[^:]+:\/*[^/]*$/;
|
|
229
179
|
var protocol = /^([^:]+:)[\s\S]*$/;
|
|
230
180
|
var domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* @param {string} base
|
|
234
|
-
* @param {string} href
|
|
235
|
-
*/
|
|
236
181
|
function resolveUrl(base, href) {
|
|
237
|
-
if (!baseUrls[
|
|
238
|
-
// we can ignore everything in base after the last slash of its path component,
|
|
239
|
-
// but we might need to add _that_
|
|
240
|
-
// https://tools.ietf.org/html/rfc3986#section-3
|
|
182
|
+
if (!baseUrls[" " + base]) {
|
|
241
183
|
if (justDomain.test(base)) {
|
|
242
|
-
baseUrls[
|
|
184
|
+
baseUrls[" " + base] = base + "/";
|
|
243
185
|
} else {
|
|
244
|
-
baseUrls[
|
|
186
|
+
baseUrls[" " + base] = rtrim(base, "/", true);
|
|
245
187
|
}
|
|
246
188
|
}
|
|
247
|
-
base = baseUrls[
|
|
248
|
-
|
|
249
|
-
if (href.substring(0, 2) ===
|
|
189
|
+
base = baseUrls[" " + base];
|
|
190
|
+
const relativeBase = base.indexOf(":") === -1;
|
|
191
|
+
if (href.substring(0, 2) === "//") {
|
|
250
192
|
if (relativeBase) {
|
|
251
193
|
return href;
|
|
252
194
|
}
|
|
253
|
-
return base.replace(protocol,
|
|
254
|
-
} else if (href.charAt(0) ===
|
|
195
|
+
return base.replace(protocol, "$1") + href;
|
|
196
|
+
} else if (href.charAt(0) === "/") {
|
|
255
197
|
if (relativeBase) {
|
|
256
198
|
return href;
|
|
257
199
|
}
|
|
258
|
-
return base.replace(domain,
|
|
200
|
+
return base.replace(domain, "$1") + href;
|
|
259
201
|
} else {
|
|
260
202
|
return base + href;
|
|
261
203
|
}
|
|
262
204
|
}
|
|
263
|
-
var noopTest = {
|
|
264
|
-
exec: function noopTest() {}
|
|
265
|
-
};
|
|
205
|
+
var noopTest = { exec: () => null };
|
|
266
206
|
function splitCells(tableRow, count) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
// add space before unescaped |
|
|
279
|
-
return ' |';
|
|
280
|
-
}
|
|
281
|
-
}),
|
|
282
|
-
cells = row.split(/ \|/);
|
|
283
|
-
var i = 0;
|
|
284
|
-
|
|
285
|
-
// First/last cell in a row cannot be empty if it has no leading/trailing pipe
|
|
207
|
+
const row = tableRow.replace(/\|/g, (match, offset, str) => {
|
|
208
|
+
let escaped = false, curr = offset;
|
|
209
|
+
while (--curr >= 0 && str[curr] === "\\")
|
|
210
|
+
escaped = !escaped;
|
|
211
|
+
if (escaped) {
|
|
212
|
+
return "|";
|
|
213
|
+
} else {
|
|
214
|
+
return " |";
|
|
215
|
+
}
|
|
216
|
+
}), cells = row.split(/ \|/);
|
|
217
|
+
let i = 0;
|
|
286
218
|
if (!cells[0].trim()) {
|
|
287
219
|
cells.shift();
|
|
288
220
|
}
|
|
@@ -292,35 +224,22 @@ function splitCells(tableRow, count) {
|
|
|
292
224
|
if (cells.length > count) {
|
|
293
225
|
cells.splice(count);
|
|
294
226
|
} else {
|
|
295
|
-
while (cells.length < count)
|
|
227
|
+
while (cells.length < count)
|
|
228
|
+
cells.push("");
|
|
296
229
|
}
|
|
297
230
|
for (; i < cells.length; i++) {
|
|
298
|
-
|
|
299
|
-
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
|
231
|
+
cells[i] = cells[i].trim().replace(/\\\|/g, "|");
|
|
300
232
|
}
|
|
301
233
|
return cells;
|
|
302
234
|
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
306
|
-
* /c*$/ is vulnerable to REDOS.
|
|
307
|
-
*
|
|
308
|
-
* @param {string} str
|
|
309
|
-
* @param {string} c
|
|
310
|
-
* @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
|
|
311
|
-
*/
|
|
312
235
|
function rtrim(str, c, invert) {
|
|
313
|
-
|
|
236
|
+
const l = str.length;
|
|
314
237
|
if (l === 0) {
|
|
315
|
-
return
|
|
238
|
+
return "";
|
|
316
239
|
}
|
|
317
|
-
|
|
318
|
-
// Length of suffix matching the invert condition.
|
|
319
|
-
var suffLen = 0;
|
|
320
|
-
|
|
321
|
-
// Step left until we fail to match the invert condition.
|
|
240
|
+
let suffLen = 0;
|
|
322
241
|
while (suffLen < l) {
|
|
323
|
-
|
|
242
|
+
const currChar = str.charAt(l - suffLen - 1);
|
|
324
243
|
if (currChar === c && !invert) {
|
|
325
244
|
suffLen++;
|
|
326
245
|
} else if (currChar !== c && invert) {
|
|
@@ -335,11 +254,10 @@ function findClosingBracket(str, b) {
|
|
|
335
254
|
if (str.indexOf(b[1]) === -1) {
|
|
336
255
|
return -1;
|
|
337
256
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
i = 0;
|
|
257
|
+
const l = str.length;
|
|
258
|
+
let level = 0, i = 0;
|
|
341
259
|
for (; i < l; i++) {
|
|
342
|
-
if (str[i] ===
|
|
260
|
+
if (str[i] === "\\") {
|
|
343
261
|
i++;
|
|
344
262
|
} else if (str[i] === b[0]) {
|
|
345
263
|
level++;
|
|
@@ -357,267 +275,235 @@ function checkDeprecations(opt, callback) {
|
|
|
357
275
|
return;
|
|
358
276
|
}
|
|
359
277
|
if (callback) {
|
|
360
|
-
console.warn(
|
|
278
|
+
console.warn("marked(): callback is deprecated since version 5.0.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/using_pro#async");
|
|
361
279
|
}
|
|
362
280
|
if (opt.sanitize || opt.sanitizer) {
|
|
363
|
-
console.warn(
|
|
281
|
+
console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options");
|
|
364
282
|
}
|
|
365
|
-
if (opt.highlight || opt.langPrefix !==
|
|
366
|
-
console.warn(
|
|
283
|
+
if (opt.highlight || opt.langPrefix !== "language-") {
|
|
284
|
+
console.warn("marked(): highlight and langPrefix parameters are deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-highlight.");
|
|
367
285
|
}
|
|
368
286
|
if (opt.mangle) {
|
|
369
|
-
console.warn(
|
|
287
|
+
console.warn("marked(): mangle parameter is enabled by default, but is deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-mangle, or disable by setting `{mangle: false}`.");
|
|
370
288
|
}
|
|
371
289
|
if (opt.baseUrl) {
|
|
372
|
-
console.warn(
|
|
290
|
+
console.warn("marked(): baseUrl parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-base-url.");
|
|
373
291
|
}
|
|
374
292
|
if (opt.smartypants) {
|
|
375
|
-
console.warn(
|
|
293
|
+
console.warn("marked(): smartypants parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-smartypants.");
|
|
376
294
|
}
|
|
377
295
|
if (opt.xhtml) {
|
|
378
|
-
console.warn(
|
|
296
|
+
console.warn("marked(): xhtml parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-xhtml.");
|
|
379
297
|
}
|
|
380
298
|
if (opt.headerIds || opt.headerPrefix) {
|
|
381
|
-
console.warn(
|
|
299
|
+
console.warn("marked(): headerIds and headerPrefix parameters enabled by default, but are deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-gfm-heading-id, or disable by setting `{headerIds: false}`.");
|
|
382
300
|
}
|
|
383
301
|
}
|
|
384
302
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
303
|
+
// src/Tokenizer.ts
|
|
304
|
+
function outputLink(cap, link, raw, lexer2) {
|
|
305
|
+
const href = link.href;
|
|
306
|
+
const title = link.title ? escape(link.title) : null;
|
|
307
|
+
const text = cap[1].replace(/\\([\[\]])/g, "$1");
|
|
308
|
+
if (cap[0].charAt(0) !== "!") {
|
|
309
|
+
lexer2.state.inLink = true;
|
|
310
|
+
const token = {
|
|
311
|
+
type: "link",
|
|
312
|
+
raw,
|
|
313
|
+
href,
|
|
314
|
+
title,
|
|
315
|
+
text,
|
|
316
|
+
tokens: lexer2.inlineTokens(text)
|
|
398
317
|
};
|
|
399
|
-
|
|
318
|
+
lexer2.state.inLink = false;
|
|
400
319
|
return token;
|
|
401
320
|
}
|
|
402
321
|
return {
|
|
403
|
-
type:
|
|
404
|
-
raw
|
|
405
|
-
href
|
|
406
|
-
title
|
|
322
|
+
type: "image",
|
|
323
|
+
raw,
|
|
324
|
+
href,
|
|
325
|
+
title,
|
|
407
326
|
text: escape(text)
|
|
408
327
|
};
|
|
409
328
|
}
|
|
410
329
|
function indentCodeCompensation(raw, text) {
|
|
411
|
-
|
|
330
|
+
const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
|
412
331
|
if (matchIndentToCode === null) {
|
|
413
332
|
return text;
|
|
414
333
|
}
|
|
415
|
-
|
|
416
|
-
return text.split(
|
|
417
|
-
|
|
334
|
+
const indentToCode = matchIndentToCode[1];
|
|
335
|
+
return text.split("\n").map((node) => {
|
|
336
|
+
const matchIndentInNode = node.match(/^\s+/);
|
|
418
337
|
if (matchIndentInNode === null) {
|
|
419
338
|
return node;
|
|
420
339
|
}
|
|
421
|
-
|
|
340
|
+
const [indentInNode] = matchIndentInNode;
|
|
422
341
|
if (indentInNode.length >= indentToCode.length) {
|
|
423
342
|
return node.slice(indentToCode.length);
|
|
424
343
|
}
|
|
425
344
|
return node;
|
|
426
|
-
}).join(
|
|
345
|
+
}).join("\n");
|
|
427
346
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
*/
|
|
432
|
-
var Tokenizer = /*#__PURE__*/function () {
|
|
433
|
-
function Tokenizer(options) {
|
|
434
|
-
this.options = options || exports.defaults;
|
|
347
|
+
var _Tokenizer = class {
|
|
348
|
+
constructor(options2) {
|
|
349
|
+
this.options = options2 || _defaults;
|
|
435
350
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
var cap = this.rules.block.newline.exec(src);
|
|
351
|
+
space(src) {
|
|
352
|
+
const cap = this.rules.block.newline.exec(src);
|
|
439
353
|
if (cap && cap[0].length > 0) {
|
|
440
354
|
return {
|
|
441
|
-
type:
|
|
355
|
+
type: "space",
|
|
442
356
|
raw: cap[0]
|
|
443
357
|
};
|
|
444
358
|
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
|
|
359
|
+
}
|
|
360
|
+
code(src) {
|
|
361
|
+
const cap = this.rules.block.code.exec(src);
|
|
448
362
|
if (cap) {
|
|
449
|
-
|
|
363
|
+
const text = cap[0].replace(/^ {1,4}/gm, "");
|
|
450
364
|
return {
|
|
451
|
-
type:
|
|
365
|
+
type: "code",
|
|
452
366
|
raw: cap[0],
|
|
453
|
-
codeBlockStyle:
|
|
454
|
-
text: !this.options.pedantic ? rtrim(text,
|
|
367
|
+
codeBlockStyle: "indented",
|
|
368
|
+
text: !this.options.pedantic ? rtrim(text, "\n") : text
|
|
455
369
|
};
|
|
456
370
|
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
371
|
+
}
|
|
372
|
+
fences(src) {
|
|
373
|
+
const cap = this.rules.block.fences.exec(src);
|
|
460
374
|
if (cap) {
|
|
461
|
-
|
|
462
|
-
|
|
375
|
+
const raw = cap[0];
|
|
376
|
+
const text = indentCodeCompensation(raw, cap[3] || "");
|
|
463
377
|
return {
|
|
464
|
-
type:
|
|
465
|
-
raw
|
|
466
|
-
lang: cap[2] ? cap[2].trim().replace(this.rules.inline._escapes,
|
|
467
|
-
text
|
|
378
|
+
type: "code",
|
|
379
|
+
raw,
|
|
380
|
+
lang: cap[2] ? cap[2].trim().replace(this.rules.inline._escapes, "$1") : cap[2],
|
|
381
|
+
text
|
|
468
382
|
};
|
|
469
383
|
}
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
|
|
384
|
+
}
|
|
385
|
+
heading(src) {
|
|
386
|
+
const cap = this.rules.block.heading.exec(src);
|
|
473
387
|
if (cap) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
// remove trailing #s
|
|
388
|
+
let text = cap[2].trim();
|
|
477
389
|
if (/#$/.test(text)) {
|
|
478
|
-
|
|
390
|
+
const trimmed = rtrim(text, "#");
|
|
479
391
|
if (this.options.pedantic) {
|
|
480
392
|
text = trimmed.trim();
|
|
481
393
|
} else if (!trimmed || / $/.test(trimmed)) {
|
|
482
|
-
// CommonMark requires space before trailing #s
|
|
483
394
|
text = trimmed.trim();
|
|
484
395
|
}
|
|
485
396
|
}
|
|
486
397
|
return {
|
|
487
|
-
type:
|
|
398
|
+
type: "heading",
|
|
488
399
|
raw: cap[0],
|
|
489
400
|
depth: cap[1].length,
|
|
490
|
-
text
|
|
401
|
+
text,
|
|
491
402
|
tokens: this.lexer.inline(text)
|
|
492
403
|
};
|
|
493
404
|
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
|
|
405
|
+
}
|
|
406
|
+
hr(src) {
|
|
407
|
+
const cap = this.rules.block.hr.exec(src);
|
|
497
408
|
if (cap) {
|
|
498
409
|
return {
|
|
499
|
-
type:
|
|
410
|
+
type: "hr",
|
|
500
411
|
raw: cap[0]
|
|
501
412
|
};
|
|
502
413
|
}
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
|
|
414
|
+
}
|
|
415
|
+
blockquote(src) {
|
|
416
|
+
const cap = this.rules.block.blockquote.exec(src);
|
|
506
417
|
if (cap) {
|
|
507
|
-
|
|
508
|
-
|
|
418
|
+
const text = cap[0].replace(/^ *>[ \t]?/gm, "");
|
|
419
|
+
const top = this.lexer.state.top;
|
|
509
420
|
this.lexer.state.top = true;
|
|
510
|
-
|
|
421
|
+
const tokens = this.lexer.blockTokens(text);
|
|
511
422
|
this.lexer.state.top = top;
|
|
512
423
|
return {
|
|
513
|
-
type:
|
|
424
|
+
type: "blockquote",
|
|
514
425
|
raw: cap[0],
|
|
515
|
-
tokens
|
|
516
|
-
text
|
|
426
|
+
tokens,
|
|
427
|
+
text
|
|
517
428
|
};
|
|
518
429
|
}
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
430
|
+
}
|
|
431
|
+
list(src) {
|
|
432
|
+
let cap = this.rules.block.list.exec(src);
|
|
522
433
|
if (cap) {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
type:
|
|
528
|
-
raw:
|
|
434
|
+
let raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine, line, nextLine, rawLine, itemContents, endEarly;
|
|
435
|
+
let bull = cap[1].trim();
|
|
436
|
+
const isordered = bull.length > 1;
|
|
437
|
+
const list = {
|
|
438
|
+
type: "list",
|
|
439
|
+
raw: "",
|
|
529
440
|
ordered: isordered,
|
|
530
|
-
start: isordered ? +bull.slice(0, -1) :
|
|
441
|
+
start: isordered ? +bull.slice(0, -1) : "",
|
|
531
442
|
loose: false,
|
|
532
443
|
items: []
|
|
533
444
|
};
|
|
534
|
-
bull = isordered ?
|
|
445
|
+
bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
|
|
535
446
|
if (this.options.pedantic) {
|
|
536
|
-
bull = isordered ? bull :
|
|
447
|
+
bull = isordered ? bull : "[*+-]";
|
|
537
448
|
}
|
|
538
|
-
|
|
539
|
-
// Get next list item
|
|
540
|
-
var itemRegex = new RegExp("^( {0,3}" + bull + ")((?:[\t ][^\\n]*)?(?:\\n|$))");
|
|
541
|
-
|
|
542
|
-
// Check if current bullet point can start a new List Item
|
|
449
|
+
const itemRegex = new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`);
|
|
543
450
|
while (src) {
|
|
544
451
|
endEarly = false;
|
|
545
452
|
if (!(cap = itemRegex.exec(src))) {
|
|
546
453
|
break;
|
|
547
454
|
}
|
|
548
455
|
if (this.rules.block.hr.test(src)) {
|
|
549
|
-
// End list if bullet was actually HR (possibly move into itemRegex?)
|
|
550
456
|
break;
|
|
551
457
|
}
|
|
552
458
|
raw = cap[0];
|
|
553
459
|
src = src.substring(raw.length);
|
|
554
|
-
line = cap[2].split(
|
|
555
|
-
|
|
556
|
-
});
|
|
557
|
-
nextLine = src.split('\n', 1)[0];
|
|
460
|
+
line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t) => " ".repeat(3 * t.length));
|
|
461
|
+
nextLine = src.split("\n", 1)[0];
|
|
558
462
|
if (this.options.pedantic) {
|
|
559
463
|
indent = 2;
|
|
560
464
|
itemContents = line.trimLeft();
|
|
561
465
|
} else {
|
|
562
|
-
indent = cap[2].search(/[^ ]/);
|
|
563
|
-
indent = indent > 4 ? 1 : indent;
|
|
466
|
+
indent = cap[2].search(/[^ ]/);
|
|
467
|
+
indent = indent > 4 ? 1 : indent;
|
|
564
468
|
itemContents = line.slice(indent);
|
|
565
469
|
indent += cap[1].length;
|
|
566
470
|
}
|
|
567
471
|
blankLine = false;
|
|
568
472
|
if (!line && /^ *$/.test(nextLine)) {
|
|
569
|
-
|
|
570
|
-
raw += nextLine + '\n';
|
|
473
|
+
raw += nextLine + "\n";
|
|
571
474
|
src = src.substring(nextLine.length + 1);
|
|
572
475
|
endEarly = true;
|
|
573
476
|
}
|
|
574
477
|
if (!endEarly) {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
// Check if following lines should be included in List Item
|
|
478
|
+
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`);
|
|
479
|
+
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
|
|
480
|
+
const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
|
|
481
|
+
const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
|
|
581
482
|
while (src) {
|
|
582
|
-
rawLine = src.split(
|
|
483
|
+
rawLine = src.split("\n", 1)[0];
|
|
583
484
|
nextLine = rawLine;
|
|
584
|
-
|
|
585
|
-
// Re-align to follow commonmark nesting rules
|
|
586
485
|
if (this.options.pedantic) {
|
|
587
|
-
nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g,
|
|
486
|
+
nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
|
|
588
487
|
}
|
|
589
|
-
|
|
590
|
-
// End list item if found code fences
|
|
591
488
|
if (fencesBeginRegex.test(nextLine)) {
|
|
592
489
|
break;
|
|
593
490
|
}
|
|
594
|
-
|
|
595
|
-
// End list item if found start of new heading
|
|
596
491
|
if (headingBeginRegex.test(nextLine)) {
|
|
597
492
|
break;
|
|
598
493
|
}
|
|
599
|
-
|
|
600
|
-
// End list item if found start of new bullet
|
|
601
494
|
if (nextBulletRegex.test(nextLine)) {
|
|
602
495
|
break;
|
|
603
496
|
}
|
|
604
|
-
|
|
605
|
-
// Horizontal rule found
|
|
606
497
|
if (hrRegex.test(src)) {
|
|
607
498
|
break;
|
|
608
499
|
}
|
|
609
500
|
if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) {
|
|
610
|
-
|
|
611
|
-
itemContents += '\n' + nextLine.slice(indent);
|
|
501
|
+
itemContents += "\n" + nextLine.slice(indent);
|
|
612
502
|
} else {
|
|
613
|
-
// not enough indentation
|
|
614
503
|
if (blankLine) {
|
|
615
504
|
break;
|
|
616
505
|
}
|
|
617
|
-
|
|
618
|
-
// paragraph continuation unless last line was a different block level element
|
|
619
506
|
if (line.search(/[^ ]/) >= 4) {
|
|
620
|
-
// indented code block
|
|
621
507
|
break;
|
|
622
508
|
}
|
|
623
509
|
if (fencesBeginRegex.test(line)) {
|
|
@@ -629,37 +515,33 @@ var Tokenizer = /*#__PURE__*/function () {
|
|
|
629
515
|
if (hrRegex.test(line)) {
|
|
630
516
|
break;
|
|
631
517
|
}
|
|
632
|
-
itemContents +=
|
|
518
|
+
itemContents += "\n" + nextLine;
|
|
633
519
|
}
|
|
634
520
|
if (!blankLine && !nextLine.trim()) {
|
|
635
|
-
// Check if current line is blank
|
|
636
521
|
blankLine = true;
|
|
637
522
|
}
|
|
638
|
-
raw += rawLine +
|
|
523
|
+
raw += rawLine + "\n";
|
|
639
524
|
src = src.substring(rawLine.length + 1);
|
|
640
525
|
line = nextLine.slice(indent);
|
|
641
526
|
}
|
|
642
527
|
}
|
|
643
528
|
if (!list.loose) {
|
|
644
|
-
// If the previous item ended with a blank line, the list is loose
|
|
645
529
|
if (endsWithBlankLine) {
|
|
646
530
|
list.loose = true;
|
|
647
531
|
} else if (/\n *\n *$/.test(raw)) {
|
|
648
532
|
endsWithBlankLine = true;
|
|
649
533
|
}
|
|
650
534
|
}
|
|
651
|
-
|
|
652
|
-
// Check for task list items
|
|
653
535
|
if (this.options.gfm) {
|
|
654
536
|
istask = /^\[[ xX]\] /.exec(itemContents);
|
|
655
537
|
if (istask) {
|
|
656
|
-
ischecked = istask[0] !==
|
|
657
|
-
itemContents = itemContents.replace(/^\[[ xX]\] +/,
|
|
538
|
+
ischecked = istask[0] !== "[ ] ";
|
|
539
|
+
itemContents = itemContents.replace(/^\[[ xX]\] +/, "");
|
|
658
540
|
}
|
|
659
541
|
}
|
|
660
542
|
list.items.push({
|
|
661
|
-
type:
|
|
662
|
-
raw
|
|
543
|
+
type: "list_item",
|
|
544
|
+
raw,
|
|
663
545
|
task: !!istask,
|
|
664
546
|
checked: ischecked,
|
|
665
547
|
loose: false,
|
|
@@ -667,30 +549,19 @@ var Tokenizer = /*#__PURE__*/function () {
|
|
|
667
549
|
});
|
|
668
550
|
list.raw += raw;
|
|
669
551
|
}
|
|
670
|
-
|
|
671
|
-
// Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
|
|
672
552
|
list.items[list.items.length - 1].raw = raw.trimRight();
|
|
673
553
|
list.items[list.items.length - 1].text = itemContents.trimRight();
|
|
674
554
|
list.raw = list.raw.trimRight();
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
// Item child tokens handled here at end because we needed to have the final item to trim it first
|
|
555
|
+
const l = list.items.length;
|
|
678
556
|
for (i = 0; i < l; i++) {
|
|
679
557
|
this.lexer.state.top = false;
|
|
680
558
|
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
|
|
681
559
|
if (!list.loose) {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
return t.type === 'space';
|
|
685
|
-
});
|
|
686
|
-
var hasMultipleLineBreaks = spacers.length > 0 && spacers.some(function (t) {
|
|
687
|
-
return /\n.*\n/.test(t.raw);
|
|
688
|
-
});
|
|
560
|
+
const spacers = list.items[i].tokens.filter((t) => t.type === "space");
|
|
561
|
+
const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => /\n.*\n/.test(t.raw));
|
|
689
562
|
list.loose = hasMultipleLineBreaks;
|
|
690
563
|
}
|
|
691
564
|
}
|
|
692
|
-
|
|
693
|
-
// Set all items to loose if list is loose
|
|
694
565
|
if (list.loose) {
|
|
695
566
|
for (i = 0; i < l; i++) {
|
|
696
567
|
list.items[i].loose = true;
|
|
@@ -698,87 +569,80 @@ var Tokenizer = /*#__PURE__*/function () {
|
|
|
698
569
|
}
|
|
699
570
|
return list;
|
|
700
571
|
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
|
|
572
|
+
}
|
|
573
|
+
html(src) {
|
|
574
|
+
const cap = this.rules.block.html.exec(src);
|
|
704
575
|
if (cap) {
|
|
705
|
-
|
|
706
|
-
type:
|
|
576
|
+
const token = {
|
|
577
|
+
type: "html",
|
|
707
578
|
block: true,
|
|
708
579
|
raw: cap[0],
|
|
709
|
-
pre: !this.options.sanitizer && (cap[1] ===
|
|
580
|
+
pre: !this.options.sanitizer && (cap[1] === "pre" || cap[1] === "script" || cap[1] === "style"),
|
|
710
581
|
text: cap[0]
|
|
711
582
|
};
|
|
712
583
|
if (this.options.sanitize) {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
584
|
+
const text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
|
|
585
|
+
const paragraph = token;
|
|
586
|
+
paragraph.type = "paragraph";
|
|
587
|
+
paragraph.text = text;
|
|
588
|
+
paragraph.tokens = this.lexer.inline(text);
|
|
717
589
|
}
|
|
718
590
|
return token;
|
|
719
591
|
}
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
|
|
592
|
+
}
|
|
593
|
+
def(src) {
|
|
594
|
+
const cap = this.rules.block.def.exec(src);
|
|
723
595
|
if (cap) {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
596
|
+
const tag = cap[1].toLowerCase().replace(/\s+/g, " ");
|
|
597
|
+
const href = cap[2] ? cap[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline._escapes, "$1") : "";
|
|
598
|
+
const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline._escapes, "$1") : cap[3];
|
|
727
599
|
return {
|
|
728
|
-
type:
|
|
729
|
-
tag
|
|
600
|
+
type: "def",
|
|
601
|
+
tag,
|
|
730
602
|
raw: cap[0],
|
|
731
|
-
href
|
|
732
|
-
title
|
|
603
|
+
href,
|
|
604
|
+
title
|
|
733
605
|
};
|
|
734
606
|
}
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
|
|
607
|
+
}
|
|
608
|
+
table(src) {
|
|
609
|
+
const cap = this.rules.block.table.exec(src);
|
|
738
610
|
if (cap) {
|
|
739
|
-
|
|
740
|
-
type:
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
};
|
|
611
|
+
const item = {
|
|
612
|
+
type: "table",
|
|
613
|
+
// splitCells expects a number as second argument
|
|
614
|
+
// @ts-expect-error
|
|
615
|
+
header: splitCells(cap[1]).map((c) => {
|
|
616
|
+
return { text: c };
|
|
745
617
|
}),
|
|
746
|
-
align: cap[2].replace(/^ *|\| *$/g,
|
|
747
|
-
rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/,
|
|
618
|
+
align: cap[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
|
|
619
|
+
rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : []
|
|
748
620
|
};
|
|
749
621
|
if (item.header.length === item.align.length) {
|
|
750
622
|
item.raw = cap[0];
|
|
751
|
-
|
|
752
|
-
|
|
623
|
+
let l = item.align.length;
|
|
624
|
+
let i, j, k, row;
|
|
753
625
|
for (i = 0; i < l; i++) {
|
|
754
626
|
if (/^ *-+: *$/.test(item.align[i])) {
|
|
755
|
-
item.align[i] =
|
|
627
|
+
item.align[i] = "right";
|
|
756
628
|
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
757
|
-
item.align[i] =
|
|
629
|
+
item.align[i] = "center";
|
|
758
630
|
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
759
|
-
item.align[i] =
|
|
631
|
+
item.align[i] = "left";
|
|
760
632
|
} else {
|
|
761
633
|
item.align[i] = null;
|
|
762
634
|
}
|
|
763
635
|
}
|
|
764
636
|
l = item.rows.length;
|
|
765
637
|
for (i = 0; i < l; i++) {
|
|
766
|
-
item.rows[i] = splitCells(item.rows[i], item.header.length).map(
|
|
767
|
-
return {
|
|
768
|
-
text: c
|
|
769
|
-
};
|
|
638
|
+
item.rows[i] = splitCells(item.rows[i], item.header.length).map((c) => {
|
|
639
|
+
return { text: c };
|
|
770
640
|
});
|
|
771
641
|
}
|
|
772
|
-
|
|
773
|
-
// parse child tokens inside headers and cells
|
|
774
|
-
|
|
775
|
-
// header child tokens
|
|
776
642
|
l = item.header.length;
|
|
777
643
|
for (j = 0; j < l; j++) {
|
|
778
644
|
item.header[j].tokens = this.lexer.inline(item.header[j].text);
|
|
779
645
|
}
|
|
780
|
-
|
|
781
|
-
// cell child tokens
|
|
782
646
|
l = item.rows.length;
|
|
783
647
|
for (j = 0; j < l; j++) {
|
|
784
648
|
row = item.rows[j];
|
|
@@ -789,54 +653,54 @@ var Tokenizer = /*#__PURE__*/function () {
|
|
|
789
653
|
return item;
|
|
790
654
|
}
|
|
791
655
|
}
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
|
|
656
|
+
}
|
|
657
|
+
lheading(src) {
|
|
658
|
+
const cap = this.rules.block.lheading.exec(src);
|
|
795
659
|
if (cap) {
|
|
796
660
|
return {
|
|
797
|
-
type:
|
|
661
|
+
type: "heading",
|
|
798
662
|
raw: cap[0],
|
|
799
|
-
depth: cap[2].charAt(0) ===
|
|
663
|
+
depth: cap[2].charAt(0) === "=" ? 1 : 2,
|
|
800
664
|
text: cap[1],
|
|
801
665
|
tokens: this.lexer.inline(cap[1])
|
|
802
666
|
};
|
|
803
667
|
}
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
|
|
668
|
+
}
|
|
669
|
+
paragraph(src) {
|
|
670
|
+
const cap = this.rules.block.paragraph.exec(src);
|
|
807
671
|
if (cap) {
|
|
808
|
-
|
|
672
|
+
const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
|
|
809
673
|
return {
|
|
810
|
-
type:
|
|
674
|
+
type: "paragraph",
|
|
811
675
|
raw: cap[0],
|
|
812
|
-
text
|
|
676
|
+
text,
|
|
813
677
|
tokens: this.lexer.inline(text)
|
|
814
678
|
};
|
|
815
679
|
}
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
|
|
680
|
+
}
|
|
681
|
+
text(src) {
|
|
682
|
+
const cap = this.rules.block.text.exec(src);
|
|
819
683
|
if (cap) {
|
|
820
684
|
return {
|
|
821
|
-
type:
|
|
685
|
+
type: "text",
|
|
822
686
|
raw: cap[0],
|
|
823
687
|
text: cap[0],
|
|
824
688
|
tokens: this.lexer.inline(cap[0])
|
|
825
689
|
};
|
|
826
690
|
}
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
|
|
691
|
+
}
|
|
692
|
+
escape(src) {
|
|
693
|
+
const cap = this.rules.inline.escape.exec(src);
|
|
830
694
|
if (cap) {
|
|
831
695
|
return {
|
|
832
|
-
type:
|
|
696
|
+
type: "escape",
|
|
833
697
|
raw: cap[0],
|
|
834
698
|
text: escape(cap[1])
|
|
835
699
|
};
|
|
836
700
|
}
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
|
|
701
|
+
}
|
|
702
|
+
tag(src) {
|
|
703
|
+
const cap = this.rules.inline.tag.exec(src);
|
|
840
704
|
if (cap) {
|
|
841
705
|
if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
|
|
842
706
|
this.lexer.state.inLink = true;
|
|
@@ -849,7 +713,7 @@ var Tokenizer = /*#__PURE__*/function () {
|
|
|
849
713
|
this.lexer.state.inRawBlock = false;
|
|
850
714
|
}
|
|
851
715
|
return {
|
|
852
|
-
type: this.options.sanitize ?
|
|
716
|
+
type: this.options.sanitize ? "text" : "html",
|
|
853
717
|
raw: cap[0],
|
|
854
718
|
inLink: this.lexer.state.inLink,
|
|
855
719
|
inRawBlock: this.lexer.state.inRawBlock,
|
|
@@ -857,260 +721,238 @@ var Tokenizer = /*#__PURE__*/function () {
|
|
|
857
721
|
text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0]
|
|
858
722
|
};
|
|
859
723
|
}
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
|
|
724
|
+
}
|
|
725
|
+
link(src) {
|
|
726
|
+
const cap = this.rules.inline.link.exec(src);
|
|
863
727
|
if (cap) {
|
|
864
|
-
|
|
728
|
+
const trimmedUrl = cap[2].trim();
|
|
865
729
|
if (!this.options.pedantic && /^</.test(trimmedUrl)) {
|
|
866
|
-
// commonmark requires matching angle brackets
|
|
867
730
|
if (!/>$/.test(trimmedUrl)) {
|
|
868
731
|
return;
|
|
869
732
|
}
|
|
870
|
-
|
|
871
|
-
// ending angle bracket cannot be escaped
|
|
872
|
-
var rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
|
|
733
|
+
const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
|
|
873
734
|
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
|
|
874
735
|
return;
|
|
875
736
|
}
|
|
876
737
|
} else {
|
|
877
|
-
|
|
878
|
-
var lastParenIndex = findClosingBracket(cap[2], '()');
|
|
738
|
+
const lastParenIndex = findClosingBracket(cap[2], "()");
|
|
879
739
|
if (lastParenIndex > -1) {
|
|
880
|
-
|
|
881
|
-
|
|
740
|
+
const start = cap[0].indexOf("!") === 0 ? 5 : 4;
|
|
741
|
+
const linkLen = start + cap[1].length + lastParenIndex;
|
|
882
742
|
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
883
743
|
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
884
|
-
cap[3] =
|
|
744
|
+
cap[3] = "";
|
|
885
745
|
}
|
|
886
746
|
}
|
|
887
|
-
|
|
888
|
-
|
|
747
|
+
let href = cap[2];
|
|
748
|
+
let title = "";
|
|
889
749
|
if (this.options.pedantic) {
|
|
890
|
-
|
|
891
|
-
var link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
750
|
+
const link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
892
751
|
if (link) {
|
|
893
752
|
href = link[1];
|
|
894
753
|
title = link[3];
|
|
895
754
|
}
|
|
896
755
|
} else {
|
|
897
|
-
title = cap[3] ? cap[3].slice(1, -1) :
|
|
756
|
+
title = cap[3] ? cap[3].slice(1, -1) : "";
|
|
898
757
|
}
|
|
899
758
|
href = href.trim();
|
|
900
759
|
if (/^</.test(href)) {
|
|
901
760
|
if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
|
|
902
|
-
// pedantic allows starting angle bracket without ending angle bracket
|
|
903
761
|
href = href.slice(1);
|
|
904
762
|
} else {
|
|
905
763
|
href = href.slice(1, -1);
|
|
906
764
|
}
|
|
907
765
|
}
|
|
908
766
|
return outputLink(cap, {
|
|
909
|
-
href: href ? href.replace(this.rules.inline._escapes,
|
|
910
|
-
title: title ? title.replace(this.rules.inline._escapes,
|
|
767
|
+
href: href ? href.replace(this.rules.inline._escapes, "$1") : href,
|
|
768
|
+
title: title ? title.replace(this.rules.inline._escapes, "$1") : title
|
|
911
769
|
}, cap[0], this.lexer);
|
|
912
770
|
}
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
|
|
771
|
+
}
|
|
772
|
+
reflink(src, links) {
|
|
773
|
+
let cap;
|
|
916
774
|
if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
|
|
917
|
-
|
|
775
|
+
let link = (cap[2] || cap[1]).replace(/\s+/g, " ");
|
|
918
776
|
link = links[link.toLowerCase()];
|
|
919
777
|
if (!link) {
|
|
920
|
-
|
|
778
|
+
const text = cap[0].charAt(0);
|
|
921
779
|
return {
|
|
922
|
-
type:
|
|
780
|
+
type: "text",
|
|
923
781
|
raw: text,
|
|
924
|
-
text
|
|
782
|
+
text
|
|
925
783
|
};
|
|
926
784
|
}
|
|
927
785
|
return outputLink(cap, link, cap[0], this.lexer);
|
|
928
786
|
}
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
// _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
|
|
938
|
-
if (match[3] && prevChar.match(/(?:[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u0660-\u0669\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09F9\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AE6-\u0AEF\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F\u0B71-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0BE6-\u0BF2\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C66-\u0C6F\u0C78-\u0C7E\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CE6-\u0CEF\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D58-\u0D61\u0D66-\u0D78\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DE6-\u0DEF\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F20-\u0F33\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F-\u1049\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA830-\uA835\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uA9E0-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDE80-\uDE9C\uDEA0-\uDED0\uDEE1-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE40-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE4\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD23\uDD30-\uDD39\uDE60-\uDE7E\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF27\uDF30-\uDF45\uDF51-\uDF54\uDF70-\uDF81\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC52-\uDC6F\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD03-\uDD26\uDD36-\uDD3F\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDD0-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDEF0-\uDEF9\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC50-\uDC59\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE50-\uDE59\uDE80-\uDEAA\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF30-\uDF3B\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDF50-\uDF59\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD834[\uDEC0-\uDED3\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD40-\uDD49\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB\uDEF0-\uDEF9]|\uD839[\uDCD0-\uDCEB\uDCF0-\uDCF9\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCCF\uDD00-\uDD43\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])/)) return;
|
|
939
|
-
var nextChar = match[1] || match[2] || '';
|
|
787
|
+
}
|
|
788
|
+
emStrong(src, maskedSrc, prevChar = "") {
|
|
789
|
+
let match = this.rules.inline.emStrong.lDelim.exec(src);
|
|
790
|
+
if (!match)
|
|
791
|
+
return;
|
|
792
|
+
if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
|
|
793
|
+
return;
|
|
794
|
+
const nextChar = match[1] || match[2] || "";
|
|
940
795
|
if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
delimTotal = lLength,
|
|
945
|
-
midDelimTotal = 0;
|
|
946
|
-
var endReg = match[0][0] === '*' ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
|
|
796
|
+
const lLength = match[0].length - 1;
|
|
797
|
+
let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
|
|
798
|
+
const endReg = match[0][0] === "*" ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
|
|
947
799
|
endReg.lastIndex = 0;
|
|
948
|
-
|
|
949
|
-
// Clip maskedSrc to same section of string as src (move to lexer?)
|
|
950
800
|
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
|
|
951
801
|
while ((match = endReg.exec(maskedSrc)) != null) {
|
|
952
802
|
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
|
|
953
|
-
if (!rDelim)
|
|
954
|
-
|
|
803
|
+
if (!rDelim)
|
|
804
|
+
continue;
|
|
955
805
|
rLength = rDelim.length;
|
|
956
806
|
if (match[3] || match[4]) {
|
|
957
|
-
// found another Left Delim
|
|
958
807
|
delimTotal += rLength;
|
|
959
808
|
continue;
|
|
960
809
|
} else if (match[5] || match[6]) {
|
|
961
|
-
// either Left or Right Delim
|
|
962
810
|
if (lLength % 3 && !((lLength + rLength) % 3)) {
|
|
963
811
|
midDelimTotal += rLength;
|
|
964
|
-
continue;
|
|
812
|
+
continue;
|
|
965
813
|
}
|
|
966
814
|
}
|
|
967
|
-
|
|
968
815
|
delimTotal -= rLength;
|
|
969
|
-
if (delimTotal > 0)
|
|
970
|
-
|
|
971
|
-
// Remove extra characters. *a*** -> *a*
|
|
816
|
+
if (delimTotal > 0)
|
|
817
|
+
continue;
|
|
972
818
|
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
// Create `em` if smallest delimiter has odd char count. *a***
|
|
819
|
+
const raw = src.slice(0, lLength + match.index + rLength + 1);
|
|
976
820
|
if (Math.min(lLength, rLength) % 2) {
|
|
977
|
-
|
|
821
|
+
const text2 = raw.slice(1, -1);
|
|
978
822
|
return {
|
|
979
|
-
type:
|
|
980
|
-
raw
|
|
981
|
-
text:
|
|
982
|
-
tokens: this.lexer.inlineTokens(
|
|
823
|
+
type: "em",
|
|
824
|
+
raw,
|
|
825
|
+
text: text2,
|
|
826
|
+
tokens: this.lexer.inlineTokens(text2)
|
|
983
827
|
};
|
|
984
828
|
}
|
|
985
|
-
|
|
986
|
-
// Create 'strong' if smallest delimiter has even char count. **a***
|
|
987
|
-
var text = raw.slice(2, -2);
|
|
829
|
+
const text = raw.slice(2, -2);
|
|
988
830
|
return {
|
|
989
|
-
type:
|
|
990
|
-
raw
|
|
991
|
-
text
|
|
831
|
+
type: "strong",
|
|
832
|
+
raw,
|
|
833
|
+
text,
|
|
992
834
|
tokens: this.lexer.inlineTokens(text)
|
|
993
835
|
};
|
|
994
836
|
}
|
|
995
837
|
}
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
|
|
838
|
+
}
|
|
839
|
+
codespan(src) {
|
|
840
|
+
const cap = this.rules.inline.code.exec(src);
|
|
999
841
|
if (cap) {
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
842
|
+
let text = cap[2].replace(/\n/g, " ");
|
|
843
|
+
const hasNonSpaceChars = /[^ ]/.test(text);
|
|
844
|
+
const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
|
|
1003
845
|
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
1004
846
|
text = text.substring(1, text.length - 1);
|
|
1005
847
|
}
|
|
1006
848
|
text = escape(text, true);
|
|
1007
849
|
return {
|
|
1008
|
-
type:
|
|
850
|
+
type: "codespan",
|
|
1009
851
|
raw: cap[0],
|
|
1010
|
-
text
|
|
852
|
+
text
|
|
1011
853
|
};
|
|
1012
854
|
}
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
|
|
855
|
+
}
|
|
856
|
+
br(src) {
|
|
857
|
+
const cap = this.rules.inline.br.exec(src);
|
|
1016
858
|
if (cap) {
|
|
1017
859
|
return {
|
|
1018
|
-
type:
|
|
860
|
+
type: "br",
|
|
1019
861
|
raw: cap[0]
|
|
1020
862
|
};
|
|
1021
863
|
}
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
|
|
864
|
+
}
|
|
865
|
+
del(src) {
|
|
866
|
+
const cap = this.rules.inline.del.exec(src);
|
|
1025
867
|
if (cap) {
|
|
1026
868
|
return {
|
|
1027
|
-
type:
|
|
869
|
+
type: "del",
|
|
1028
870
|
raw: cap[0],
|
|
1029
871
|
text: cap[2],
|
|
1030
872
|
tokens: this.lexer.inlineTokens(cap[2])
|
|
1031
873
|
};
|
|
1032
874
|
}
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
|
|
875
|
+
}
|
|
876
|
+
autolink(src, mangle2) {
|
|
877
|
+
const cap = this.rules.inline.autolink.exec(src);
|
|
1036
878
|
if (cap) {
|
|
1037
|
-
|
|
1038
|
-
if (cap[2] ===
|
|
1039
|
-
text = escape(this.options.mangle ?
|
|
1040
|
-
href =
|
|
879
|
+
let text, href;
|
|
880
|
+
if (cap[2] === "@") {
|
|
881
|
+
text = escape(this.options.mangle ? mangle2(cap[1]) : cap[1]);
|
|
882
|
+
href = "mailto:" + text;
|
|
1041
883
|
} else {
|
|
1042
884
|
text = escape(cap[1]);
|
|
1043
885
|
href = text;
|
|
1044
886
|
}
|
|
1045
887
|
return {
|
|
1046
|
-
type:
|
|
888
|
+
type: "link",
|
|
1047
889
|
raw: cap[0],
|
|
1048
|
-
text
|
|
1049
|
-
href
|
|
1050
|
-
tokens: [
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
890
|
+
text,
|
|
891
|
+
href,
|
|
892
|
+
tokens: [
|
|
893
|
+
{
|
|
894
|
+
type: "text",
|
|
895
|
+
raw: text,
|
|
896
|
+
text
|
|
897
|
+
}
|
|
898
|
+
]
|
|
1055
899
|
};
|
|
1056
900
|
}
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
|
|
901
|
+
}
|
|
902
|
+
url(src, mangle2) {
|
|
903
|
+
let cap;
|
|
1060
904
|
if (cap = this.rules.inline.url.exec(src)) {
|
|
1061
|
-
|
|
1062
|
-
if (cap[2] ===
|
|
1063
|
-
text = escape(this.options.mangle ?
|
|
1064
|
-
href =
|
|
905
|
+
let text, href;
|
|
906
|
+
if (cap[2] === "@") {
|
|
907
|
+
text = escape(this.options.mangle ? mangle2(cap[0]) : cap[0]);
|
|
908
|
+
href = "mailto:" + text;
|
|
1065
909
|
} else {
|
|
1066
|
-
|
|
1067
|
-
var prevCapZero;
|
|
910
|
+
let prevCapZero;
|
|
1068
911
|
do {
|
|
1069
912
|
prevCapZero = cap[0];
|
|
1070
913
|
cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
|
|
1071
914
|
} while (prevCapZero !== cap[0]);
|
|
1072
915
|
text = escape(cap[0]);
|
|
1073
|
-
if (cap[1] ===
|
|
1074
|
-
href =
|
|
916
|
+
if (cap[1] === "www.") {
|
|
917
|
+
href = "http://" + cap[0];
|
|
1075
918
|
} else {
|
|
1076
919
|
href = cap[0];
|
|
1077
920
|
}
|
|
1078
921
|
}
|
|
1079
922
|
return {
|
|
1080
|
-
type:
|
|
923
|
+
type: "link",
|
|
1081
924
|
raw: cap[0],
|
|
1082
|
-
text
|
|
1083
|
-
href
|
|
1084
|
-
tokens: [
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
925
|
+
text,
|
|
926
|
+
href,
|
|
927
|
+
tokens: [
|
|
928
|
+
{
|
|
929
|
+
type: "text",
|
|
930
|
+
raw: text,
|
|
931
|
+
text
|
|
932
|
+
}
|
|
933
|
+
]
|
|
1089
934
|
};
|
|
1090
935
|
}
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
|
|
936
|
+
}
|
|
937
|
+
inlineText(src, smartypants2) {
|
|
938
|
+
const cap = this.rules.inline.text.exec(src);
|
|
1094
939
|
if (cap) {
|
|
1095
|
-
|
|
940
|
+
let text;
|
|
1096
941
|
if (this.lexer.state.inRawBlock) {
|
|
1097
942
|
text = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0];
|
|
1098
943
|
} else {
|
|
1099
|
-
text = escape(this.options.smartypants ?
|
|
944
|
+
text = escape(this.options.smartypants ? smartypants2(cap[0]) : cap[0]);
|
|
1100
945
|
}
|
|
1101
946
|
return {
|
|
1102
|
-
type:
|
|
947
|
+
type: "text",
|
|
1103
948
|
raw: cap[0],
|
|
1104
|
-
text
|
|
949
|
+
text
|
|
1105
950
|
};
|
|
1106
951
|
}
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
}();
|
|
952
|
+
}
|
|
953
|
+
};
|
|
1110
954
|
|
|
1111
|
-
|
|
1112
|
-
* Block-Level Grammar
|
|
1113
|
-
*/
|
|
955
|
+
// src/rules.ts
|
|
1114
956
|
var block = {
|
|
1115
957
|
newline: /^(?: *(?:\n|$))+/,
|
|
1116
958
|
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
@@ -1119,16 +961,7 @@ var block = {
|
|
|
1119
961
|
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
1120
962
|
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
|
1121
963
|
list: /^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,
|
|
1122
|
-
html:
|
|
1123
|
-
+ '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
1124
|
-
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
1125
|
-
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
|
|
1126
|
-
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
|
|
1127
|
-
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
|
|
1128
|
-
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
|
|
1129
|
-
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
|
|
1130
|
-
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
|
|
1131
|
-
+ ')',
|
|
964
|
+
html: "^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",
|
|
1132
965
|
def: /^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
|
|
1133
966
|
table: noopTest,
|
|
1134
967
|
lheading: /^((?:(?!^bull ).|\n(?!\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
@@ -1139,130 +972,86 @@ var block = {
|
|
|
1139
972
|
};
|
|
1140
973
|
block._label = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
|
|
1141
974
|
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
1142
|
-
block.def = edit(block.def).replace(
|
|
975
|
+
block.def = edit(block.def).replace("label", block._label).replace("title", block._title).getRegex();
|
|
1143
976
|
block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
1144
|
-
block.listItemStart = edit(/^( *)(bull) */).replace(
|
|
1145
|
-
block.list = edit(block.list).replace(/bull/g, block.bullet).replace(
|
|
1146
|
-
block._tag =
|
|
977
|
+
block.listItemStart = edit(/^( *)(bull) */).replace("bull", block.bullet).getRegex();
|
|
978
|
+
block.list = edit(block.list).replace(/bull/g, block.bullet).replace("hr", "\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def", "\\n+(?=" + block.def.source + ")").getRegex();
|
|
979
|
+
block._tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
|
|
1147
980
|
block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
1148
|
-
block.html = edit(block.html,
|
|
1149
|
-
block.lheading = edit(block.lheading).replace(/bull/g, block.bullet)
|
|
1150
|
-
.getRegex();
|
|
1151
|
-
block.
|
|
1152
|
-
.
|
|
1153
|
-
|
|
1154
|
-
.
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
block.normal
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
*/
|
|
1166
|
-
|
|
1167
|
-
block.gfm = _extends({}, block.normal, {
|
|
1168
|
-
table: '^ *([^\\n ].*\\|.*)\\n' // Header
|
|
1169
|
-
+ ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
|
|
1170
|
-
+ '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
1171
|
-
});
|
|
1172
|
-
|
|
1173
|
-
block.gfm.table = edit(block.gfm.table).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('blockquote', ' {0,3}>').replace('code', ' {4}[^\\n]').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1174
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
1175
|
-
.getRegex();
|
|
1176
|
-
block.gfm.paragraph = edit(block._paragraph).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
1177
|
-
.replace('table', block.gfm.table) // interrupt paragraphs with table
|
|
1178
|
-
.replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1179
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
1180
|
-
.getRegex();
|
|
1181
|
-
/**
|
|
1182
|
-
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
1183
|
-
*/
|
|
1184
|
-
|
|
1185
|
-
block.pedantic = _extends({}, block.normal, {
|
|
1186
|
-
html: edit('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
1187
|
-
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))').replace('comment', block._comment).replace(/tag/g, '(?!(?:' + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b').getRegex(),
|
|
981
|
+
block.html = edit(block.html, "i").replace("comment", block._comment).replace("tag", block._tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
982
|
+
block.lheading = edit(block.lheading).replace(/bull/g, block.bullet).getRegex();
|
|
983
|
+
block.paragraph = edit(block._paragraph).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
|
|
984
|
+
block.blockquote = edit(block.blockquote).replace("paragraph", block.paragraph).getRegex();
|
|
985
|
+
block.normal = { ...block };
|
|
986
|
+
block.gfm = {
|
|
987
|
+
...block.normal,
|
|
988
|
+
table: "^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
|
|
989
|
+
// Cells
|
|
990
|
+
};
|
|
991
|
+
block.gfm.table = edit(block.gfm.table).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
|
|
992
|
+
block.gfm.paragraph = edit(block._paragraph).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("table", block.gfm.table).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
|
|
993
|
+
block.pedantic = {
|
|
994
|
+
...block.normal,
|
|
995
|
+
html: edit(
|
|
996
|
+
`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
|
|
997
|
+
).replace("comment", block._comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
|
|
1188
998
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1189
999
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
1190
1000
|
fences: noopTest,
|
|
1191
1001
|
// fences not supported
|
|
1192
1002
|
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1193
|
-
paragraph: edit(block.normal._paragraph).replace(
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
/**
|
|
1197
|
-
* Inline-Level Grammar
|
|
1198
|
-
*/
|
|
1003
|
+
paragraph: edit(block.normal._paragraph).replace("hr", block.hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", block.lheading).replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").getRegex()
|
|
1004
|
+
};
|
|
1199
1005
|
var inline = {
|
|
1200
1006
|
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
1201
1007
|
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
1202
1008
|
url: noopTest,
|
|
1203
|
-
tag:
|
|
1204
|
-
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
|
1205
|
-
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
|
1206
|
-
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
|
1207
|
-
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>',
|
|
1009
|
+
tag: "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",
|
|
1208
1010
|
// CDATA section
|
|
1209
1011
|
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
|
|
1210
1012
|
reflink: /^!?\[(label)\]\[(ref)\]/,
|
|
1211
1013
|
nolink: /^!?\[(ref)\](?:\[\])?/,
|
|
1212
|
-
reflinkSearch:
|
|
1014
|
+
reflinkSearch: "reflink|nolink(?!\\()",
|
|
1213
1015
|
emStrong: {
|
|
1214
1016
|
lDelim: /^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,
|
|
1215
1017
|
// (1) and (2) can only be a Right Delimiter. (3) and (4) can only be Left. (5) and (6) can be either Left or Right.
|
|
1216
1018
|
// | Skip orphan inside strong | Consume to delim | (1) #*** | (2) a***#, a*** | (3) #***a, ***a | (4) ***# | (5) #***# | (6) a***a
|
|
1217
1019
|
rDelimAst: /^[^_*]*?__[^_*]*?\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\*)[punct](\*+)(?=[\s]|$)|[^punct\s](\*+)(?!\*)(?=[punct\s]|$)|(?!\*)[punct\s](\*+)(?=[^punct\s])|[\s](\*+)(?!\*)(?=[punct])|(?!\*)[punct](\*+)(?!\*)(?=[punct])|[^punct\s](\*+)(?=[^punct\s])/,
|
|
1218
|
-
rDelimUnd: /^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/
|
|
1020
|
+
rDelimUnd: /^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/
|
|
1021
|
+
// ^- Not allowed for _
|
|
1219
1022
|
},
|
|
1220
|
-
|
|
1221
1023
|
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
1222
1024
|
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
1223
1025
|
del: noopTest,
|
|
1224
1026
|
text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
1225
1027
|
punctuation: /^((?![*_])[\spunctuation])/
|
|
1226
1028
|
};
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
inline._punctuation = '\\p{P}$+<=>`^|~';
|
|
1230
|
-
inline.punctuation = edit(inline.punctuation, 'u').replace(/punctuation/g, inline._punctuation).getRegex();
|
|
1231
|
-
|
|
1232
|
-
// sequences em should skip over [title](link), `code`, <html>
|
|
1029
|
+
inline._punctuation = "\\p{P}$+<=>`^|~";
|
|
1030
|
+
inline.punctuation = edit(inline.punctuation, "u").replace(/punctuation/g, inline._punctuation).getRegex();
|
|
1233
1031
|
inline.blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
|
|
1234
1032
|
inline.anyPunctuation = /\\[punct]/g;
|
|
1235
1033
|
inline._escapes = /\\([punct])/g;
|
|
1236
|
-
inline._comment = edit(block._comment).replace(
|
|
1237
|
-
inline.emStrong.lDelim = edit(inline.emStrong.lDelim,
|
|
1238
|
-
inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst,
|
|
1239
|
-
inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd,
|
|
1240
|
-
inline.anyPunctuation = edit(inline.anyPunctuation,
|
|
1241
|
-
inline._escapes = edit(inline._escapes,
|
|
1034
|
+
inline._comment = edit(block._comment).replace("(?:-->|$)", "-->").getRegex();
|
|
1035
|
+
inline.emStrong.lDelim = edit(inline.emStrong.lDelim, "u").replace(/punct/g, inline._punctuation).getRegex();
|
|
1036
|
+
inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst, "gu").replace(/punct/g, inline._punctuation).getRegex();
|
|
1037
|
+
inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd, "gu").replace(/punct/g, inline._punctuation).getRegex();
|
|
1038
|
+
inline.anyPunctuation = edit(inline.anyPunctuation, "gu").replace(/punct/g, inline._punctuation).getRegex();
|
|
1039
|
+
inline._escapes = edit(inline._escapes, "gu").replace(/punct/g, inline._punctuation).getRegex();
|
|
1242
1040
|
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
1243
1041
|
inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
|
|
1244
|
-
inline.autolink = edit(inline.autolink).replace(
|
|
1042
|
+
inline.autolink = edit(inline.autolink).replace("scheme", inline._scheme).replace("email", inline._email).getRegex();
|
|
1245
1043
|
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
1246
|
-
inline.tag = edit(inline.tag).replace(
|
|
1044
|
+
inline.tag = edit(inline.tag).replace("comment", inline._comment).replace("attribute", inline._attribute).getRegex();
|
|
1247
1045
|
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
1248
1046
|
inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
1249
1047
|
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
1250
|
-
inline.link = edit(inline.link).replace(
|
|
1251
|
-
inline.reflink = edit(inline.reflink).replace(
|
|
1252
|
-
inline.nolink = edit(inline.nolink).replace(
|
|
1253
|
-
inline.reflinkSearch = edit(inline.reflinkSearch,
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
*/
|
|
1258
|
-
|
|
1259
|
-
inline.normal = _extends({}, inline);
|
|
1260
|
-
|
|
1261
|
-
/**
|
|
1262
|
-
* Pedantic Inline Grammar
|
|
1263
|
-
*/
|
|
1264
|
-
|
|
1265
|
-
inline.pedantic = _extends({}, inline.normal, {
|
|
1048
|
+
inline.link = edit(inline.link).replace("label", inline._label).replace("href", inline._href).replace("title", inline._title).getRegex();
|
|
1049
|
+
inline.reflink = edit(inline.reflink).replace("label", inline._label).replace("ref", block._label).getRegex();
|
|
1050
|
+
inline.nolink = edit(inline.nolink).replace("ref", block._label).getRegex();
|
|
1051
|
+
inline.reflinkSearch = edit(inline.reflinkSearch, "g").replace("reflink", inline.reflink).replace("nolink", inline.nolink).getRegex();
|
|
1052
|
+
inline.normal = { ...inline };
|
|
1053
|
+
inline.pedantic = {
|
|
1054
|
+
...inline.normal,
|
|
1266
1055
|
strong: {
|
|
1267
1056
|
start: /^__|\*\*/,
|
|
1268
1057
|
middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
@@ -1275,82 +1064,47 @@ inline.pedantic = _extends({}, inline.normal, {
|
|
|
1275
1064
|
endAst: /\*(?!\*)/g,
|
|
1276
1065
|
endUnd: /_(?!_)/g
|
|
1277
1066
|
},
|
|
1278
|
-
link: edit(/^!?\[(label)\]\((.*?)\)/).replace(
|
|
1279
|
-
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
*/
|
|
1285
|
-
|
|
1286
|
-
inline.gfm = _extends({}, inline.normal, {
|
|
1287
|
-
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
|
|
1067
|
+
link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", inline._label).getRegex(),
|
|
1068
|
+
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", inline._label).getRegex()
|
|
1069
|
+
};
|
|
1070
|
+
inline.gfm = {
|
|
1071
|
+
...inline.normal,
|
|
1072
|
+
escape: edit(inline.escape).replace("])", "~|])").getRegex(),
|
|
1288
1073
|
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
1289
1074
|
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
1290
1075
|
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
1291
1076
|
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
1292
1077
|
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
1293
|
-
}
|
|
1294
|
-
inline.gfm.url = edit(inline.gfm.url,
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
br: edit(inline.br).replace('{2,}', '*').getRegex(),
|
|
1301
|
-
text: edit(inline.gfm.text).replace('\\b_', '\\b_| {2,}\\n').replace(/\{2,\}/g, '*').getRegex()
|
|
1302
|
-
});
|
|
1078
|
+
};
|
|
1079
|
+
inline.gfm.url = edit(inline.gfm.url, "i").replace("email", inline.gfm._extended_email).getRegex();
|
|
1080
|
+
inline.breaks = {
|
|
1081
|
+
...inline.gfm,
|
|
1082
|
+
br: edit(inline.br).replace("{2,}", "*").getRegex(),
|
|
1083
|
+
text: edit(inline.gfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
1084
|
+
};
|
|
1303
1085
|
|
|
1304
|
-
|
|
1305
|
-
* smartypants text replacement
|
|
1306
|
-
* @param {string} text
|
|
1307
|
-
*/
|
|
1086
|
+
// src/Lexer.ts
|
|
1308
1087
|
function smartypants(text) {
|
|
1309
|
-
return text
|
|
1310
|
-
// em-dashes
|
|
1311
|
-
.replace(/---/g, "\u2014")
|
|
1312
|
-
// en-dashes
|
|
1313
|
-
.replace(/--/g, "\u2013")
|
|
1314
|
-
// opening singles
|
|
1315
|
-
.replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018")
|
|
1316
|
-
// closing singles & apostrophes
|
|
1317
|
-
.replace(/'/g, "\u2019")
|
|
1318
|
-
// opening doubles
|
|
1319
|
-
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201C")
|
|
1320
|
-
// closing doubles
|
|
1321
|
-
.replace(/"/g, "\u201D")
|
|
1322
|
-
// ellipses
|
|
1323
|
-
.replace(/\.{3}/g, "\u2026");
|
|
1088
|
+
return text.replace(/---/g, "\u2014").replace(/--/g, "\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018").replace(/'/g, "\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201C").replace(/"/g, "\u201D").replace(/\.{3}/g, "\u2026");
|
|
1324
1089
|
}
|
|
1325
|
-
|
|
1326
|
-
/**
|
|
1327
|
-
* mangle email addresses
|
|
1328
|
-
* @param {string} text
|
|
1329
|
-
*/
|
|
1330
1090
|
function mangle(text) {
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
ch;
|
|
1334
|
-
var l = text.length;
|
|
1091
|
+
let out = "", i, ch;
|
|
1092
|
+
const l = text.length;
|
|
1335
1093
|
for (i = 0; i < l; i++) {
|
|
1336
1094
|
ch = text.charCodeAt(i);
|
|
1337
1095
|
if (Math.random() > 0.5) {
|
|
1338
|
-
ch =
|
|
1096
|
+
ch = "x" + ch.toString(16);
|
|
1339
1097
|
}
|
|
1340
|
-
out +=
|
|
1098
|
+
out += "&#" + ch + ";";
|
|
1341
1099
|
}
|
|
1342
1100
|
return out;
|
|
1343
1101
|
}
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
* Block Lexer
|
|
1347
|
-
*/
|
|
1348
|
-
var Lexer = /*#__PURE__*/function () {
|
|
1349
|
-
function Lexer(options) {
|
|
1102
|
+
var _Lexer = class {
|
|
1103
|
+
constructor(options2) {
|
|
1350
1104
|
this.tokens = [];
|
|
1351
|
-
this.tokens.links = Object.create(null);
|
|
1352
|
-
this.options =
|
|
1353
|
-
this.options.tokenizer = this.options.tokenizer || new
|
|
1105
|
+
this.tokens.links = /* @__PURE__ */ Object.create(null);
|
|
1106
|
+
this.options = options2 || _defaults;
|
|
1107
|
+
this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
|
|
1354
1108
|
this.tokenizer = this.options.tokenizer;
|
|
1355
1109
|
this.tokenizer.options = this.options;
|
|
1356
1110
|
this.tokenizer.lexer = this;
|
|
@@ -1360,7 +1114,7 @@ var Lexer = /*#__PURE__*/function () {
|
|
|
1360
1114
|
inRawBlock: false,
|
|
1361
1115
|
top: true
|
|
1362
1116
|
};
|
|
1363
|
-
|
|
1117
|
+
const rules = {
|
|
1364
1118
|
block: block.normal,
|
|
1365
1119
|
inline: inline.normal
|
|
1366
1120
|
};
|
|
@@ -1377,183 +1131,145 @@ var Lexer = /*#__PURE__*/function () {
|
|
|
1377
1131
|
}
|
|
1378
1132
|
this.tokenizer.rules = rules;
|
|
1379
1133
|
}
|
|
1380
|
-
|
|
1381
1134
|
/**
|
|
1382
1135
|
* Expose Rules
|
|
1383
1136
|
*/
|
|
1137
|
+
static get rules() {
|
|
1138
|
+
return {
|
|
1139
|
+
block,
|
|
1140
|
+
inline
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1384
1143
|
/**
|
|
1385
1144
|
* Static Lex Method
|
|
1386
1145
|
*/
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
return
|
|
1146
|
+
static lex(src, options2) {
|
|
1147
|
+
const lexer2 = new _Lexer(options2);
|
|
1148
|
+
return lexer2.lex(src);
|
|
1390
1149
|
}
|
|
1391
|
-
|
|
1392
1150
|
/**
|
|
1393
1151
|
* Static Lex Inline Method
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
return
|
|
1152
|
+
*/
|
|
1153
|
+
static lexInline(src, options2) {
|
|
1154
|
+
const lexer2 = new _Lexer(options2);
|
|
1155
|
+
return lexer2.inlineTokens(src);
|
|
1398
1156
|
}
|
|
1399
|
-
|
|
1400
1157
|
/**
|
|
1401
1158
|
* Preprocessing
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
src = src.replace(/\r\n|\r/g, '\n');
|
|
1159
|
+
*/
|
|
1160
|
+
lex(src) {
|
|
1161
|
+
src = src.replace(/\r\n|\r/g, "\n");
|
|
1406
1162
|
this.blockTokens(src, this.tokens);
|
|
1407
|
-
|
|
1163
|
+
let next;
|
|
1408
1164
|
while (next = this.inlineQueue.shift()) {
|
|
1409
1165
|
this.inlineTokens(next.src, next.tokens);
|
|
1410
1166
|
}
|
|
1411
1167
|
return this.tokens;
|
|
1412
1168
|
}
|
|
1413
|
-
|
|
1414
|
-
/**
|
|
1415
|
-
* Lexing
|
|
1416
|
-
*/;
|
|
1417
|
-
_proto.blockTokens = function blockTokens(src, tokens) {
|
|
1418
|
-
var _this = this;
|
|
1419
|
-
if (tokens === void 0) {
|
|
1420
|
-
tokens = [];
|
|
1421
|
-
}
|
|
1169
|
+
blockTokens(src, tokens = []) {
|
|
1422
1170
|
if (this.options.pedantic) {
|
|
1423
|
-
src = src.replace(/\t/g,
|
|
1171
|
+
src = src.replace(/\t/g, " ").replace(/^ +$/gm, "");
|
|
1424
1172
|
} else {
|
|
1425
|
-
src = src.replace(/^( *)(\t+)/gm,
|
|
1426
|
-
return leading +
|
|
1173
|
+
src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
|
|
1174
|
+
return leading + " ".repeat(tabs.length);
|
|
1427
1175
|
});
|
|
1428
1176
|
}
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
if (
|
|
1432
|
-
if (token = extTokenizer.call({
|
|
1433
|
-
lexer: _this
|
|
1434
|
-
}, src, tokens)) {
|
|
1177
|
+
let token, lastToken, cutSrc, lastParagraphClipped;
|
|
1178
|
+
while (src) {
|
|
1179
|
+
if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
|
|
1180
|
+
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
1435
1181
|
src = src.substring(token.raw.length);
|
|
1436
1182
|
tokens.push(token);
|
|
1437
1183
|
return true;
|
|
1438
1184
|
}
|
|
1439
1185
|
return false;
|
|
1440
1186
|
})) {
|
|
1441
|
-
|
|
1187
|
+
continue;
|
|
1442
1188
|
}
|
|
1443
|
-
|
|
1444
|
-
// newline
|
|
1445
|
-
if (token = _this.tokenizer.space(src)) {
|
|
1189
|
+
if (token = this.tokenizer.space(src)) {
|
|
1446
1190
|
src = src.substring(token.raw.length);
|
|
1447
1191
|
if (token.raw.length === 1 && tokens.length > 0) {
|
|
1448
|
-
|
|
1449
|
-
// so move it there so that we don't get unecessary paragraph tags
|
|
1450
|
-
tokens[tokens.length - 1].raw += '\n';
|
|
1192
|
+
tokens[tokens.length - 1].raw += "\n";
|
|
1451
1193
|
} else {
|
|
1452
1194
|
tokens.push(token);
|
|
1453
1195
|
}
|
|
1454
|
-
|
|
1196
|
+
continue;
|
|
1455
1197
|
}
|
|
1456
|
-
|
|
1457
|
-
// code
|
|
1458
|
-
if (token = _this.tokenizer.code(src)) {
|
|
1198
|
+
if (token = this.tokenizer.code(src)) {
|
|
1459
1199
|
src = src.substring(token.raw.length);
|
|
1460
1200
|
lastToken = tokens[tokens.length - 1];
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
lastToken.
|
|
1464
|
-
|
|
1465
|
-
_this.inlineQueue[_this.inlineQueue.length - 1].src = lastToken.text;
|
|
1201
|
+
if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
|
|
1202
|
+
lastToken.raw += "\n" + token.raw;
|
|
1203
|
+
lastToken.text += "\n" + token.text;
|
|
1204
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
1466
1205
|
} else {
|
|
1467
1206
|
tokens.push(token);
|
|
1468
1207
|
}
|
|
1469
|
-
|
|
1208
|
+
continue;
|
|
1470
1209
|
}
|
|
1471
|
-
|
|
1472
|
-
// fences
|
|
1473
|
-
if (token = _this.tokenizer.fences(src)) {
|
|
1210
|
+
if (token = this.tokenizer.fences(src)) {
|
|
1474
1211
|
src = src.substring(token.raw.length);
|
|
1475
1212
|
tokens.push(token);
|
|
1476
|
-
|
|
1213
|
+
continue;
|
|
1477
1214
|
}
|
|
1478
|
-
|
|
1479
|
-
// heading
|
|
1480
|
-
if (token = _this.tokenizer.heading(src)) {
|
|
1215
|
+
if (token = this.tokenizer.heading(src)) {
|
|
1481
1216
|
src = src.substring(token.raw.length);
|
|
1482
1217
|
tokens.push(token);
|
|
1483
|
-
|
|
1218
|
+
continue;
|
|
1484
1219
|
}
|
|
1485
|
-
|
|
1486
|
-
// hr
|
|
1487
|
-
if (token = _this.tokenizer.hr(src)) {
|
|
1220
|
+
if (token = this.tokenizer.hr(src)) {
|
|
1488
1221
|
src = src.substring(token.raw.length);
|
|
1489
1222
|
tokens.push(token);
|
|
1490
|
-
|
|
1223
|
+
continue;
|
|
1491
1224
|
}
|
|
1492
|
-
|
|
1493
|
-
// blockquote
|
|
1494
|
-
if (token = _this.tokenizer.blockquote(src)) {
|
|
1225
|
+
if (token = this.tokenizer.blockquote(src)) {
|
|
1495
1226
|
src = src.substring(token.raw.length);
|
|
1496
1227
|
tokens.push(token);
|
|
1497
|
-
|
|
1228
|
+
continue;
|
|
1498
1229
|
}
|
|
1499
|
-
|
|
1500
|
-
// list
|
|
1501
|
-
if (token = _this.tokenizer.list(src)) {
|
|
1230
|
+
if (token = this.tokenizer.list(src)) {
|
|
1502
1231
|
src = src.substring(token.raw.length);
|
|
1503
1232
|
tokens.push(token);
|
|
1504
|
-
|
|
1233
|
+
continue;
|
|
1505
1234
|
}
|
|
1506
|
-
|
|
1507
|
-
// html
|
|
1508
|
-
if (token = _this.tokenizer.html(src)) {
|
|
1235
|
+
if (token = this.tokenizer.html(src)) {
|
|
1509
1236
|
src = src.substring(token.raw.length);
|
|
1510
1237
|
tokens.push(token);
|
|
1511
|
-
|
|
1238
|
+
continue;
|
|
1512
1239
|
}
|
|
1513
|
-
|
|
1514
|
-
// def
|
|
1515
|
-
if (token = _this.tokenizer.def(src)) {
|
|
1240
|
+
if (token = this.tokenizer.def(src)) {
|
|
1516
1241
|
src = src.substring(token.raw.length);
|
|
1517
1242
|
lastToken = tokens[tokens.length - 1];
|
|
1518
|
-
if (lastToken && (lastToken.type ===
|
|
1519
|
-
lastToken.raw +=
|
|
1520
|
-
lastToken.text +=
|
|
1521
|
-
|
|
1522
|
-
} else if (!
|
|
1523
|
-
|
|
1243
|
+
if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
|
|
1244
|
+
lastToken.raw += "\n" + token.raw;
|
|
1245
|
+
lastToken.text += "\n" + token.raw;
|
|
1246
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
1247
|
+
} else if (!this.tokens.links[token.tag]) {
|
|
1248
|
+
this.tokens.links[token.tag] = {
|
|
1524
1249
|
href: token.href,
|
|
1525
1250
|
title: token.title
|
|
1526
1251
|
};
|
|
1527
1252
|
}
|
|
1528
|
-
|
|
1253
|
+
continue;
|
|
1529
1254
|
}
|
|
1530
|
-
|
|
1531
|
-
// table (gfm)
|
|
1532
|
-
if (token = _this.tokenizer.table(src)) {
|
|
1255
|
+
if (token = this.tokenizer.table(src)) {
|
|
1533
1256
|
src = src.substring(token.raw.length);
|
|
1534
1257
|
tokens.push(token);
|
|
1535
|
-
|
|
1258
|
+
continue;
|
|
1536
1259
|
}
|
|
1537
|
-
|
|
1538
|
-
// lheading
|
|
1539
|
-
if (token = _this.tokenizer.lheading(src)) {
|
|
1260
|
+
if (token = this.tokenizer.lheading(src)) {
|
|
1540
1261
|
src = src.substring(token.raw.length);
|
|
1541
1262
|
tokens.push(token);
|
|
1542
|
-
|
|
1263
|
+
continue;
|
|
1543
1264
|
}
|
|
1544
|
-
|
|
1545
|
-
// top-level paragraph
|
|
1546
|
-
// prevent paragraph consuming extensions by clipping 'src' to extension start
|
|
1547
1265
|
cutSrc = src;
|
|
1548
|
-
if (
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
tempStart = getStartIndex.call({
|
|
1554
|
-
|
|
1555
|
-
}, tempSrc);
|
|
1556
|
-
if (typeof tempStart === 'number' && tempStart >= 0) {
|
|
1266
|
+
if (this.options.extensions && this.options.extensions.startBlock) {
|
|
1267
|
+
let startIndex = Infinity;
|
|
1268
|
+
const tempSrc = src.slice(1);
|
|
1269
|
+
let tempStart;
|
|
1270
|
+
this.options.extensions.startBlock.forEach((getStartIndex) => {
|
|
1271
|
+
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
1272
|
+
if (typeof tempStart === "number" && tempStart >= 0) {
|
|
1557
1273
|
startIndex = Math.min(startIndex, tempStart);
|
|
1558
1274
|
}
|
|
1559
1275
|
});
|
|
@@ -1561,213 +1277,159 @@ var Lexer = /*#__PURE__*/function () {
|
|
|
1561
1277
|
cutSrc = src.substring(0, startIndex + 1);
|
|
1562
1278
|
}
|
|
1563
1279
|
}
|
|
1564
|
-
if (
|
|
1280
|
+
if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
1565
1281
|
lastToken = tokens[tokens.length - 1];
|
|
1566
|
-
if (lastParagraphClipped && lastToken.type ===
|
|
1567
|
-
lastToken.raw +=
|
|
1568
|
-
lastToken.text +=
|
|
1569
|
-
|
|
1570
|
-
|
|
1282
|
+
if (lastParagraphClipped && lastToken.type === "paragraph") {
|
|
1283
|
+
lastToken.raw += "\n" + token.raw;
|
|
1284
|
+
lastToken.text += "\n" + token.text;
|
|
1285
|
+
this.inlineQueue.pop();
|
|
1286
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
1571
1287
|
} else {
|
|
1572
1288
|
tokens.push(token);
|
|
1573
1289
|
}
|
|
1574
1290
|
lastParagraphClipped = cutSrc.length !== src.length;
|
|
1575
1291
|
src = src.substring(token.raw.length);
|
|
1576
|
-
|
|
1292
|
+
continue;
|
|
1577
1293
|
}
|
|
1578
|
-
|
|
1579
|
-
// text
|
|
1580
|
-
if (token = _this.tokenizer.text(src)) {
|
|
1294
|
+
if (token = this.tokenizer.text(src)) {
|
|
1581
1295
|
src = src.substring(token.raw.length);
|
|
1582
1296
|
lastToken = tokens[tokens.length - 1];
|
|
1583
|
-
if (lastToken && lastToken.type ===
|
|
1584
|
-
lastToken.raw +=
|
|
1585
|
-
lastToken.text +=
|
|
1586
|
-
|
|
1587
|
-
|
|
1297
|
+
if (lastToken && lastToken.type === "text") {
|
|
1298
|
+
lastToken.raw += "\n" + token.raw;
|
|
1299
|
+
lastToken.text += "\n" + token.text;
|
|
1300
|
+
this.inlineQueue.pop();
|
|
1301
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
1588
1302
|
} else {
|
|
1589
1303
|
tokens.push(token);
|
|
1590
1304
|
}
|
|
1591
|
-
|
|
1305
|
+
continue;
|
|
1592
1306
|
}
|
|
1593
1307
|
if (src) {
|
|
1594
|
-
|
|
1595
|
-
if (
|
|
1308
|
+
const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
|
|
1309
|
+
if (this.options.silent) {
|
|
1596
1310
|
console.error(errMsg);
|
|
1597
|
-
|
|
1311
|
+
break;
|
|
1598
1312
|
} else {
|
|
1599
1313
|
throw new Error(errMsg);
|
|
1600
1314
|
}
|
|
1601
1315
|
}
|
|
1602
|
-
};
|
|
1603
|
-
while (src) {
|
|
1604
|
-
var _ret = _loop();
|
|
1605
|
-
if (_ret === "continue") continue;
|
|
1606
|
-
if (_ret === "break") break;
|
|
1607
1316
|
}
|
|
1608
1317
|
this.state.top = true;
|
|
1609
1318
|
return tokens;
|
|
1610
|
-
}
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
tokens = [];
|
|
1614
|
-
}
|
|
1615
|
-
this.inlineQueue.push({
|
|
1616
|
-
src: src,
|
|
1617
|
-
tokens: tokens
|
|
1618
|
-
});
|
|
1319
|
+
}
|
|
1320
|
+
inline(src, tokens = []) {
|
|
1321
|
+
this.inlineQueue.push({ src, tokens });
|
|
1619
1322
|
return tokens;
|
|
1620
1323
|
}
|
|
1621
|
-
|
|
1622
1324
|
/**
|
|
1623
1325
|
* Lexing/Compiling
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
var token, lastToken, cutSrc;
|
|
1631
|
-
|
|
1632
|
-
// String with links masked to avoid interference with em and strong
|
|
1633
|
-
var maskedSrc = src;
|
|
1634
|
-
var match;
|
|
1635
|
-
var keepPrevChar, prevChar;
|
|
1636
|
-
|
|
1637
|
-
// Mask out reflinks
|
|
1326
|
+
*/
|
|
1327
|
+
inlineTokens(src, tokens = []) {
|
|
1328
|
+
let token, lastToken, cutSrc;
|
|
1329
|
+
let maskedSrc = src;
|
|
1330
|
+
let match;
|
|
1331
|
+
let keepPrevChar, prevChar;
|
|
1638
1332
|
if (this.tokens.links) {
|
|
1639
|
-
|
|
1333
|
+
const links = Object.keys(this.tokens.links);
|
|
1640
1334
|
if (links.length > 0) {
|
|
1641
1335
|
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
|
1642
|
-
if (links.includes(match[0].slice(match[0].lastIndexOf(
|
|
1643
|
-
maskedSrc = maskedSrc.slice(0, match.index) +
|
|
1336
|
+
if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
|
|
1337
|
+
maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
|
|
1644
1338
|
}
|
|
1645
1339
|
}
|
|
1646
1340
|
}
|
|
1647
1341
|
}
|
|
1648
|
-
// Mask out other blocks
|
|
1649
1342
|
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
1650
|
-
maskedSrc = maskedSrc.slice(0, match.index) +
|
|
1343
|
+
maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
1651
1344
|
}
|
|
1652
|
-
|
|
1653
|
-
// Mask out escaped characters
|
|
1654
1345
|
while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
|
|
1655
|
-
maskedSrc = maskedSrc.slice(0, match.index) +
|
|
1346
|
+
maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
1656
1347
|
}
|
|
1657
|
-
|
|
1348
|
+
while (src) {
|
|
1658
1349
|
if (!keepPrevChar) {
|
|
1659
|
-
prevChar =
|
|
1350
|
+
prevChar = "";
|
|
1660
1351
|
}
|
|
1661
1352
|
keepPrevChar = false;
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
if (_this2.options.extensions && _this2.options.extensions.inline && _this2.options.extensions.inline.some(function (extTokenizer) {
|
|
1665
|
-
if (token = extTokenizer.call({
|
|
1666
|
-
lexer: _this2
|
|
1667
|
-
}, src, tokens)) {
|
|
1353
|
+
if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((extTokenizer) => {
|
|
1354
|
+
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
1668
1355
|
src = src.substring(token.raw.length);
|
|
1669
1356
|
tokens.push(token);
|
|
1670
1357
|
return true;
|
|
1671
1358
|
}
|
|
1672
1359
|
return false;
|
|
1673
1360
|
})) {
|
|
1674
|
-
|
|
1361
|
+
continue;
|
|
1675
1362
|
}
|
|
1676
|
-
|
|
1677
|
-
// escape
|
|
1678
|
-
if (token = _this2.tokenizer.escape(src)) {
|
|
1363
|
+
if (token = this.tokenizer.escape(src)) {
|
|
1679
1364
|
src = src.substring(token.raw.length);
|
|
1680
1365
|
tokens.push(token);
|
|
1681
|
-
|
|
1366
|
+
continue;
|
|
1682
1367
|
}
|
|
1683
|
-
|
|
1684
|
-
// tag
|
|
1685
|
-
if (token = _this2.tokenizer.tag(src)) {
|
|
1368
|
+
if (token = this.tokenizer.tag(src)) {
|
|
1686
1369
|
src = src.substring(token.raw.length);
|
|
1687
1370
|
lastToken = tokens[tokens.length - 1];
|
|
1688
|
-
if (lastToken && token.type ===
|
|
1371
|
+
if (lastToken && token.type === "text" && lastToken.type === "text") {
|
|
1689
1372
|
lastToken.raw += token.raw;
|
|
1690
1373
|
lastToken.text += token.text;
|
|
1691
1374
|
} else {
|
|
1692
1375
|
tokens.push(token);
|
|
1693
1376
|
}
|
|
1694
|
-
|
|
1377
|
+
continue;
|
|
1695
1378
|
}
|
|
1696
|
-
|
|
1697
|
-
// link
|
|
1698
|
-
if (token = _this2.tokenizer.link(src)) {
|
|
1379
|
+
if (token = this.tokenizer.link(src)) {
|
|
1699
1380
|
src = src.substring(token.raw.length);
|
|
1700
1381
|
tokens.push(token);
|
|
1701
|
-
|
|
1382
|
+
continue;
|
|
1702
1383
|
}
|
|
1703
|
-
|
|
1704
|
-
// reflink, nolink
|
|
1705
|
-
if (token = _this2.tokenizer.reflink(src, _this2.tokens.links)) {
|
|
1384
|
+
if (token = this.tokenizer.reflink(src, this.tokens.links)) {
|
|
1706
1385
|
src = src.substring(token.raw.length);
|
|
1707
1386
|
lastToken = tokens[tokens.length - 1];
|
|
1708
|
-
if (lastToken && token.type ===
|
|
1387
|
+
if (lastToken && token.type === "text" && lastToken.type === "text") {
|
|
1709
1388
|
lastToken.raw += token.raw;
|
|
1710
1389
|
lastToken.text += token.text;
|
|
1711
1390
|
} else {
|
|
1712
1391
|
tokens.push(token);
|
|
1713
1392
|
}
|
|
1714
|
-
|
|
1393
|
+
continue;
|
|
1715
1394
|
}
|
|
1716
|
-
|
|
1717
|
-
// em & strong
|
|
1718
|
-
if (token = _this2.tokenizer.emStrong(src, maskedSrc, prevChar)) {
|
|
1395
|
+
if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
|
|
1719
1396
|
src = src.substring(token.raw.length);
|
|
1720
1397
|
tokens.push(token);
|
|
1721
|
-
|
|
1398
|
+
continue;
|
|
1722
1399
|
}
|
|
1723
|
-
|
|
1724
|
-
// code
|
|
1725
|
-
if (token = _this2.tokenizer.codespan(src)) {
|
|
1400
|
+
if (token = this.tokenizer.codespan(src)) {
|
|
1726
1401
|
src = src.substring(token.raw.length);
|
|
1727
1402
|
tokens.push(token);
|
|
1728
|
-
|
|
1403
|
+
continue;
|
|
1729
1404
|
}
|
|
1730
|
-
|
|
1731
|
-
// br
|
|
1732
|
-
if (token = _this2.tokenizer.br(src)) {
|
|
1405
|
+
if (token = this.tokenizer.br(src)) {
|
|
1733
1406
|
src = src.substring(token.raw.length);
|
|
1734
1407
|
tokens.push(token);
|
|
1735
|
-
|
|
1408
|
+
continue;
|
|
1736
1409
|
}
|
|
1737
|
-
|
|
1738
|
-
// del (gfm)
|
|
1739
|
-
if (token = _this2.tokenizer.del(src)) {
|
|
1410
|
+
if (token = this.tokenizer.del(src)) {
|
|
1740
1411
|
src = src.substring(token.raw.length);
|
|
1741
1412
|
tokens.push(token);
|
|
1742
|
-
|
|
1413
|
+
continue;
|
|
1743
1414
|
}
|
|
1744
|
-
|
|
1745
|
-
// autolink
|
|
1746
|
-
if (token = _this2.tokenizer.autolink(src, mangle)) {
|
|
1415
|
+
if (token = this.tokenizer.autolink(src, mangle)) {
|
|
1747
1416
|
src = src.substring(token.raw.length);
|
|
1748
1417
|
tokens.push(token);
|
|
1749
|
-
|
|
1418
|
+
continue;
|
|
1750
1419
|
}
|
|
1751
|
-
|
|
1752
|
-
// url (gfm)
|
|
1753
|
-
if (!_this2.state.inLink && (token = _this2.tokenizer.url(src, mangle))) {
|
|
1420
|
+
if (!this.state.inLink && (token = this.tokenizer.url(src, mangle))) {
|
|
1754
1421
|
src = src.substring(token.raw.length);
|
|
1755
1422
|
tokens.push(token);
|
|
1756
|
-
|
|
1423
|
+
continue;
|
|
1757
1424
|
}
|
|
1758
|
-
|
|
1759
|
-
// text
|
|
1760
|
-
// prevent inlineText consuming extensions by clipping 'src' to extension start
|
|
1761
1425
|
cutSrc = src;
|
|
1762
|
-
if (
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
tempStart = getStartIndex.call({
|
|
1768
|
-
|
|
1769
|
-
}, tempSrc);
|
|
1770
|
-
if (typeof tempStart === 'number' && tempStart >= 0) {
|
|
1426
|
+
if (this.options.extensions && this.options.extensions.startInline) {
|
|
1427
|
+
let startIndex = Infinity;
|
|
1428
|
+
const tempSrc = src.slice(1);
|
|
1429
|
+
let tempStart;
|
|
1430
|
+
this.options.extensions.startInline.forEach((getStartIndex) => {
|
|
1431
|
+
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
1432
|
+
if (typeof tempStart === "number" && tempStart >= 0) {
|
|
1771
1433
|
startIndex = Math.min(startIndex, tempStart);
|
|
1772
1434
|
}
|
|
1773
1435
|
});
|
|
@@ -1775,291 +1437,204 @@ var Lexer = /*#__PURE__*/function () {
|
|
|
1775
1437
|
cutSrc = src.substring(0, startIndex + 1);
|
|
1776
1438
|
}
|
|
1777
1439
|
}
|
|
1778
|
-
if (token =
|
|
1440
|
+
if (token = this.tokenizer.inlineText(cutSrc, smartypants)) {
|
|
1779
1441
|
src = src.substring(token.raw.length);
|
|
1780
|
-
if (token.raw.slice(-1) !==
|
|
1781
|
-
// Track prevChar before string of ____ started
|
|
1442
|
+
if (token.raw.slice(-1) !== "_") {
|
|
1782
1443
|
prevChar = token.raw.slice(-1);
|
|
1783
1444
|
}
|
|
1784
1445
|
keepPrevChar = true;
|
|
1785
1446
|
lastToken = tokens[tokens.length - 1];
|
|
1786
|
-
if (lastToken && lastToken.type ===
|
|
1447
|
+
if (lastToken && lastToken.type === "text") {
|
|
1787
1448
|
lastToken.raw += token.raw;
|
|
1788
1449
|
lastToken.text += token.text;
|
|
1789
1450
|
} else {
|
|
1790
1451
|
tokens.push(token);
|
|
1791
1452
|
}
|
|
1792
|
-
|
|
1453
|
+
continue;
|
|
1793
1454
|
}
|
|
1794
1455
|
if (src) {
|
|
1795
|
-
|
|
1796
|
-
if (
|
|
1456
|
+
const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
|
|
1457
|
+
if (this.options.silent) {
|
|
1797
1458
|
console.error(errMsg);
|
|
1798
|
-
|
|
1459
|
+
break;
|
|
1799
1460
|
} else {
|
|
1800
1461
|
throw new Error(errMsg);
|
|
1801
1462
|
}
|
|
1802
1463
|
}
|
|
1803
|
-
};
|
|
1804
|
-
while (src) {
|
|
1805
|
-
var _ret2 = _loop2();
|
|
1806
|
-
if (_ret2 === "continue") continue;
|
|
1807
|
-
if (_ret2 === "break") break;
|
|
1808
1464
|
}
|
|
1809
1465
|
return tokens;
|
|
1810
|
-
}
|
|
1811
|
-
|
|
1812
|
-
key: "rules",
|
|
1813
|
-
get: function get() {
|
|
1814
|
-
return {
|
|
1815
|
-
block: block,
|
|
1816
|
-
inline: inline
|
|
1817
|
-
};
|
|
1818
|
-
}
|
|
1819
|
-
}]);
|
|
1820
|
-
return Lexer;
|
|
1821
|
-
}();
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1822
1468
|
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
function Renderer(options) {
|
|
1828
|
-
this.options = options || exports.defaults;
|
|
1469
|
+
// src/Renderer.ts
|
|
1470
|
+
var _Renderer = class {
|
|
1471
|
+
constructor(options2) {
|
|
1472
|
+
this.options = options2 || _defaults;
|
|
1829
1473
|
}
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
var lang = (infostring || '').match(/\S*/)[0];
|
|
1474
|
+
code(code, infostring, escaped) {
|
|
1475
|
+
const lang = (infostring || "").match(/\S*/)[0];
|
|
1833
1476
|
if (this.options.highlight) {
|
|
1834
|
-
|
|
1835
|
-
if (out != null && out !==
|
|
1477
|
+
const out = this.options.highlight(code, lang);
|
|
1478
|
+
if (out != null && out !== code) {
|
|
1836
1479
|
escaped = true;
|
|
1837
|
-
|
|
1480
|
+
code = out;
|
|
1838
1481
|
}
|
|
1839
1482
|
}
|
|
1840
|
-
|
|
1483
|
+
code = code.replace(/\n$/, "") + "\n";
|
|
1841
1484
|
if (!lang) {
|
|
1842
|
-
return
|
|
1485
|
+
return "<pre><code>" + (escaped ? code : escape(code, true)) + "</code></pre>\n";
|
|
1843
1486
|
}
|
|
1844
|
-
return '<pre><code class="' + this.options.langPrefix + escape(lang) + '">' + (escaped ?
|
|
1487
|
+
return '<pre><code class="' + this.options.langPrefix + escape(lang) + '">' + (escaped ? code : escape(code, true)) + "</code></pre>\n";
|
|
1845
1488
|
}
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
_proto.blockquote = function blockquote(quote) {
|
|
1851
|
-
return "<blockquote>\n" + quote + "</blockquote>\n";
|
|
1852
|
-
};
|
|
1853
|
-
_proto.html = function html(_html, block) {
|
|
1854
|
-
return _html;
|
|
1489
|
+
blockquote(quote) {
|
|
1490
|
+
return `<blockquote>
|
|
1491
|
+
${quote}</blockquote>
|
|
1492
|
+
`;
|
|
1855
1493
|
}
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
* @param {string} raw
|
|
1861
|
-
* @param {any} slugger
|
|
1862
|
-
*/;
|
|
1863
|
-
_proto.heading = function heading(text, level, raw, slugger) {
|
|
1494
|
+
html(html, block2) {
|
|
1495
|
+
return html;
|
|
1496
|
+
}
|
|
1497
|
+
heading(text, level, raw, slugger) {
|
|
1864
1498
|
if (this.options.headerIds) {
|
|
1865
|
-
|
|
1866
|
-
return
|
|
1499
|
+
const id = this.options.headerPrefix + slugger.slug(raw);
|
|
1500
|
+
return `<h${level} id="${id}">${text}</h${level}>
|
|
1501
|
+
`;
|
|
1867
1502
|
}
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
return "<h" + level + ">" + text + "</h" + level + ">\n";
|
|
1871
|
-
};
|
|
1872
|
-
_proto.hr = function hr() {
|
|
1873
|
-
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
|
1874
|
-
};
|
|
1875
|
-
_proto.list = function list(body, ordered, start) {
|
|
1876
|
-
var type = ordered ? 'ol' : 'ul',
|
|
1877
|
-
startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
|
|
1878
|
-
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
|
1503
|
+
return `<h${level}>${text}</h${level}>
|
|
1504
|
+
`;
|
|
1879
1505
|
}
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
* @param {string} text
|
|
1883
|
-
*/;
|
|
1884
|
-
_proto.listitem = function listitem(text) {
|
|
1885
|
-
return "<li>" + text + "</li>\n";
|
|
1886
|
-
};
|
|
1887
|
-
_proto.checkbox = function checkbox(checked) {
|
|
1888
|
-
return '<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox"' + (this.options.xhtml ? ' /' : '') + '> ';
|
|
1506
|
+
hr() {
|
|
1507
|
+
return this.options.xhtml ? "<hr/>\n" : "<hr>\n";
|
|
1889
1508
|
}
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
*/;
|
|
1894
|
-
_proto.paragraph = function paragraph(text) {
|
|
1895
|
-
return "<p>" + text + "</p>\n";
|
|
1509
|
+
list(body, ordered, start) {
|
|
1510
|
+
const type = ordered ? "ol" : "ul", startatt = ordered && start !== 1 ? ' start="' + start + '"' : "";
|
|
1511
|
+
return "<" + type + startatt + ">\n" + body + "</" + type + ">\n";
|
|
1896
1512
|
}
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
* @param {string} body
|
|
1901
|
-
*/;
|
|
1902
|
-
_proto.table = function table(header, body) {
|
|
1903
|
-
if (body) body = "<tbody>" + body + "</tbody>";
|
|
1904
|
-
return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n';
|
|
1513
|
+
listitem(text, task, checked) {
|
|
1514
|
+
return `<li>${text}</li>
|
|
1515
|
+
`;
|
|
1905
1516
|
}
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
return
|
|
1517
|
+
checkbox(checked) {
|
|
1518
|
+
return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox"' + (this.options.xhtml ? " /" : "") + "> ";
|
|
1519
|
+
}
|
|
1520
|
+
paragraph(text) {
|
|
1521
|
+
return `<p>${text}</p>
|
|
1522
|
+
`;
|
|
1523
|
+
}
|
|
1524
|
+
table(header, body) {
|
|
1525
|
+
if (body)
|
|
1526
|
+
body = `<tbody>${body}</tbody>`;
|
|
1527
|
+
return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
|
|
1528
|
+
}
|
|
1529
|
+
tablerow(content) {
|
|
1530
|
+
return `<tr>
|
|
1531
|
+
${content}</tr>
|
|
1532
|
+
`;
|
|
1533
|
+
}
|
|
1534
|
+
tablecell(content, flags) {
|
|
1535
|
+
const type = flags.header ? "th" : "td";
|
|
1536
|
+
const tag = flags.align ? `<${type} align="${flags.align}">` : `<${type}>`;
|
|
1537
|
+
return tag + content + `</${type}>
|
|
1538
|
+
`;
|
|
1917
1539
|
}
|
|
1918
|
-
|
|
1919
1540
|
/**
|
|
1920
1541
|
* span level renderer
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
return "<strong>" + text + "</strong>";
|
|
1542
|
+
*/
|
|
1543
|
+
strong(text) {
|
|
1544
|
+
return `<strong>${text}</strong>`;
|
|
1925
1545
|
}
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
* @param {string} text
|
|
1929
|
-
*/;
|
|
1930
|
-
_proto.em = function em(text) {
|
|
1931
|
-
return "<em>" + text + "</em>";
|
|
1546
|
+
em(text) {
|
|
1547
|
+
return `<em>${text}</em>`;
|
|
1932
1548
|
}
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
* @param {string} text
|
|
1936
|
-
*/;
|
|
1937
|
-
_proto.codespan = function codespan(text) {
|
|
1938
|
-
return "<code>" + text + "</code>";
|
|
1939
|
-
};
|
|
1940
|
-
_proto.br = function br() {
|
|
1941
|
-
return this.options.xhtml ? '<br/>' : '<br>';
|
|
1549
|
+
codespan(text) {
|
|
1550
|
+
return `<code>${text}</code>`;
|
|
1942
1551
|
}
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
* @param {string} text
|
|
1946
|
-
*/;
|
|
1947
|
-
_proto.del = function del(text) {
|
|
1948
|
-
return "<del>" + text + "</del>";
|
|
1552
|
+
br() {
|
|
1553
|
+
return this.options.xhtml ? "<br/>" : "<br>";
|
|
1949
1554
|
}
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
* @param {string} text
|
|
1955
|
-
*/;
|
|
1956
|
-
_proto.link = function link(href, title, text) {
|
|
1555
|
+
del(text) {
|
|
1556
|
+
return `<del>${text}</del>`;
|
|
1557
|
+
}
|
|
1558
|
+
link(href, title, text) {
|
|
1957
1559
|
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
1958
1560
|
if (href === null) {
|
|
1959
1561
|
return text;
|
|
1960
1562
|
}
|
|
1961
|
-
|
|
1563
|
+
let out = '<a href="' + href + '"';
|
|
1962
1564
|
if (title) {
|
|
1963
1565
|
out += ' title="' + title + '"';
|
|
1964
1566
|
}
|
|
1965
|
-
out +=
|
|
1567
|
+
out += ">" + text + "</a>";
|
|
1966
1568
|
return out;
|
|
1967
1569
|
}
|
|
1968
|
-
|
|
1969
|
-
/**
|
|
1970
|
-
* @param {string} href
|
|
1971
|
-
* @param {string} title
|
|
1972
|
-
* @param {string} text
|
|
1973
|
-
*/;
|
|
1974
|
-
_proto.image = function image(href, title, text) {
|
|
1570
|
+
image(href, title, text) {
|
|
1975
1571
|
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
1976
1572
|
if (href === null) {
|
|
1977
1573
|
return text;
|
|
1978
1574
|
}
|
|
1979
|
-
|
|
1575
|
+
let out = `<img src="${href}" alt="${text}"`;
|
|
1980
1576
|
if (title) {
|
|
1981
|
-
out +=
|
|
1577
|
+
out += ` title="${title}"`;
|
|
1982
1578
|
}
|
|
1983
|
-
out += this.options.xhtml ?
|
|
1579
|
+
out += this.options.xhtml ? "/>" : ">";
|
|
1984
1580
|
return out;
|
|
1985
|
-
}
|
|
1986
|
-
|
|
1987
|
-
return
|
|
1988
|
-
}
|
|
1989
|
-
|
|
1990
|
-
}();
|
|
1581
|
+
}
|
|
1582
|
+
text(text) {
|
|
1583
|
+
return text;
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1991
1586
|
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
* returns only the textual part of the token
|
|
1995
|
-
*/
|
|
1996
|
-
var TextRenderer = /*#__PURE__*/function () {
|
|
1997
|
-
function TextRenderer() {}
|
|
1998
|
-
var _proto = TextRenderer.prototype;
|
|
1587
|
+
// src/TextRenderer.ts
|
|
1588
|
+
var _TextRenderer = class {
|
|
1999
1589
|
// no need for block level renderers
|
|
2000
|
-
|
|
1590
|
+
strong(text) {
|
|
2001
1591
|
return text;
|
|
2002
|
-
}
|
|
2003
|
-
|
|
1592
|
+
}
|
|
1593
|
+
em(text) {
|
|
2004
1594
|
return text;
|
|
2005
|
-
}
|
|
2006
|
-
|
|
1595
|
+
}
|
|
1596
|
+
codespan(text) {
|
|
2007
1597
|
return text;
|
|
2008
|
-
}
|
|
2009
|
-
|
|
1598
|
+
}
|
|
1599
|
+
del(text) {
|
|
2010
1600
|
return text;
|
|
2011
|
-
}
|
|
2012
|
-
|
|
1601
|
+
}
|
|
1602
|
+
html(text) {
|
|
2013
1603
|
return text;
|
|
2014
|
-
}
|
|
2015
|
-
|
|
2016
|
-
return
|
|
2017
|
-
}
|
|
2018
|
-
|
|
2019
|
-
return
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
return
|
|
2023
|
-
}
|
|
2024
|
-
|
|
2025
|
-
return
|
|
2026
|
-
}
|
|
2027
|
-
|
|
2028
|
-
}();
|
|
1604
|
+
}
|
|
1605
|
+
text(text) {
|
|
1606
|
+
return text;
|
|
1607
|
+
}
|
|
1608
|
+
link(href, title, text) {
|
|
1609
|
+
return "" + text;
|
|
1610
|
+
}
|
|
1611
|
+
image(href, title, text) {
|
|
1612
|
+
return "" + text;
|
|
1613
|
+
}
|
|
1614
|
+
br() {
|
|
1615
|
+
return "";
|
|
1616
|
+
}
|
|
1617
|
+
};
|
|
2029
1618
|
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
var Slugger = /*#__PURE__*/function () {
|
|
2034
|
-
function Slugger() {
|
|
1619
|
+
// src/Slugger.ts
|
|
1620
|
+
var _Slugger = class {
|
|
1621
|
+
constructor() {
|
|
2035
1622
|
this.seen = {};
|
|
2036
1623
|
}
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
* @param {string} value
|
|
2040
|
-
*/
|
|
2041
|
-
var _proto = Slugger.prototype;
|
|
2042
|
-
_proto.serialize = function serialize(value) {
|
|
2043
|
-
return value.toLowerCase().trim()
|
|
2044
|
-
// remove html tags
|
|
2045
|
-
.replace(/<[!\/a-z].*?>/ig, '')
|
|
2046
|
-
// remove unwanted chars
|
|
2047
|
-
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '').replace(/\s/g, '-');
|
|
1624
|
+
serialize(value) {
|
|
1625
|
+
return value.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig, "").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "").replace(/\s/g, "-");
|
|
2048
1626
|
}
|
|
2049
|
-
|
|
2050
1627
|
/**
|
|
2051
1628
|
* Finds the next safe (unique) slug to use
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
var slug = originalSlug;
|
|
2057
|
-
var occurenceAccumulator = 0;
|
|
1629
|
+
*/
|
|
1630
|
+
getNextSafeSlug(originalSlug, isDryRun) {
|
|
1631
|
+
let slug = originalSlug;
|
|
1632
|
+
let occurenceAccumulator = 0;
|
|
2058
1633
|
if (this.seen.hasOwnProperty(slug)) {
|
|
2059
1634
|
occurenceAccumulator = this.seen[originalSlug];
|
|
2060
1635
|
do {
|
|
2061
1636
|
occurenceAccumulator++;
|
|
2062
|
-
slug = originalSlug +
|
|
1637
|
+
slug = originalSlug + "-" + occurenceAccumulator;
|
|
2063
1638
|
} while (this.seen.hasOwnProperty(slug));
|
|
2064
1639
|
}
|
|
2065
1640
|
if (!isDryRun) {
|
|
@@ -2068,440 +1643,346 @@ var Slugger = /*#__PURE__*/function () {
|
|
|
2068
1643
|
}
|
|
2069
1644
|
return slug;
|
|
2070
1645
|
}
|
|
2071
|
-
|
|
2072
1646
|
/**
|
|
2073
1647
|
* Convert string to unique id
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
options = {};
|
|
2081
|
-
}
|
|
2082
|
-
var slug = this.serialize(value);
|
|
2083
|
-
return this.getNextSafeSlug(slug, options.dryrun);
|
|
2084
|
-
};
|
|
2085
|
-
return Slugger;
|
|
2086
|
-
}();
|
|
1648
|
+
*/
|
|
1649
|
+
slug(value, options2 = {}) {
|
|
1650
|
+
const slug = this.serialize(value);
|
|
1651
|
+
return this.getNextSafeSlug(slug, options2.dryrun);
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
2087
1654
|
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
this.options = options || exports.defaults;
|
|
2094
|
-
this.options.renderer = this.options.renderer || new Renderer();
|
|
1655
|
+
// src/Parser.ts
|
|
1656
|
+
var _Parser = class {
|
|
1657
|
+
constructor(options2) {
|
|
1658
|
+
this.options = options2 || _defaults;
|
|
1659
|
+
this.options.renderer = this.options.renderer || new _Renderer();
|
|
2095
1660
|
this.renderer = this.options.renderer;
|
|
2096
1661
|
this.renderer.options = this.options;
|
|
2097
|
-
this.textRenderer = new
|
|
2098
|
-
this.slugger = new
|
|
1662
|
+
this.textRenderer = new _TextRenderer();
|
|
1663
|
+
this.slugger = new _Slugger();
|
|
2099
1664
|
}
|
|
2100
|
-
|
|
2101
1665
|
/**
|
|
2102
1666
|
* Static Parse Method
|
|
2103
1667
|
*/
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
return
|
|
1668
|
+
static parse(tokens, options2) {
|
|
1669
|
+
const parser2 = new _Parser(options2);
|
|
1670
|
+
return parser2.parse(tokens);
|
|
2107
1671
|
}
|
|
2108
|
-
|
|
2109
1672
|
/**
|
|
2110
1673
|
* Static Parse Inline Method
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
return
|
|
1674
|
+
*/
|
|
1675
|
+
static parseInline(tokens, options2) {
|
|
1676
|
+
const parser2 = new _Parser(options2);
|
|
1677
|
+
return parser2.parseInline(tokens);
|
|
2115
1678
|
}
|
|
2116
|
-
|
|
2117
1679
|
/**
|
|
2118
1680
|
* Parse Loop
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
top = true;
|
|
2124
|
-
}
|
|
2125
|
-
var out = '',
|
|
2126
|
-
i,
|
|
2127
|
-
j,
|
|
2128
|
-
k,
|
|
2129
|
-
l2,
|
|
2130
|
-
l3,
|
|
2131
|
-
row,
|
|
2132
|
-
cell,
|
|
2133
|
-
header,
|
|
2134
|
-
body,
|
|
2135
|
-
token,
|
|
2136
|
-
ordered,
|
|
2137
|
-
start,
|
|
2138
|
-
loose,
|
|
2139
|
-
itemBody,
|
|
2140
|
-
item,
|
|
2141
|
-
checked,
|
|
2142
|
-
task,
|
|
2143
|
-
checkbox,
|
|
2144
|
-
ret;
|
|
2145
|
-
var l = tokens.length;
|
|
1681
|
+
*/
|
|
1682
|
+
parse(tokens, top = true) {
|
|
1683
|
+
let out = "", i, j, k, l2, l3, row, cell, header, body, token, ordered, start, loose, itemBody, item, checked, task, checkbox, ret;
|
|
1684
|
+
const l = tokens.length;
|
|
2146
1685
|
for (i = 0; i < l; i++) {
|
|
2147
1686
|
token = tokens[i];
|
|
2148
|
-
|
|
2149
|
-
// Run any renderer extensions
|
|
2150
1687
|
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
2151
|
-
ret = this.options.extensions.renderers[token.type].call({
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(token.type)) {
|
|
2155
|
-
out += ret || '';
|
|
1688
|
+
ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
|
|
1689
|
+
if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(token.type)) {
|
|
1690
|
+
out += ret || "";
|
|
2156
1691
|
continue;
|
|
2157
1692
|
}
|
|
2158
1693
|
}
|
|
2159
1694
|
switch (token.type) {
|
|
2160
|
-
case
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
1695
|
+
case "space": {
|
|
1696
|
+
continue;
|
|
1697
|
+
}
|
|
1698
|
+
case "hr": {
|
|
1699
|
+
out += this.renderer.hr();
|
|
1700
|
+
continue;
|
|
1701
|
+
}
|
|
1702
|
+
case "heading": {
|
|
1703
|
+
out += this.renderer.heading(
|
|
1704
|
+
this.parseInline(token.tokens),
|
|
1705
|
+
token.depth,
|
|
1706
|
+
unescape(this.parseInline(token.tokens, this.textRenderer)),
|
|
1707
|
+
this.slugger
|
|
1708
|
+
);
|
|
1709
|
+
continue;
|
|
1710
|
+
}
|
|
1711
|
+
case "code": {
|
|
1712
|
+
out += this.renderer.code(
|
|
1713
|
+
token.text,
|
|
1714
|
+
token.lang,
|
|
1715
|
+
!!token.escaped
|
|
1716
|
+
);
|
|
1717
|
+
continue;
|
|
1718
|
+
}
|
|
1719
|
+
case "table": {
|
|
1720
|
+
header = "";
|
|
1721
|
+
cell = "";
|
|
1722
|
+
l2 = token.header.length;
|
|
1723
|
+
for (j = 0; j < l2; j++) {
|
|
1724
|
+
cell += this.renderer.tablecell(
|
|
1725
|
+
this.parseInline(token.header[j].tokens),
|
|
1726
|
+
{ header: true, align: token.align[j] }
|
|
1727
|
+
);
|
|
2178
1728
|
}
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
cell =
|
|
2185
|
-
|
|
2186
|
-
for (
|
|
2187
|
-
cell += this.renderer.tablecell(
|
|
2188
|
-
|
|
2189
|
-
align: token.align[
|
|
2190
|
-
|
|
2191
|
-
}
|
|
2192
|
-
header += this.renderer.tablerow(cell);
|
|
2193
|
-
body = '';
|
|
2194
|
-
l2 = token.rows.length;
|
|
2195
|
-
for (j = 0; j < l2; j++) {
|
|
2196
|
-
row = token.rows[j];
|
|
2197
|
-
cell = '';
|
|
2198
|
-
l3 = row.length;
|
|
2199
|
-
for (k = 0; k < l3; k++) {
|
|
2200
|
-
cell += this.renderer.tablecell(this.parseInline(row[k].tokens), {
|
|
2201
|
-
header: false,
|
|
2202
|
-
align: token.align[k]
|
|
2203
|
-
});
|
|
2204
|
-
}
|
|
2205
|
-
body += this.renderer.tablerow(cell);
|
|
1729
|
+
header += this.renderer.tablerow(cell);
|
|
1730
|
+
body = "";
|
|
1731
|
+
l2 = token.rows.length;
|
|
1732
|
+
for (j = 0; j < l2; j++) {
|
|
1733
|
+
row = token.rows[j];
|
|
1734
|
+
cell = "";
|
|
1735
|
+
l3 = row.length;
|
|
1736
|
+
for (k = 0; k < l3; k++) {
|
|
1737
|
+
cell += this.renderer.tablecell(
|
|
1738
|
+
this.parseInline(row[k].tokens),
|
|
1739
|
+
{ header: false, align: token.align[k] }
|
|
1740
|
+
);
|
|
2206
1741
|
}
|
|
2207
|
-
|
|
2208
|
-
continue;
|
|
2209
|
-
}
|
|
2210
|
-
case 'blockquote':
|
|
2211
|
-
{
|
|
2212
|
-
body = this.parse(token.tokens);
|
|
2213
|
-
out += this.renderer.blockquote(body);
|
|
2214
|
-
continue;
|
|
1742
|
+
body += this.renderer.tablerow(cell);
|
|
2215
1743
|
}
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
1744
|
+
out += this.renderer.table(header, body);
|
|
1745
|
+
continue;
|
|
1746
|
+
}
|
|
1747
|
+
case "blockquote": {
|
|
1748
|
+
body = this.parse(token.tokens);
|
|
1749
|
+
out += this.renderer.blockquote(body);
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
case "list": {
|
|
1753
|
+
ordered = token.ordered;
|
|
1754
|
+
start = token.start;
|
|
1755
|
+
loose = token.loose;
|
|
1756
|
+
l2 = token.items.length;
|
|
1757
|
+
body = "";
|
|
1758
|
+
for (j = 0; j < l2; j++) {
|
|
1759
|
+
item = token.items[j];
|
|
1760
|
+
checked = item.checked;
|
|
1761
|
+
task = item.task;
|
|
1762
|
+
itemBody = "";
|
|
1763
|
+
if (item.task) {
|
|
1764
|
+
checkbox = this.renderer.checkbox(!!checked);
|
|
1765
|
+
if (loose) {
|
|
1766
|
+
if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
|
|
1767
|
+
item.tokens[0].text = checkbox + " " + item.tokens[0].text;
|
|
1768
|
+
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
|
|
1769
|
+
item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
|
|
2241
1770
|
}
|
|
2242
1771
|
} else {
|
|
2243
|
-
|
|
1772
|
+
item.tokens.unshift({
|
|
1773
|
+
type: "text",
|
|
1774
|
+
text: checkbox
|
|
1775
|
+
});
|
|
2244
1776
|
}
|
|
1777
|
+
} else {
|
|
1778
|
+
itemBody += checkbox;
|
|
2245
1779
|
}
|
|
2246
|
-
itemBody += this.parse(item.tokens, loose);
|
|
2247
|
-
body += this.renderer.listitem(itemBody, task, checked);
|
|
2248
1780
|
}
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
}
|
|
2252
|
-
case 'html':
|
|
2253
|
-
{
|
|
2254
|
-
out += this.renderer.html(token.text, token.block);
|
|
2255
|
-
continue;
|
|
1781
|
+
itemBody += this.parse(item.tokens, loose);
|
|
1782
|
+
body += this.renderer.listitem(itemBody, task, !!checked);
|
|
2256
1783
|
}
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
1784
|
+
out += this.renderer.list(body, ordered, start);
|
|
1785
|
+
continue;
|
|
1786
|
+
}
|
|
1787
|
+
case "html": {
|
|
1788
|
+
out += this.renderer.html(token.text, token.block);
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
case "paragraph": {
|
|
1792
|
+
out += this.renderer.paragraph(this.parseInline(token.tokens));
|
|
1793
|
+
continue;
|
|
1794
|
+
}
|
|
1795
|
+
case "text": {
|
|
1796
|
+
body = token.tokens ? this.parseInline(token.tokens) : token.text;
|
|
1797
|
+
while (i + 1 < l && tokens[i + 1].type === "text") {
|
|
1798
|
+
token = tokens[++i];
|
|
1799
|
+
body += "\n" + (token.tokens ? this.parseInline(token.tokens) : token.text);
|
|
2271
1800
|
}
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
1801
|
+
out += top ? this.renderer.paragraph(body) : body;
|
|
1802
|
+
continue;
|
|
1803
|
+
}
|
|
1804
|
+
default: {
|
|
1805
|
+
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
1806
|
+
if (this.options.silent) {
|
|
1807
|
+
console.error(errMsg);
|
|
1808
|
+
return "";
|
|
1809
|
+
} else {
|
|
1810
|
+
throw new Error(errMsg);
|
|
2281
1811
|
}
|
|
1812
|
+
}
|
|
2282
1813
|
}
|
|
2283
1814
|
}
|
|
2284
1815
|
return out;
|
|
2285
1816
|
}
|
|
2286
|
-
|
|
2287
1817
|
/**
|
|
2288
1818
|
* Parse Inline Tokens
|
|
2289
|
-
|
|
2290
|
-
|
|
1819
|
+
*/
|
|
1820
|
+
parseInline(tokens, renderer) {
|
|
2291
1821
|
renderer = renderer || this.renderer;
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
token,
|
|
2295
|
-
ret;
|
|
2296
|
-
var l = tokens.length;
|
|
1822
|
+
let out = "", i, token, ret;
|
|
1823
|
+
const l = tokens.length;
|
|
2297
1824
|
for (i = 0; i < l; i++) {
|
|
2298
1825
|
token = tokens[i];
|
|
2299
|
-
|
|
2300
|
-
// Run any renderer extensions
|
|
2301
1826
|
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
2302
|
-
ret = this.options.extensions.renderers[token.type].call({
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) {
|
|
2306
|
-
out += ret || '';
|
|
1827
|
+
ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
|
|
1828
|
+
if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(token.type)) {
|
|
1829
|
+
out += ret || "";
|
|
2307
1830
|
continue;
|
|
2308
1831
|
}
|
|
2309
1832
|
}
|
|
2310
1833
|
switch (token.type) {
|
|
2311
|
-
case
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
case
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
out += renderer.text(token.text);
|
|
2359
|
-
break;
|
|
2360
|
-
}
|
|
2361
|
-
default:
|
|
2362
|
-
{
|
|
2363
|
-
var errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
2364
|
-
if (this.options.silent) {
|
|
2365
|
-
console.error(errMsg);
|
|
2366
|
-
return;
|
|
2367
|
-
} else {
|
|
2368
|
-
throw new Error(errMsg);
|
|
2369
|
-
}
|
|
1834
|
+
case "escape": {
|
|
1835
|
+
out += renderer.text(token.text);
|
|
1836
|
+
break;
|
|
1837
|
+
}
|
|
1838
|
+
case "html": {
|
|
1839
|
+
out += renderer.html(token.text);
|
|
1840
|
+
break;
|
|
1841
|
+
}
|
|
1842
|
+
case "link": {
|
|
1843
|
+
out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
|
|
1844
|
+
break;
|
|
1845
|
+
}
|
|
1846
|
+
case "image": {
|
|
1847
|
+
out += renderer.image(token.href, token.title, token.text);
|
|
1848
|
+
break;
|
|
1849
|
+
}
|
|
1850
|
+
case "strong": {
|
|
1851
|
+
out += renderer.strong(this.parseInline(token.tokens, renderer));
|
|
1852
|
+
break;
|
|
1853
|
+
}
|
|
1854
|
+
case "em": {
|
|
1855
|
+
out += renderer.em(this.parseInline(token.tokens, renderer));
|
|
1856
|
+
break;
|
|
1857
|
+
}
|
|
1858
|
+
case "codespan": {
|
|
1859
|
+
out += renderer.codespan(token.text);
|
|
1860
|
+
break;
|
|
1861
|
+
}
|
|
1862
|
+
case "br": {
|
|
1863
|
+
out += renderer.br();
|
|
1864
|
+
break;
|
|
1865
|
+
}
|
|
1866
|
+
case "del": {
|
|
1867
|
+
out += renderer.del(this.parseInline(token.tokens, renderer));
|
|
1868
|
+
break;
|
|
1869
|
+
}
|
|
1870
|
+
case "text": {
|
|
1871
|
+
out += renderer.text(token.text);
|
|
1872
|
+
break;
|
|
1873
|
+
}
|
|
1874
|
+
default: {
|
|
1875
|
+
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
1876
|
+
if (this.options.silent) {
|
|
1877
|
+
console.error(errMsg);
|
|
1878
|
+
return "";
|
|
1879
|
+
} else {
|
|
1880
|
+
throw new Error(errMsg);
|
|
2370
1881
|
}
|
|
1882
|
+
}
|
|
2371
1883
|
}
|
|
2372
1884
|
}
|
|
2373
1885
|
return out;
|
|
2374
|
-
}
|
|
2375
|
-
|
|
2376
|
-
}();
|
|
1886
|
+
}
|
|
1887
|
+
};
|
|
2377
1888
|
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
1889
|
+
// src/Hooks.ts
|
|
1890
|
+
var _Hooks = class {
|
|
1891
|
+
constructor(options2) {
|
|
1892
|
+
this.options = options2 || _defaults;
|
|
2381
1893
|
}
|
|
2382
|
-
var _proto = Hooks.prototype;
|
|
2383
1894
|
/**
|
|
2384
1895
|
* Process markdown before marked
|
|
2385
1896
|
*/
|
|
2386
|
-
|
|
1897
|
+
preprocess(markdown) {
|
|
2387
1898
|
return markdown;
|
|
2388
1899
|
}
|
|
2389
|
-
|
|
2390
1900
|
/**
|
|
2391
1901
|
* Process HTML after marked is finished
|
|
2392
|
-
|
|
2393
|
-
|
|
1902
|
+
*/
|
|
1903
|
+
postprocess(html) {
|
|
2394
1904
|
return html;
|
|
2395
|
-
}
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
});
|
|
2410
|
-
this.defaults = getDefaults();
|
|
1905
|
+
}
|
|
1906
|
+
};
|
|
1907
|
+
_Hooks.passThroughHooks = /* @__PURE__ */ new Set([
|
|
1908
|
+
"preprocess",
|
|
1909
|
+
"postprocess"
|
|
1910
|
+
]);
|
|
1911
|
+
|
|
1912
|
+
// src/Instance.ts
|
|
1913
|
+
var _parseMarkdown, parseMarkdown_fn, _onError, onError_fn;
|
|
1914
|
+
var Marked = class {
|
|
1915
|
+
constructor(...args) {
|
|
1916
|
+
__privateAdd(this, _parseMarkdown);
|
|
1917
|
+
__privateAdd(this, _onError);
|
|
1918
|
+
this.defaults = _getDefaults();
|
|
2411
1919
|
this.options = this.setOptions;
|
|
2412
|
-
this.parse =
|
|
2413
|
-
this.parseInline =
|
|
2414
|
-
this.Parser =
|
|
2415
|
-
this.parser =
|
|
2416
|
-
this.Renderer =
|
|
2417
|
-
this.TextRenderer =
|
|
2418
|
-
this.Lexer =
|
|
2419
|
-
this.lexer =
|
|
2420
|
-
this.Tokenizer =
|
|
2421
|
-
this.Slugger =
|
|
2422
|
-
this.Hooks =
|
|
2423
|
-
this.use
|
|
2424
|
-
}
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
values = values.concat(callback.call(
|
|
1920
|
+
this.parse = __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lex, _Parser.parse);
|
|
1921
|
+
this.parseInline = __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lexInline, _Parser.parseInline);
|
|
1922
|
+
this.Parser = _Parser;
|
|
1923
|
+
this.parser = _Parser.parse;
|
|
1924
|
+
this.Renderer = _Renderer;
|
|
1925
|
+
this.TextRenderer = _TextRenderer;
|
|
1926
|
+
this.Lexer = _Lexer;
|
|
1927
|
+
this.lexer = _Lexer.lex;
|
|
1928
|
+
this.Tokenizer = _Tokenizer;
|
|
1929
|
+
this.Slugger = _Slugger;
|
|
1930
|
+
this.Hooks = _Hooks;
|
|
1931
|
+
this.use(...args);
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* Run callback for every token
|
|
1935
|
+
*/
|
|
1936
|
+
walkTokens(tokens, callback) {
|
|
1937
|
+
let values = [];
|
|
1938
|
+
for (const token of tokens) {
|
|
1939
|
+
values = values.concat(callback.call(this, token));
|
|
2432
1940
|
switch (token.type) {
|
|
2433
|
-
case
|
|
2434
|
-
{
|
|
2435
|
-
|
|
2436
|
-
var cell = _step2.value;
|
|
2437
|
-
values = values.concat(_this.walkTokens(cell.tokens, callback));
|
|
2438
|
-
}
|
|
2439
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(token.rows), _step3; !(_step3 = _iterator3()).done;) {
|
|
2440
|
-
var row = _step3.value;
|
|
2441
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose(row), _step4; !(_step4 = _iterator4()).done;) {
|
|
2442
|
-
var _cell = _step4.value;
|
|
2443
|
-
values = values.concat(_this.walkTokens(_cell.tokens, callback));
|
|
2444
|
-
}
|
|
2445
|
-
}
|
|
2446
|
-
break;
|
|
2447
|
-
}
|
|
2448
|
-
case 'list':
|
|
2449
|
-
{
|
|
2450
|
-
values = values.concat(_this.walkTokens(token.items, callback));
|
|
2451
|
-
break;
|
|
1941
|
+
case "table": {
|
|
1942
|
+
for (const cell of token.header) {
|
|
1943
|
+
values = values.concat(this.walkTokens(cell.tokens, callback));
|
|
2452
1944
|
}
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
// Walk any extensions
|
|
2457
|
-
_this.defaults.extensions.childTokens[token.type].forEach(function (childTokens) {
|
|
2458
|
-
values = values.concat(_this.walkTokens(token[childTokens], callback));
|
|
2459
|
-
});
|
|
2460
|
-
} else if (token.tokens) {
|
|
2461
|
-
values = values.concat(_this.walkTokens(token.tokens, callback));
|
|
1945
|
+
for (const row of token.rows) {
|
|
1946
|
+
for (const cell of row) {
|
|
1947
|
+
values = values.concat(this.walkTokens(cell.tokens, callback));
|
|
2462
1948
|
}
|
|
2463
1949
|
}
|
|
1950
|
+
break;
|
|
1951
|
+
}
|
|
1952
|
+
case "list": {
|
|
1953
|
+
values = values.concat(this.walkTokens(token.items, callback));
|
|
1954
|
+
break;
|
|
1955
|
+
}
|
|
1956
|
+
default: {
|
|
1957
|
+
if (this.defaults.extensions && this.defaults.extensions.childTokens && this.defaults.extensions.childTokens[token.type]) {
|
|
1958
|
+
this.defaults.extensions.childTokens[token.type].forEach((childTokens) => {
|
|
1959
|
+
values = values.concat(this.walkTokens(token[childTokens], callback));
|
|
1960
|
+
});
|
|
1961
|
+
} else if (token.tokens) {
|
|
1962
|
+
values = values.concat(this.walkTokens(token.tokens, callback));
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
2464
1965
|
}
|
|
2465
|
-
};
|
|
2466
|
-
for (var _iterator = _createForOfIteratorHelperLoose(tokens), _step; !(_step = _iterator()).done;) {
|
|
2467
|
-
_loop();
|
|
2468
1966
|
}
|
|
2469
1967
|
return values;
|
|
2470
|
-
}
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
};
|
|
2477
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2478
|
-
args[_key] = arguments[_key];
|
|
2479
|
-
}
|
|
2480
|
-
args.forEach(function (pack) {
|
|
2481
|
-
// copy options to new object
|
|
2482
|
-
var opts = _extends({}, pack);
|
|
2483
|
-
|
|
2484
|
-
// set async to true if it was set to true before
|
|
2485
|
-
opts.async = _this2.defaults.async || opts.async || false;
|
|
2486
|
-
|
|
2487
|
-
// ==-- Parse "addon" extensions --== //
|
|
1968
|
+
}
|
|
1969
|
+
use(...args) {
|
|
1970
|
+
const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
1971
|
+
args.forEach((pack) => {
|
|
1972
|
+
const opts = { ...pack };
|
|
1973
|
+
opts.async = this.defaults.async || opts.async || false;
|
|
2488
1974
|
if (pack.extensions) {
|
|
2489
|
-
pack.extensions.forEach(
|
|
1975
|
+
pack.extensions.forEach((ext) => {
|
|
2490
1976
|
if (!ext.name) {
|
|
2491
|
-
throw new Error(
|
|
1977
|
+
throw new Error("extension name required");
|
|
2492
1978
|
}
|
|
2493
|
-
if (ext
|
|
2494
|
-
|
|
2495
|
-
var prevRenderer = extensions.renderers[ext.name];
|
|
1979
|
+
if ("renderer" in ext) {
|
|
1980
|
+
const prevRenderer = extensions.renderers[ext.name];
|
|
2496
1981
|
if (prevRenderer) {
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2500
|
-
args[_key2] = arguments[_key2];
|
|
2501
|
-
}
|
|
2502
|
-
var ret = ext.renderer.apply(this, args);
|
|
1982
|
+
extensions.renderers[ext.name] = function(...args2) {
|
|
1983
|
+
let ret = ext.renderer.apply(this, args2);
|
|
2503
1984
|
if (ret === false) {
|
|
2504
|
-
ret = prevRenderer.apply(this,
|
|
1985
|
+
ret = prevRenderer.apply(this, args2);
|
|
2505
1986
|
}
|
|
2506
1987
|
return ret;
|
|
2507
1988
|
};
|
|
@@ -2509,9 +1990,8 @@ var Marked = /*#__PURE__*/function () {
|
|
|
2509
1990
|
extensions.renderers[ext.name] = ext.renderer;
|
|
2510
1991
|
}
|
|
2511
1992
|
}
|
|
2512
|
-
if (ext
|
|
2513
|
-
|
|
2514
|
-
if (!ext.level || ext.level !== 'block' && ext.level !== 'inline') {
|
|
1993
|
+
if ("tokenizer" in ext) {
|
|
1994
|
+
if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
|
|
2515
1995
|
throw new Error("extension level must be 'block' or 'inline'");
|
|
2516
1996
|
}
|
|
2517
1997
|
if (extensions[ext.level]) {
|
|
@@ -2520,14 +2000,13 @@ var Marked = /*#__PURE__*/function () {
|
|
|
2520
2000
|
extensions[ext.level] = [ext.tokenizer];
|
|
2521
2001
|
}
|
|
2522
2002
|
if (ext.start) {
|
|
2523
|
-
|
|
2524
|
-
if (ext.level === 'block') {
|
|
2003
|
+
if (ext.level === "block") {
|
|
2525
2004
|
if (extensions.startBlock) {
|
|
2526
2005
|
extensions.startBlock.push(ext.start);
|
|
2527
2006
|
} else {
|
|
2528
2007
|
extensions.startBlock = [ext.start];
|
|
2529
2008
|
}
|
|
2530
|
-
} else if (ext.level ===
|
|
2009
|
+
} else if (ext.level === "inline") {
|
|
2531
2010
|
if (extensions.startInline) {
|
|
2532
2011
|
extensions.startInline.push(ext.start);
|
|
2533
2012
|
} else {
|
|
@@ -2536,155 +2015,125 @@ var Marked = /*#__PURE__*/function () {
|
|
|
2536
2015
|
}
|
|
2537
2016
|
}
|
|
2538
2017
|
}
|
|
2539
|
-
if (ext.childTokens) {
|
|
2540
|
-
// Child tokens to be visited by walkTokens
|
|
2018
|
+
if ("childTokens" in ext && ext.childTokens) {
|
|
2541
2019
|
extensions.childTokens[ext.name] = ext.childTokens;
|
|
2542
2020
|
}
|
|
2543
2021
|
});
|
|
2544
2022
|
opts.extensions = extensions;
|
|
2545
2023
|
}
|
|
2546
|
-
|
|
2547
|
-
// ==-- Parse "overwrite" extensions --== //
|
|
2548
2024
|
if (pack.renderer) {
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
2555
|
-
args[_key3] = arguments[_key3];
|
|
2556
|
-
}
|
|
2557
|
-
var ret = pack.renderer[prop].apply(renderer, args);
|
|
2025
|
+
const renderer = this.defaults.renderer || new _Renderer(this.defaults);
|
|
2026
|
+
for (const prop in pack.renderer) {
|
|
2027
|
+
const prevRenderer = renderer[prop];
|
|
2028
|
+
renderer[prop] = (...args2) => {
|
|
2029
|
+
let ret = pack.renderer[prop].apply(renderer, args2);
|
|
2558
2030
|
if (ret === false) {
|
|
2559
|
-
ret = prevRenderer.apply(renderer,
|
|
2031
|
+
ret = prevRenderer.apply(renderer, args2);
|
|
2560
2032
|
}
|
|
2561
2033
|
return ret;
|
|
2562
2034
|
};
|
|
2563
|
-
};
|
|
2564
|
-
for (var prop in pack.renderer) {
|
|
2565
|
-
_loop2(prop);
|
|
2566
2035
|
}
|
|
2567
2036
|
opts.renderer = renderer;
|
|
2568
2037
|
}
|
|
2569
2038
|
if (pack.tokenizer) {
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
2576
|
-
args[_key4] = arguments[_key4];
|
|
2577
|
-
}
|
|
2578
|
-
var ret = pack.tokenizer[_prop].apply(tokenizer, args);
|
|
2039
|
+
const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
|
|
2040
|
+
for (const prop in pack.tokenizer) {
|
|
2041
|
+
const prevTokenizer = tokenizer[prop];
|
|
2042
|
+
tokenizer[prop] = (...args2) => {
|
|
2043
|
+
let ret = pack.tokenizer[prop].apply(tokenizer, args2);
|
|
2579
2044
|
if (ret === false) {
|
|
2580
|
-
ret = prevTokenizer.apply(tokenizer,
|
|
2045
|
+
ret = prevTokenizer.apply(tokenizer, args2);
|
|
2581
2046
|
}
|
|
2582
2047
|
return ret;
|
|
2583
2048
|
};
|
|
2584
|
-
};
|
|
2585
|
-
for (var _prop in pack.tokenizer) {
|
|
2586
|
-
_loop3(_prop);
|
|
2587
2049
|
}
|
|
2588
2050
|
opts.tokenizer = tokenizer;
|
|
2589
2051
|
}
|
|
2590
|
-
|
|
2591
|
-
// ==-- Parse Hooks extensions --== //
|
|
2592
2052
|
if (pack.hooks) {
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
if (
|
|
2597
|
-
hooks[
|
|
2598
|
-
if (
|
|
2599
|
-
return Promise.resolve(pack.hooks[
|
|
2600
|
-
return prevHook.call(hooks,
|
|
2053
|
+
const hooks = this.defaults.hooks || new _Hooks();
|
|
2054
|
+
for (const prop in pack.hooks) {
|
|
2055
|
+
const prevHook = hooks[prop];
|
|
2056
|
+
if (_Hooks.passThroughHooks.has(prop)) {
|
|
2057
|
+
hooks[prop] = (arg) => {
|
|
2058
|
+
if (this.defaults.async) {
|
|
2059
|
+
return Promise.resolve(pack.hooks[prop].call(hooks, arg)).then((ret2) => {
|
|
2060
|
+
return prevHook.call(hooks, ret2);
|
|
2601
2061
|
});
|
|
2602
2062
|
}
|
|
2603
|
-
|
|
2063
|
+
const ret = pack.hooks[prop].call(hooks, arg);
|
|
2604
2064
|
return prevHook.call(hooks, ret);
|
|
2605
2065
|
};
|
|
2606
2066
|
} else {
|
|
2607
|
-
hooks[
|
|
2608
|
-
|
|
2609
|
-
args[_key5] = arguments[_key5];
|
|
2610
|
-
}
|
|
2611
|
-
var ret = pack.hooks[_prop2].apply(hooks, args);
|
|
2067
|
+
hooks[prop] = (...args2) => {
|
|
2068
|
+
let ret = pack.hooks[prop].apply(hooks, args2);
|
|
2612
2069
|
if (ret === false) {
|
|
2613
|
-
ret = prevHook.apply(hooks,
|
|
2070
|
+
ret = prevHook.apply(hooks, args2);
|
|
2614
2071
|
}
|
|
2615
2072
|
return ret;
|
|
2616
2073
|
};
|
|
2617
2074
|
}
|
|
2618
|
-
};
|
|
2619
|
-
for (var _prop2 in pack.hooks) {
|
|
2620
|
-
_loop4(_prop2);
|
|
2621
2075
|
}
|
|
2622
2076
|
opts.hooks = hooks;
|
|
2623
2077
|
}
|
|
2624
|
-
|
|
2625
|
-
// ==-- Parse WalkTokens extensions --== //
|
|
2626
2078
|
if (pack.walkTokens) {
|
|
2627
|
-
|
|
2628
|
-
opts.walkTokens = function
|
|
2629
|
-
|
|
2079
|
+
const walkTokens2 = this.defaults.walkTokens;
|
|
2080
|
+
opts.walkTokens = function(token) {
|
|
2081
|
+
let values = [];
|
|
2630
2082
|
values.push(pack.walkTokens.call(this, token));
|
|
2631
|
-
if (
|
|
2632
|
-
values = values.concat(
|
|
2083
|
+
if (walkTokens2) {
|
|
2084
|
+
values = values.concat(walkTokens2.call(this, token));
|
|
2633
2085
|
}
|
|
2634
2086
|
return values;
|
|
2635
2087
|
};
|
|
2636
2088
|
}
|
|
2637
|
-
|
|
2089
|
+
this.defaults = { ...this.defaults, ...opts };
|
|
2638
2090
|
});
|
|
2639
2091
|
return this;
|
|
2640
|
-
}
|
|
2641
|
-
|
|
2642
|
-
this.defaults =
|
|
2092
|
+
}
|
|
2093
|
+
setOptions(opt) {
|
|
2094
|
+
this.defaults = { ...this.defaults, ...opt };
|
|
2643
2095
|
return this;
|
|
2644
|
-
}
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
function
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
}
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
if (typeof src
|
|
2660
|
-
return throwError(new Error(
|
|
2661
|
-
}
|
|
2662
|
-
if (typeof src !== 'string') {
|
|
2663
|
-
return throwError(new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected'));
|
|
2096
|
+
}
|
|
2097
|
+
};
|
|
2098
|
+
_parseMarkdown = new WeakSet();
|
|
2099
|
+
parseMarkdown_fn = function(lexer2, parser2) {
|
|
2100
|
+
return (src, optOrCallback, callback) => {
|
|
2101
|
+
if (typeof optOrCallback === "function") {
|
|
2102
|
+
callback = optOrCallback;
|
|
2103
|
+
optOrCallback = null;
|
|
2104
|
+
}
|
|
2105
|
+
const origOpt = { ...optOrCallback };
|
|
2106
|
+
const opt = { ...this.defaults, ...origOpt };
|
|
2107
|
+
const throwError = __privateMethod(this, _onError, onError_fn).call(this, !!opt.silent, !!opt.async, callback);
|
|
2108
|
+
if (typeof src === "undefined" || src === null) {
|
|
2109
|
+
return throwError(new Error("marked(): input parameter is undefined or null"));
|
|
2110
|
+
}
|
|
2111
|
+
if (typeof src !== "string") {
|
|
2112
|
+
return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
|
|
2664
2113
|
}
|
|
2665
2114
|
checkDeprecations(opt, callback);
|
|
2666
2115
|
if (opt.hooks) {
|
|
2667
2116
|
opt.hooks.options = opt;
|
|
2668
2117
|
}
|
|
2669
2118
|
if (callback) {
|
|
2670
|
-
|
|
2671
|
-
|
|
2119
|
+
const highlight = opt.highlight;
|
|
2120
|
+
let tokens;
|
|
2672
2121
|
try {
|
|
2673
2122
|
if (opt.hooks) {
|
|
2674
2123
|
src = opt.hooks.preprocess(src);
|
|
2675
2124
|
}
|
|
2676
|
-
tokens =
|
|
2125
|
+
tokens = lexer2(src, opt);
|
|
2677
2126
|
} catch (e) {
|
|
2678
2127
|
return throwError(e);
|
|
2679
2128
|
}
|
|
2680
|
-
|
|
2681
|
-
|
|
2129
|
+
const done = (err) => {
|
|
2130
|
+
let out;
|
|
2682
2131
|
if (!err) {
|
|
2683
2132
|
try {
|
|
2684
2133
|
if (opt.walkTokens) {
|
|
2685
|
-
|
|
2134
|
+
this.walkTokens(tokens, opt.walkTokens);
|
|
2686
2135
|
}
|
|
2687
|
-
out =
|
|
2136
|
+
out = parser2(tokens, opt);
|
|
2688
2137
|
if (opt.hooks) {
|
|
2689
2138
|
out = opt.hooks.postprocess(out);
|
|
2690
2139
|
}
|
|
@@ -2699,13 +2148,14 @@ function _parseMarkdown2(lexer, parser) {
|
|
|
2699
2148
|
return done();
|
|
2700
2149
|
}
|
|
2701
2150
|
delete opt.highlight;
|
|
2702
|
-
if (!tokens.length)
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2151
|
+
if (!tokens.length)
|
|
2152
|
+
return done();
|
|
2153
|
+
let pending = 0;
|
|
2154
|
+
this.walkTokens(tokens, (token) => {
|
|
2155
|
+
if (token.type === "code") {
|
|
2706
2156
|
pending++;
|
|
2707
|
-
setTimeout(
|
|
2708
|
-
highlight(token.text, token.lang,
|
|
2157
|
+
setTimeout(() => {
|
|
2158
|
+
highlight(token.text, token.lang, (err, code) => {
|
|
2709
2159
|
if (err) {
|
|
2710
2160
|
return done(err);
|
|
2711
2161
|
}
|
|
@@ -2727,27 +2177,17 @@ function _parseMarkdown2(lexer, parser) {
|
|
|
2727
2177
|
return;
|
|
2728
2178
|
}
|
|
2729
2179
|
if (opt.async) {
|
|
2730
|
-
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then(
|
|
2731
|
-
return lexer(src, opt);
|
|
2732
|
-
}).then(function (tokens) {
|
|
2733
|
-
return opt.walkTokens ? Promise.all(_this3.walkTokens(tokens, opt.walkTokens)).then(function () {
|
|
2734
|
-
return tokens;
|
|
2735
|
-
}) : tokens;
|
|
2736
|
-
}).then(function (tokens) {
|
|
2737
|
-
return parser(tokens, opt);
|
|
2738
|
-
}).then(function (html) {
|
|
2739
|
-
return opt.hooks ? opt.hooks.postprocess(html) : html;
|
|
2740
|
-
})["catch"](throwError);
|
|
2180
|
+
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html) => opt.hooks ? opt.hooks.postprocess(html) : html).catch(throwError);
|
|
2741
2181
|
}
|
|
2742
2182
|
try {
|
|
2743
2183
|
if (opt.hooks) {
|
|
2744
2184
|
src = opt.hooks.preprocess(src);
|
|
2745
2185
|
}
|
|
2746
|
-
|
|
2186
|
+
const tokens = lexer2(src, opt);
|
|
2747
2187
|
if (opt.walkTokens) {
|
|
2748
|
-
|
|
2188
|
+
this.walkTokens(tokens, opt.walkTokens);
|
|
2749
2189
|
}
|
|
2750
|
-
|
|
2190
|
+
let html = parser2(tokens, opt);
|
|
2751
2191
|
if (opt.hooks) {
|
|
2752
2192
|
html = opt.hooks.postprocess(html);
|
|
2753
2193
|
}
|
|
@@ -2756,12 +2196,13 @@ function _parseMarkdown2(lexer, parser) {
|
|
|
2756
2196
|
return throwError(e);
|
|
2757
2197
|
}
|
|
2758
2198
|
};
|
|
2759
|
-
}
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2199
|
+
};
|
|
2200
|
+
_onError = new WeakSet();
|
|
2201
|
+
onError_fn = function(silent, async, callback) {
|
|
2202
|
+
return (e) => {
|
|
2203
|
+
e.message += "\nPlease report this to https://github.com/markedjs/marked.";
|
|
2763
2204
|
if (silent) {
|
|
2764
|
-
|
|
2205
|
+
const msg = "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
|
|
2765
2206
|
if (async) {
|
|
2766
2207
|
return Promise.resolve(msg);
|
|
2767
2208
|
}
|
|
@@ -2780,67 +2221,40 @@ function _onError2(silent, async, callback) {
|
|
|
2780
2221
|
}
|
|
2781
2222
|
throw e;
|
|
2782
2223
|
};
|
|
2783
|
-
}
|
|
2784
|
-
|
|
2785
|
-
var markedInstance = new Marked(exports.defaults);
|
|
2224
|
+
};
|
|
2786
2225
|
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
*/
|
|
2226
|
+
// src/marked.ts
|
|
2227
|
+
var markedInstance = new Marked();
|
|
2790
2228
|
function marked(src, opt, callback) {
|
|
2791
2229
|
return markedInstance.parse(src, opt, callback);
|
|
2792
2230
|
}
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
* Options
|
|
2796
|
-
*/
|
|
2797
|
-
|
|
2798
|
-
marked.options = marked.setOptions = function (opt) {
|
|
2799
|
-
markedInstance.setOptions(opt);
|
|
2231
|
+
marked.options = marked.setOptions = function(options2) {
|
|
2232
|
+
markedInstance.setOptions(options2);
|
|
2800
2233
|
marked.defaults = markedInstance.defaults;
|
|
2801
2234
|
changeDefaults(marked.defaults);
|
|
2802
2235
|
return marked;
|
|
2803
2236
|
};
|
|
2804
|
-
marked.getDefaults =
|
|
2805
|
-
marked.defaults =
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
* Use Extension
|
|
2809
|
-
*/
|
|
2810
|
-
|
|
2811
|
-
marked.use = function () {
|
|
2812
|
-
markedInstance.use.apply(markedInstance, arguments);
|
|
2237
|
+
marked.getDefaults = _getDefaults;
|
|
2238
|
+
marked.defaults = _defaults;
|
|
2239
|
+
marked.use = function(...args) {
|
|
2240
|
+
markedInstance.use(...args);
|
|
2813
2241
|
marked.defaults = markedInstance.defaults;
|
|
2814
2242
|
changeDefaults(marked.defaults);
|
|
2815
2243
|
return marked;
|
|
2816
2244
|
};
|
|
2817
|
-
|
|
2818
|
-
/**
|
|
2819
|
-
* Run callback for every token
|
|
2820
|
-
*/
|
|
2821
|
-
|
|
2822
|
-
marked.walkTokens = function (tokens, callback) {
|
|
2245
|
+
marked.walkTokens = function(tokens, callback) {
|
|
2823
2246
|
return markedInstance.walkTokens(tokens, callback);
|
|
2824
2247
|
};
|
|
2825
|
-
|
|
2826
|
-
/**
|
|
2827
|
-
* Parse Inline
|
|
2828
|
-
* @param {string} src
|
|
2829
|
-
*/
|
|
2830
2248
|
marked.parseInline = markedInstance.parseInline;
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
marked.
|
|
2836
|
-
marked.
|
|
2837
|
-
marked.
|
|
2838
|
-
marked.
|
|
2839
|
-
marked.
|
|
2840
|
-
marked.lexer = Lexer.lex;
|
|
2841
|
-
marked.Tokenizer = Tokenizer;
|
|
2842
|
-
marked.Slugger = Slugger;
|
|
2843
|
-
marked.Hooks = Hooks;
|
|
2249
|
+
marked.Parser = _Parser;
|
|
2250
|
+
marked.parser = _Parser.parse;
|
|
2251
|
+
marked.Renderer = _Renderer;
|
|
2252
|
+
marked.TextRenderer = _TextRenderer;
|
|
2253
|
+
marked.Lexer = _Lexer;
|
|
2254
|
+
marked.lexer = _Lexer.lex;
|
|
2255
|
+
marked.Tokenizer = _Tokenizer;
|
|
2256
|
+
marked.Slugger = _Slugger;
|
|
2257
|
+
marked.Hooks = _Hooks;
|
|
2844
2258
|
marked.parse = marked;
|
|
2845
2259
|
var options = marked.options;
|
|
2846
2260
|
var setOptions = marked.setOptions;
|
|
@@ -2848,24 +2262,28 @@ var use = marked.use;
|
|
|
2848
2262
|
var walkTokens = marked.walkTokens;
|
|
2849
2263
|
var parseInline = marked.parseInline;
|
|
2850
2264
|
var parse = marked;
|
|
2851
|
-
var parser =
|
|
2852
|
-
var lexer =
|
|
2853
|
-
|
|
2854
|
-
exports
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2265
|
+
var parser = _Parser.parse;
|
|
2266
|
+
var lexer = _Lexer.lex;
|
|
2267
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2268
|
+
0 && (module.exports = {
|
|
2269
|
+
Hooks,
|
|
2270
|
+
Lexer,
|
|
2271
|
+
Marked,
|
|
2272
|
+
Parser,
|
|
2273
|
+
Renderer,
|
|
2274
|
+
Slugger,
|
|
2275
|
+
TextRenderer,
|
|
2276
|
+
Tokenizer,
|
|
2277
|
+
defaults,
|
|
2278
|
+
getDefaults,
|
|
2279
|
+
lexer,
|
|
2280
|
+
marked,
|
|
2281
|
+
options,
|
|
2282
|
+
parse,
|
|
2283
|
+
parseInline,
|
|
2284
|
+
parser,
|
|
2285
|
+
setOptions,
|
|
2286
|
+
use,
|
|
2287
|
+
walkTokens
|
|
2288
|
+
});
|
|
2289
|
+
//# sourceMappingURL=marked.cjs.map
|