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.umd.js
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,100 +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
|
-
for (var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
28
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
29
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
30
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
31
|
-
writable: false
|
|
32
|
-
});
|
|
33
|
-
return Constructor;
|
|
34
|
-
}
|
|
35
|
-
function _extends() {
|
|
36
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
37
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
38
|
-
var source = arguments[i];
|
|
39
|
-
for (var key in source) {
|
|
40
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
41
|
-
target[key] = source[key];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return target;
|
|
46
|
-
};
|
|
47
|
-
return _extends.apply(this, arguments);
|
|
48
|
-
}
|
|
49
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
50
|
-
if (!o) return;
|
|
51
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
52
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
53
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
54
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
55
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
56
|
-
}
|
|
57
|
-
function _arrayLikeToArray(arr, len) {
|
|
58
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
59
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
60
|
-
return arr2;
|
|
61
|
-
}
|
|
62
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
63
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
64
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
65
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
66
|
-
if (it) o = it;
|
|
67
|
-
var i = 0;
|
|
68
|
-
return function () {
|
|
69
|
-
if (i >= o.length) return {
|
|
70
|
-
done: true
|
|
71
|
-
};
|
|
72
|
-
return {
|
|
73
|
-
done: false,
|
|
74
|
-
value: o[i++]
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
79
|
-
}
|
|
80
|
-
function _toPrimitive(input, hint) {
|
|
81
|
-
if (typeof input !== "object" || input === null) return input;
|
|
82
|
-
var prim = input[Symbol.toPrimitive];
|
|
83
|
-
if (prim !== undefined) {
|
|
84
|
-
var res = prim.call(input, hint || "default");
|
|
85
|
-
if (typeof res !== "object") return res;
|
|
86
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
87
|
-
}
|
|
88
|
-
return (hint === "string" ? String : Number)(input);
|
|
89
|
-
}
|
|
90
|
-
function _toPropertyKey(arg) {
|
|
91
|
-
var key = _toPrimitive(arg, "string");
|
|
92
|
-
return typeof key === "symbol" ? key : String(key);
|
|
93
|
-
}
|
|
94
|
-
var id = 0;
|
|
95
|
-
function _classPrivateFieldLooseKey(name) {
|
|
96
|
-
return "__private_" + id++ + "_" + name;
|
|
97
|
-
}
|
|
98
|
-
function _classPrivateFieldLooseBase(receiver, privateKey) {
|
|
99
|
-
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
|
|
100
|
-
throw new TypeError("attempted to use private field on non-instance");
|
|
12
|
+
"use strict";
|
|
13
|
+
var marked = (() => {
|
|
14
|
+
var __defProp = Object.defineProperty;
|
|
15
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
16
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
17
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
+
var __export = (target, all) => {
|
|
19
|
+
for (var name in all)
|
|
20
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
|
+
};
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(from))
|
|
25
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
26
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
101
27
|
}
|
|
102
|
-
return
|
|
103
|
-
}
|
|
28
|
+
return to;
|
|
29
|
+
};
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
+
var __accessCheck = (obj, member, msg) => {
|
|
32
|
+
if (!member.has(obj))
|
|
33
|
+
throw TypeError("Cannot " + msg);
|
|
34
|
+
};
|
|
35
|
+
var __privateAdd = (obj, member, value) => {
|
|
36
|
+
if (member.has(obj))
|
|
37
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
38
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
39
|
+
};
|
|
40
|
+
var __privateMethod = (obj, member, method) => {
|
|
41
|
+
__accessCheck(obj, member, "access private method");
|
|
42
|
+
return method;
|
|
43
|
+
};
|
|
104
44
|
|
|
105
|
-
|
|
45
|
+
// src/marked.ts
|
|
46
|
+
var marked_exports = {};
|
|
47
|
+
__export(marked_exports, {
|
|
48
|
+
Hooks: () => _Hooks,
|
|
49
|
+
Lexer: () => _Lexer,
|
|
50
|
+
Marked: () => Marked,
|
|
51
|
+
Parser: () => _Parser,
|
|
52
|
+
Renderer: () => _Renderer,
|
|
53
|
+
Slugger: () => _Slugger,
|
|
54
|
+
TextRenderer: () => _TextRenderer,
|
|
55
|
+
Tokenizer: () => _Tokenizer,
|
|
56
|
+
defaults: () => _defaults,
|
|
57
|
+
getDefaults: () => _getDefaults,
|
|
58
|
+
lexer: () => lexer,
|
|
59
|
+
marked: () => marked,
|
|
60
|
+
options: () => options,
|
|
61
|
+
parse: () => parse,
|
|
62
|
+
parseInline: () => parseInline,
|
|
63
|
+
parser: () => parser,
|
|
64
|
+
setOptions: () => setOptions,
|
|
65
|
+
use: () => use,
|
|
66
|
+
walkTokens: () => walkTokens
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// src/defaults.ts
|
|
70
|
+
function _getDefaults() {
|
|
106
71
|
return {
|
|
107
72
|
async: false,
|
|
108
73
|
baseUrl: null,
|
|
@@ -110,10 +75,10 @@
|
|
|
110
75
|
extensions: null,
|
|
111
76
|
gfm: true,
|
|
112
77
|
headerIds: true,
|
|
113
|
-
headerPrefix:
|
|
78
|
+
headerPrefix: "",
|
|
114
79
|
highlight: null,
|
|
115
80
|
hooks: null,
|
|
116
|
-
langPrefix:
|
|
81
|
+
langPrefix: "language-",
|
|
117
82
|
mangle: true,
|
|
118
83
|
pedantic: false,
|
|
119
84
|
renderer: null,
|
|
@@ -126,28 +91,24 @@
|
|
|
126
91
|
xhtml: false
|
|
127
92
|
};
|
|
128
93
|
}
|
|
129
|
-
|
|
94
|
+
var _defaults = _getDefaults();
|
|
130
95
|
function changeDefaults(newDefaults) {
|
|
131
|
-
|
|
96
|
+
_defaults = newDefaults;
|
|
132
97
|
}
|
|
133
98
|
|
|
134
|
-
|
|
135
|
-
* Helpers
|
|
136
|
-
*/
|
|
99
|
+
// src/helpers.ts
|
|
137
100
|
var escapeTest = /[&<>"']/;
|
|
138
|
-
var escapeReplace = new RegExp(escapeTest.source,
|
|
101
|
+
var escapeReplace = new RegExp(escapeTest.source, "g");
|
|
139
102
|
var escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
|
|
140
|
-
var escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source,
|
|
103
|
+
var escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, "g");
|
|
141
104
|
var escapeReplacements = {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
'"':
|
|
146
|
-
"'":
|
|
147
|
-
};
|
|
148
|
-
var getEscapeReplacement = function getEscapeReplacement(ch) {
|
|
149
|
-
return escapeReplacements[ch];
|
|
105
|
+
"&": "&",
|
|
106
|
+
"<": "<",
|
|
107
|
+
">": ">",
|
|
108
|
+
'"': """,
|
|
109
|
+
"'": "'"
|
|
150
110
|
};
|
|
111
|
+
var getEscapeReplacement = (ch) => escapeReplacements[ch];
|
|
151
112
|
function escape(html, encode) {
|
|
152
113
|
if (encode) {
|
|
153
114
|
if (escapeTest.test(html)) {
|
|
@@ -161,38 +122,29 @@
|
|
|
161
122
|
return html;
|
|
162
123
|
}
|
|
163
124
|
var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* @param {string} html
|
|
167
|
-
*/
|
|
168
125
|
function unescape(html) {
|
|
169
|
-
|
|
170
|
-
return html.replace(unescapeTest, function (_, n) {
|
|
126
|
+
return html.replace(unescapeTest, (_, n) => {
|
|
171
127
|
n = n.toLowerCase();
|
|
172
|
-
if (n ===
|
|
173
|
-
|
|
174
|
-
|
|
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));
|
|
175
132
|
}
|
|
176
|
-
return
|
|
133
|
+
return "";
|
|
177
134
|
});
|
|
178
135
|
}
|
|
179
136
|
var caret = /(^|[^\[])\^/g;
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* @param {string | RegExp} regex
|
|
183
|
-
* @param {string} opt
|
|
184
|
-
*/
|
|
185
137
|
function edit(regex, opt) {
|
|
186
|
-
regex = typeof regex ===
|
|
187
|
-
opt = opt ||
|
|
188
|
-
|
|
189
|
-
replace:
|
|
190
|
-
val = val.source
|
|
191
|
-
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");
|
|
192
144
|
regex = regex.replace(name, val);
|
|
193
145
|
return obj;
|
|
194
146
|
},
|
|
195
|
-
getRegex:
|
|
147
|
+
getRegex: () => {
|
|
196
148
|
return new RegExp(regex, opt);
|
|
197
149
|
}
|
|
198
150
|
};
|
|
@@ -200,21 +152,15 @@
|
|
|
200
152
|
}
|
|
201
153
|
var nonWordAndColonTest = /[^\w:]/g;
|
|
202
154
|
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* @param {boolean} sanitize
|
|
206
|
-
* @param {string} base
|
|
207
|
-
* @param {string} href
|
|
208
|
-
*/
|
|
209
155
|
function cleanUrl(sanitize, base, href) {
|
|
210
156
|
if (sanitize) {
|
|
211
|
-
|
|
157
|
+
let prot;
|
|
212
158
|
try {
|
|
213
|
-
prot = decodeURIComponent(unescape(href)).replace(nonWordAndColonTest,
|
|
159
|
+
prot = decodeURIComponent(unescape(href)).replace(nonWordAndColonTest, "").toLowerCase();
|
|
214
160
|
} catch (e) {
|
|
215
161
|
return null;
|
|
216
162
|
}
|
|
217
|
-
if (prot.indexOf(
|
|
163
|
+
if (prot.indexOf("javascript:") === 0 || prot.indexOf("vbscript:") === 0 || prot.indexOf("data:") === 0) {
|
|
218
164
|
return null;
|
|
219
165
|
}
|
|
220
166
|
}
|
|
@@ -222,7 +168,7 @@
|
|
|
222
168
|
href = resolveUrl(base, href);
|
|
223
169
|
}
|
|
224
170
|
try {
|
|
225
|
-
href = encodeURI(href).replace(/%25/g,
|
|
171
|
+
href = encodeURI(href).replace(/%25/g, "%");
|
|
226
172
|
} catch (e) {
|
|
227
173
|
return null;
|
|
228
174
|
}
|
|
@@ -232,61 +178,43 @@
|
|
|
232
178
|
var justDomain = /^[^:]+:\/*[^/]*$/;
|
|
233
179
|
var protocol = /^([^:]+:)[\s\S]*$/;
|
|
234
180
|
var domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* @param {string} base
|
|
238
|
-
* @param {string} href
|
|
239
|
-
*/
|
|
240
181
|
function resolveUrl(base, href) {
|
|
241
|
-
if (!baseUrls[
|
|
242
|
-
// we can ignore everything in base after the last slash of its path component,
|
|
243
|
-
// but we might need to add _that_
|
|
244
|
-
// https://tools.ietf.org/html/rfc3986#section-3
|
|
182
|
+
if (!baseUrls[" " + base]) {
|
|
245
183
|
if (justDomain.test(base)) {
|
|
246
|
-
baseUrls[
|
|
184
|
+
baseUrls[" " + base] = base + "/";
|
|
247
185
|
} else {
|
|
248
|
-
baseUrls[
|
|
186
|
+
baseUrls[" " + base] = rtrim(base, "/", true);
|
|
249
187
|
}
|
|
250
188
|
}
|
|
251
|
-
base = baseUrls[
|
|
252
|
-
|
|
253
|
-
if (href.substring(0, 2) ===
|
|
189
|
+
base = baseUrls[" " + base];
|
|
190
|
+
const relativeBase = base.indexOf(":") === -1;
|
|
191
|
+
if (href.substring(0, 2) === "//") {
|
|
254
192
|
if (relativeBase) {
|
|
255
193
|
return href;
|
|
256
194
|
}
|
|
257
|
-
return base.replace(protocol,
|
|
258
|
-
} else if (href.charAt(0) ===
|
|
195
|
+
return base.replace(protocol, "$1") + href;
|
|
196
|
+
} else if (href.charAt(0) === "/") {
|
|
259
197
|
if (relativeBase) {
|
|
260
198
|
return href;
|
|
261
199
|
}
|
|
262
|
-
return base.replace(domain,
|
|
200
|
+
return base.replace(domain, "$1") + href;
|
|
263
201
|
} else {
|
|
264
202
|
return base + href;
|
|
265
203
|
}
|
|
266
204
|
}
|
|
267
|
-
var noopTest = {
|
|
268
|
-
exec: function noopTest() {}
|
|
269
|
-
};
|
|
205
|
+
var noopTest = { exec: () => null };
|
|
270
206
|
function splitCells(tableRow, count) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
// add space before unescaped |
|
|
283
|
-
return ' |';
|
|
284
|
-
}
|
|
285
|
-
}),
|
|
286
|
-
cells = row.split(/ \|/);
|
|
287
|
-
var i = 0;
|
|
288
|
-
|
|
289
|
-
// 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;
|
|
290
218
|
if (!cells[0].trim()) {
|
|
291
219
|
cells.shift();
|
|
292
220
|
}
|
|
@@ -296,35 +224,22 @@
|
|
|
296
224
|
if (cells.length > count) {
|
|
297
225
|
cells.splice(count);
|
|
298
226
|
} else {
|
|
299
|
-
while (cells.length < count)
|
|
227
|
+
while (cells.length < count)
|
|
228
|
+
cells.push("");
|
|
300
229
|
}
|
|
301
230
|
for (; i < cells.length; i++) {
|
|
302
|
-
|
|
303
|
-
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
|
231
|
+
cells[i] = cells[i].trim().replace(/\\\|/g, "|");
|
|
304
232
|
}
|
|
305
233
|
return cells;
|
|
306
234
|
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
310
|
-
* /c*$/ is vulnerable to REDOS.
|
|
311
|
-
*
|
|
312
|
-
* @param {string} str
|
|
313
|
-
* @param {string} c
|
|
314
|
-
* @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
|
|
315
|
-
*/
|
|
316
235
|
function rtrim(str, c, invert) {
|
|
317
|
-
|
|
236
|
+
const l = str.length;
|
|
318
237
|
if (l === 0) {
|
|
319
|
-
return
|
|
238
|
+
return "";
|
|
320
239
|
}
|
|
321
|
-
|
|
322
|
-
// Length of suffix matching the invert condition.
|
|
323
|
-
var suffLen = 0;
|
|
324
|
-
|
|
325
|
-
// Step left until we fail to match the invert condition.
|
|
240
|
+
let suffLen = 0;
|
|
326
241
|
while (suffLen < l) {
|
|
327
|
-
|
|
242
|
+
const currChar = str.charAt(l - suffLen - 1);
|
|
328
243
|
if (currChar === c && !invert) {
|
|
329
244
|
suffLen++;
|
|
330
245
|
} else if (currChar !== c && invert) {
|
|
@@ -339,11 +254,10 @@
|
|
|
339
254
|
if (str.indexOf(b[1]) === -1) {
|
|
340
255
|
return -1;
|
|
341
256
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
i = 0;
|
|
257
|
+
const l = str.length;
|
|
258
|
+
let level = 0, i = 0;
|
|
345
259
|
for (; i < l; i++) {
|
|
346
|
-
if (str[i] ===
|
|
260
|
+
if (str[i] === "\\") {
|
|
347
261
|
i++;
|
|
348
262
|
} else if (str[i] === b[0]) {
|
|
349
263
|
level++;
|
|
@@ -361,267 +275,235 @@
|
|
|
361
275
|
return;
|
|
362
276
|
}
|
|
363
277
|
if (callback) {
|
|
364
|
-
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");
|
|
365
279
|
}
|
|
366
280
|
if (opt.sanitize || opt.sanitizer) {
|
|
367
|
-
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");
|
|
368
282
|
}
|
|
369
|
-
if (opt.highlight || opt.langPrefix !==
|
|
370
|
-
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.");
|
|
371
285
|
}
|
|
372
286
|
if (opt.mangle) {
|
|
373
|
-
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}`.");
|
|
374
288
|
}
|
|
375
289
|
if (opt.baseUrl) {
|
|
376
|
-
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.");
|
|
377
291
|
}
|
|
378
292
|
if (opt.smartypants) {
|
|
379
|
-
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.");
|
|
380
294
|
}
|
|
381
295
|
if (opt.xhtml) {
|
|
382
|
-
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.");
|
|
383
297
|
}
|
|
384
298
|
if (opt.headerIds || opt.headerPrefix) {
|
|
385
|
-
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}`.");
|
|
386
300
|
}
|
|
387
301
|
}
|
|
388
302
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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)
|
|
402
317
|
};
|
|
403
|
-
|
|
318
|
+
lexer2.state.inLink = false;
|
|
404
319
|
return token;
|
|
405
320
|
}
|
|
406
321
|
return {
|
|
407
|
-
type:
|
|
408
|
-
raw
|
|
409
|
-
href
|
|
410
|
-
title
|
|
322
|
+
type: "image",
|
|
323
|
+
raw,
|
|
324
|
+
href,
|
|
325
|
+
title,
|
|
411
326
|
text: escape(text)
|
|
412
327
|
};
|
|
413
328
|
}
|
|
414
329
|
function indentCodeCompensation(raw, text) {
|
|
415
|
-
|
|
330
|
+
const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
|
416
331
|
if (matchIndentToCode === null) {
|
|
417
332
|
return text;
|
|
418
333
|
}
|
|
419
|
-
|
|
420
|
-
return text.split(
|
|
421
|
-
|
|
334
|
+
const indentToCode = matchIndentToCode[1];
|
|
335
|
+
return text.split("\n").map((node) => {
|
|
336
|
+
const matchIndentInNode = node.match(/^\s+/);
|
|
422
337
|
if (matchIndentInNode === null) {
|
|
423
338
|
return node;
|
|
424
339
|
}
|
|
425
|
-
|
|
340
|
+
const [indentInNode] = matchIndentInNode;
|
|
426
341
|
if (indentInNode.length >= indentToCode.length) {
|
|
427
342
|
return node.slice(indentToCode.length);
|
|
428
343
|
}
|
|
429
344
|
return node;
|
|
430
|
-
}).join(
|
|
345
|
+
}).join("\n");
|
|
431
346
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
this.options = options || exports.defaults;
|
|
439
|
-
}
|
|
440
|
-
var _proto = Tokenizer.prototype;
|
|
441
|
-
_proto.space = function space(src) {
|
|
442
|
-
var cap = this.rules.block.newline.exec(src);
|
|
347
|
+
var _Tokenizer = class {
|
|
348
|
+
constructor(options2) {
|
|
349
|
+
this.options = options2 || _defaults;
|
|
350
|
+
}
|
|
351
|
+
space(src) {
|
|
352
|
+
const cap = this.rules.block.newline.exec(src);
|
|
443
353
|
if (cap && cap[0].length > 0) {
|
|
444
354
|
return {
|
|
445
|
-
type:
|
|
355
|
+
type: "space",
|
|
446
356
|
raw: cap[0]
|
|
447
357
|
};
|
|
448
358
|
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
|
|
359
|
+
}
|
|
360
|
+
code(src) {
|
|
361
|
+
const cap = this.rules.block.code.exec(src);
|
|
452
362
|
if (cap) {
|
|
453
|
-
|
|
363
|
+
const text = cap[0].replace(/^ {1,4}/gm, "");
|
|
454
364
|
return {
|
|
455
|
-
type:
|
|
365
|
+
type: "code",
|
|
456
366
|
raw: cap[0],
|
|
457
|
-
codeBlockStyle:
|
|
458
|
-
text: !this.options.pedantic ? rtrim(text,
|
|
367
|
+
codeBlockStyle: "indented",
|
|
368
|
+
text: !this.options.pedantic ? rtrim(text, "\n") : text
|
|
459
369
|
};
|
|
460
370
|
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
|
|
371
|
+
}
|
|
372
|
+
fences(src) {
|
|
373
|
+
const cap = this.rules.block.fences.exec(src);
|
|
464
374
|
if (cap) {
|
|
465
|
-
|
|
466
|
-
|
|
375
|
+
const raw = cap[0];
|
|
376
|
+
const text = indentCodeCompensation(raw, cap[3] || "");
|
|
467
377
|
return {
|
|
468
|
-
type:
|
|
469
|
-
raw
|
|
470
|
-
lang: cap[2] ? cap[2].trim().replace(this.rules.inline._escapes,
|
|
471
|
-
text
|
|
378
|
+
type: "code",
|
|
379
|
+
raw,
|
|
380
|
+
lang: cap[2] ? cap[2].trim().replace(this.rules.inline._escapes, "$1") : cap[2],
|
|
381
|
+
text
|
|
472
382
|
};
|
|
473
383
|
}
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
|
|
384
|
+
}
|
|
385
|
+
heading(src) {
|
|
386
|
+
const cap = this.rules.block.heading.exec(src);
|
|
477
387
|
if (cap) {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
// remove trailing #s
|
|
388
|
+
let text = cap[2].trim();
|
|
481
389
|
if (/#$/.test(text)) {
|
|
482
|
-
|
|
390
|
+
const trimmed = rtrim(text, "#");
|
|
483
391
|
if (this.options.pedantic) {
|
|
484
392
|
text = trimmed.trim();
|
|
485
393
|
} else if (!trimmed || / $/.test(trimmed)) {
|
|
486
|
-
// CommonMark requires space before trailing #s
|
|
487
394
|
text = trimmed.trim();
|
|
488
395
|
}
|
|
489
396
|
}
|
|
490
397
|
return {
|
|
491
|
-
type:
|
|
398
|
+
type: "heading",
|
|
492
399
|
raw: cap[0],
|
|
493
400
|
depth: cap[1].length,
|
|
494
|
-
text
|
|
401
|
+
text,
|
|
495
402
|
tokens: this.lexer.inline(text)
|
|
496
403
|
};
|
|
497
404
|
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
|
|
405
|
+
}
|
|
406
|
+
hr(src) {
|
|
407
|
+
const cap = this.rules.block.hr.exec(src);
|
|
501
408
|
if (cap) {
|
|
502
409
|
return {
|
|
503
|
-
type:
|
|
410
|
+
type: "hr",
|
|
504
411
|
raw: cap[0]
|
|
505
412
|
};
|
|
506
413
|
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
|
|
414
|
+
}
|
|
415
|
+
blockquote(src) {
|
|
416
|
+
const cap = this.rules.block.blockquote.exec(src);
|
|
510
417
|
if (cap) {
|
|
511
|
-
|
|
512
|
-
|
|
418
|
+
const text = cap[0].replace(/^ *>[ \t]?/gm, "");
|
|
419
|
+
const top = this.lexer.state.top;
|
|
513
420
|
this.lexer.state.top = true;
|
|
514
|
-
|
|
421
|
+
const tokens = this.lexer.blockTokens(text);
|
|
515
422
|
this.lexer.state.top = top;
|
|
516
423
|
return {
|
|
517
|
-
type:
|
|
424
|
+
type: "blockquote",
|
|
518
425
|
raw: cap[0],
|
|
519
|
-
tokens
|
|
520
|
-
text
|
|
426
|
+
tokens,
|
|
427
|
+
text
|
|
521
428
|
};
|
|
522
429
|
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
|
|
430
|
+
}
|
|
431
|
+
list(src) {
|
|
432
|
+
let cap = this.rules.block.list.exec(src);
|
|
526
433
|
if (cap) {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
type:
|
|
532
|
-
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: "",
|
|
533
440
|
ordered: isordered,
|
|
534
|
-
start: isordered ? +bull.slice(0, -1) :
|
|
441
|
+
start: isordered ? +bull.slice(0, -1) : "",
|
|
535
442
|
loose: false,
|
|
536
443
|
items: []
|
|
537
444
|
};
|
|
538
|
-
bull = isordered ?
|
|
445
|
+
bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
|
|
539
446
|
if (this.options.pedantic) {
|
|
540
|
-
bull = isordered ? bull :
|
|
447
|
+
bull = isordered ? bull : "[*+-]";
|
|
541
448
|
}
|
|
542
|
-
|
|
543
|
-
// Get next list item
|
|
544
|
-
var itemRegex = new RegExp("^( {0,3}" + bull + ")((?:[\t ][^\\n]*)?(?:\\n|$))");
|
|
545
|
-
|
|
546
|
-
// Check if current bullet point can start a new List Item
|
|
449
|
+
const itemRegex = new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`);
|
|
547
450
|
while (src) {
|
|
548
451
|
endEarly = false;
|
|
549
452
|
if (!(cap = itemRegex.exec(src))) {
|
|
550
453
|
break;
|
|
551
454
|
}
|
|
552
455
|
if (this.rules.block.hr.test(src)) {
|
|
553
|
-
// End list if bullet was actually HR (possibly move into itemRegex?)
|
|
554
456
|
break;
|
|
555
457
|
}
|
|
556
458
|
raw = cap[0];
|
|
557
459
|
src = src.substring(raw.length);
|
|
558
|
-
line = cap[2].split(
|
|
559
|
-
|
|
560
|
-
});
|
|
561
|
-
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];
|
|
562
462
|
if (this.options.pedantic) {
|
|
563
463
|
indent = 2;
|
|
564
464
|
itemContents = line.trimLeft();
|
|
565
465
|
} else {
|
|
566
|
-
indent = cap[2].search(/[^ ]/);
|
|
567
|
-
indent = indent > 4 ? 1 : indent;
|
|
466
|
+
indent = cap[2].search(/[^ ]/);
|
|
467
|
+
indent = indent > 4 ? 1 : indent;
|
|
568
468
|
itemContents = line.slice(indent);
|
|
569
469
|
indent += cap[1].length;
|
|
570
470
|
}
|
|
571
471
|
blankLine = false;
|
|
572
472
|
if (!line && /^ *$/.test(nextLine)) {
|
|
573
|
-
|
|
574
|
-
raw += nextLine + '\n';
|
|
473
|
+
raw += nextLine + "\n";
|
|
575
474
|
src = src.substring(nextLine.length + 1);
|
|
576
475
|
endEarly = true;
|
|
577
476
|
}
|
|
578
477
|
if (!endEarly) {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
// 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)}}#`);
|
|
585
482
|
while (src) {
|
|
586
|
-
rawLine = src.split(
|
|
483
|
+
rawLine = src.split("\n", 1)[0];
|
|
587
484
|
nextLine = rawLine;
|
|
588
|
-
|
|
589
|
-
// Re-align to follow commonmark nesting rules
|
|
590
485
|
if (this.options.pedantic) {
|
|
591
|
-
nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g,
|
|
486
|
+
nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
|
|
592
487
|
}
|
|
593
|
-
|
|
594
|
-
// End list item if found code fences
|
|
595
488
|
if (fencesBeginRegex.test(nextLine)) {
|
|
596
489
|
break;
|
|
597
490
|
}
|
|
598
|
-
|
|
599
|
-
// End list item if found start of new heading
|
|
600
491
|
if (headingBeginRegex.test(nextLine)) {
|
|
601
492
|
break;
|
|
602
493
|
}
|
|
603
|
-
|
|
604
|
-
// End list item if found start of new bullet
|
|
605
494
|
if (nextBulletRegex.test(nextLine)) {
|
|
606
495
|
break;
|
|
607
496
|
}
|
|
608
|
-
|
|
609
|
-
// Horizontal rule found
|
|
610
497
|
if (hrRegex.test(src)) {
|
|
611
498
|
break;
|
|
612
499
|
}
|
|
613
500
|
if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) {
|
|
614
|
-
|
|
615
|
-
itemContents += '\n' + nextLine.slice(indent);
|
|
501
|
+
itemContents += "\n" + nextLine.slice(indent);
|
|
616
502
|
} else {
|
|
617
|
-
// not enough indentation
|
|
618
503
|
if (blankLine) {
|
|
619
504
|
break;
|
|
620
505
|
}
|
|
621
|
-
|
|
622
|
-
// paragraph continuation unless last line was a different block level element
|
|
623
506
|
if (line.search(/[^ ]/) >= 4) {
|
|
624
|
-
// indented code block
|
|
625
507
|
break;
|
|
626
508
|
}
|
|
627
509
|
if (fencesBeginRegex.test(line)) {
|
|
@@ -633,37 +515,33 @@
|
|
|
633
515
|
if (hrRegex.test(line)) {
|
|
634
516
|
break;
|
|
635
517
|
}
|
|
636
|
-
itemContents +=
|
|
518
|
+
itemContents += "\n" + nextLine;
|
|
637
519
|
}
|
|
638
520
|
if (!blankLine && !nextLine.trim()) {
|
|
639
|
-
// Check if current line is blank
|
|
640
521
|
blankLine = true;
|
|
641
522
|
}
|
|
642
|
-
raw += rawLine +
|
|
523
|
+
raw += rawLine + "\n";
|
|
643
524
|
src = src.substring(rawLine.length + 1);
|
|
644
525
|
line = nextLine.slice(indent);
|
|
645
526
|
}
|
|
646
527
|
}
|
|
647
528
|
if (!list.loose) {
|
|
648
|
-
// If the previous item ended with a blank line, the list is loose
|
|
649
529
|
if (endsWithBlankLine) {
|
|
650
530
|
list.loose = true;
|
|
651
531
|
} else if (/\n *\n *$/.test(raw)) {
|
|
652
532
|
endsWithBlankLine = true;
|
|
653
533
|
}
|
|
654
534
|
}
|
|
655
|
-
|
|
656
|
-
// Check for task list items
|
|
657
535
|
if (this.options.gfm) {
|
|
658
536
|
istask = /^\[[ xX]\] /.exec(itemContents);
|
|
659
537
|
if (istask) {
|
|
660
|
-
ischecked = istask[0] !==
|
|
661
|
-
itemContents = itemContents.replace(/^\[[ xX]\] +/,
|
|
538
|
+
ischecked = istask[0] !== "[ ] ";
|
|
539
|
+
itemContents = itemContents.replace(/^\[[ xX]\] +/, "");
|
|
662
540
|
}
|
|
663
541
|
}
|
|
664
542
|
list.items.push({
|
|
665
|
-
type:
|
|
666
|
-
raw
|
|
543
|
+
type: "list_item",
|
|
544
|
+
raw,
|
|
667
545
|
task: !!istask,
|
|
668
546
|
checked: ischecked,
|
|
669
547
|
loose: false,
|
|
@@ -671,30 +549,19 @@
|
|
|
671
549
|
});
|
|
672
550
|
list.raw += raw;
|
|
673
551
|
}
|
|
674
|
-
|
|
675
|
-
// Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
|
|
676
552
|
list.items[list.items.length - 1].raw = raw.trimRight();
|
|
677
553
|
list.items[list.items.length - 1].text = itemContents.trimRight();
|
|
678
554
|
list.raw = list.raw.trimRight();
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
// 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;
|
|
682
556
|
for (i = 0; i < l; i++) {
|
|
683
557
|
this.lexer.state.top = false;
|
|
684
558
|
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
|
|
685
559
|
if (!list.loose) {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
return t.type === 'space';
|
|
689
|
-
});
|
|
690
|
-
var hasMultipleLineBreaks = spacers.length > 0 && spacers.some(function (t) {
|
|
691
|
-
return /\n.*\n/.test(t.raw);
|
|
692
|
-
});
|
|
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));
|
|
693
562
|
list.loose = hasMultipleLineBreaks;
|
|
694
563
|
}
|
|
695
564
|
}
|
|
696
|
-
|
|
697
|
-
// Set all items to loose if list is loose
|
|
698
565
|
if (list.loose) {
|
|
699
566
|
for (i = 0; i < l; i++) {
|
|
700
567
|
list.items[i].loose = true;
|
|
@@ -702,87 +569,80 @@
|
|
|
702
569
|
}
|
|
703
570
|
return list;
|
|
704
571
|
}
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
|
|
572
|
+
}
|
|
573
|
+
html(src) {
|
|
574
|
+
const cap = this.rules.block.html.exec(src);
|
|
708
575
|
if (cap) {
|
|
709
|
-
|
|
710
|
-
type:
|
|
576
|
+
const token = {
|
|
577
|
+
type: "html",
|
|
711
578
|
block: true,
|
|
712
579
|
raw: cap[0],
|
|
713
|
-
pre: !this.options.sanitizer && (cap[1] ===
|
|
580
|
+
pre: !this.options.sanitizer && (cap[1] === "pre" || cap[1] === "script" || cap[1] === "style"),
|
|
714
581
|
text: cap[0]
|
|
715
582
|
};
|
|
716
583
|
if (this.options.sanitize) {
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
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);
|
|
721
589
|
}
|
|
722
590
|
return token;
|
|
723
591
|
}
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
|
|
592
|
+
}
|
|
593
|
+
def(src) {
|
|
594
|
+
const cap = this.rules.block.def.exec(src);
|
|
727
595
|
if (cap) {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
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];
|
|
731
599
|
return {
|
|
732
|
-
type:
|
|
733
|
-
tag
|
|
600
|
+
type: "def",
|
|
601
|
+
tag,
|
|
734
602
|
raw: cap[0],
|
|
735
|
-
href
|
|
736
|
-
title
|
|
603
|
+
href,
|
|
604
|
+
title
|
|
737
605
|
};
|
|
738
606
|
}
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
|
|
607
|
+
}
|
|
608
|
+
table(src) {
|
|
609
|
+
const cap = this.rules.block.table.exec(src);
|
|
742
610
|
if (cap) {
|
|
743
|
-
|
|
744
|
-
type:
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
};
|
|
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 };
|
|
749
617
|
}),
|
|
750
|
-
align: cap[2].replace(/^ *|\| *$/g,
|
|
751
|
-
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") : []
|
|
752
620
|
};
|
|
753
621
|
if (item.header.length === item.align.length) {
|
|
754
622
|
item.raw = cap[0];
|
|
755
|
-
|
|
756
|
-
|
|
623
|
+
let l = item.align.length;
|
|
624
|
+
let i, j, k, row;
|
|
757
625
|
for (i = 0; i < l; i++) {
|
|
758
626
|
if (/^ *-+: *$/.test(item.align[i])) {
|
|
759
|
-
item.align[i] =
|
|
627
|
+
item.align[i] = "right";
|
|
760
628
|
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
761
|
-
item.align[i] =
|
|
629
|
+
item.align[i] = "center";
|
|
762
630
|
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
763
|
-
item.align[i] =
|
|
631
|
+
item.align[i] = "left";
|
|
764
632
|
} else {
|
|
765
633
|
item.align[i] = null;
|
|
766
634
|
}
|
|
767
635
|
}
|
|
768
636
|
l = item.rows.length;
|
|
769
637
|
for (i = 0; i < l; i++) {
|
|
770
|
-
item.rows[i] = splitCells(item.rows[i], item.header.length).map(
|
|
771
|
-
return {
|
|
772
|
-
text: c
|
|
773
|
-
};
|
|
638
|
+
item.rows[i] = splitCells(item.rows[i], item.header.length).map((c) => {
|
|
639
|
+
return { text: c };
|
|
774
640
|
});
|
|
775
641
|
}
|
|
776
|
-
|
|
777
|
-
// parse child tokens inside headers and cells
|
|
778
|
-
|
|
779
|
-
// header child tokens
|
|
780
642
|
l = item.header.length;
|
|
781
643
|
for (j = 0; j < l; j++) {
|
|
782
644
|
item.header[j].tokens = this.lexer.inline(item.header[j].text);
|
|
783
645
|
}
|
|
784
|
-
|
|
785
|
-
// cell child tokens
|
|
786
646
|
l = item.rows.length;
|
|
787
647
|
for (j = 0; j < l; j++) {
|
|
788
648
|
row = item.rows[j];
|
|
@@ -793,54 +653,54 @@
|
|
|
793
653
|
return item;
|
|
794
654
|
}
|
|
795
655
|
}
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
|
|
656
|
+
}
|
|
657
|
+
lheading(src) {
|
|
658
|
+
const cap = this.rules.block.lheading.exec(src);
|
|
799
659
|
if (cap) {
|
|
800
660
|
return {
|
|
801
|
-
type:
|
|
661
|
+
type: "heading",
|
|
802
662
|
raw: cap[0],
|
|
803
|
-
depth: cap[2].charAt(0) ===
|
|
663
|
+
depth: cap[2].charAt(0) === "=" ? 1 : 2,
|
|
804
664
|
text: cap[1],
|
|
805
665
|
tokens: this.lexer.inline(cap[1])
|
|
806
666
|
};
|
|
807
667
|
}
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
|
|
668
|
+
}
|
|
669
|
+
paragraph(src) {
|
|
670
|
+
const cap = this.rules.block.paragraph.exec(src);
|
|
811
671
|
if (cap) {
|
|
812
|
-
|
|
672
|
+
const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
|
|
813
673
|
return {
|
|
814
|
-
type:
|
|
674
|
+
type: "paragraph",
|
|
815
675
|
raw: cap[0],
|
|
816
|
-
text
|
|
676
|
+
text,
|
|
817
677
|
tokens: this.lexer.inline(text)
|
|
818
678
|
};
|
|
819
679
|
}
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
|
|
680
|
+
}
|
|
681
|
+
text(src) {
|
|
682
|
+
const cap = this.rules.block.text.exec(src);
|
|
823
683
|
if (cap) {
|
|
824
684
|
return {
|
|
825
|
-
type:
|
|
685
|
+
type: "text",
|
|
826
686
|
raw: cap[0],
|
|
827
687
|
text: cap[0],
|
|
828
688
|
tokens: this.lexer.inline(cap[0])
|
|
829
689
|
};
|
|
830
690
|
}
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
|
|
691
|
+
}
|
|
692
|
+
escape(src) {
|
|
693
|
+
const cap = this.rules.inline.escape.exec(src);
|
|
834
694
|
if (cap) {
|
|
835
695
|
return {
|
|
836
|
-
type:
|
|
696
|
+
type: "escape",
|
|
837
697
|
raw: cap[0],
|
|
838
698
|
text: escape(cap[1])
|
|
839
699
|
};
|
|
840
700
|
}
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
|
|
701
|
+
}
|
|
702
|
+
tag(src) {
|
|
703
|
+
const cap = this.rules.inline.tag.exec(src);
|
|
844
704
|
if (cap) {
|
|
845
705
|
if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
|
|
846
706
|
this.lexer.state.inLink = true;
|
|
@@ -853,7 +713,7 @@
|
|
|
853
713
|
this.lexer.state.inRawBlock = false;
|
|
854
714
|
}
|
|
855
715
|
return {
|
|
856
|
-
type: this.options.sanitize ?
|
|
716
|
+
type: this.options.sanitize ? "text" : "html",
|
|
857
717
|
raw: cap[0],
|
|
858
718
|
inLink: this.lexer.state.inLink,
|
|
859
719
|
inRawBlock: this.lexer.state.inRawBlock,
|
|
@@ -861,260 +721,238 @@
|
|
|
861
721
|
text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0]
|
|
862
722
|
};
|
|
863
723
|
}
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
|
|
724
|
+
}
|
|
725
|
+
link(src) {
|
|
726
|
+
const cap = this.rules.inline.link.exec(src);
|
|
867
727
|
if (cap) {
|
|
868
|
-
|
|
728
|
+
const trimmedUrl = cap[2].trim();
|
|
869
729
|
if (!this.options.pedantic && /^</.test(trimmedUrl)) {
|
|
870
|
-
// commonmark requires matching angle brackets
|
|
871
730
|
if (!/>$/.test(trimmedUrl)) {
|
|
872
731
|
return;
|
|
873
732
|
}
|
|
874
|
-
|
|
875
|
-
// ending angle bracket cannot be escaped
|
|
876
|
-
var rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
|
|
733
|
+
const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
|
|
877
734
|
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
|
|
878
735
|
return;
|
|
879
736
|
}
|
|
880
737
|
} else {
|
|
881
|
-
|
|
882
|
-
var lastParenIndex = findClosingBracket(cap[2], '()');
|
|
738
|
+
const lastParenIndex = findClosingBracket(cap[2], "()");
|
|
883
739
|
if (lastParenIndex > -1) {
|
|
884
|
-
|
|
885
|
-
|
|
740
|
+
const start = cap[0].indexOf("!") === 0 ? 5 : 4;
|
|
741
|
+
const linkLen = start + cap[1].length + lastParenIndex;
|
|
886
742
|
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
887
743
|
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
888
|
-
cap[3] =
|
|
744
|
+
cap[3] = "";
|
|
889
745
|
}
|
|
890
746
|
}
|
|
891
|
-
|
|
892
|
-
|
|
747
|
+
let href = cap[2];
|
|
748
|
+
let title = "";
|
|
893
749
|
if (this.options.pedantic) {
|
|
894
|
-
|
|
895
|
-
var link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
750
|
+
const link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
896
751
|
if (link) {
|
|
897
752
|
href = link[1];
|
|
898
753
|
title = link[3];
|
|
899
754
|
}
|
|
900
755
|
} else {
|
|
901
|
-
title = cap[3] ? cap[3].slice(1, -1) :
|
|
756
|
+
title = cap[3] ? cap[3].slice(1, -1) : "";
|
|
902
757
|
}
|
|
903
758
|
href = href.trim();
|
|
904
759
|
if (/^</.test(href)) {
|
|
905
760
|
if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
|
|
906
|
-
// pedantic allows starting angle bracket without ending angle bracket
|
|
907
761
|
href = href.slice(1);
|
|
908
762
|
} else {
|
|
909
763
|
href = href.slice(1, -1);
|
|
910
764
|
}
|
|
911
765
|
}
|
|
912
766
|
return outputLink(cap, {
|
|
913
|
-
href: href ? href.replace(this.rules.inline._escapes,
|
|
914
|
-
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
|
|
915
769
|
}, cap[0], this.lexer);
|
|
916
770
|
}
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
|
|
771
|
+
}
|
|
772
|
+
reflink(src, links) {
|
|
773
|
+
let cap;
|
|
920
774
|
if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
|
|
921
|
-
|
|
775
|
+
let link = (cap[2] || cap[1]).replace(/\s+/g, " ");
|
|
922
776
|
link = links[link.toLowerCase()];
|
|
923
777
|
if (!link) {
|
|
924
|
-
|
|
778
|
+
const text = cap[0].charAt(0);
|
|
925
779
|
return {
|
|
926
|
-
type:
|
|
780
|
+
type: "text",
|
|
927
781
|
raw: text,
|
|
928
|
-
text
|
|
782
|
+
text
|
|
929
783
|
};
|
|
930
784
|
}
|
|
931
785
|
return outputLink(cap, link, cap[0], this.lexer);
|
|
932
786
|
}
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
// _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
|
|
942
|
-
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;
|
|
943
|
-
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] || "";
|
|
944
795
|
if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
delimTotal = lLength,
|
|
949
|
-
midDelimTotal = 0;
|
|
950
|
-
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;
|
|
951
799
|
endReg.lastIndex = 0;
|
|
952
|
-
|
|
953
|
-
// Clip maskedSrc to same section of string as src (move to lexer?)
|
|
954
800
|
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
|
|
955
801
|
while ((match = endReg.exec(maskedSrc)) != null) {
|
|
956
802
|
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
|
|
957
|
-
if (!rDelim)
|
|
958
|
-
|
|
803
|
+
if (!rDelim)
|
|
804
|
+
continue;
|
|
959
805
|
rLength = rDelim.length;
|
|
960
806
|
if (match[3] || match[4]) {
|
|
961
|
-
// found another Left Delim
|
|
962
807
|
delimTotal += rLength;
|
|
963
808
|
continue;
|
|
964
809
|
} else if (match[5] || match[6]) {
|
|
965
|
-
// either Left or Right Delim
|
|
966
810
|
if (lLength % 3 && !((lLength + rLength) % 3)) {
|
|
967
811
|
midDelimTotal += rLength;
|
|
968
|
-
continue;
|
|
812
|
+
continue;
|
|
969
813
|
}
|
|
970
814
|
}
|
|
971
|
-
|
|
972
815
|
delimTotal -= rLength;
|
|
973
|
-
if (delimTotal > 0)
|
|
974
|
-
|
|
975
|
-
// Remove extra characters. *a*** -> *a*
|
|
816
|
+
if (delimTotal > 0)
|
|
817
|
+
continue;
|
|
976
818
|
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
// Create `em` if smallest delimiter has odd char count. *a***
|
|
819
|
+
const raw = src.slice(0, lLength + match.index + rLength + 1);
|
|
980
820
|
if (Math.min(lLength, rLength) % 2) {
|
|
981
|
-
|
|
821
|
+
const text2 = raw.slice(1, -1);
|
|
982
822
|
return {
|
|
983
|
-
type:
|
|
984
|
-
raw
|
|
985
|
-
text:
|
|
986
|
-
tokens: this.lexer.inlineTokens(
|
|
823
|
+
type: "em",
|
|
824
|
+
raw,
|
|
825
|
+
text: text2,
|
|
826
|
+
tokens: this.lexer.inlineTokens(text2)
|
|
987
827
|
};
|
|
988
828
|
}
|
|
989
|
-
|
|
990
|
-
// Create 'strong' if smallest delimiter has even char count. **a***
|
|
991
|
-
var text = raw.slice(2, -2);
|
|
829
|
+
const text = raw.slice(2, -2);
|
|
992
830
|
return {
|
|
993
|
-
type:
|
|
994
|
-
raw
|
|
995
|
-
text
|
|
831
|
+
type: "strong",
|
|
832
|
+
raw,
|
|
833
|
+
text,
|
|
996
834
|
tokens: this.lexer.inlineTokens(text)
|
|
997
835
|
};
|
|
998
836
|
}
|
|
999
837
|
}
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
|
|
838
|
+
}
|
|
839
|
+
codespan(src) {
|
|
840
|
+
const cap = this.rules.inline.code.exec(src);
|
|
1003
841
|
if (cap) {
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
842
|
+
let text = cap[2].replace(/\n/g, " ");
|
|
843
|
+
const hasNonSpaceChars = /[^ ]/.test(text);
|
|
844
|
+
const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
|
|
1007
845
|
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
1008
846
|
text = text.substring(1, text.length - 1);
|
|
1009
847
|
}
|
|
1010
848
|
text = escape(text, true);
|
|
1011
849
|
return {
|
|
1012
|
-
type:
|
|
850
|
+
type: "codespan",
|
|
1013
851
|
raw: cap[0],
|
|
1014
|
-
text
|
|
852
|
+
text
|
|
1015
853
|
};
|
|
1016
854
|
}
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
|
|
855
|
+
}
|
|
856
|
+
br(src) {
|
|
857
|
+
const cap = this.rules.inline.br.exec(src);
|
|
1020
858
|
if (cap) {
|
|
1021
859
|
return {
|
|
1022
|
-
type:
|
|
860
|
+
type: "br",
|
|
1023
861
|
raw: cap[0]
|
|
1024
862
|
};
|
|
1025
863
|
}
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
|
|
864
|
+
}
|
|
865
|
+
del(src) {
|
|
866
|
+
const cap = this.rules.inline.del.exec(src);
|
|
1029
867
|
if (cap) {
|
|
1030
868
|
return {
|
|
1031
|
-
type:
|
|
869
|
+
type: "del",
|
|
1032
870
|
raw: cap[0],
|
|
1033
871
|
text: cap[2],
|
|
1034
872
|
tokens: this.lexer.inlineTokens(cap[2])
|
|
1035
873
|
};
|
|
1036
874
|
}
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
|
|
875
|
+
}
|
|
876
|
+
autolink(src, mangle2) {
|
|
877
|
+
const cap = this.rules.inline.autolink.exec(src);
|
|
1040
878
|
if (cap) {
|
|
1041
|
-
|
|
1042
|
-
if (cap[2] ===
|
|
1043
|
-
text = escape(this.options.mangle ?
|
|
1044
|
-
href =
|
|
879
|
+
let text, href;
|
|
880
|
+
if (cap[2] === "@") {
|
|
881
|
+
text = escape(this.options.mangle ? mangle2(cap[1]) : cap[1]);
|
|
882
|
+
href = "mailto:" + text;
|
|
1045
883
|
} else {
|
|
1046
884
|
text = escape(cap[1]);
|
|
1047
885
|
href = text;
|
|
1048
886
|
}
|
|
1049
887
|
return {
|
|
1050
|
-
type:
|
|
888
|
+
type: "link",
|
|
1051
889
|
raw: cap[0],
|
|
1052
|
-
text
|
|
1053
|
-
href
|
|
1054
|
-
tokens: [
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
890
|
+
text,
|
|
891
|
+
href,
|
|
892
|
+
tokens: [
|
|
893
|
+
{
|
|
894
|
+
type: "text",
|
|
895
|
+
raw: text,
|
|
896
|
+
text
|
|
897
|
+
}
|
|
898
|
+
]
|
|
1059
899
|
};
|
|
1060
900
|
}
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
|
|
901
|
+
}
|
|
902
|
+
url(src, mangle2) {
|
|
903
|
+
let cap;
|
|
1064
904
|
if (cap = this.rules.inline.url.exec(src)) {
|
|
1065
|
-
|
|
1066
|
-
if (cap[2] ===
|
|
1067
|
-
text = escape(this.options.mangle ?
|
|
1068
|
-
href =
|
|
905
|
+
let text, href;
|
|
906
|
+
if (cap[2] === "@") {
|
|
907
|
+
text = escape(this.options.mangle ? mangle2(cap[0]) : cap[0]);
|
|
908
|
+
href = "mailto:" + text;
|
|
1069
909
|
} else {
|
|
1070
|
-
|
|
1071
|
-
var prevCapZero;
|
|
910
|
+
let prevCapZero;
|
|
1072
911
|
do {
|
|
1073
912
|
prevCapZero = cap[0];
|
|
1074
913
|
cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
|
|
1075
914
|
} while (prevCapZero !== cap[0]);
|
|
1076
915
|
text = escape(cap[0]);
|
|
1077
|
-
if (cap[1] ===
|
|
1078
|
-
href =
|
|
916
|
+
if (cap[1] === "www.") {
|
|
917
|
+
href = "http://" + cap[0];
|
|
1079
918
|
} else {
|
|
1080
919
|
href = cap[0];
|
|
1081
920
|
}
|
|
1082
921
|
}
|
|
1083
922
|
return {
|
|
1084
|
-
type:
|
|
923
|
+
type: "link",
|
|
1085
924
|
raw: cap[0],
|
|
1086
|
-
text
|
|
1087
|
-
href
|
|
1088
|
-
tokens: [
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
925
|
+
text,
|
|
926
|
+
href,
|
|
927
|
+
tokens: [
|
|
928
|
+
{
|
|
929
|
+
type: "text",
|
|
930
|
+
raw: text,
|
|
931
|
+
text
|
|
932
|
+
}
|
|
933
|
+
]
|
|
1093
934
|
};
|
|
1094
935
|
}
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
|
|
936
|
+
}
|
|
937
|
+
inlineText(src, smartypants2) {
|
|
938
|
+
const cap = this.rules.inline.text.exec(src);
|
|
1098
939
|
if (cap) {
|
|
1099
|
-
|
|
940
|
+
let text;
|
|
1100
941
|
if (this.lexer.state.inRawBlock) {
|
|
1101
942
|
text = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0];
|
|
1102
943
|
} else {
|
|
1103
|
-
text = escape(this.options.smartypants ?
|
|
944
|
+
text = escape(this.options.smartypants ? smartypants2(cap[0]) : cap[0]);
|
|
1104
945
|
}
|
|
1105
946
|
return {
|
|
1106
|
-
type:
|
|
947
|
+
type: "text",
|
|
1107
948
|
raw: cap[0],
|
|
1108
|
-
text
|
|
949
|
+
text
|
|
1109
950
|
};
|
|
1110
951
|
}
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
}();
|
|
952
|
+
}
|
|
953
|
+
};
|
|
1114
954
|
|
|
1115
|
-
|
|
1116
|
-
* Block-Level Grammar
|
|
1117
|
-
*/
|
|
955
|
+
// src/rules.ts
|
|
1118
956
|
var block = {
|
|
1119
957
|
newline: /^(?: *(?:\n|$))+/,
|
|
1120
958
|
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
@@ -1123,16 +961,7 @@
|
|
|
1123
961
|
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
1124
962
|
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
|
1125
963
|
list: /^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,
|
|
1126
|
-
html:
|
|
1127
|
-
+ '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
1128
|
-
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
1129
|
-
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
|
|
1130
|
-
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
|
|
1131
|
-
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
|
|
1132
|
-
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
|
|
1133
|
-
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
|
|
1134
|
-
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
|
|
1135
|
-
+ ')',
|
|
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|$))",
|
|
1136
965
|
def: /^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
|
|
1137
966
|
table: noopTest,
|
|
1138
967
|
lheading: /^((?:(?!^bull ).|\n(?!\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
@@ -1143,130 +972,86 @@
|
|
|
1143
972
|
};
|
|
1144
973
|
block._label = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
|
|
1145
974
|
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
1146
|
-
block.def = edit(block.def).replace(
|
|
975
|
+
block.def = edit(block.def).replace("label", block._label).replace("title", block._title).getRegex();
|
|
1147
976
|
block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
1148
|
-
block.listItemStart = edit(/^( *)(bull) */).replace(
|
|
1149
|
-
block.list = edit(block.list).replace(/bull/g, block.bullet).replace(
|
|
1150
|
-
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";
|
|
1151
980
|
block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
1152
|
-
block.html = edit(block.html,
|
|
1153
|
-
block.lheading = edit(block.lheading).replace(/bull/g, block.bullet)
|
|
1154
|
-
.getRegex();
|
|
1155
|
-
block.
|
|
1156
|
-
.
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
*/
|
|
1170
|
-
|
|
1171
|
-
block.gfm = _extends({}, block.normal, {
|
|
1172
|
-
table: '^ *([^\\n ].*\\|.*)\\n' // Header
|
|
1173
|
-
+ ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
|
|
1174
|
-
+ '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
1175
|
-
});
|
|
1176
|
-
|
|
1177
|
-
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
|
|
1178
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
1179
|
-
.getRegex();
|
|
1180
|
-
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
|
|
1181
|
-
.replace('table', block.gfm.table) // interrupt paragraphs with table
|
|
1182
|
-
.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
|
|
1183
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
1184
|
-
.getRegex();
|
|
1185
|
-
/**
|
|
1186
|
-
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
1187
|
-
*/
|
|
1188
|
-
|
|
1189
|
-
block.pedantic = _extends({}, block.normal, {
|
|
1190
|
-
html: edit('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
1191
|
-
+ '|<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(),
|
|
1192
998
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1193
999
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
1194
1000
|
fences: noopTest,
|
|
1195
1001
|
// fences not supported
|
|
1196
1002
|
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1197
|
-
paragraph: edit(block.normal._paragraph).replace(
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
/**
|
|
1201
|
-
* Inline-Level Grammar
|
|
1202
|
-
*/
|
|
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
|
+
};
|
|
1203
1005
|
var inline = {
|
|
1204
1006
|
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
1205
1007
|
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
1206
1008
|
url: noopTest,
|
|
1207
|
-
tag:
|
|
1208
|
-
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
|
1209
|
-
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
|
1210
|
-
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
|
1211
|
-
+ '|^<!\\[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]*?\\]\\]>",
|
|
1212
1010
|
// CDATA section
|
|
1213
1011
|
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
|
|
1214
1012
|
reflink: /^!?\[(label)\]\[(ref)\]/,
|
|
1215
1013
|
nolink: /^!?\[(ref)\](?:\[\])?/,
|
|
1216
|
-
reflinkSearch:
|
|
1014
|
+
reflinkSearch: "reflink|nolink(?!\\()",
|
|
1217
1015
|
emStrong: {
|
|
1218
1016
|
lDelim: /^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,
|
|
1219
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.
|
|
1220
1018
|
// | Skip orphan inside strong | Consume to delim | (1) #*** | (2) a***#, a*** | (3) #***a, ***a | (4) ***# | (5) #***# | (6) a***a
|
|
1221
1019
|
rDelimAst: /^[^_*]*?__[^_*]*?\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\*)[punct](\*+)(?=[\s]|$)|[^punct\s](\*+)(?!\*)(?=[punct\s]|$)|(?!\*)[punct\s](\*+)(?=[^punct\s])|[\s](\*+)(?!\*)(?=[punct])|(?!\*)[punct](\*+)(?!\*)(?=[punct])|[^punct\s](\*+)(?=[^punct\s])/,
|
|
1222
|
-
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 _
|
|
1223
1022
|
},
|
|
1224
|
-
|
|
1225
1023
|
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
1226
1024
|
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
1227
1025
|
del: noopTest,
|
|
1228
1026
|
text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
1229
1027
|
punctuation: /^((?![*_])[\spunctuation])/
|
|
1230
1028
|
};
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
inline._punctuation = '\\p{P}$+<=>`^|~';
|
|
1234
|
-
inline.punctuation = edit(inline.punctuation, 'u').replace(/punctuation/g, inline._punctuation).getRegex();
|
|
1235
|
-
|
|
1236
|
-
// 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();
|
|
1237
1031
|
inline.blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
|
|
1238
1032
|
inline.anyPunctuation = /\\[punct]/g;
|
|
1239
1033
|
inline._escapes = /\\([punct])/g;
|
|
1240
|
-
inline._comment = edit(block._comment).replace(
|
|
1241
|
-
inline.emStrong.lDelim = edit(inline.emStrong.lDelim,
|
|
1242
|
-
inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst,
|
|
1243
|
-
inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd,
|
|
1244
|
-
inline.anyPunctuation = edit(inline.anyPunctuation,
|
|
1245
|
-
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();
|
|
1246
1040
|
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
1247
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])?)+(?![-_])/;
|
|
1248
|
-
inline.autolink = edit(inline.autolink).replace(
|
|
1042
|
+
inline.autolink = edit(inline.autolink).replace("scheme", inline._scheme).replace("email", inline._email).getRegex();
|
|
1249
1043
|
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
1250
|
-
inline.tag = edit(inline.tag).replace(
|
|
1044
|
+
inline.tag = edit(inline.tag).replace("comment", inline._comment).replace("attribute", inline._attribute).getRegex();
|
|
1251
1045
|
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
1252
1046
|
inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
1253
1047
|
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
1254
|
-
inline.link = edit(inline.link).replace(
|
|
1255
|
-
inline.reflink = edit(inline.reflink).replace(
|
|
1256
|
-
inline.nolink = edit(inline.nolink).replace(
|
|
1257
|
-
inline.reflinkSearch = edit(inline.reflinkSearch,
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
*/
|
|
1262
|
-
|
|
1263
|
-
inline.normal = _extends({}, inline);
|
|
1264
|
-
|
|
1265
|
-
/**
|
|
1266
|
-
* Pedantic Inline Grammar
|
|
1267
|
-
*/
|
|
1268
|
-
|
|
1269
|
-
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,
|
|
1270
1055
|
strong: {
|
|
1271
1056
|
start: /^__|\*\*/,
|
|
1272
1057
|
middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
@@ -1279,82 +1064,47 @@
|
|
|
1279
1064
|
endAst: /\*(?!\*)/g,
|
|
1280
1065
|
endUnd: /_(?!_)/g
|
|
1281
1066
|
},
|
|
1282
|
-
link: edit(/^!?\[(label)\]\((.*?)\)/).replace(
|
|
1283
|
-
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
*/
|
|
1289
|
-
|
|
1290
|
-
inline.gfm = _extends({}, inline.normal, {
|
|
1291
|
-
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(),
|
|
1292
1073
|
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
1293
1074
|
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
1294
1075
|
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
1295
1076
|
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
1296
1077
|
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
1297
|
-
}
|
|
1298
|
-
inline.gfm.url = edit(inline.gfm.url,
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
br: edit(inline.br).replace('{2,}', '*').getRegex(),
|
|
1305
|
-
text: edit(inline.gfm.text).replace('\\b_', '\\b_| {2,}\\n').replace(/\{2,\}/g, '*').getRegex()
|
|
1306
|
-
});
|
|
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
|
+
};
|
|
1307
1085
|
|
|
1308
|
-
|
|
1309
|
-
* smartypants text replacement
|
|
1310
|
-
* @param {string} text
|
|
1311
|
-
*/
|
|
1086
|
+
// src/Lexer.ts
|
|
1312
1087
|
function smartypants(text) {
|
|
1313
|
-
return text
|
|
1314
|
-
// em-dashes
|
|
1315
|
-
.replace(/---/g, "\u2014")
|
|
1316
|
-
// en-dashes
|
|
1317
|
-
.replace(/--/g, "\u2013")
|
|
1318
|
-
// opening singles
|
|
1319
|
-
.replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018")
|
|
1320
|
-
// closing singles & apostrophes
|
|
1321
|
-
.replace(/'/g, "\u2019")
|
|
1322
|
-
// opening doubles
|
|
1323
|
-
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201C")
|
|
1324
|
-
// closing doubles
|
|
1325
|
-
.replace(/"/g, "\u201D")
|
|
1326
|
-
// ellipses
|
|
1327
|
-
.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");
|
|
1328
1089
|
}
|
|
1329
|
-
|
|
1330
|
-
/**
|
|
1331
|
-
* mangle email addresses
|
|
1332
|
-
* @param {string} text
|
|
1333
|
-
*/
|
|
1334
1090
|
function mangle(text) {
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
ch;
|
|
1338
|
-
var l = text.length;
|
|
1091
|
+
let out = "", i, ch;
|
|
1092
|
+
const l = text.length;
|
|
1339
1093
|
for (i = 0; i < l; i++) {
|
|
1340
1094
|
ch = text.charCodeAt(i);
|
|
1341
1095
|
if (Math.random() > 0.5) {
|
|
1342
|
-
ch =
|
|
1096
|
+
ch = "x" + ch.toString(16);
|
|
1343
1097
|
}
|
|
1344
|
-
out +=
|
|
1098
|
+
out += "&#" + ch + ";";
|
|
1345
1099
|
}
|
|
1346
1100
|
return out;
|
|
1347
1101
|
}
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
* Block Lexer
|
|
1351
|
-
*/
|
|
1352
|
-
var Lexer = /*#__PURE__*/function () {
|
|
1353
|
-
function Lexer(options) {
|
|
1102
|
+
var _Lexer = class {
|
|
1103
|
+
constructor(options2) {
|
|
1354
1104
|
this.tokens = [];
|
|
1355
|
-
this.tokens.links = Object.create(null);
|
|
1356
|
-
this.options =
|
|
1357
|
-
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();
|
|
1358
1108
|
this.tokenizer = this.options.tokenizer;
|
|
1359
1109
|
this.tokenizer.options = this.options;
|
|
1360
1110
|
this.tokenizer.lexer = this;
|
|
@@ -1364,7 +1114,7 @@
|
|
|
1364
1114
|
inRawBlock: false,
|
|
1365
1115
|
top: true
|
|
1366
1116
|
};
|
|
1367
|
-
|
|
1117
|
+
const rules = {
|
|
1368
1118
|
block: block.normal,
|
|
1369
1119
|
inline: inline.normal
|
|
1370
1120
|
};
|
|
@@ -1381,183 +1131,145 @@
|
|
|
1381
1131
|
}
|
|
1382
1132
|
this.tokenizer.rules = rules;
|
|
1383
1133
|
}
|
|
1384
|
-
|
|
1385
1134
|
/**
|
|
1386
1135
|
* Expose Rules
|
|
1387
1136
|
*/
|
|
1137
|
+
static get rules() {
|
|
1138
|
+
return {
|
|
1139
|
+
block,
|
|
1140
|
+
inline
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1388
1143
|
/**
|
|
1389
1144
|
* Static Lex Method
|
|
1390
1145
|
*/
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
return
|
|
1146
|
+
static lex(src, options2) {
|
|
1147
|
+
const lexer2 = new _Lexer(options2);
|
|
1148
|
+
return lexer2.lex(src);
|
|
1394
1149
|
}
|
|
1395
|
-
|
|
1396
1150
|
/**
|
|
1397
1151
|
* Static Lex Inline Method
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
return
|
|
1152
|
+
*/
|
|
1153
|
+
static lexInline(src, options2) {
|
|
1154
|
+
const lexer2 = new _Lexer(options2);
|
|
1155
|
+
return lexer2.inlineTokens(src);
|
|
1402
1156
|
}
|
|
1403
|
-
|
|
1404
1157
|
/**
|
|
1405
1158
|
* Preprocessing
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
src = src.replace(/\r\n|\r/g, '\n');
|
|
1159
|
+
*/
|
|
1160
|
+
lex(src) {
|
|
1161
|
+
src = src.replace(/\r\n|\r/g, "\n");
|
|
1410
1162
|
this.blockTokens(src, this.tokens);
|
|
1411
|
-
|
|
1163
|
+
let next;
|
|
1412
1164
|
while (next = this.inlineQueue.shift()) {
|
|
1413
1165
|
this.inlineTokens(next.src, next.tokens);
|
|
1414
1166
|
}
|
|
1415
1167
|
return this.tokens;
|
|
1416
1168
|
}
|
|
1417
|
-
|
|
1418
|
-
/**
|
|
1419
|
-
* Lexing
|
|
1420
|
-
*/;
|
|
1421
|
-
_proto.blockTokens = function blockTokens(src, tokens) {
|
|
1422
|
-
var _this = this;
|
|
1423
|
-
if (tokens === void 0) {
|
|
1424
|
-
tokens = [];
|
|
1425
|
-
}
|
|
1169
|
+
blockTokens(src, tokens = []) {
|
|
1426
1170
|
if (this.options.pedantic) {
|
|
1427
|
-
src = src.replace(/\t/g,
|
|
1171
|
+
src = src.replace(/\t/g, " ").replace(/^ +$/gm, "");
|
|
1428
1172
|
} else {
|
|
1429
|
-
src = src.replace(/^( *)(\t+)/gm,
|
|
1430
|
-
return leading +
|
|
1173
|
+
src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
|
|
1174
|
+
return leading + " ".repeat(tabs.length);
|
|
1431
1175
|
});
|
|
1432
1176
|
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
if (
|
|
1436
|
-
if (token = extTokenizer.call({
|
|
1437
|
-
lexer: _this
|
|
1438
|
-
}, 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)) {
|
|
1439
1181
|
src = src.substring(token.raw.length);
|
|
1440
1182
|
tokens.push(token);
|
|
1441
1183
|
return true;
|
|
1442
1184
|
}
|
|
1443
1185
|
return false;
|
|
1444
1186
|
})) {
|
|
1445
|
-
|
|
1187
|
+
continue;
|
|
1446
1188
|
}
|
|
1447
|
-
|
|
1448
|
-
// newline
|
|
1449
|
-
if (token = _this.tokenizer.space(src)) {
|
|
1189
|
+
if (token = this.tokenizer.space(src)) {
|
|
1450
1190
|
src = src.substring(token.raw.length);
|
|
1451
1191
|
if (token.raw.length === 1 && tokens.length > 0) {
|
|
1452
|
-
|
|
1453
|
-
// so move it there so that we don't get unecessary paragraph tags
|
|
1454
|
-
tokens[tokens.length - 1].raw += '\n';
|
|
1192
|
+
tokens[tokens.length - 1].raw += "\n";
|
|
1455
1193
|
} else {
|
|
1456
1194
|
tokens.push(token);
|
|
1457
1195
|
}
|
|
1458
|
-
|
|
1196
|
+
continue;
|
|
1459
1197
|
}
|
|
1460
|
-
|
|
1461
|
-
// code
|
|
1462
|
-
if (token = _this.tokenizer.code(src)) {
|
|
1198
|
+
if (token = this.tokenizer.code(src)) {
|
|
1463
1199
|
src = src.substring(token.raw.length);
|
|
1464
1200
|
lastToken = tokens[tokens.length - 1];
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
lastToken.
|
|
1468
|
-
|
|
1469
|
-
_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;
|
|
1470
1205
|
} else {
|
|
1471
1206
|
tokens.push(token);
|
|
1472
1207
|
}
|
|
1473
|
-
|
|
1208
|
+
continue;
|
|
1474
1209
|
}
|
|
1475
|
-
|
|
1476
|
-
// fences
|
|
1477
|
-
if (token = _this.tokenizer.fences(src)) {
|
|
1210
|
+
if (token = this.tokenizer.fences(src)) {
|
|
1478
1211
|
src = src.substring(token.raw.length);
|
|
1479
1212
|
tokens.push(token);
|
|
1480
|
-
|
|
1213
|
+
continue;
|
|
1481
1214
|
}
|
|
1482
|
-
|
|
1483
|
-
// heading
|
|
1484
|
-
if (token = _this.tokenizer.heading(src)) {
|
|
1215
|
+
if (token = this.tokenizer.heading(src)) {
|
|
1485
1216
|
src = src.substring(token.raw.length);
|
|
1486
1217
|
tokens.push(token);
|
|
1487
|
-
|
|
1218
|
+
continue;
|
|
1488
1219
|
}
|
|
1489
|
-
|
|
1490
|
-
// hr
|
|
1491
|
-
if (token = _this.tokenizer.hr(src)) {
|
|
1220
|
+
if (token = this.tokenizer.hr(src)) {
|
|
1492
1221
|
src = src.substring(token.raw.length);
|
|
1493
1222
|
tokens.push(token);
|
|
1494
|
-
|
|
1223
|
+
continue;
|
|
1495
1224
|
}
|
|
1496
|
-
|
|
1497
|
-
// blockquote
|
|
1498
|
-
if (token = _this.tokenizer.blockquote(src)) {
|
|
1225
|
+
if (token = this.tokenizer.blockquote(src)) {
|
|
1499
1226
|
src = src.substring(token.raw.length);
|
|
1500
1227
|
tokens.push(token);
|
|
1501
|
-
|
|
1228
|
+
continue;
|
|
1502
1229
|
}
|
|
1503
|
-
|
|
1504
|
-
// list
|
|
1505
|
-
if (token = _this.tokenizer.list(src)) {
|
|
1230
|
+
if (token = this.tokenizer.list(src)) {
|
|
1506
1231
|
src = src.substring(token.raw.length);
|
|
1507
1232
|
tokens.push(token);
|
|
1508
|
-
|
|
1233
|
+
continue;
|
|
1509
1234
|
}
|
|
1510
|
-
|
|
1511
|
-
// html
|
|
1512
|
-
if (token = _this.tokenizer.html(src)) {
|
|
1235
|
+
if (token = this.tokenizer.html(src)) {
|
|
1513
1236
|
src = src.substring(token.raw.length);
|
|
1514
1237
|
tokens.push(token);
|
|
1515
|
-
|
|
1238
|
+
continue;
|
|
1516
1239
|
}
|
|
1517
|
-
|
|
1518
|
-
// def
|
|
1519
|
-
if (token = _this.tokenizer.def(src)) {
|
|
1240
|
+
if (token = this.tokenizer.def(src)) {
|
|
1520
1241
|
src = src.substring(token.raw.length);
|
|
1521
1242
|
lastToken = tokens[tokens.length - 1];
|
|
1522
|
-
if (lastToken && (lastToken.type ===
|
|
1523
|
-
lastToken.raw +=
|
|
1524
|
-
lastToken.text +=
|
|
1525
|
-
|
|
1526
|
-
} else if (!
|
|
1527
|
-
|
|
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] = {
|
|
1528
1249
|
href: token.href,
|
|
1529
1250
|
title: token.title
|
|
1530
1251
|
};
|
|
1531
1252
|
}
|
|
1532
|
-
|
|
1253
|
+
continue;
|
|
1533
1254
|
}
|
|
1534
|
-
|
|
1535
|
-
// table (gfm)
|
|
1536
|
-
if (token = _this.tokenizer.table(src)) {
|
|
1255
|
+
if (token = this.tokenizer.table(src)) {
|
|
1537
1256
|
src = src.substring(token.raw.length);
|
|
1538
1257
|
tokens.push(token);
|
|
1539
|
-
|
|
1258
|
+
continue;
|
|
1540
1259
|
}
|
|
1541
|
-
|
|
1542
|
-
// lheading
|
|
1543
|
-
if (token = _this.tokenizer.lheading(src)) {
|
|
1260
|
+
if (token = this.tokenizer.lheading(src)) {
|
|
1544
1261
|
src = src.substring(token.raw.length);
|
|
1545
1262
|
tokens.push(token);
|
|
1546
|
-
|
|
1263
|
+
continue;
|
|
1547
1264
|
}
|
|
1548
|
-
|
|
1549
|
-
// top-level paragraph
|
|
1550
|
-
// prevent paragraph consuming extensions by clipping 'src' to extension start
|
|
1551
1265
|
cutSrc = src;
|
|
1552
|
-
if (
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
tempStart = getStartIndex.call({
|
|
1558
|
-
|
|
1559
|
-
}, tempSrc);
|
|
1560
|
-
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) {
|
|
1561
1273
|
startIndex = Math.min(startIndex, tempStart);
|
|
1562
1274
|
}
|
|
1563
1275
|
});
|
|
@@ -1565,213 +1277,159 @@
|
|
|
1565
1277
|
cutSrc = src.substring(0, startIndex + 1);
|
|
1566
1278
|
}
|
|
1567
1279
|
}
|
|
1568
|
-
if (
|
|
1280
|
+
if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
1569
1281
|
lastToken = tokens[tokens.length - 1];
|
|
1570
|
-
if (lastParagraphClipped && lastToken.type ===
|
|
1571
|
-
lastToken.raw +=
|
|
1572
|
-
lastToken.text +=
|
|
1573
|
-
|
|
1574
|
-
|
|
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;
|
|
1575
1287
|
} else {
|
|
1576
1288
|
tokens.push(token);
|
|
1577
1289
|
}
|
|
1578
1290
|
lastParagraphClipped = cutSrc.length !== src.length;
|
|
1579
1291
|
src = src.substring(token.raw.length);
|
|
1580
|
-
|
|
1292
|
+
continue;
|
|
1581
1293
|
}
|
|
1582
|
-
|
|
1583
|
-
// text
|
|
1584
|
-
if (token = _this.tokenizer.text(src)) {
|
|
1294
|
+
if (token = this.tokenizer.text(src)) {
|
|
1585
1295
|
src = src.substring(token.raw.length);
|
|
1586
1296
|
lastToken = tokens[tokens.length - 1];
|
|
1587
|
-
if (lastToken && lastToken.type ===
|
|
1588
|
-
lastToken.raw +=
|
|
1589
|
-
lastToken.text +=
|
|
1590
|
-
|
|
1591
|
-
|
|
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;
|
|
1592
1302
|
} else {
|
|
1593
1303
|
tokens.push(token);
|
|
1594
1304
|
}
|
|
1595
|
-
|
|
1305
|
+
continue;
|
|
1596
1306
|
}
|
|
1597
1307
|
if (src) {
|
|
1598
|
-
|
|
1599
|
-
if (
|
|
1308
|
+
const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
|
|
1309
|
+
if (this.options.silent) {
|
|
1600
1310
|
console.error(errMsg);
|
|
1601
|
-
|
|
1311
|
+
break;
|
|
1602
1312
|
} else {
|
|
1603
1313
|
throw new Error(errMsg);
|
|
1604
1314
|
}
|
|
1605
1315
|
}
|
|
1606
|
-
};
|
|
1607
|
-
while (src) {
|
|
1608
|
-
var _ret = _loop();
|
|
1609
|
-
if (_ret === "continue") continue;
|
|
1610
|
-
if (_ret === "break") break;
|
|
1611
1316
|
}
|
|
1612
1317
|
this.state.top = true;
|
|
1613
1318
|
return tokens;
|
|
1614
|
-
}
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
tokens = [];
|
|
1618
|
-
}
|
|
1619
|
-
this.inlineQueue.push({
|
|
1620
|
-
src: src,
|
|
1621
|
-
tokens: tokens
|
|
1622
|
-
});
|
|
1319
|
+
}
|
|
1320
|
+
inline(src, tokens = []) {
|
|
1321
|
+
this.inlineQueue.push({ src, tokens });
|
|
1623
1322
|
return tokens;
|
|
1624
1323
|
}
|
|
1625
|
-
|
|
1626
1324
|
/**
|
|
1627
1325
|
* Lexing/Compiling
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
var token, lastToken, cutSrc;
|
|
1635
|
-
|
|
1636
|
-
// String with links masked to avoid interference with em and strong
|
|
1637
|
-
var maskedSrc = src;
|
|
1638
|
-
var match;
|
|
1639
|
-
var keepPrevChar, prevChar;
|
|
1640
|
-
|
|
1641
|
-
// Mask out reflinks
|
|
1326
|
+
*/
|
|
1327
|
+
inlineTokens(src, tokens = []) {
|
|
1328
|
+
let token, lastToken, cutSrc;
|
|
1329
|
+
let maskedSrc = src;
|
|
1330
|
+
let match;
|
|
1331
|
+
let keepPrevChar, prevChar;
|
|
1642
1332
|
if (this.tokens.links) {
|
|
1643
|
-
|
|
1333
|
+
const links = Object.keys(this.tokens.links);
|
|
1644
1334
|
if (links.length > 0) {
|
|
1645
1335
|
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
|
1646
|
-
if (links.includes(match[0].slice(match[0].lastIndexOf(
|
|
1647
|
-
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);
|
|
1648
1338
|
}
|
|
1649
1339
|
}
|
|
1650
1340
|
}
|
|
1651
1341
|
}
|
|
1652
|
-
// Mask out other blocks
|
|
1653
1342
|
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
1654
|
-
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);
|
|
1655
1344
|
}
|
|
1656
|
-
|
|
1657
|
-
// Mask out escaped characters
|
|
1658
1345
|
while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
|
|
1659
|
-
maskedSrc = maskedSrc.slice(0, match.index) +
|
|
1346
|
+
maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
1660
1347
|
}
|
|
1661
|
-
|
|
1348
|
+
while (src) {
|
|
1662
1349
|
if (!keepPrevChar) {
|
|
1663
|
-
prevChar =
|
|
1350
|
+
prevChar = "";
|
|
1664
1351
|
}
|
|
1665
1352
|
keepPrevChar = false;
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
if (_this2.options.extensions && _this2.options.extensions.inline && _this2.options.extensions.inline.some(function (extTokenizer) {
|
|
1669
|
-
if (token = extTokenizer.call({
|
|
1670
|
-
lexer: _this2
|
|
1671
|
-
}, 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)) {
|
|
1672
1355
|
src = src.substring(token.raw.length);
|
|
1673
1356
|
tokens.push(token);
|
|
1674
1357
|
return true;
|
|
1675
1358
|
}
|
|
1676
1359
|
return false;
|
|
1677
1360
|
})) {
|
|
1678
|
-
|
|
1361
|
+
continue;
|
|
1679
1362
|
}
|
|
1680
|
-
|
|
1681
|
-
// escape
|
|
1682
|
-
if (token = _this2.tokenizer.escape(src)) {
|
|
1363
|
+
if (token = this.tokenizer.escape(src)) {
|
|
1683
1364
|
src = src.substring(token.raw.length);
|
|
1684
1365
|
tokens.push(token);
|
|
1685
|
-
|
|
1366
|
+
continue;
|
|
1686
1367
|
}
|
|
1687
|
-
|
|
1688
|
-
// tag
|
|
1689
|
-
if (token = _this2.tokenizer.tag(src)) {
|
|
1368
|
+
if (token = this.tokenizer.tag(src)) {
|
|
1690
1369
|
src = src.substring(token.raw.length);
|
|
1691
1370
|
lastToken = tokens[tokens.length - 1];
|
|
1692
|
-
if (lastToken && token.type ===
|
|
1371
|
+
if (lastToken && token.type === "text" && lastToken.type === "text") {
|
|
1693
1372
|
lastToken.raw += token.raw;
|
|
1694
1373
|
lastToken.text += token.text;
|
|
1695
1374
|
} else {
|
|
1696
1375
|
tokens.push(token);
|
|
1697
1376
|
}
|
|
1698
|
-
|
|
1377
|
+
continue;
|
|
1699
1378
|
}
|
|
1700
|
-
|
|
1701
|
-
// link
|
|
1702
|
-
if (token = _this2.tokenizer.link(src)) {
|
|
1379
|
+
if (token = this.tokenizer.link(src)) {
|
|
1703
1380
|
src = src.substring(token.raw.length);
|
|
1704
1381
|
tokens.push(token);
|
|
1705
|
-
|
|
1382
|
+
continue;
|
|
1706
1383
|
}
|
|
1707
|
-
|
|
1708
|
-
// reflink, nolink
|
|
1709
|
-
if (token = _this2.tokenizer.reflink(src, _this2.tokens.links)) {
|
|
1384
|
+
if (token = this.tokenizer.reflink(src, this.tokens.links)) {
|
|
1710
1385
|
src = src.substring(token.raw.length);
|
|
1711
1386
|
lastToken = tokens[tokens.length - 1];
|
|
1712
|
-
if (lastToken && token.type ===
|
|
1387
|
+
if (lastToken && token.type === "text" && lastToken.type === "text") {
|
|
1713
1388
|
lastToken.raw += token.raw;
|
|
1714
1389
|
lastToken.text += token.text;
|
|
1715
1390
|
} else {
|
|
1716
1391
|
tokens.push(token);
|
|
1717
1392
|
}
|
|
1718
|
-
|
|
1393
|
+
continue;
|
|
1719
1394
|
}
|
|
1720
|
-
|
|
1721
|
-
// em & strong
|
|
1722
|
-
if (token = _this2.tokenizer.emStrong(src, maskedSrc, prevChar)) {
|
|
1395
|
+
if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
|
|
1723
1396
|
src = src.substring(token.raw.length);
|
|
1724
1397
|
tokens.push(token);
|
|
1725
|
-
|
|
1398
|
+
continue;
|
|
1726
1399
|
}
|
|
1727
|
-
|
|
1728
|
-
// code
|
|
1729
|
-
if (token = _this2.tokenizer.codespan(src)) {
|
|
1400
|
+
if (token = this.tokenizer.codespan(src)) {
|
|
1730
1401
|
src = src.substring(token.raw.length);
|
|
1731
1402
|
tokens.push(token);
|
|
1732
|
-
|
|
1403
|
+
continue;
|
|
1733
1404
|
}
|
|
1734
|
-
|
|
1735
|
-
// br
|
|
1736
|
-
if (token = _this2.tokenizer.br(src)) {
|
|
1405
|
+
if (token = this.tokenizer.br(src)) {
|
|
1737
1406
|
src = src.substring(token.raw.length);
|
|
1738
1407
|
tokens.push(token);
|
|
1739
|
-
|
|
1408
|
+
continue;
|
|
1740
1409
|
}
|
|
1741
|
-
|
|
1742
|
-
// del (gfm)
|
|
1743
|
-
if (token = _this2.tokenizer.del(src)) {
|
|
1410
|
+
if (token = this.tokenizer.del(src)) {
|
|
1744
1411
|
src = src.substring(token.raw.length);
|
|
1745
1412
|
tokens.push(token);
|
|
1746
|
-
|
|
1413
|
+
continue;
|
|
1747
1414
|
}
|
|
1748
|
-
|
|
1749
|
-
// autolink
|
|
1750
|
-
if (token = _this2.tokenizer.autolink(src, mangle)) {
|
|
1415
|
+
if (token = this.tokenizer.autolink(src, mangle)) {
|
|
1751
1416
|
src = src.substring(token.raw.length);
|
|
1752
1417
|
tokens.push(token);
|
|
1753
|
-
|
|
1418
|
+
continue;
|
|
1754
1419
|
}
|
|
1755
|
-
|
|
1756
|
-
// url (gfm)
|
|
1757
|
-
if (!_this2.state.inLink && (token = _this2.tokenizer.url(src, mangle))) {
|
|
1420
|
+
if (!this.state.inLink && (token = this.tokenizer.url(src, mangle))) {
|
|
1758
1421
|
src = src.substring(token.raw.length);
|
|
1759
1422
|
tokens.push(token);
|
|
1760
|
-
|
|
1423
|
+
continue;
|
|
1761
1424
|
}
|
|
1762
|
-
|
|
1763
|
-
// text
|
|
1764
|
-
// prevent inlineText consuming extensions by clipping 'src' to extension start
|
|
1765
1425
|
cutSrc = src;
|
|
1766
|
-
if (
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
tempStart = getStartIndex.call({
|
|
1772
|
-
|
|
1773
|
-
}, tempSrc);
|
|
1774
|
-
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) {
|
|
1775
1433
|
startIndex = Math.min(startIndex, tempStart);
|
|
1776
1434
|
}
|
|
1777
1435
|
});
|
|
@@ -1779,291 +1437,204 @@
|
|
|
1779
1437
|
cutSrc = src.substring(0, startIndex + 1);
|
|
1780
1438
|
}
|
|
1781
1439
|
}
|
|
1782
|
-
if (token =
|
|
1440
|
+
if (token = this.tokenizer.inlineText(cutSrc, smartypants)) {
|
|
1783
1441
|
src = src.substring(token.raw.length);
|
|
1784
|
-
if (token.raw.slice(-1) !==
|
|
1785
|
-
// Track prevChar before string of ____ started
|
|
1442
|
+
if (token.raw.slice(-1) !== "_") {
|
|
1786
1443
|
prevChar = token.raw.slice(-1);
|
|
1787
1444
|
}
|
|
1788
1445
|
keepPrevChar = true;
|
|
1789
1446
|
lastToken = tokens[tokens.length - 1];
|
|
1790
|
-
if (lastToken && lastToken.type ===
|
|
1447
|
+
if (lastToken && lastToken.type === "text") {
|
|
1791
1448
|
lastToken.raw += token.raw;
|
|
1792
1449
|
lastToken.text += token.text;
|
|
1793
1450
|
} else {
|
|
1794
1451
|
tokens.push(token);
|
|
1795
1452
|
}
|
|
1796
|
-
|
|
1453
|
+
continue;
|
|
1797
1454
|
}
|
|
1798
1455
|
if (src) {
|
|
1799
|
-
|
|
1800
|
-
if (
|
|
1456
|
+
const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
|
|
1457
|
+
if (this.options.silent) {
|
|
1801
1458
|
console.error(errMsg);
|
|
1802
|
-
|
|
1459
|
+
break;
|
|
1803
1460
|
} else {
|
|
1804
1461
|
throw new Error(errMsg);
|
|
1805
1462
|
}
|
|
1806
1463
|
}
|
|
1807
|
-
};
|
|
1808
|
-
while (src) {
|
|
1809
|
-
var _ret2 = _loop2();
|
|
1810
|
-
if (_ret2 === "continue") continue;
|
|
1811
|
-
if (_ret2 === "break") break;
|
|
1812
1464
|
}
|
|
1813
1465
|
return tokens;
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
key: "rules",
|
|
1817
|
-
get: function get() {
|
|
1818
|
-
return {
|
|
1819
|
-
block: block,
|
|
1820
|
-
inline: inline
|
|
1821
|
-
};
|
|
1822
|
-
}
|
|
1823
|
-
}]);
|
|
1824
|
-
return Lexer;
|
|
1825
|
-
}();
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1826
1468
|
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
var _proto = Renderer.prototype;
|
|
1835
|
-
_proto.code = function code(_code, infostring, escaped) {
|
|
1836
|
-
var lang = (infostring || '').match(/\S*/)[0];
|
|
1469
|
+
// src/Renderer.ts
|
|
1470
|
+
var _Renderer = class {
|
|
1471
|
+
constructor(options2) {
|
|
1472
|
+
this.options = options2 || _defaults;
|
|
1473
|
+
}
|
|
1474
|
+
code(code, infostring, escaped) {
|
|
1475
|
+
const lang = (infostring || "").match(/\S*/)[0];
|
|
1837
1476
|
if (this.options.highlight) {
|
|
1838
|
-
|
|
1839
|
-
if (out != null && out !==
|
|
1477
|
+
const out = this.options.highlight(code, lang);
|
|
1478
|
+
if (out != null && out !== code) {
|
|
1840
1479
|
escaped = true;
|
|
1841
|
-
|
|
1480
|
+
code = out;
|
|
1842
1481
|
}
|
|
1843
1482
|
}
|
|
1844
|
-
|
|
1483
|
+
code = code.replace(/\n$/, "") + "\n";
|
|
1845
1484
|
if (!lang) {
|
|
1846
|
-
return
|
|
1485
|
+
return "<pre><code>" + (escaped ? code : escape(code, true)) + "</code></pre>\n";
|
|
1847
1486
|
}
|
|
1848
|
-
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";
|
|
1849
1488
|
}
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
_proto.blockquote = function blockquote(quote) {
|
|
1855
|
-
return "<blockquote>\n" + quote + "</blockquote>\n";
|
|
1856
|
-
};
|
|
1857
|
-
_proto.html = function html(_html, block) {
|
|
1858
|
-
return _html;
|
|
1489
|
+
blockquote(quote) {
|
|
1490
|
+
return `<blockquote>
|
|
1491
|
+
${quote}</blockquote>
|
|
1492
|
+
`;
|
|
1859
1493
|
}
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
* @param {string} raw
|
|
1865
|
-
* @param {any} slugger
|
|
1866
|
-
*/;
|
|
1867
|
-
_proto.heading = function heading(text, level, raw, slugger) {
|
|
1494
|
+
html(html, block2) {
|
|
1495
|
+
return html;
|
|
1496
|
+
}
|
|
1497
|
+
heading(text, level, raw, slugger) {
|
|
1868
1498
|
if (this.options.headerIds) {
|
|
1869
|
-
|
|
1870
|
-
return
|
|
1499
|
+
const id = this.options.headerPrefix + slugger.slug(raw);
|
|
1500
|
+
return `<h${level} id="${id}">${text}</h${level}>
|
|
1501
|
+
`;
|
|
1871
1502
|
}
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
return "<h" + level + ">" + text + "</h" + level + ">\n";
|
|
1875
|
-
};
|
|
1876
|
-
_proto.hr = function hr() {
|
|
1877
|
-
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
|
1878
|
-
};
|
|
1879
|
-
_proto.list = function list(body, ordered, start) {
|
|
1880
|
-
var type = ordered ? 'ol' : 'ul',
|
|
1881
|
-
startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
|
|
1882
|
-
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
|
1503
|
+
return `<h${level}>${text}</h${level}>
|
|
1504
|
+
`;
|
|
1883
1505
|
}
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
* @param {string} text
|
|
1887
|
-
*/;
|
|
1888
|
-
_proto.listitem = function listitem(text) {
|
|
1889
|
-
return "<li>" + text + "</li>\n";
|
|
1890
|
-
};
|
|
1891
|
-
_proto.checkbox = function checkbox(checked) {
|
|
1892
|
-
return '<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox"' + (this.options.xhtml ? ' /' : '') + '> ';
|
|
1506
|
+
hr() {
|
|
1507
|
+
return this.options.xhtml ? "<hr/>\n" : "<hr>\n";
|
|
1893
1508
|
}
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
*/;
|
|
1898
|
-
_proto.paragraph = function paragraph(text) {
|
|
1899
|
-
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";
|
|
1900
1512
|
}
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
* @param {string} body
|
|
1905
|
-
*/;
|
|
1906
|
-
_proto.table = function table(header, body) {
|
|
1907
|
-
if (body) body = "<tbody>" + body + "</tbody>";
|
|
1908
|
-
return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n';
|
|
1513
|
+
listitem(text, task, checked) {
|
|
1514
|
+
return `<li>${text}</li>
|
|
1515
|
+
`;
|
|
1909
1516
|
}
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
}
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
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
|
+
`;
|
|
1921
1539
|
}
|
|
1922
|
-
|
|
1923
1540
|
/**
|
|
1924
1541
|
* span level renderer
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
return "<strong>" + text + "</strong>";
|
|
1542
|
+
*/
|
|
1543
|
+
strong(text) {
|
|
1544
|
+
return `<strong>${text}</strong>`;
|
|
1929
1545
|
}
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
* @param {string} text
|
|
1933
|
-
*/;
|
|
1934
|
-
_proto.em = function em(text) {
|
|
1935
|
-
return "<em>" + text + "</em>";
|
|
1546
|
+
em(text) {
|
|
1547
|
+
return `<em>${text}</em>`;
|
|
1936
1548
|
}
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
* @param {string} text
|
|
1940
|
-
*/;
|
|
1941
|
-
_proto.codespan = function codespan(text) {
|
|
1942
|
-
return "<code>" + text + "</code>";
|
|
1943
|
-
};
|
|
1944
|
-
_proto.br = function br() {
|
|
1945
|
-
return this.options.xhtml ? '<br/>' : '<br>';
|
|
1549
|
+
codespan(text) {
|
|
1550
|
+
return `<code>${text}</code>`;
|
|
1946
1551
|
}
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
* @param {string} text
|
|
1950
|
-
*/;
|
|
1951
|
-
_proto.del = function del(text) {
|
|
1952
|
-
return "<del>" + text + "</del>";
|
|
1552
|
+
br() {
|
|
1553
|
+
return this.options.xhtml ? "<br/>" : "<br>";
|
|
1953
1554
|
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
* @param {string} text
|
|
1959
|
-
*/;
|
|
1960
|
-
_proto.link = function link(href, title, text) {
|
|
1555
|
+
del(text) {
|
|
1556
|
+
return `<del>${text}</del>`;
|
|
1557
|
+
}
|
|
1558
|
+
link(href, title, text) {
|
|
1961
1559
|
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
1962
1560
|
if (href === null) {
|
|
1963
1561
|
return text;
|
|
1964
1562
|
}
|
|
1965
|
-
|
|
1563
|
+
let out = '<a href="' + href + '"';
|
|
1966
1564
|
if (title) {
|
|
1967
1565
|
out += ' title="' + title + '"';
|
|
1968
1566
|
}
|
|
1969
|
-
out +=
|
|
1567
|
+
out += ">" + text + "</a>";
|
|
1970
1568
|
return out;
|
|
1971
1569
|
}
|
|
1972
|
-
|
|
1973
|
-
/**
|
|
1974
|
-
* @param {string} href
|
|
1975
|
-
* @param {string} title
|
|
1976
|
-
* @param {string} text
|
|
1977
|
-
*/;
|
|
1978
|
-
_proto.image = function image(href, title, text) {
|
|
1570
|
+
image(href, title, text) {
|
|
1979
1571
|
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
1980
1572
|
if (href === null) {
|
|
1981
1573
|
return text;
|
|
1982
1574
|
}
|
|
1983
|
-
|
|
1575
|
+
let out = `<img src="${href}" alt="${text}"`;
|
|
1984
1576
|
if (title) {
|
|
1985
|
-
out +=
|
|
1577
|
+
out += ` title="${title}"`;
|
|
1986
1578
|
}
|
|
1987
|
-
out += this.options.xhtml ?
|
|
1579
|
+
out += this.options.xhtml ? "/>" : ">";
|
|
1988
1580
|
return out;
|
|
1989
|
-
}
|
|
1990
|
-
|
|
1991
|
-
return
|
|
1992
|
-
}
|
|
1993
|
-
|
|
1994
|
-
}();
|
|
1581
|
+
}
|
|
1582
|
+
text(text) {
|
|
1583
|
+
return text;
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1995
1586
|
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
* returns only the textual part of the token
|
|
1999
|
-
*/
|
|
2000
|
-
var TextRenderer = /*#__PURE__*/function () {
|
|
2001
|
-
function TextRenderer() {}
|
|
2002
|
-
var _proto = TextRenderer.prototype;
|
|
1587
|
+
// src/TextRenderer.ts
|
|
1588
|
+
var _TextRenderer = class {
|
|
2003
1589
|
// no need for block level renderers
|
|
2004
|
-
|
|
1590
|
+
strong(text) {
|
|
2005
1591
|
return text;
|
|
2006
|
-
}
|
|
2007
|
-
|
|
1592
|
+
}
|
|
1593
|
+
em(text) {
|
|
2008
1594
|
return text;
|
|
2009
|
-
}
|
|
2010
|
-
|
|
1595
|
+
}
|
|
1596
|
+
codespan(text) {
|
|
2011
1597
|
return text;
|
|
2012
|
-
}
|
|
2013
|
-
|
|
1598
|
+
}
|
|
1599
|
+
del(text) {
|
|
2014
1600
|
return text;
|
|
2015
|
-
}
|
|
2016
|
-
|
|
1601
|
+
}
|
|
1602
|
+
html(text) {
|
|
2017
1603
|
return text;
|
|
2018
|
-
}
|
|
2019
|
-
|
|
2020
|
-
return
|
|
2021
|
-
}
|
|
2022
|
-
|
|
2023
|
-
return
|
|
2024
|
-
}
|
|
2025
|
-
|
|
2026
|
-
return
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2029
|
-
return
|
|
2030
|
-
}
|
|
2031
|
-
|
|
2032
|
-
}();
|
|
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
|
+
};
|
|
2033
1618
|
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
var Slugger = /*#__PURE__*/function () {
|
|
2038
|
-
function Slugger() {
|
|
1619
|
+
// src/Slugger.ts
|
|
1620
|
+
var _Slugger = class {
|
|
1621
|
+
constructor() {
|
|
2039
1622
|
this.seen = {};
|
|
2040
1623
|
}
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
* @param {string} value
|
|
2044
|
-
*/
|
|
2045
|
-
var _proto = Slugger.prototype;
|
|
2046
|
-
_proto.serialize = function serialize(value) {
|
|
2047
|
-
return value.toLowerCase().trim()
|
|
2048
|
-
// remove html tags
|
|
2049
|
-
.replace(/<[!\/a-z].*?>/ig, '')
|
|
2050
|
-
// remove unwanted chars
|
|
2051
|
-
.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, "-");
|
|
2052
1626
|
}
|
|
2053
|
-
|
|
2054
1627
|
/**
|
|
2055
1628
|
* Finds the next safe (unique) slug to use
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
var slug = originalSlug;
|
|
2061
|
-
var occurenceAccumulator = 0;
|
|
1629
|
+
*/
|
|
1630
|
+
getNextSafeSlug(originalSlug, isDryRun) {
|
|
1631
|
+
let slug = originalSlug;
|
|
1632
|
+
let occurenceAccumulator = 0;
|
|
2062
1633
|
if (this.seen.hasOwnProperty(slug)) {
|
|
2063
1634
|
occurenceAccumulator = this.seen[originalSlug];
|
|
2064
1635
|
do {
|
|
2065
1636
|
occurenceAccumulator++;
|
|
2066
|
-
slug = originalSlug +
|
|
1637
|
+
slug = originalSlug + "-" + occurenceAccumulator;
|
|
2067
1638
|
} while (this.seen.hasOwnProperty(slug));
|
|
2068
1639
|
}
|
|
2069
1640
|
if (!isDryRun) {
|
|
@@ -2072,440 +1643,346 @@
|
|
|
2072
1643
|
}
|
|
2073
1644
|
return slug;
|
|
2074
1645
|
}
|
|
2075
|
-
|
|
2076
1646
|
/**
|
|
2077
1647
|
* Convert string to unique id
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
options = {};
|
|
2085
|
-
}
|
|
2086
|
-
var slug = this.serialize(value);
|
|
2087
|
-
return this.getNextSafeSlug(slug, options.dryrun);
|
|
2088
|
-
};
|
|
2089
|
-
return Slugger;
|
|
2090
|
-
}();
|
|
1648
|
+
*/
|
|
1649
|
+
slug(value, options2 = {}) {
|
|
1650
|
+
const slug = this.serialize(value);
|
|
1651
|
+
return this.getNextSafeSlug(slug, options2.dryrun);
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
2091
1654
|
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
this.options = options || exports.defaults;
|
|
2098
|
-
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();
|
|
2099
1660
|
this.renderer = this.options.renderer;
|
|
2100
1661
|
this.renderer.options = this.options;
|
|
2101
|
-
this.textRenderer = new
|
|
2102
|
-
this.slugger = new
|
|
1662
|
+
this.textRenderer = new _TextRenderer();
|
|
1663
|
+
this.slugger = new _Slugger();
|
|
2103
1664
|
}
|
|
2104
|
-
|
|
2105
1665
|
/**
|
|
2106
1666
|
* Static Parse Method
|
|
2107
1667
|
*/
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
return
|
|
1668
|
+
static parse(tokens, options2) {
|
|
1669
|
+
const parser2 = new _Parser(options2);
|
|
1670
|
+
return parser2.parse(tokens);
|
|
2111
1671
|
}
|
|
2112
|
-
|
|
2113
1672
|
/**
|
|
2114
1673
|
* Static Parse Inline Method
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
return
|
|
1674
|
+
*/
|
|
1675
|
+
static parseInline(tokens, options2) {
|
|
1676
|
+
const parser2 = new _Parser(options2);
|
|
1677
|
+
return parser2.parseInline(tokens);
|
|
2119
1678
|
}
|
|
2120
|
-
|
|
2121
1679
|
/**
|
|
2122
1680
|
* Parse Loop
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
top = true;
|
|
2128
|
-
}
|
|
2129
|
-
var out = '',
|
|
2130
|
-
i,
|
|
2131
|
-
j,
|
|
2132
|
-
k,
|
|
2133
|
-
l2,
|
|
2134
|
-
l3,
|
|
2135
|
-
row,
|
|
2136
|
-
cell,
|
|
2137
|
-
header,
|
|
2138
|
-
body,
|
|
2139
|
-
token,
|
|
2140
|
-
ordered,
|
|
2141
|
-
start,
|
|
2142
|
-
loose,
|
|
2143
|
-
itemBody,
|
|
2144
|
-
item,
|
|
2145
|
-
checked,
|
|
2146
|
-
task,
|
|
2147
|
-
checkbox,
|
|
2148
|
-
ret;
|
|
2149
|
-
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;
|
|
2150
1685
|
for (i = 0; i < l; i++) {
|
|
2151
1686
|
token = tokens[i];
|
|
2152
|
-
|
|
2153
|
-
// Run any renderer extensions
|
|
2154
1687
|
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
2155
|
-
ret = this.options.extensions.renderers[token.type].call({
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(token.type)) {
|
|
2159
|
-
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 || "";
|
|
2160
1691
|
continue;
|
|
2161
1692
|
}
|
|
2162
1693
|
}
|
|
2163
1694
|
switch (token.type) {
|
|
2164
|
-
case
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
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
|
+
);
|
|
2182
1728
|
}
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
cell =
|
|
2189
|
-
|
|
2190
|
-
for (
|
|
2191
|
-
cell += this.renderer.tablecell(
|
|
2192
|
-
|
|
2193
|
-
align: token.align[
|
|
2194
|
-
|
|
2195
|
-
}
|
|
2196
|
-
header += this.renderer.tablerow(cell);
|
|
2197
|
-
body = '';
|
|
2198
|
-
l2 = token.rows.length;
|
|
2199
|
-
for (j = 0; j < l2; j++) {
|
|
2200
|
-
row = token.rows[j];
|
|
2201
|
-
cell = '';
|
|
2202
|
-
l3 = row.length;
|
|
2203
|
-
for (k = 0; k < l3; k++) {
|
|
2204
|
-
cell += this.renderer.tablecell(this.parseInline(row[k].tokens), {
|
|
2205
|
-
header: false,
|
|
2206
|
-
align: token.align[k]
|
|
2207
|
-
});
|
|
2208
|
-
}
|
|
2209
|
-
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
|
+
);
|
|
2210
1741
|
}
|
|
2211
|
-
|
|
2212
|
-
continue;
|
|
2213
|
-
}
|
|
2214
|
-
case 'blockquote':
|
|
2215
|
-
{
|
|
2216
|
-
body = this.parse(token.tokens);
|
|
2217
|
-
out += this.renderer.blockquote(body);
|
|
2218
|
-
continue;
|
|
1742
|
+
body += this.renderer.tablerow(cell);
|
|
2219
1743
|
}
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
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;
|
|
2245
1770
|
}
|
|
2246
1771
|
} else {
|
|
2247
|
-
|
|
1772
|
+
item.tokens.unshift({
|
|
1773
|
+
type: "text",
|
|
1774
|
+
text: checkbox
|
|
1775
|
+
});
|
|
2248
1776
|
}
|
|
1777
|
+
} else {
|
|
1778
|
+
itemBody += checkbox;
|
|
2249
1779
|
}
|
|
2250
|
-
itemBody += this.parse(item.tokens, loose);
|
|
2251
|
-
body += this.renderer.listitem(itemBody, task, checked);
|
|
2252
1780
|
}
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
}
|
|
2256
|
-
case 'html':
|
|
2257
|
-
{
|
|
2258
|
-
out += this.renderer.html(token.text, token.block);
|
|
2259
|
-
continue;
|
|
2260
|
-
}
|
|
2261
|
-
case 'paragraph':
|
|
2262
|
-
{
|
|
2263
|
-
out += this.renderer.paragraph(this.parseInline(token.tokens));
|
|
2264
|
-
continue;
|
|
1781
|
+
itemBody += this.parse(item.tokens, loose);
|
|
1782
|
+
body += this.renderer.listitem(itemBody, task, !!checked);
|
|
2265
1783
|
}
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
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);
|
|
2275
1800
|
}
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
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);
|
|
2285
1811
|
}
|
|
1812
|
+
}
|
|
2286
1813
|
}
|
|
2287
1814
|
}
|
|
2288
1815
|
return out;
|
|
2289
1816
|
}
|
|
2290
|
-
|
|
2291
1817
|
/**
|
|
2292
1818
|
* Parse Inline Tokens
|
|
2293
|
-
|
|
2294
|
-
|
|
1819
|
+
*/
|
|
1820
|
+
parseInline(tokens, renderer) {
|
|
2295
1821
|
renderer = renderer || this.renderer;
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
token,
|
|
2299
|
-
ret;
|
|
2300
|
-
var l = tokens.length;
|
|
1822
|
+
let out = "", i, token, ret;
|
|
1823
|
+
const l = tokens.length;
|
|
2301
1824
|
for (i = 0; i < l; i++) {
|
|
2302
1825
|
token = tokens[i];
|
|
2303
|
-
|
|
2304
|
-
// Run any renderer extensions
|
|
2305
1826
|
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
2306
|
-
ret = this.options.extensions.renderers[token.type].call({
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) {
|
|
2310
|
-
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 || "";
|
|
2311
1830
|
continue;
|
|
2312
1831
|
}
|
|
2313
1832
|
}
|
|
2314
1833
|
switch (token.type) {
|
|
2315
|
-
case
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
case
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
out += renderer.text(token.text);
|
|
2363
|
-
break;
|
|
2364
|
-
}
|
|
2365
|
-
default:
|
|
2366
|
-
{
|
|
2367
|
-
var errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
2368
|
-
if (this.options.silent) {
|
|
2369
|
-
console.error(errMsg);
|
|
2370
|
-
return;
|
|
2371
|
-
} else {
|
|
2372
|
-
throw new Error(errMsg);
|
|
2373
|
-
}
|
|
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);
|
|
2374
1881
|
}
|
|
1882
|
+
}
|
|
2375
1883
|
}
|
|
2376
1884
|
}
|
|
2377
1885
|
return out;
|
|
2378
|
-
}
|
|
2379
|
-
|
|
2380
|
-
}();
|
|
1886
|
+
}
|
|
1887
|
+
};
|
|
2381
1888
|
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
1889
|
+
// src/Hooks.ts
|
|
1890
|
+
var _Hooks = class {
|
|
1891
|
+
constructor(options2) {
|
|
1892
|
+
this.options = options2 || _defaults;
|
|
2385
1893
|
}
|
|
2386
|
-
var _proto = Hooks.prototype;
|
|
2387
1894
|
/**
|
|
2388
1895
|
* Process markdown before marked
|
|
2389
1896
|
*/
|
|
2390
|
-
|
|
1897
|
+
preprocess(markdown) {
|
|
2391
1898
|
return markdown;
|
|
2392
1899
|
}
|
|
2393
|
-
|
|
2394
1900
|
/**
|
|
2395
1901
|
* Process HTML after marked is finished
|
|
2396
|
-
|
|
2397
|
-
|
|
1902
|
+
*/
|
|
1903
|
+
postprocess(html) {
|
|
2398
1904
|
return html;
|
|
2399
|
-
}
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
});
|
|
2414
|
-
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();
|
|
2415
1919
|
this.options = this.setOptions;
|
|
2416
|
-
this.parse =
|
|
2417
|
-
this.parseInline =
|
|
2418
|
-
this.Parser =
|
|
2419
|
-
this.parser =
|
|
2420
|
-
this.Renderer =
|
|
2421
|
-
this.TextRenderer =
|
|
2422
|
-
this.Lexer =
|
|
2423
|
-
this.lexer =
|
|
2424
|
-
this.Tokenizer =
|
|
2425
|
-
this.Slugger =
|
|
2426
|
-
this.Hooks =
|
|
2427
|
-
this.use
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
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));
|
|
2436
1940
|
switch (token.type) {
|
|
2437
|
-
case
|
|
2438
|
-
{
|
|
2439
|
-
|
|
2440
|
-
var cell = _step2.value;
|
|
2441
|
-
values = values.concat(_this.walkTokens(cell.tokens, callback));
|
|
2442
|
-
}
|
|
2443
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(token.rows), _step3; !(_step3 = _iterator3()).done;) {
|
|
2444
|
-
var row = _step3.value;
|
|
2445
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose(row), _step4; !(_step4 = _iterator4()).done;) {
|
|
2446
|
-
var _cell = _step4.value;
|
|
2447
|
-
values = values.concat(_this.walkTokens(_cell.tokens, callback));
|
|
2448
|
-
}
|
|
2449
|
-
}
|
|
2450
|
-
break;
|
|
2451
|
-
}
|
|
2452
|
-
case 'list':
|
|
2453
|
-
{
|
|
2454
|
-
values = values.concat(_this.walkTokens(token.items, callback));
|
|
2455
|
-
break;
|
|
1941
|
+
case "table": {
|
|
1942
|
+
for (const cell of token.header) {
|
|
1943
|
+
values = values.concat(this.walkTokens(cell.tokens, callback));
|
|
2456
1944
|
}
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
// Walk any extensions
|
|
2461
|
-
_this.defaults.extensions.childTokens[token.type].forEach(function (childTokens) {
|
|
2462
|
-
values = values.concat(_this.walkTokens(token[childTokens], callback));
|
|
2463
|
-
});
|
|
2464
|
-
} else if (token.tokens) {
|
|
2465
|
-
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));
|
|
2466
1948
|
}
|
|
2467
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
|
+
}
|
|
2468
1965
|
}
|
|
2469
|
-
};
|
|
2470
|
-
for (var _iterator = _createForOfIteratorHelperLoose(tokens), _step; !(_step = _iterator()).done;) {
|
|
2471
|
-
_loop();
|
|
2472
1966
|
}
|
|
2473
1967
|
return values;
|
|
2474
|
-
}
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
};
|
|
2481
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2482
|
-
args[_key] = arguments[_key];
|
|
2483
|
-
}
|
|
2484
|
-
args.forEach(function (pack) {
|
|
2485
|
-
// copy options to new object
|
|
2486
|
-
var opts = _extends({}, pack);
|
|
2487
|
-
|
|
2488
|
-
// set async to true if it was set to true before
|
|
2489
|
-
opts.async = _this2.defaults.async || opts.async || false;
|
|
2490
|
-
|
|
2491
|
-
// ==-- 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;
|
|
2492
1974
|
if (pack.extensions) {
|
|
2493
|
-
pack.extensions.forEach(
|
|
1975
|
+
pack.extensions.forEach((ext) => {
|
|
2494
1976
|
if (!ext.name) {
|
|
2495
|
-
throw new Error(
|
|
1977
|
+
throw new Error("extension name required");
|
|
2496
1978
|
}
|
|
2497
|
-
if (ext
|
|
2498
|
-
|
|
2499
|
-
var prevRenderer = extensions.renderers[ext.name];
|
|
1979
|
+
if ("renderer" in ext) {
|
|
1980
|
+
const prevRenderer = extensions.renderers[ext.name];
|
|
2500
1981
|
if (prevRenderer) {
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2504
|
-
args[_key2] = arguments[_key2];
|
|
2505
|
-
}
|
|
2506
|
-
var ret = ext.renderer.apply(this, args);
|
|
1982
|
+
extensions.renderers[ext.name] = function(...args2) {
|
|
1983
|
+
let ret = ext.renderer.apply(this, args2);
|
|
2507
1984
|
if (ret === false) {
|
|
2508
|
-
ret = prevRenderer.apply(this,
|
|
1985
|
+
ret = prevRenderer.apply(this, args2);
|
|
2509
1986
|
}
|
|
2510
1987
|
return ret;
|
|
2511
1988
|
};
|
|
@@ -2513,9 +1990,8 @@
|
|
|
2513
1990
|
extensions.renderers[ext.name] = ext.renderer;
|
|
2514
1991
|
}
|
|
2515
1992
|
}
|
|
2516
|
-
if (ext
|
|
2517
|
-
|
|
2518
|
-
if (!ext.level || ext.level !== 'block' && ext.level !== 'inline') {
|
|
1993
|
+
if ("tokenizer" in ext) {
|
|
1994
|
+
if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
|
|
2519
1995
|
throw new Error("extension level must be 'block' or 'inline'");
|
|
2520
1996
|
}
|
|
2521
1997
|
if (extensions[ext.level]) {
|
|
@@ -2524,14 +2000,13 @@
|
|
|
2524
2000
|
extensions[ext.level] = [ext.tokenizer];
|
|
2525
2001
|
}
|
|
2526
2002
|
if (ext.start) {
|
|
2527
|
-
|
|
2528
|
-
if (ext.level === 'block') {
|
|
2003
|
+
if (ext.level === "block") {
|
|
2529
2004
|
if (extensions.startBlock) {
|
|
2530
2005
|
extensions.startBlock.push(ext.start);
|
|
2531
2006
|
} else {
|
|
2532
2007
|
extensions.startBlock = [ext.start];
|
|
2533
2008
|
}
|
|
2534
|
-
} else if (ext.level ===
|
|
2009
|
+
} else if (ext.level === "inline") {
|
|
2535
2010
|
if (extensions.startInline) {
|
|
2536
2011
|
extensions.startInline.push(ext.start);
|
|
2537
2012
|
} else {
|
|
@@ -2540,155 +2015,125 @@
|
|
|
2540
2015
|
}
|
|
2541
2016
|
}
|
|
2542
2017
|
}
|
|
2543
|
-
if (ext.childTokens) {
|
|
2544
|
-
// Child tokens to be visited by walkTokens
|
|
2018
|
+
if ("childTokens" in ext && ext.childTokens) {
|
|
2545
2019
|
extensions.childTokens[ext.name] = ext.childTokens;
|
|
2546
2020
|
}
|
|
2547
2021
|
});
|
|
2548
2022
|
opts.extensions = extensions;
|
|
2549
2023
|
}
|
|
2550
|
-
|
|
2551
|
-
// ==-- Parse "overwrite" extensions --== //
|
|
2552
2024
|
if (pack.renderer) {
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
2559
|
-
args[_key3] = arguments[_key3];
|
|
2560
|
-
}
|
|
2561
|
-
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);
|
|
2562
2030
|
if (ret === false) {
|
|
2563
|
-
ret = prevRenderer.apply(renderer,
|
|
2031
|
+
ret = prevRenderer.apply(renderer, args2);
|
|
2564
2032
|
}
|
|
2565
2033
|
return ret;
|
|
2566
2034
|
};
|
|
2567
|
-
};
|
|
2568
|
-
for (var prop in pack.renderer) {
|
|
2569
|
-
_loop2(prop);
|
|
2570
2035
|
}
|
|
2571
2036
|
opts.renderer = renderer;
|
|
2572
2037
|
}
|
|
2573
2038
|
if (pack.tokenizer) {
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
2580
|
-
args[_key4] = arguments[_key4];
|
|
2581
|
-
}
|
|
2582
|
-
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);
|
|
2583
2044
|
if (ret === false) {
|
|
2584
|
-
ret = prevTokenizer.apply(tokenizer,
|
|
2045
|
+
ret = prevTokenizer.apply(tokenizer, args2);
|
|
2585
2046
|
}
|
|
2586
2047
|
return ret;
|
|
2587
2048
|
};
|
|
2588
|
-
};
|
|
2589
|
-
for (var _prop in pack.tokenizer) {
|
|
2590
|
-
_loop3(_prop);
|
|
2591
2049
|
}
|
|
2592
2050
|
opts.tokenizer = tokenizer;
|
|
2593
2051
|
}
|
|
2594
|
-
|
|
2595
|
-
// ==-- Parse Hooks extensions --== //
|
|
2596
2052
|
if (pack.hooks) {
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
if (
|
|
2601
|
-
hooks[
|
|
2602
|
-
if (
|
|
2603
|
-
return Promise.resolve(pack.hooks[
|
|
2604
|
-
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);
|
|
2605
2061
|
});
|
|
2606
2062
|
}
|
|
2607
|
-
|
|
2063
|
+
const ret = pack.hooks[prop].call(hooks, arg);
|
|
2608
2064
|
return prevHook.call(hooks, ret);
|
|
2609
2065
|
};
|
|
2610
2066
|
} else {
|
|
2611
|
-
hooks[
|
|
2612
|
-
|
|
2613
|
-
args[_key5] = arguments[_key5];
|
|
2614
|
-
}
|
|
2615
|
-
var ret = pack.hooks[_prop2].apply(hooks, args);
|
|
2067
|
+
hooks[prop] = (...args2) => {
|
|
2068
|
+
let ret = pack.hooks[prop].apply(hooks, args2);
|
|
2616
2069
|
if (ret === false) {
|
|
2617
|
-
ret = prevHook.apply(hooks,
|
|
2070
|
+
ret = prevHook.apply(hooks, args2);
|
|
2618
2071
|
}
|
|
2619
2072
|
return ret;
|
|
2620
2073
|
};
|
|
2621
2074
|
}
|
|
2622
|
-
};
|
|
2623
|
-
for (var _prop2 in pack.hooks) {
|
|
2624
|
-
_loop4(_prop2);
|
|
2625
2075
|
}
|
|
2626
2076
|
opts.hooks = hooks;
|
|
2627
2077
|
}
|
|
2628
|
-
|
|
2629
|
-
// ==-- Parse WalkTokens extensions --== //
|
|
2630
2078
|
if (pack.walkTokens) {
|
|
2631
|
-
|
|
2632
|
-
opts.walkTokens = function
|
|
2633
|
-
|
|
2079
|
+
const walkTokens2 = this.defaults.walkTokens;
|
|
2080
|
+
opts.walkTokens = function(token) {
|
|
2081
|
+
let values = [];
|
|
2634
2082
|
values.push(pack.walkTokens.call(this, token));
|
|
2635
|
-
if (
|
|
2636
|
-
values = values.concat(
|
|
2083
|
+
if (walkTokens2) {
|
|
2084
|
+
values = values.concat(walkTokens2.call(this, token));
|
|
2637
2085
|
}
|
|
2638
2086
|
return values;
|
|
2639
2087
|
};
|
|
2640
2088
|
}
|
|
2641
|
-
|
|
2089
|
+
this.defaults = { ...this.defaults, ...opts };
|
|
2642
2090
|
});
|
|
2643
2091
|
return this;
|
|
2644
|
-
}
|
|
2645
|
-
|
|
2646
|
-
this.defaults =
|
|
2092
|
+
}
|
|
2093
|
+
setOptions(opt) {
|
|
2094
|
+
this.defaults = { ...this.defaults, ...opt };
|
|
2647
2095
|
return this;
|
|
2648
|
-
}
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
function
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
}
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
if (typeof src
|
|
2664
|
-
return throwError(new Error(
|
|
2665
|
-
}
|
|
2666
|
-
if (typeof src !== 'string') {
|
|
2667
|
-
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"));
|
|
2668
2113
|
}
|
|
2669
2114
|
checkDeprecations(opt, callback);
|
|
2670
2115
|
if (opt.hooks) {
|
|
2671
2116
|
opt.hooks.options = opt;
|
|
2672
2117
|
}
|
|
2673
2118
|
if (callback) {
|
|
2674
|
-
|
|
2675
|
-
|
|
2119
|
+
const highlight = opt.highlight;
|
|
2120
|
+
let tokens;
|
|
2676
2121
|
try {
|
|
2677
2122
|
if (opt.hooks) {
|
|
2678
2123
|
src = opt.hooks.preprocess(src);
|
|
2679
2124
|
}
|
|
2680
|
-
tokens =
|
|
2125
|
+
tokens = lexer2(src, opt);
|
|
2681
2126
|
} catch (e) {
|
|
2682
2127
|
return throwError(e);
|
|
2683
2128
|
}
|
|
2684
|
-
|
|
2685
|
-
|
|
2129
|
+
const done = (err) => {
|
|
2130
|
+
let out;
|
|
2686
2131
|
if (!err) {
|
|
2687
2132
|
try {
|
|
2688
2133
|
if (opt.walkTokens) {
|
|
2689
|
-
|
|
2134
|
+
this.walkTokens(tokens, opt.walkTokens);
|
|
2690
2135
|
}
|
|
2691
|
-
out =
|
|
2136
|
+
out = parser2(tokens, opt);
|
|
2692
2137
|
if (opt.hooks) {
|
|
2693
2138
|
out = opt.hooks.postprocess(out);
|
|
2694
2139
|
}
|
|
@@ -2703,13 +2148,14 @@
|
|
|
2703
2148
|
return done();
|
|
2704
2149
|
}
|
|
2705
2150
|
delete opt.highlight;
|
|
2706
|
-
if (!tokens.length)
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2151
|
+
if (!tokens.length)
|
|
2152
|
+
return done();
|
|
2153
|
+
let pending = 0;
|
|
2154
|
+
this.walkTokens(tokens, (token) => {
|
|
2155
|
+
if (token.type === "code") {
|
|
2710
2156
|
pending++;
|
|
2711
|
-
setTimeout(
|
|
2712
|
-
highlight(token.text, token.lang,
|
|
2157
|
+
setTimeout(() => {
|
|
2158
|
+
highlight(token.text, token.lang, (err, code) => {
|
|
2713
2159
|
if (err) {
|
|
2714
2160
|
return done(err);
|
|
2715
2161
|
}
|
|
@@ -2731,27 +2177,17 @@
|
|
|
2731
2177
|
return;
|
|
2732
2178
|
}
|
|
2733
2179
|
if (opt.async) {
|
|
2734
|
-
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then(
|
|
2735
|
-
return lexer(src, opt);
|
|
2736
|
-
}).then(function (tokens) {
|
|
2737
|
-
return opt.walkTokens ? Promise.all(_this3.walkTokens(tokens, opt.walkTokens)).then(function () {
|
|
2738
|
-
return tokens;
|
|
2739
|
-
}) : tokens;
|
|
2740
|
-
}).then(function (tokens) {
|
|
2741
|
-
return parser(tokens, opt);
|
|
2742
|
-
}).then(function (html) {
|
|
2743
|
-
return opt.hooks ? opt.hooks.postprocess(html) : html;
|
|
2744
|
-
})["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);
|
|
2745
2181
|
}
|
|
2746
2182
|
try {
|
|
2747
2183
|
if (opt.hooks) {
|
|
2748
2184
|
src = opt.hooks.preprocess(src);
|
|
2749
2185
|
}
|
|
2750
|
-
|
|
2186
|
+
const tokens = lexer2(src, opt);
|
|
2751
2187
|
if (opt.walkTokens) {
|
|
2752
|
-
|
|
2188
|
+
this.walkTokens(tokens, opt.walkTokens);
|
|
2753
2189
|
}
|
|
2754
|
-
|
|
2190
|
+
let html = parser2(tokens, opt);
|
|
2755
2191
|
if (opt.hooks) {
|
|
2756
2192
|
html = opt.hooks.postprocess(html);
|
|
2757
2193
|
}
|
|
@@ -2760,12 +2196,13 @@
|
|
|
2760
2196
|
return throwError(e);
|
|
2761
2197
|
}
|
|
2762
2198
|
};
|
|
2763
|
-
}
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
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.";
|
|
2767
2204
|
if (silent) {
|
|
2768
|
-
|
|
2205
|
+
const msg = "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
|
|
2769
2206
|
if (async) {
|
|
2770
2207
|
return Promise.resolve(msg);
|
|
2771
2208
|
}
|
|
@@ -2784,67 +2221,40 @@
|
|
|
2784
2221
|
}
|
|
2785
2222
|
throw e;
|
|
2786
2223
|
};
|
|
2787
|
-
}
|
|
2788
|
-
|
|
2789
|
-
var markedInstance = new Marked(exports.defaults);
|
|
2224
|
+
};
|
|
2790
2225
|
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
*/
|
|
2226
|
+
// src/marked.ts
|
|
2227
|
+
var markedInstance = new Marked();
|
|
2794
2228
|
function marked(src, opt, callback) {
|
|
2795
2229
|
return markedInstance.parse(src, opt, callback);
|
|
2796
2230
|
}
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
* Options
|
|
2800
|
-
*/
|
|
2801
|
-
|
|
2802
|
-
marked.options = marked.setOptions = function (opt) {
|
|
2803
|
-
markedInstance.setOptions(opt);
|
|
2231
|
+
marked.options = marked.setOptions = function(options2) {
|
|
2232
|
+
markedInstance.setOptions(options2);
|
|
2804
2233
|
marked.defaults = markedInstance.defaults;
|
|
2805
2234
|
changeDefaults(marked.defaults);
|
|
2806
2235
|
return marked;
|
|
2807
2236
|
};
|
|
2808
|
-
marked.getDefaults =
|
|
2809
|
-
marked.defaults =
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
* Use Extension
|
|
2813
|
-
*/
|
|
2814
|
-
|
|
2815
|
-
marked.use = function () {
|
|
2816
|
-
markedInstance.use.apply(markedInstance, arguments);
|
|
2237
|
+
marked.getDefaults = _getDefaults;
|
|
2238
|
+
marked.defaults = _defaults;
|
|
2239
|
+
marked.use = function(...args) {
|
|
2240
|
+
markedInstance.use(...args);
|
|
2817
2241
|
marked.defaults = markedInstance.defaults;
|
|
2818
2242
|
changeDefaults(marked.defaults);
|
|
2819
2243
|
return marked;
|
|
2820
2244
|
};
|
|
2821
|
-
|
|
2822
|
-
/**
|
|
2823
|
-
* Run callback for every token
|
|
2824
|
-
*/
|
|
2825
|
-
|
|
2826
|
-
marked.walkTokens = function (tokens, callback) {
|
|
2245
|
+
marked.walkTokens = function(tokens, callback) {
|
|
2827
2246
|
return markedInstance.walkTokens(tokens, callback);
|
|
2828
2247
|
};
|
|
2829
|
-
|
|
2830
|
-
/**
|
|
2831
|
-
* Parse Inline
|
|
2832
|
-
* @param {string} src
|
|
2833
|
-
*/
|
|
2834
2248
|
marked.parseInline = markedInstance.parseInline;
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
marked.
|
|
2840
|
-
marked.
|
|
2841
|
-
marked.
|
|
2842
|
-
marked.
|
|
2843
|
-
marked.
|
|
2844
|
-
marked.lexer = Lexer.lex;
|
|
2845
|
-
marked.Tokenizer = Tokenizer;
|
|
2846
|
-
marked.Slugger = Slugger;
|
|
2847
|
-
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;
|
|
2848
2258
|
marked.parse = marked;
|
|
2849
2259
|
var options = marked.options;
|
|
2850
2260
|
var setOptions = marked.setOptions;
|
|
@@ -2852,26 +2262,8 @@
|
|
|
2852
2262
|
var walkTokens = marked.walkTokens;
|
|
2853
2263
|
var parseInline = marked.parseInline;
|
|
2854
2264
|
var parse = marked;
|
|
2855
|
-
var parser =
|
|
2856
|
-
var lexer =
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
exports.Marked = Marked;
|
|
2861
|
-
exports.Parser = Parser;
|
|
2862
|
-
exports.Renderer = Renderer;
|
|
2863
|
-
exports.Slugger = Slugger;
|
|
2864
|
-
exports.TextRenderer = TextRenderer;
|
|
2865
|
-
exports.Tokenizer = Tokenizer;
|
|
2866
|
-
exports.getDefaults = getDefaults;
|
|
2867
|
-
exports.lexer = lexer;
|
|
2868
|
-
exports.marked = marked;
|
|
2869
|
-
exports.options = options;
|
|
2870
|
-
exports.parse = parse;
|
|
2871
|
-
exports.parseInline = parseInline;
|
|
2872
|
-
exports.parser = parser;
|
|
2873
|
-
exports.setOptions = setOptions;
|
|
2874
|
-
exports.use = use;
|
|
2875
|
-
exports.walkTokens = walkTokens;
|
|
2876
|
-
|
|
2877
|
-
}));
|
|
2265
|
+
var parser = _Parser.parse;
|
|
2266
|
+
var lexer = _Lexer.lex;
|
|
2267
|
+
return __toCommonJS(marked_exports);
|
|
2268
|
+
})();
|
|
2269
|
+
//# sourceMappingURL=marked.umd.js.map
|