@uiw/react-md-editor 4.1.6 → 4.1.7
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 +1 -1
- package/dist/mdeditor.css +5 -0
- package/dist/mdeditor.js +2378 -1029
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/esm/Editor.factory.js +60 -10
- package/esm/components/TextArea/Markdown.common.d.ts +3 -5
- package/esm/components/TextArea/Markdown.common.js +2 -56
- package/esm/components/TextArea/Markdown.d.ts +3 -5
- package/esm/components/TextArea/Markdown.factory.d.ts +6 -0
- package/esm/components/TextArea/Markdown.factory.js +138 -0
- package/esm/components/TextArea/Markdown.js +2 -63
- package/esm/components/TextArea/index.css +5 -0
- package/esm/components/TextArea/index.less +5 -0
- package/esm/components/TextArea/splitBlocks.d.ts +13 -0
- package/esm/components/TextArea/splitBlocks.js +111 -0
- package/esm/package.json +1 -0
- package/lib/Editor.factory.js +68 -11
- package/lib/components/TextArea/Markdown.common.d.ts +3 -5
- package/lib/components/TextArea/Markdown.common.js +3 -60
- package/lib/components/TextArea/Markdown.d.ts +3 -5
- package/lib/components/TextArea/Markdown.factory.d.ts +6 -0
- package/lib/components/TextArea/Markdown.factory.js +148 -0
- package/lib/components/TextArea/Markdown.js +3 -67
- package/lib/components/TextArea/index.less +5 -0
- package/lib/components/TextArea/splitBlocks.d.ts +13 -0
- package/lib/components/TextArea/splitBlocks.js +117 -0
- package/markdown-editor.css +5 -0
- package/package.json +18 -12
- package/src/Editor.factory.tsx +59 -4
- package/src/components/TextArea/Markdown.common.tsx +3 -46
- package/src/components/TextArea/Markdown.factory.tsx +132 -0
- package/src/components/TextArea/Markdown.tsx +3 -55
- package/src/components/TextArea/index.less +5 -0
- package/src/components/TextArea/splitBlocks.ts +114 -0
package/dist/mdeditor.js
CHANGED
|
@@ -103,276 +103,6 @@ module.exports = {
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
/***/ },
|
|
107
|
-
|
|
108
|
-
/***/ 689
|
|
109
|
-
(module) {
|
|
110
|
-
|
|
111
|
-
"use strict";
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// http://www.w3.org/TR/CSS21/grammar.html
|
|
115
|
-
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
|
116
|
-
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
117
|
-
|
|
118
|
-
var NEWLINE_REGEX = /\n/g;
|
|
119
|
-
var WHITESPACE_REGEX = /^\s*/;
|
|
120
|
-
|
|
121
|
-
// declaration
|
|
122
|
-
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
|
|
123
|
-
var COLON_REGEX = /^:\s*/;
|
|
124
|
-
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
|
|
125
|
-
var SEMICOLON_REGEX = /^[;\s]*/;
|
|
126
|
-
|
|
127
|
-
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
|
|
128
|
-
var TRIM_REGEX = /^\s+|\s+$/g;
|
|
129
|
-
|
|
130
|
-
// strings
|
|
131
|
-
var NEWLINE = '\n';
|
|
132
|
-
var FORWARD_SLASH = '/';
|
|
133
|
-
var ASTERISK = '*';
|
|
134
|
-
var EMPTY_STRING = '';
|
|
135
|
-
|
|
136
|
-
// types
|
|
137
|
-
var TYPE_COMMENT = 'comment';
|
|
138
|
-
var TYPE_DECLARATION = 'declaration';
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @param {String} style
|
|
142
|
-
* @param {Object} [options]
|
|
143
|
-
* @return {Object[]}
|
|
144
|
-
* @throws {TypeError}
|
|
145
|
-
* @throws {Error}
|
|
146
|
-
*/
|
|
147
|
-
function index (style, options) {
|
|
148
|
-
if (typeof style !== 'string') {
|
|
149
|
-
throw new TypeError('First argument must be a string');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (!style) return [];
|
|
153
|
-
|
|
154
|
-
options = options || {};
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Positional.
|
|
158
|
-
*/
|
|
159
|
-
var lineno = 1;
|
|
160
|
-
var column = 1;
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Update lineno and column based on `str`.
|
|
164
|
-
*
|
|
165
|
-
* @param {String} str
|
|
166
|
-
*/
|
|
167
|
-
function updatePosition(str) {
|
|
168
|
-
var lines = str.match(NEWLINE_REGEX);
|
|
169
|
-
if (lines) lineno += lines.length;
|
|
170
|
-
var i = str.lastIndexOf(NEWLINE);
|
|
171
|
-
column = ~i ? str.length - i : column + str.length;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Mark position and patch `node.position`.
|
|
176
|
-
*
|
|
177
|
-
* @return {Function}
|
|
178
|
-
*/
|
|
179
|
-
function position() {
|
|
180
|
-
var start = { line: lineno, column: column };
|
|
181
|
-
return function (node) {
|
|
182
|
-
node.position = new Position(start);
|
|
183
|
-
whitespace();
|
|
184
|
-
return node;
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Store position information for a node.
|
|
190
|
-
*
|
|
191
|
-
* @constructor
|
|
192
|
-
* @property {Object} start
|
|
193
|
-
* @property {Object} end
|
|
194
|
-
* @property {undefined|String} source
|
|
195
|
-
*/
|
|
196
|
-
function Position(start) {
|
|
197
|
-
this.start = start;
|
|
198
|
-
this.end = { line: lineno, column: column };
|
|
199
|
-
this.source = options.source;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Non-enumerable source string.
|
|
204
|
-
*/
|
|
205
|
-
Position.prototype.content = style;
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Error `msg`.
|
|
209
|
-
*
|
|
210
|
-
* @param {String} msg
|
|
211
|
-
* @throws {Error}
|
|
212
|
-
*/
|
|
213
|
-
function error(msg) {
|
|
214
|
-
var err = new Error(
|
|
215
|
-
options.source + ':' + lineno + ':' + column + ': ' + msg
|
|
216
|
-
);
|
|
217
|
-
err.reason = msg;
|
|
218
|
-
err.filename = options.source;
|
|
219
|
-
err.line = lineno;
|
|
220
|
-
err.column = column;
|
|
221
|
-
err.source = style;
|
|
222
|
-
|
|
223
|
-
if (options.silent) ; else {
|
|
224
|
-
throw err;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Match `re` and return captures.
|
|
230
|
-
*
|
|
231
|
-
* @param {RegExp} re
|
|
232
|
-
* @return {undefined|Array}
|
|
233
|
-
*/
|
|
234
|
-
function match(re) {
|
|
235
|
-
var m = re.exec(style);
|
|
236
|
-
if (!m) return;
|
|
237
|
-
var str = m[0];
|
|
238
|
-
updatePosition(str);
|
|
239
|
-
style = style.slice(str.length);
|
|
240
|
-
return m;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Parse whitespace.
|
|
245
|
-
*/
|
|
246
|
-
function whitespace() {
|
|
247
|
-
match(WHITESPACE_REGEX);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Parse comments.
|
|
252
|
-
*
|
|
253
|
-
* @param {Object[]} [rules]
|
|
254
|
-
* @return {Object[]}
|
|
255
|
-
*/
|
|
256
|
-
function comments(rules) {
|
|
257
|
-
var c;
|
|
258
|
-
rules = rules || [];
|
|
259
|
-
while ((c = comment())) {
|
|
260
|
-
if (c !== false) {
|
|
261
|
-
rules.push(c);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
return rules;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Parse comment.
|
|
269
|
-
*
|
|
270
|
-
* @return {Object}
|
|
271
|
-
* @throws {Error}
|
|
272
|
-
*/
|
|
273
|
-
function comment() {
|
|
274
|
-
var pos = position();
|
|
275
|
-
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
|
|
276
|
-
|
|
277
|
-
var i = 2;
|
|
278
|
-
while (
|
|
279
|
-
EMPTY_STRING != style.charAt(i) &&
|
|
280
|
-
(ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))
|
|
281
|
-
) {
|
|
282
|
-
++i;
|
|
283
|
-
}
|
|
284
|
-
i += 2;
|
|
285
|
-
|
|
286
|
-
if (EMPTY_STRING === style.charAt(i - 1)) {
|
|
287
|
-
return error('End of comment missing');
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
var str = style.slice(2, i - 2);
|
|
291
|
-
column += 2;
|
|
292
|
-
updatePosition(str);
|
|
293
|
-
style = style.slice(i);
|
|
294
|
-
column += 2;
|
|
295
|
-
|
|
296
|
-
return pos({
|
|
297
|
-
type: TYPE_COMMENT,
|
|
298
|
-
comment: str
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Parse declaration.
|
|
304
|
-
*
|
|
305
|
-
* @return {Object}
|
|
306
|
-
* @throws {Error}
|
|
307
|
-
*/
|
|
308
|
-
function declaration() {
|
|
309
|
-
var pos = position();
|
|
310
|
-
|
|
311
|
-
// prop
|
|
312
|
-
var prop = match(PROPERTY_REGEX);
|
|
313
|
-
if (!prop) return;
|
|
314
|
-
comment();
|
|
315
|
-
|
|
316
|
-
// :
|
|
317
|
-
if (!match(COLON_REGEX)) return error("property missing ':'");
|
|
318
|
-
|
|
319
|
-
// val
|
|
320
|
-
var val = match(VALUE_REGEX);
|
|
321
|
-
|
|
322
|
-
var ret = pos({
|
|
323
|
-
type: TYPE_DECLARATION,
|
|
324
|
-
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
|
|
325
|
-
value: val
|
|
326
|
-
? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))
|
|
327
|
-
: EMPTY_STRING
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
// ;
|
|
331
|
-
match(SEMICOLON_REGEX);
|
|
332
|
-
|
|
333
|
-
return ret;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Parse declarations.
|
|
338
|
-
*
|
|
339
|
-
* @return {Object[]}
|
|
340
|
-
*/
|
|
341
|
-
function declarations() {
|
|
342
|
-
var decls = [];
|
|
343
|
-
|
|
344
|
-
comments(decls);
|
|
345
|
-
|
|
346
|
-
// declarations
|
|
347
|
-
var decl;
|
|
348
|
-
while ((decl = declaration())) {
|
|
349
|
-
if (decl !== false) {
|
|
350
|
-
decls.push(decl);
|
|
351
|
-
comments(decls);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return decls;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
whitespace();
|
|
359
|
-
return declarations();
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* Trim `str`.
|
|
364
|
-
*
|
|
365
|
-
* @param {String} str
|
|
366
|
-
* @return {String}
|
|
367
|
-
*/
|
|
368
|
-
function trim(str) {
|
|
369
|
-
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
module.exports = index;
|
|
373
|
-
//# sourceMappingURL=index.js.map
|
|
374
|
-
|
|
375
|
-
|
|
376
106
|
/***/ },
|
|
377
107
|
|
|
378
108
|
/***/ 934
|
|
@@ -416,111 +146,6 @@ exports["default"] = parsePart;
|
|
|
416
146
|
module.exports = parsePart;
|
|
417
147
|
|
|
418
148
|
|
|
419
|
-
/***/ },
|
|
420
|
-
|
|
421
|
-
/***/ 969
|
|
422
|
-
(__unused_webpack_module, exports) {
|
|
423
|
-
|
|
424
|
-
"use strict";
|
|
425
|
-
|
|
426
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
427
|
-
exports.camelCase = void 0;
|
|
428
|
-
var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9_-]+$/;
|
|
429
|
-
var HYPHEN_REGEX = /-([a-z])/g;
|
|
430
|
-
var NO_HYPHEN_REGEX = /^[^-]+$/;
|
|
431
|
-
var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/;
|
|
432
|
-
var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/;
|
|
433
|
-
/**
|
|
434
|
-
* Checks whether to skip camelCase.
|
|
435
|
-
*/
|
|
436
|
-
var skipCamelCase = function (property) {
|
|
437
|
-
return !property ||
|
|
438
|
-
NO_HYPHEN_REGEX.test(property) ||
|
|
439
|
-
CUSTOM_PROPERTY_REGEX.test(property);
|
|
440
|
-
};
|
|
441
|
-
/**
|
|
442
|
-
* Replacer that capitalizes first character.
|
|
443
|
-
*/
|
|
444
|
-
var capitalize = function (match, character) {
|
|
445
|
-
return character.toUpperCase();
|
|
446
|
-
};
|
|
447
|
-
/**
|
|
448
|
-
* Replacer that removes beginning hyphen of vendor prefix property.
|
|
449
|
-
*/
|
|
450
|
-
var trimHyphen = function (match, prefix) { return "".concat(prefix, "-"); };
|
|
451
|
-
/**
|
|
452
|
-
* CamelCases a CSS property.
|
|
453
|
-
*/
|
|
454
|
-
var camelCase = function (property, options) {
|
|
455
|
-
if (options === void 0) { options = {}; }
|
|
456
|
-
if (skipCamelCase(property)) {
|
|
457
|
-
return property;
|
|
458
|
-
}
|
|
459
|
-
property = property.toLowerCase();
|
|
460
|
-
if (options.reactCompat) {
|
|
461
|
-
// `-ms` vendor prefix should not be capitalized
|
|
462
|
-
property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen);
|
|
463
|
-
}
|
|
464
|
-
else {
|
|
465
|
-
// for non-React, remove first hyphen so vendor prefix is not capitalized
|
|
466
|
-
property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen);
|
|
467
|
-
}
|
|
468
|
-
return property.replace(HYPHEN_REGEX, capitalize);
|
|
469
|
-
};
|
|
470
|
-
exports.camelCase = camelCase;
|
|
471
|
-
//# sourceMappingURL=utilities.js.map
|
|
472
|
-
|
|
473
|
-
/***/ },
|
|
474
|
-
|
|
475
|
-
/***/ 857
|
|
476
|
-
(__unused_webpack_module, exports, __webpack_require__) {
|
|
477
|
-
|
|
478
|
-
"use strict";
|
|
479
|
-
|
|
480
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
481
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
482
|
-
};
|
|
483
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
484
|
-
exports["default"] = StyleToObject;
|
|
485
|
-
const inline_style_parser_1 = __importDefault(__webpack_require__(689));
|
|
486
|
-
/**
|
|
487
|
-
* Parses inline style to object.
|
|
488
|
-
*
|
|
489
|
-
* @param style - Inline style.
|
|
490
|
-
* @param iterator - Iterator.
|
|
491
|
-
* @returns - Style object or null.
|
|
492
|
-
*
|
|
493
|
-
* @example Parsing inline style to object:
|
|
494
|
-
*
|
|
495
|
-
* ```js
|
|
496
|
-
* import parse from 'style-to-object';
|
|
497
|
-
* parse('line-height: 42;'); // { 'line-height': '42' }
|
|
498
|
-
* ```
|
|
499
|
-
*/
|
|
500
|
-
function StyleToObject(style, iterator) {
|
|
501
|
-
let styleObject = null;
|
|
502
|
-
if (!style || typeof style !== 'string') {
|
|
503
|
-
return styleObject;
|
|
504
|
-
}
|
|
505
|
-
const declarations = (0, inline_style_parser_1.default)(style);
|
|
506
|
-
const hasIterator = typeof iterator === 'function';
|
|
507
|
-
declarations.forEach((declaration) => {
|
|
508
|
-
if (declaration.type !== 'declaration') {
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
const { property, value } = declaration;
|
|
512
|
-
if (hasIterator) {
|
|
513
|
-
iterator(property, value, declaration);
|
|
514
|
-
}
|
|
515
|
-
else if (value) {
|
|
516
|
-
styleObject = styleObject || {};
|
|
517
|
-
styleObject[property] = value;
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
return styleObject;
|
|
521
|
-
}
|
|
522
|
-
//# sourceMappingURL=index.js.map
|
|
523
|
-
|
|
524
149
|
/***/ },
|
|
525
150
|
|
|
526
151
|
/***/ 442
|
|
@@ -824,45 +449,6 @@ if (true) {
|
|
|
824
449
|
|
|
825
450
|
});
|
|
826
451
|
|
|
827
|
-
// MODULE: ../node_modules/style-to-js/cjs/index.js
|
|
828
|
-
var style_to_js_cjs_namespaceFn = /*#__PURE__*/__webpack_require__.cw(function(module) {
|
|
829
|
-
|
|
830
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
831
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
832
|
-
};
|
|
833
|
-
var style_to_object_1 = __importDefault((cjs_namespaceFn()));
|
|
834
|
-
var utilities_1 = (utilities_namespaceFn());
|
|
835
|
-
/**
|
|
836
|
-
* Parses CSS inline style to JavaScript object (camelCased).
|
|
837
|
-
*/
|
|
838
|
-
function StyleToJS(style, options) {
|
|
839
|
-
var output = {};
|
|
840
|
-
if (!style || typeof style !== 'string') {
|
|
841
|
-
return output;
|
|
842
|
-
}
|
|
843
|
-
(0, style_to_object_1.default)(style, function (property, value) {
|
|
844
|
-
// skip CSS comment
|
|
845
|
-
if (property && value) {
|
|
846
|
-
output[(0, utilities_1.camelCase)(property, options)] = value;
|
|
847
|
-
}
|
|
848
|
-
});
|
|
849
|
-
return output;
|
|
850
|
-
}
|
|
851
|
-
StyleToJS.default = StyleToJS;
|
|
852
|
-
module.exports = StyleToJS;
|
|
853
|
-
//# sourceMappingURL=index.js.map
|
|
854
|
-
});
|
|
855
|
-
|
|
856
|
-
// EXTERNAL MODULE: ../node_modules/style-to-js/cjs/utilities.js
|
|
857
|
-
var utilities_namespaceFn = () => {
|
|
858
|
-
return __webpack_require__(969);
|
|
859
|
-
};
|
|
860
|
-
|
|
861
|
-
// EXTERNAL MODULE: ../node_modules/style-to-object/cjs/index.js
|
|
862
|
-
var cjs_namespaceFn = () => {
|
|
863
|
-
return __webpack_require__(857);
|
|
864
|
-
};
|
|
865
|
-
|
|
866
452
|
// EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}
|
|
867
453
|
var external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn = () => {
|
|
868
454
|
return __webpack_require__(442);
|
|
@@ -8554,6 +8140,8 @@ function space_separated_tokens_stringify(values) {
|
|
|
8554
8140
|
|
|
8555
8141
|
|
|
8556
8142
|
/**
|
|
8143
|
+
* Create an `h` function.
|
|
8144
|
+
*
|
|
8557
8145
|
* @param {Schema} schema
|
|
8558
8146
|
* Schema to use.
|
|
8559
8147
|
* @param {string} defaultTagName
|
|
@@ -8571,23 +8159,25 @@ function createH(schema, defaultTagName, caseSensitive) {
|
|
|
8571
8159
|
*
|
|
8572
8160
|
* @overload
|
|
8573
8161
|
* @param {null | undefined} [selector]
|
|
8162
|
+
* Nothing to get a root.
|
|
8574
8163
|
* @param {...Child} children
|
|
8164
|
+
* Children.
|
|
8575
8165
|
* @returns {Root}
|
|
8166
|
+
* Root.
|
|
8576
8167
|
*
|
|
8577
8168
|
* @overload
|
|
8578
8169
|
* @param {string} selector
|
|
8579
|
-
*
|
|
8580
|
-
* @param {
|
|
8581
|
-
*
|
|
8582
|
-
*
|
|
8583
|
-
* @overload
|
|
8584
|
-
* @param {string} selector
|
|
8170
|
+
* Selector.
|
|
8171
|
+
* @param {Child | Properties} [properties]
|
|
8172
|
+
* Properties (or first child) (default: `undefined`).
|
|
8585
8173
|
* @param {...Child} children
|
|
8174
|
+
* Children.
|
|
8586
8175
|
* @returns {Element}
|
|
8176
|
+
* Element.
|
|
8587
8177
|
*
|
|
8588
8178
|
* @param {string | null | undefined} [selector]
|
|
8589
8179
|
* Selector.
|
|
8590
|
-
* @param {Child | Properties
|
|
8180
|
+
* @param {Child | Properties} [properties]
|
|
8591
8181
|
* Properties (or first child) (default: `undefined`).
|
|
8592
8182
|
* @param {...Child} children
|
|
8593
8183
|
* Children.
|
|
@@ -8625,7 +8215,11 @@ function createH(schema, defaultTagName, caseSensitive) {
|
|
|
8625
8215
|
addChild(node.children, child)
|
|
8626
8216
|
}
|
|
8627
8217
|
|
|
8628
|
-
if (
|
|
8218
|
+
if (
|
|
8219
|
+
node.type === 'element' &&
|
|
8220
|
+
node.tagName === 'template' &&
|
|
8221
|
+
schema.space === 'html'
|
|
8222
|
+
) {
|
|
8629
8223
|
node.content = {type: 'root', children: node.children}
|
|
8630
8224
|
node.children = []
|
|
8631
8225
|
}
|
|
@@ -8686,6 +8280,8 @@ function isChild(value) {
|
|
|
8686
8280
|
}
|
|
8687
8281
|
|
|
8688
8282
|
/**
|
|
8283
|
+
* Add a property.
|
|
8284
|
+
*
|
|
8689
8285
|
* @param {Schema} schema
|
|
8690
8286
|
* Schema.
|
|
8691
8287
|
* @param {Properties} properties
|
|
@@ -8698,13 +8294,13 @@ function isChild(value) {
|
|
|
8698
8294
|
* Nothing.
|
|
8699
8295
|
*/
|
|
8700
8296
|
function addProperty(schema, properties, key, value) {
|
|
8297
|
+
// Ignore nullish and NaN values.
|
|
8298
|
+
if (value === null || value === undefined) return
|
|
8299
|
+
|
|
8701
8300
|
const info = find(schema, key)
|
|
8702
8301
|
/** @type {PropertyValue} */
|
|
8703
8302
|
let result
|
|
8704
8303
|
|
|
8705
|
-
// Ignore nullish and NaN values.
|
|
8706
|
-
if (value === null || value === undefined) return
|
|
8707
|
-
|
|
8708
8304
|
if (typeof value === 'number') {
|
|
8709
8305
|
// Ignore NaN.
|
|
8710
8306
|
if (Number.isNaN(value)) return
|
|
@@ -8729,7 +8325,7 @@ function addProperty(schema, properties, key, value) {
|
|
|
8729
8325
|
} else if (Array.isArray(value)) {
|
|
8730
8326
|
result = [...value]
|
|
8731
8327
|
} else {
|
|
8732
|
-
result = info.property === 'style' ?
|
|
8328
|
+
result = info.property === 'style' ? style(value) : String(value)
|
|
8733
8329
|
}
|
|
8734
8330
|
|
|
8735
8331
|
if (Array.isArray(result)) {
|
|
@@ -8751,15 +8347,16 @@ function addProperty(schema, properties, key, value) {
|
|
|
8751
8347
|
// Class names (which can be added both on the `selector` and here).
|
|
8752
8348
|
if (info.property === 'className' && Array.isArray(properties.className)) {
|
|
8753
8349
|
// Assume no booleans in `className`.
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
)
|
|
8350
|
+
const add = /** @type {Array<number | string> | number | string} */ (result)
|
|
8351
|
+
result = [...properties.className, ...(Array.isArray(add) ? add : [add])]
|
|
8757
8352
|
}
|
|
8758
8353
|
|
|
8759
8354
|
properties[info.property] = result
|
|
8760
8355
|
}
|
|
8761
8356
|
|
|
8762
8357
|
/**
|
|
8358
|
+
* Add a child.
|
|
8359
|
+
*
|
|
8763
8360
|
* @param {Array<RootContent>} nodes
|
|
8764
8361
|
* Children.
|
|
8765
8362
|
* @param {Child} value
|
|
@@ -8824,7 +8421,7 @@ function parsePrimitive(info, name, value) {
|
|
|
8824
8421
|
* @returns {string}
|
|
8825
8422
|
* CSS string.
|
|
8826
8423
|
*/
|
|
8827
|
-
function
|
|
8424
|
+
function style(styles) {
|
|
8828
8425
|
/** @type {Array<string>} */
|
|
8829
8426
|
const result = []
|
|
8830
8427
|
|
|
@@ -36974,7 +36571,7 @@ const webNamespaces = {
|
|
|
36974
36571
|
|
|
36975
36572
|
;// ../node_modules/hast-util-from-parse5/lib/index.js
|
|
36976
36573
|
/**
|
|
36977
|
-
* @import {ElementData, Element, Nodes, RootContent, Root} from 'hast'
|
|
36574
|
+
* @import {ElementContent, ElementData, Element, Nodes, RootContent, Root} from 'hast'
|
|
36978
36575
|
* @import {DefaultTreeAdapterMap, Token} from 'parse5'
|
|
36979
36576
|
* @import {Schema} from 'property-information'
|
|
36980
36577
|
* @import {Point, Position} from 'unist'
|
|
@@ -37145,7 +36742,7 @@ function hast_util_from_parse5_lib_all(state, nodes) {
|
|
|
37145
36742
|
* hast node.
|
|
37146
36743
|
*/
|
|
37147
36744
|
function lib_element(state, node) {
|
|
37148
|
-
const schema = state
|
|
36745
|
+
const {schema} = state
|
|
37149
36746
|
|
|
37150
36747
|
state.schema = node.namespaceURI === webNamespaces.svg ? property_information_svg : property_information_html
|
|
37151
36748
|
|
|
@@ -37170,19 +36767,30 @@ function lib_element(state, node) {
|
|
|
37170
36767
|
|
|
37171
36768
|
// Switch content.
|
|
37172
36769
|
if (result.tagName === 'template') {
|
|
37173
|
-
|
|
37174
|
-
|
|
37175
|
-
|
|
37176
|
-
|
|
37177
|
-
|
|
37178
|
-
|
|
37179
|
-
|
|
37180
|
-
|
|
37181
|
-
|
|
37182
|
-
|
|
36770
|
+
// Only `template`s in HTML have content.
|
|
36771
|
+
if (node.namespaceURI === webNamespaces.html) {
|
|
36772
|
+
const reference = /** @type {DefaultTreeAdapterMap['template']} */ (node)
|
|
36773
|
+
const pos = reference.sourceCodeLocation
|
|
36774
|
+
const startTag = pos && pos.startTag && position(pos.startTag)
|
|
36775
|
+
const endTag = pos && pos.endTag && position(pos.endTag)
|
|
36776
|
+
|
|
36777
|
+
// Root in, root out.
|
|
36778
|
+
const content = /** @type {Root} */ (hast_util_from_parse5_lib_one(state, reference.content))
|
|
36779
|
+
|
|
36780
|
+
if (startTag && endTag && state.file) {
|
|
36781
|
+
content.position = {start: startTag.end, end: endTag.start}
|
|
36782
|
+
}
|
|
36783
|
+
|
|
36784
|
+
result.content = content
|
|
36785
|
+
} else if (result.content) {
|
|
36786
|
+
// In SVG and MathML `template`s are normal elements.
|
|
36787
|
+
// `h` moves their children into `content`, move them back.
|
|
36788
|
+
// And assume no roots or doctypes in `content`.
|
|
36789
|
+
result.children = /** @type {Array<ElementContent>} */ (
|
|
36790
|
+
result.content.children
|
|
36791
|
+
)
|
|
36792
|
+
delete result.content
|
|
37183
36793
|
}
|
|
37184
|
-
|
|
37185
|
-
result.content = content
|
|
37186
36794
|
}
|
|
37187
36795
|
|
|
37188
36796
|
state.schema = schema
|
|
@@ -37355,7 +36963,7 @@ const emptyOptions = {}
|
|
|
37355
36963
|
|
|
37356
36964
|
const hast_util_to_parse5_lib_own = {}.hasOwnProperty
|
|
37357
36965
|
|
|
37358
|
-
const hast_util_to_parse5_lib_one = zwitch('type', {handlers: {root: lib_root, element: hast_util_to_parse5_lib_element, text: lib_text, comment
|
|
36966
|
+
const hast_util_to_parse5_lib_one = zwitch('type', {handlers: {root: lib_root, element: hast_util_to_parse5_lib_element, text: lib_text, comment, doctype}})
|
|
37359
36967
|
|
|
37360
36968
|
/**
|
|
37361
36969
|
* Transform a hast tree to a `parse5` AST.
|
|
@@ -37453,7 +37061,7 @@ function lib_text(node) {
|
|
|
37453
37061
|
* @returns {Parse5Comment}
|
|
37454
37062
|
* Parse5 node.
|
|
37455
37063
|
*/
|
|
37456
|
-
function
|
|
37064
|
+
function comment(node) {
|
|
37457
37065
|
/** @type {Parse5Comment} */
|
|
37458
37066
|
const result = {
|
|
37459
37067
|
nodeName: '#comment',
|
|
@@ -46438,7 +46046,7 @@ function raw(tree, options) {
|
|
|
46438
46046
|
const document = documentMode(tree)
|
|
46439
46047
|
/** @type {(node: Nodes, state: State) => undefined} */
|
|
46440
46048
|
const one = zwitch('type', {
|
|
46441
|
-
handlers: {root: hast_util_raw_lib_root, element: hast_util_raw_lib_element, text: hast_util_raw_lib_text, comment:
|
|
46049
|
+
handlers: {root: hast_util_raw_lib_root, element: hast_util_raw_lib_element, text: hast_util_raw_lib_text, comment: lib_comment, doctype: lib_doctype, raw: handleRaw},
|
|
46442
46050
|
unknown
|
|
46443
46051
|
})
|
|
46444
46052
|
|
|
@@ -46633,7 +46241,7 @@ function stitch(node, state) {
|
|
|
46633
46241
|
// Hack: `value` is supposed to be a string, but as none of the tools
|
|
46634
46242
|
// (`parse5` or `hast-util-from-parse5`) looks at it, we can pass nodes
|
|
46635
46243
|
// through.
|
|
46636
|
-
|
|
46244
|
+
lib_comment({type: 'comment', value: {stitch: clone}}, state)
|
|
46637
46245
|
}
|
|
46638
46246
|
|
|
46639
46247
|
/**
|
|
@@ -46646,7 +46254,7 @@ function stitch(node, state) {
|
|
|
46646
46254
|
* @returns {undefined}
|
|
46647
46255
|
* Nothing.
|
|
46648
46256
|
*/
|
|
46649
|
-
function
|
|
46257
|
+
function lib_comment(node, state) {
|
|
46650
46258
|
/** @type {string} */
|
|
46651
46259
|
// @ts-expect-error: we pass stitches through.
|
|
46652
46260
|
const data = node.value
|
|
@@ -47193,9 +46801,288 @@ const hastToReact = {
|
|
|
47193
46801
|
xmlnsXLink: 'xmlnsXlink'
|
|
47194
46802
|
}
|
|
47195
46803
|
|
|
47196
|
-
;// ../node_modules/style-
|
|
47197
|
-
|
|
46804
|
+
;// ../node_modules/inline-style-parser/esm/index.mjs
|
|
46805
|
+
// http://www.w3.org/TR/CSS21/grammar.html
|
|
46806
|
+
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
|
46807
|
+
var COMMENT_REGEX = /\/\*(?:[^*]|\*(?!\/))*\*\//g;
|
|
46808
|
+
|
|
46809
|
+
var NEWLINE_REGEX = /\n/g;
|
|
46810
|
+
var WHITESPACE_REGEX = /^\s*/;
|
|
46811
|
+
|
|
46812
|
+
// declaration
|
|
46813
|
+
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
|
|
46814
|
+
var COLON_REGEX = /^:\s*/;
|
|
46815
|
+
var VALUE_REGEX =
|
|
46816
|
+
/^((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|url\((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|[^)]*)\)|[^};])+)/;
|
|
46817
|
+
var SEMICOLON_REGEX = /^[;\s]*/;
|
|
46818
|
+
|
|
46819
|
+
// strings
|
|
46820
|
+
var NEWLINE = '\n';
|
|
46821
|
+
var FORWARD_SLASH = '/';
|
|
46822
|
+
var ASTERISK = '*';
|
|
46823
|
+
var EMPTY_STRING = '';
|
|
46824
|
+
|
|
46825
|
+
// types
|
|
46826
|
+
var TYPE_COMMENT = 'comment';
|
|
46827
|
+
var TYPE_DECLARATION = 'declaration';
|
|
46828
|
+
|
|
46829
|
+
/**
|
|
46830
|
+
* @param {String} style
|
|
46831
|
+
* @param {Object} [options]
|
|
46832
|
+
* @return {Object[]}
|
|
46833
|
+
* @throws {TypeError}
|
|
46834
|
+
* @throws {Error}
|
|
46835
|
+
*/
|
|
46836
|
+
function index (style, options) {
|
|
46837
|
+
if (typeof style !== 'string') {
|
|
46838
|
+
throw new TypeError('First argument must be a string');
|
|
46839
|
+
}
|
|
46840
|
+
|
|
46841
|
+
if (!style) return [];
|
|
46842
|
+
|
|
46843
|
+
options = options || {};
|
|
46844
|
+
|
|
46845
|
+
/**
|
|
46846
|
+
* Positional.
|
|
46847
|
+
*/
|
|
46848
|
+
var lineno = 1;
|
|
46849
|
+
var column = 1;
|
|
46850
|
+
|
|
46851
|
+
/**
|
|
46852
|
+
* Update lineno and column based on `str`.
|
|
46853
|
+
*
|
|
46854
|
+
* @param {String} str
|
|
46855
|
+
*/
|
|
46856
|
+
function updatePosition(str) {
|
|
46857
|
+
var lines = str.match(NEWLINE_REGEX);
|
|
46858
|
+
if (lines) lineno += lines.length;
|
|
46859
|
+
var i = str.lastIndexOf(NEWLINE);
|
|
46860
|
+
column = ~i ? str.length - i : column + str.length;
|
|
46861
|
+
}
|
|
46862
|
+
|
|
46863
|
+
/**
|
|
46864
|
+
* Mark position and patch `node.position`.
|
|
46865
|
+
*
|
|
46866
|
+
* @return {Function}
|
|
46867
|
+
*/
|
|
46868
|
+
function position() {
|
|
46869
|
+
var start = { line: lineno, column: column };
|
|
46870
|
+
return function (node) {
|
|
46871
|
+
node.position = new Position(start);
|
|
46872
|
+
whitespace();
|
|
46873
|
+
return node;
|
|
46874
|
+
};
|
|
46875
|
+
}
|
|
46876
|
+
|
|
46877
|
+
/**
|
|
46878
|
+
* Store position information for a node.
|
|
46879
|
+
*
|
|
46880
|
+
* @constructor
|
|
46881
|
+
* @property {Object} start
|
|
46882
|
+
* @property {Object} end
|
|
46883
|
+
* @property {undefined|String} source
|
|
46884
|
+
*/
|
|
46885
|
+
function Position(start) {
|
|
46886
|
+
this.start = start;
|
|
46887
|
+
this.end = { line: lineno, column: column };
|
|
46888
|
+
this.source = options.source;
|
|
46889
|
+
}
|
|
46890
|
+
|
|
46891
|
+
/**
|
|
46892
|
+
* Non-enumerable source string.
|
|
46893
|
+
*/
|
|
46894
|
+
Position.prototype.content = style;
|
|
46895
|
+
|
|
46896
|
+
/**
|
|
46897
|
+
* Error `msg`.
|
|
46898
|
+
*
|
|
46899
|
+
* @param {String} msg
|
|
46900
|
+
* @throws {Error}
|
|
46901
|
+
*/
|
|
46902
|
+
function error(msg) {
|
|
46903
|
+
var err = new Error(
|
|
46904
|
+
options.source + ':' + lineno + ':' + column + ': ' + msg
|
|
46905
|
+
);
|
|
46906
|
+
err.reason = msg;
|
|
46907
|
+
err.filename = options.source;
|
|
46908
|
+
err.line = lineno;
|
|
46909
|
+
err.column = column;
|
|
46910
|
+
err.source = style;
|
|
46911
|
+
|
|
46912
|
+
if (options.silent) ; else {
|
|
46913
|
+
throw err;
|
|
46914
|
+
}
|
|
46915
|
+
}
|
|
46916
|
+
|
|
46917
|
+
/**
|
|
46918
|
+
* Match `re` and return captures.
|
|
46919
|
+
*
|
|
46920
|
+
* @param {RegExp} re
|
|
46921
|
+
* @return {undefined|Array}
|
|
46922
|
+
*/
|
|
46923
|
+
function match(re) {
|
|
46924
|
+
var m = re.exec(style);
|
|
46925
|
+
if (!m) return;
|
|
46926
|
+
var str = m[0];
|
|
46927
|
+
updatePosition(str);
|
|
46928
|
+
style = style.slice(str.length);
|
|
46929
|
+
return m;
|
|
46930
|
+
}
|
|
46931
|
+
|
|
46932
|
+
/**
|
|
46933
|
+
* Parse whitespace.
|
|
46934
|
+
*/
|
|
46935
|
+
function whitespace() {
|
|
46936
|
+
match(WHITESPACE_REGEX);
|
|
46937
|
+
}
|
|
46938
|
+
|
|
46939
|
+
/**
|
|
46940
|
+
* Parse comments.
|
|
46941
|
+
*
|
|
46942
|
+
* @param {Object[]} rules
|
|
46943
|
+
* @return {Object[]}
|
|
46944
|
+
*/
|
|
46945
|
+
function comments(rules) {
|
|
46946
|
+
var c;
|
|
46947
|
+
while ((c = comment())) {
|
|
46948
|
+
rules.push(c);
|
|
46949
|
+
}
|
|
46950
|
+
return rules;
|
|
46951
|
+
}
|
|
46952
|
+
|
|
46953
|
+
/**
|
|
46954
|
+
* Parse comment.
|
|
46955
|
+
*
|
|
46956
|
+
* @return {Object}
|
|
46957
|
+
* @throws {Error}
|
|
46958
|
+
*/
|
|
46959
|
+
function comment() {
|
|
46960
|
+
var pos = position();
|
|
46961
|
+
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
|
|
46962
|
+
|
|
46963
|
+
var i = 2;
|
|
46964
|
+
while (
|
|
46965
|
+
EMPTY_STRING != style.charAt(i) &&
|
|
46966
|
+
(ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))
|
|
46967
|
+
) {
|
|
46968
|
+
++i;
|
|
46969
|
+
}
|
|
46970
|
+
i += 2;
|
|
46971
|
+
|
|
46972
|
+
if (EMPTY_STRING === style.charAt(i - 1)) {
|
|
46973
|
+
return error('End of comment missing');
|
|
46974
|
+
}
|
|
46975
|
+
|
|
46976
|
+
var str = style.slice(2, i - 2);
|
|
46977
|
+
column += 2;
|
|
46978
|
+
updatePosition(str);
|
|
46979
|
+
style = style.slice(i);
|
|
46980
|
+
column += 2;
|
|
46981
|
+
|
|
46982
|
+
return pos({
|
|
46983
|
+
type: TYPE_COMMENT,
|
|
46984
|
+
comment: str
|
|
46985
|
+
});
|
|
46986
|
+
}
|
|
46987
|
+
|
|
46988
|
+
/**
|
|
46989
|
+
* Parse declaration.
|
|
46990
|
+
*
|
|
46991
|
+
* @return {Object}
|
|
46992
|
+
* @throws {Error}
|
|
46993
|
+
*/
|
|
46994
|
+
function declaration() {
|
|
46995
|
+
var pos = position();
|
|
46996
|
+
|
|
46997
|
+
// prop
|
|
46998
|
+
var prop = match(PROPERTY_REGEX);
|
|
46999
|
+
if (!prop) return;
|
|
47000
|
+
comment();
|
|
47001
|
+
|
|
47002
|
+
// :
|
|
47003
|
+
if (!match(COLON_REGEX)) return error("property missing ':'");
|
|
47004
|
+
|
|
47005
|
+
// val
|
|
47006
|
+
var val = match(VALUE_REGEX);
|
|
47007
|
+
|
|
47008
|
+
var ret = pos({
|
|
47009
|
+
type: TYPE_DECLARATION,
|
|
47010
|
+
property: prop[0].replace(COMMENT_REGEX, EMPTY_STRING).trim(),
|
|
47011
|
+
value: val
|
|
47012
|
+
? val[0].replace(COMMENT_REGEX, EMPTY_STRING).trim()
|
|
47013
|
+
: EMPTY_STRING
|
|
47014
|
+
});
|
|
47015
|
+
|
|
47016
|
+
// ;
|
|
47017
|
+
match(SEMICOLON_REGEX);
|
|
47018
|
+
|
|
47019
|
+
return ret;
|
|
47020
|
+
}
|
|
47021
|
+
|
|
47022
|
+
/**
|
|
47023
|
+
* Parse declarations.
|
|
47024
|
+
*
|
|
47025
|
+
* @return {Object[]}
|
|
47026
|
+
*/
|
|
47027
|
+
function declarations() {
|
|
47028
|
+
var decls = [];
|
|
47029
|
+
|
|
47030
|
+
comments(decls);
|
|
47031
|
+
|
|
47032
|
+
// declarations
|
|
47033
|
+
var decl;
|
|
47034
|
+
while ((decl = declaration())) {
|
|
47035
|
+
decls.push(decl);
|
|
47036
|
+
comments(decls);
|
|
47037
|
+
}
|
|
47038
|
+
|
|
47039
|
+
return decls;
|
|
47040
|
+
}
|
|
47041
|
+
|
|
47042
|
+
whitespace();
|
|
47043
|
+
return declarations();
|
|
47044
|
+
}
|
|
47045
|
+
|
|
47046
|
+
|
|
47047
|
+
//# sourceMappingURL=index.mjs.map
|
|
47048
|
+
|
|
47049
|
+
;// ../node_modules/style-to-object/esm/index.mjs
|
|
47050
|
+
|
|
47051
|
+
//#region src/index.ts
|
|
47052
|
+
/**
|
|
47053
|
+
* Parses inline style to object.
|
|
47054
|
+
*
|
|
47055
|
+
* @param style - Inline style.
|
|
47056
|
+
* @param iterator - Iterator.
|
|
47057
|
+
* @returns - Style object or null.
|
|
47058
|
+
*
|
|
47059
|
+
* @example Parsing inline style to object:
|
|
47060
|
+
*
|
|
47061
|
+
* ```js
|
|
47062
|
+
* import parse from 'style-to-object';
|
|
47063
|
+
* parse('line-height: 42;'); // { 'line-height': '42' }
|
|
47064
|
+
* ```
|
|
47065
|
+
*/
|
|
47066
|
+
function StyleToObject(style, iterator) {
|
|
47067
|
+
let styleObject = null;
|
|
47068
|
+
if (!style || typeof style !== "string") return styleObject;
|
|
47069
|
+
const declarations = index(style);
|
|
47070
|
+
const hasIterator = typeof iterator === "function";
|
|
47071
|
+
declarations.forEach((declaration) => {
|
|
47072
|
+
if (declaration.type !== "declaration") return;
|
|
47073
|
+
const { property, value } = declaration;
|
|
47074
|
+
if (hasIterator) iterator(property, value, declaration);
|
|
47075
|
+
else if (value) {
|
|
47076
|
+
styleObject = styleObject ?? {};
|
|
47077
|
+
styleObject[property] = value;
|
|
47078
|
+
}
|
|
47079
|
+
});
|
|
47080
|
+
return styleObject;
|
|
47081
|
+
}
|
|
47082
|
+
//#endregion
|
|
47083
|
+
|
|
47198
47084
|
|
|
47085
|
+
//# sourceMappingURL=index.mjs.map
|
|
47199
47086
|
;// ../node_modules/vfile-message/node_modules/unist-util-stringify-position/lib/index.js
|
|
47200
47087
|
/**
|
|
47201
47088
|
* @typedef {import('unist').Node} Node
|
|
@@ -47627,6 +47514,7 @@ const hast_util_to_jsx_runtime_lib_own = {}.hasOwnProperty
|
|
|
47627
47514
|
const emptyMap = new Map()
|
|
47628
47515
|
|
|
47629
47516
|
const lib_cap = /[A-Z]/g
|
|
47517
|
+
const dashLetter = /-([a-z])/g
|
|
47630
47518
|
|
|
47631
47519
|
// `react-dom` triggers a warning for *any* white space in tables.
|
|
47632
47520
|
// To follow GFM, `mdast-util-to-hast` injects line endings between elements.
|
|
@@ -47963,6 +47851,8 @@ function addChildren(props, children) {
|
|
|
47963
47851
|
}
|
|
47964
47852
|
|
|
47965
47853
|
/**
|
|
47854
|
+
* Create a production `create` function.
|
|
47855
|
+
*
|
|
47966
47856
|
* @param {string | undefined} _
|
|
47967
47857
|
* Path to file.
|
|
47968
47858
|
* @param {Jsx} jsx
|
|
@@ -47974,7 +47864,12 @@ function addChildren(props, children) {
|
|
|
47974
47864
|
*/
|
|
47975
47865
|
function productionCreate(_, jsx, jsxs) {
|
|
47976
47866
|
return create
|
|
47977
|
-
|
|
47867
|
+
|
|
47868
|
+
/**
|
|
47869
|
+
* Create a production element.
|
|
47870
|
+
*
|
|
47871
|
+
* @type {Create}
|
|
47872
|
+
*/
|
|
47978
47873
|
function create(_, type, props, key) {
|
|
47979
47874
|
// Only an array when there are 2 or more children.
|
|
47980
47875
|
const isStaticChildren = Array.isArray(props.children)
|
|
@@ -47984,6 +47879,8 @@ function productionCreate(_, jsx, jsxs) {
|
|
|
47984
47879
|
}
|
|
47985
47880
|
|
|
47986
47881
|
/**
|
|
47882
|
+
* Create a development `create` function.
|
|
47883
|
+
*
|
|
47987
47884
|
* @param {string | undefined} filePath
|
|
47988
47885
|
* Path to file.
|
|
47989
47886
|
* @param {JsxDev} jsxDEV
|
|
@@ -47993,7 +47890,12 @@ function productionCreate(_, jsx, jsxs) {
|
|
|
47993
47890
|
*/
|
|
47994
47891
|
function developmentCreate(filePath, jsxDEV) {
|
|
47995
47892
|
return create
|
|
47996
|
-
|
|
47893
|
+
|
|
47894
|
+
/**
|
|
47895
|
+
* Create a development element.
|
|
47896
|
+
*
|
|
47897
|
+
* @type {Create}
|
|
47898
|
+
*/
|
|
47997
47899
|
function create(node, type, props, key) {
|
|
47998
47900
|
// Only an array when there are 2 or more children.
|
|
47999
47901
|
const isStaticChildren = Array.isArray(props.children)
|
|
@@ -48096,7 +47998,7 @@ function createJsxElementProps(state, node) {
|
|
|
48096
47998
|
}
|
|
48097
47999
|
} else {
|
|
48098
48000
|
// For JSX, the author is responsible of passing in the correct values.
|
|
48099
|
-
const name = attribute
|
|
48001
|
+
const {name} = attribute
|
|
48100
48002
|
/** @type {unknown} */
|
|
48101
48003
|
let value
|
|
48102
48004
|
|
|
@@ -48185,8 +48087,6 @@ function createChildren(state, node) {
|
|
|
48185
48087
|
* Field for runtime, optional.
|
|
48186
48088
|
*/
|
|
48187
48089
|
function lib_createProperty(state, prop, value) {
|
|
48188
|
-
const info = find(state.schema, prop)
|
|
48189
|
-
|
|
48190
48090
|
// Ignore nullish and `NaN` values.
|
|
48191
48091
|
if (
|
|
48192
48092
|
value === null ||
|
|
@@ -48196,6 +48096,8 @@ function lib_createProperty(state, prop, value) {
|
|
|
48196
48096
|
return
|
|
48197
48097
|
}
|
|
48198
48098
|
|
|
48099
|
+
const info = find(state.schema, prop)
|
|
48100
|
+
|
|
48199
48101
|
if (Array.isArray(value)) {
|
|
48200
48102
|
// Accept `array`.
|
|
48201
48103
|
// Most props are space-separated.
|
|
@@ -48204,12 +48106,12 @@ function lib_createProperty(state, prop, value) {
|
|
|
48204
48106
|
|
|
48205
48107
|
// React only accepts `style` as object.
|
|
48206
48108
|
if (info.property === 'style') {
|
|
48207
|
-
|
|
48208
|
-
typeof value === 'object'
|
|
48209
|
-
|
|
48210
|
-
|
|
48211
|
-
|
|
48212
|
-
|
|
48109
|
+
const styleObject =
|
|
48110
|
+
typeof value === 'object'
|
|
48111
|
+
? state.stylePropertyNameCase === 'dom'
|
|
48112
|
+
? value
|
|
48113
|
+
: transformStylesToCssCasing(value)
|
|
48114
|
+
: parseStyle(state, String(value))
|
|
48213
48115
|
|
|
48214
48116
|
return ['style', styleObject]
|
|
48215
48117
|
}
|
|
@@ -48231,12 +48133,32 @@ function lib_createProperty(state, prop, value) {
|
|
|
48231
48133
|
* CSS declarations.
|
|
48232
48134
|
* @returns {Style}
|
|
48233
48135
|
* Properties.
|
|
48234
|
-
* @throws
|
|
48235
|
-
*
|
|
48136
|
+
* @throws {VFileMessage}
|
|
48137
|
+
* When CSS cannot be parsed.
|
|
48236
48138
|
*/
|
|
48237
48139
|
function parseStyle(state, value) {
|
|
48140
|
+
/** @type {Style} */
|
|
48141
|
+
const result = {}
|
|
48142
|
+
|
|
48238
48143
|
try {
|
|
48239
|
-
|
|
48144
|
+
StyleToObject(value, function (property, value) {
|
|
48145
|
+
if (property && value) {
|
|
48146
|
+
let name = property
|
|
48147
|
+
|
|
48148
|
+
// Custom properties are case-sensitive, other properties are not.
|
|
48149
|
+
if (name.slice(0, 2) !== '--') {
|
|
48150
|
+
name = name.toLowerCase()
|
|
48151
|
+
|
|
48152
|
+
if (state.stylePropertyNameCase === 'dom') {
|
|
48153
|
+
// Handle `-ms-xxx` -> `msXxx`.
|
|
48154
|
+
if (name.slice(0, 4) === '-ms-') name = name.slice(1)
|
|
48155
|
+
name = name.replace(dashLetter, toCamel)
|
|
48156
|
+
}
|
|
48157
|
+
}
|
|
48158
|
+
|
|
48159
|
+
result[name] = value
|
|
48160
|
+
}
|
|
48161
|
+
})
|
|
48240
48162
|
} catch (error) {
|
|
48241
48163
|
if (state.ignoreInvalidStyle) {
|
|
48242
48164
|
return {}
|
|
@@ -48254,6 +48176,8 @@ function parseStyle(state, value) {
|
|
|
48254
48176
|
|
|
48255
48177
|
throw message
|
|
48256
48178
|
}
|
|
48179
|
+
|
|
48180
|
+
return result
|
|
48257
48181
|
}
|
|
48258
48182
|
|
|
48259
48183
|
/**
|
|
@@ -48321,9 +48245,14 @@ function findComponentFromName(state, name, allowExpression) {
|
|
|
48321
48245
|
}
|
|
48322
48246
|
|
|
48323
48247
|
/**
|
|
48248
|
+
* Crash because MDX estrees cannot be handled without `createEvaluater`.
|
|
48249
|
+
*
|
|
48324
48250
|
* @param {State} state
|
|
48251
|
+
* Info passed around.
|
|
48325
48252
|
* @param {Position | undefined} [place]
|
|
48253
|
+
* Place of the node that cannot be handled (optional).
|
|
48326
48254
|
* @returns {never}
|
|
48255
|
+
* Nothing (always throws).
|
|
48327
48256
|
*/
|
|
48328
48257
|
function crashEstree(state, place) {
|
|
48329
48258
|
const message = new VFileMessage(
|
|
@@ -48345,7 +48274,9 @@ function crashEstree(state, place) {
|
|
|
48345
48274
|
* Transform a DOM casing style object to a CSS casing style object.
|
|
48346
48275
|
*
|
|
48347
48276
|
* @param {Style} domCasing
|
|
48277
|
+
* DOM casing style object.
|
|
48348
48278
|
* @returns {Style}
|
|
48279
|
+
* CSS casing style object.
|
|
48349
48280
|
*/
|
|
48350
48281
|
function transformStylesToCssCasing(domCasing) {
|
|
48351
48282
|
/** @type {Style} */
|
|
@@ -48366,9 +48297,12 @@ function transformStylesToCssCasing(domCasing) {
|
|
|
48366
48297
|
* Transform a DOM casing style field to a CSS casing style field.
|
|
48367
48298
|
*
|
|
48368
48299
|
* @param {string} from
|
|
48300
|
+
* DOM casing style field.
|
|
48369
48301
|
* @returns {string}
|
|
48302
|
+
* CSS casing style field.
|
|
48370
48303
|
*/
|
|
48371
48304
|
function transformStyleToCssCasing(from) {
|
|
48305
|
+
if (from.slice(0, 2) === '--') return from
|
|
48372
48306
|
let to = from.replace(lib_cap, toDash)
|
|
48373
48307
|
// Handle `ms-xxx` -> `-ms-xxx`.
|
|
48374
48308
|
if (to.slice(0, 3) === 'ms-') to = '-' + to
|
|
@@ -48387,6 +48321,20 @@ function toDash($0) {
|
|
|
48387
48321
|
return '-' + $0.toLowerCase()
|
|
48388
48322
|
}
|
|
48389
48323
|
|
|
48324
|
+
/**
|
|
48325
|
+
* Make `$1` camel cased.
|
|
48326
|
+
*
|
|
48327
|
+
* @param {string} _
|
|
48328
|
+
* Dash and lower letter.
|
|
48329
|
+
* @param {string} $1
|
|
48330
|
+
* Lower letter.
|
|
48331
|
+
* @returns {string}
|
|
48332
|
+
* Capitalized letter.
|
|
48333
|
+
*/
|
|
48334
|
+
function toCamel(_, $1) {
|
|
48335
|
+
return $1.toUpperCase()
|
|
48336
|
+
}
|
|
48337
|
+
|
|
48390
48338
|
;// ../node_modules/html-url-attributes/lib/index.js
|
|
48391
48339
|
/**
|
|
48392
48340
|
* HTML URL properties.
|
|
@@ -50602,7 +50550,7 @@ function initializeFlow(effects) {
|
|
|
50602
50550
|
const resolver = {
|
|
50603
50551
|
resolveAll: createResolver()
|
|
50604
50552
|
};
|
|
50605
|
-
const
|
|
50553
|
+
const string = initializeFactory('string');
|
|
50606
50554
|
const text_text = initializeFactory('text');
|
|
50607
50555
|
|
|
50608
50556
|
/**
|
|
@@ -57279,7 +57227,7 @@ function lib_parse_parse(options) {
|
|
|
57279
57227
|
document: create(document_document),
|
|
57280
57228
|
flow: create(initialize_flow_flow),
|
|
57281
57229
|
lazy: {},
|
|
57282
|
-
string: create(
|
|
57230
|
+
string: create(string),
|
|
57283
57231
|
text: create(text_text)
|
|
57284
57232
|
};
|
|
57285
57233
|
return parser;
|
|
@@ -66730,460 +66678,1342 @@ function checkEmphasis(state) {
|
|
|
66730
66678
|
return marker
|
|
66731
66679
|
}
|
|
66732
66680
|
|
|
66733
|
-
;// ../node_modules/mdast-util-to-markdown/
|
|
66681
|
+
;// ../node_modules/mdast-util-to-markdown/node_modules/micromark-util-character/index.js
|
|
66734
66682
|
/**
|
|
66735
|
-
* @import {
|
|
66736
|
-
* @import {Emphasis, Parents} from 'mdast'
|
|
66683
|
+
* @import {Code} from 'micromark-util-types'
|
|
66737
66684
|
*/
|
|
66738
66685
|
|
|
66739
|
-
|
|
66740
|
-
|
|
66741
|
-
emphasis_emphasis.attention = emphasis_attention
|
|
66742
|
-
emphasis_emphasis.peek = peek
|
|
66743
|
-
|
|
66744
66686
|
/**
|
|
66745
|
-
*
|
|
66687
|
+
* Check whether the character code represents an ASCII alpha (`a` through `z`,
|
|
66688
|
+
* case insensitive).
|
|
66746
66689
|
*
|
|
66747
|
-
*
|
|
66690
|
+
* An **ASCII alpha** is an ASCII upper alpha or ASCII lower alpha.
|
|
66748
66691
|
*
|
|
66749
|
-
*
|
|
66750
|
-
*
|
|
66751
|
-
*
|
|
66752
|
-
*
|
|
66753
|
-
*
|
|
66754
|
-
*
|
|
66755
|
-
* @param
|
|
66756
|
-
*
|
|
66757
|
-
* @returns {
|
|
66758
|
-
*
|
|
66692
|
+
* An **ASCII upper alpha** is a character in the inclusive range U+0041 (`A`)
|
|
66693
|
+
* to U+005A (`Z`).
|
|
66694
|
+
*
|
|
66695
|
+
* An **ASCII lower alpha** is a character in the inclusive range U+0061 (`a`)
|
|
66696
|
+
* to U+007A (`z`).
|
|
66697
|
+
*
|
|
66698
|
+
* @param code
|
|
66699
|
+
* Code.
|
|
66700
|
+
* @returns {boolean}
|
|
66701
|
+
* Whether it matches.
|
|
66759
66702
|
*/
|
|
66760
|
-
|
|
66761
|
-
const exit = state.enter('phrasing')
|
|
66762
|
-
const value = state.containerPhrasing({type: 'root', children: [node]}, info)
|
|
66763
|
-
exit()
|
|
66764
|
-
return value
|
|
66765
|
-
}
|
|
66703
|
+
const mdast_util_to_markdown_node_modules_micromark_util_character_asciiAlpha = mdast_util_to_markdown_node_modules_micromark_util_character_regexCheck(/[A-Za-z]/);
|
|
66766
66704
|
|
|
66767
66705
|
/**
|
|
66768
|
-
*
|
|
66706
|
+
* Check whether the character code represents an ASCII alphanumeric (`a`
|
|
66707
|
+
* through `z`, case insensitive, or `0` through `9`).
|
|
66769
66708
|
*
|
|
66770
|
-
*
|
|
66771
|
-
*
|
|
66772
|
-
*
|
|
66773
|
-
*
|
|
66774
|
-
*
|
|
66775
|
-
*
|
|
66709
|
+
* An **ASCII alphanumeric** is an ASCII digit (see `asciiDigit`) or ASCII alpha
|
|
66710
|
+
* (see `asciiAlpha`).
|
|
66711
|
+
*
|
|
66712
|
+
* @param code
|
|
66713
|
+
* Code.
|
|
66714
|
+
* @returns {boolean}
|
|
66715
|
+
* Whether it matches.
|
|
66776
66716
|
*/
|
|
66777
|
-
|
|
66778
|
-
const marker = checkEmphasis(state)
|
|
66779
|
-
return {
|
|
66780
|
-
construct: 'emphasis',
|
|
66781
|
-
markers: marker === '*' ? ['*', '_'] : ['_', '*'],
|
|
66782
|
-
sizes: [1]
|
|
66783
|
-
}
|
|
66784
|
-
}
|
|
66717
|
+
const mdast_util_to_markdown_node_modules_micromark_util_character_asciiAlphanumeric = mdast_util_to_markdown_node_modules_micromark_util_character_regexCheck(/[\dA-Za-z]/);
|
|
66785
66718
|
|
|
66786
66719
|
/**
|
|
66787
|
-
*
|
|
66720
|
+
* Check whether the character code represents an ASCII atext.
|
|
66788
66721
|
*
|
|
66789
|
-
*
|
|
66790
|
-
*
|
|
66791
|
-
*
|
|
66792
|
-
*
|
|
66793
|
-
*
|
|
66794
|
-
*
|
|
66795
|
-
*
|
|
66796
|
-
*
|
|
66722
|
+
* atext is an ASCII alphanumeric (see `asciiAlphanumeric`), or a character in
|
|
66723
|
+
* the inclusive ranges U+0023 NUMBER SIGN (`#`) to U+0027 APOSTROPHE (`'`),
|
|
66724
|
+
* U+002A ASTERISK (`*`), U+002B PLUS SIGN (`+`), U+002D DASH (`-`), U+002F
|
|
66725
|
+
* SLASH (`/`), U+003D EQUALS TO (`=`), U+003F QUESTION MARK (`?`), U+005E
|
|
66726
|
+
* CARET (`^`) to U+0060 GRAVE ACCENT (`` ` ``), or U+007B LEFT CURLY BRACE
|
|
66727
|
+
* (`{`) to U+007E TILDE (`~`).
|
|
66728
|
+
*
|
|
66729
|
+
* See:
|
|
66730
|
+
* **\[RFC5322]**:
|
|
66731
|
+
* [Internet Message Format](https://tools.ietf.org/html/rfc5322).
|
|
66732
|
+
* P. Resnick.
|
|
66733
|
+
* IETF.
|
|
66734
|
+
*
|
|
66735
|
+
* @param code
|
|
66736
|
+
* Code.
|
|
66737
|
+
* @returns {boolean}
|
|
66738
|
+
* Whether it matches.
|
|
66797
66739
|
*/
|
|
66798
|
-
|
|
66799
|
-
return state.options.emphasis || '*'
|
|
66800
|
-
}
|
|
66740
|
+
const mdast_util_to_markdown_node_modules_micromark_util_character_asciiAtext = mdast_util_to_markdown_node_modules_micromark_util_character_regexCheck(/[#-'*+\--9=?A-Z^-~]/);
|
|
66801
66741
|
|
|
66802
|
-
;// ../node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
|
|
66803
66742
|
/**
|
|
66804
|
-
*
|
|
66743
|
+
* Check whether a character code is an ASCII control character.
|
|
66805
66744
|
*
|
|
66806
|
-
*
|
|
66807
|
-
*
|
|
66808
|
-
*
|
|
66809
|
-
*
|
|
66745
|
+
* An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL)
|
|
66746
|
+
* to U+001F (US), or U+007F (DEL).
|
|
66747
|
+
*
|
|
66748
|
+
* @param {Code} code
|
|
66749
|
+
* Code.
|
|
66750
|
+
* @returns {boolean}
|
|
66751
|
+
* Whether it matches.
|
|
66810
66752
|
*/
|
|
66811
|
-
function
|
|
66812
|
-
return
|
|
66753
|
+
function mdast_util_to_markdown_node_modules_micromark_util_character_asciiControl(code) {
|
|
66754
|
+
return (
|
|
66755
|
+
// Special whitespace codes (which have negative values), C0 and Control
|
|
66756
|
+
// character DEL
|
|
66757
|
+
code !== null && (code < 32 || code === 127)
|
|
66758
|
+
);
|
|
66813
66759
|
}
|
|
66814
66760
|
|
|
66815
|
-
;// ../node_modules/mdast-util-to-markdown/node_modules/mdast-util-to-string/lib/index.js
|
|
66816
66761
|
/**
|
|
66817
|
-
*
|
|
66762
|
+
* Check whether the character code represents an ASCII digit (`0` through `9`).
|
|
66818
66763
|
*
|
|
66819
|
-
*
|
|
66820
|
-
*
|
|
66821
|
-
*
|
|
66822
|
-
*
|
|
66823
|
-
*
|
|
66824
|
-
*
|
|
66764
|
+
* An **ASCII digit** is a character in the inclusive range U+0030 (`0`) to
|
|
66765
|
+
* U+0039 (`9`).
|
|
66766
|
+
*
|
|
66767
|
+
* @param code
|
|
66768
|
+
* Code.
|
|
66769
|
+
* @returns {boolean}
|
|
66770
|
+
* Whether it matches.
|
|
66825
66771
|
*/
|
|
66826
|
-
|
|
66827
|
-
/** @type {Options} */
|
|
66828
|
-
const node_modules_mdast_util_to_string_lib_emptyOptions = {}
|
|
66772
|
+
const mdast_util_to_markdown_node_modules_micromark_util_character_asciiDigit = mdast_util_to_markdown_node_modules_micromark_util_character_regexCheck(/\d/);
|
|
66829
66773
|
|
|
66830
66774
|
/**
|
|
66831
|
-
*
|
|
66775
|
+
* Check whether the character code represents an ASCII hex digit (`a` through
|
|
66776
|
+
* `f`, case insensitive, or `0` through `9`).
|
|
66832
66777
|
*
|
|
66833
|
-
*
|
|
66834
|
-
*
|
|
66778
|
+
* An **ASCII hex digit** is an ASCII digit (see `asciiDigit`), ASCII upper hex
|
|
66779
|
+
* digit, or an ASCII lower hex digit.
|
|
66835
66780
|
*
|
|
66836
|
-
*
|
|
66837
|
-
*
|
|
66838
|
-
*
|
|
66839
|
-
*
|
|
66840
|
-
*
|
|
66841
|
-
*
|
|
66781
|
+
* An **ASCII upper hex digit** is a character in the inclusive range U+0041
|
|
66782
|
+
* (`A`) to U+0046 (`F`).
|
|
66783
|
+
*
|
|
66784
|
+
* An **ASCII lower hex digit** is a character in the inclusive range U+0061
|
|
66785
|
+
* (`a`) to U+0066 (`f`).
|
|
66786
|
+
*
|
|
66787
|
+
* @param code
|
|
66788
|
+
* Code.
|
|
66789
|
+
* @returns {boolean}
|
|
66790
|
+
* Whether it matches.
|
|
66842
66791
|
*/
|
|
66843
|
-
|
|
66844
|
-
const settings = options || node_modules_mdast_util_to_string_lib_emptyOptions
|
|
66845
|
-
const includeImageAlt =
|
|
66846
|
-
typeof settings.includeImageAlt === 'boolean'
|
|
66847
|
-
? settings.includeImageAlt
|
|
66848
|
-
: true
|
|
66849
|
-
const includeHtml =
|
|
66850
|
-
typeof settings.includeHtml === 'boolean' ? settings.includeHtml : true
|
|
66851
|
-
|
|
66852
|
-
return node_modules_mdast_util_to_string_lib_one(value, includeImageAlt, includeHtml)
|
|
66853
|
-
}
|
|
66792
|
+
const mdast_util_to_markdown_node_modules_micromark_util_character_asciiHexDigit = mdast_util_to_markdown_node_modules_micromark_util_character_regexCheck(/[\dA-Fa-f]/);
|
|
66854
66793
|
|
|
66855
66794
|
/**
|
|
66856
|
-
*
|
|
66795
|
+
* Check whether the character code represents ASCII punctuation.
|
|
66857
66796
|
*
|
|
66858
|
-
*
|
|
66859
|
-
*
|
|
66860
|
-
*
|
|
66861
|
-
*
|
|
66862
|
-
*
|
|
66863
|
-
*
|
|
66864
|
-
*
|
|
66865
|
-
*
|
|
66797
|
+
* An **ASCII punctuation** is a character in the inclusive ranges U+0021
|
|
66798
|
+
* EXCLAMATION MARK (`!`) to U+002F SLASH (`/`), U+003A COLON (`:`) to U+0040 AT
|
|
66799
|
+
* SIGN (`@`), U+005B LEFT SQUARE BRACKET (`[`) to U+0060 GRAVE ACCENT
|
|
66800
|
+
* (`` ` ``), or U+007B LEFT CURLY BRACE (`{`) to U+007E TILDE (`~`).
|
|
66801
|
+
*
|
|
66802
|
+
* @param code
|
|
66803
|
+
* Code.
|
|
66804
|
+
* @returns {boolean}
|
|
66805
|
+
* Whether it matches.
|
|
66866
66806
|
*/
|
|
66867
|
-
|
|
66868
|
-
if (mdast_util_to_string_lib_node(value)) {
|
|
66869
|
-
if ('value' in value) {
|
|
66870
|
-
return value.type === 'html' && !includeHtml ? '' : value.value
|
|
66871
|
-
}
|
|
66872
|
-
|
|
66873
|
-
if (includeImageAlt && 'alt' in value && value.alt) {
|
|
66874
|
-
return value.alt
|
|
66875
|
-
}
|
|
66876
|
-
|
|
66877
|
-
if ('children' in value) {
|
|
66878
|
-
return node_modules_mdast_util_to_string_lib_all(value.children, includeImageAlt, includeHtml)
|
|
66879
|
-
}
|
|
66880
|
-
}
|
|
66881
|
-
|
|
66882
|
-
if (Array.isArray(value)) {
|
|
66883
|
-
return node_modules_mdast_util_to_string_lib_all(value, includeImageAlt, includeHtml)
|
|
66884
|
-
}
|
|
66807
|
+
const mdast_util_to_markdown_node_modules_micromark_util_character_asciiPunctuation = mdast_util_to_markdown_node_modules_micromark_util_character_regexCheck(/[!-/:-@[-`{-~]/);
|
|
66885
66808
|
|
|
66886
|
-
|
|
66809
|
+
/**
|
|
66810
|
+
* Check whether a character code is a markdown line ending.
|
|
66811
|
+
*
|
|
66812
|
+
* A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN
|
|
66813
|
+
* LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR).
|
|
66814
|
+
*
|
|
66815
|
+
* In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE
|
|
66816
|
+
* RETURN (CR) are replaced by these virtual characters depending on whether
|
|
66817
|
+
* they occurred together.
|
|
66818
|
+
*
|
|
66819
|
+
* @param {Code} code
|
|
66820
|
+
* Code.
|
|
66821
|
+
* @returns {boolean}
|
|
66822
|
+
* Whether it matches.
|
|
66823
|
+
*/
|
|
66824
|
+
function mdast_util_to_markdown_node_modules_micromark_util_character_markdownLineEnding(code) {
|
|
66825
|
+
return code !== null && code < -2;
|
|
66887
66826
|
}
|
|
66888
66827
|
|
|
66889
66828
|
/**
|
|
66890
|
-
*
|
|
66829
|
+
* Check whether a character code is a markdown line ending (see
|
|
66830
|
+
* `markdownLineEnding`) or markdown space (see `markdownSpace`).
|
|
66891
66831
|
*
|
|
66892
|
-
* @param {
|
|
66893
|
-
*
|
|
66894
|
-
* @
|
|
66895
|
-
*
|
|
66896
|
-
* @param {boolean} includeHtml
|
|
66897
|
-
* Include HTML.
|
|
66898
|
-
* @returns {string}
|
|
66899
|
-
* Serialized nodes.
|
|
66832
|
+
* @param {Code} code
|
|
66833
|
+
* Code.
|
|
66834
|
+
* @returns {boolean}
|
|
66835
|
+
* Whether it matches.
|
|
66900
66836
|
*/
|
|
66901
|
-
function
|
|
66902
|
-
|
|
66903
|
-
const result = []
|
|
66904
|
-
let index = -1
|
|
66905
|
-
|
|
66906
|
-
while (++index < values.length) {
|
|
66907
|
-
result[index] = node_modules_mdast_util_to_string_lib_one(values[index], includeImageAlt, includeHtml)
|
|
66908
|
-
}
|
|
66909
|
-
|
|
66910
|
-
return result.join('')
|
|
66837
|
+
function mdast_util_to_markdown_node_modules_micromark_util_character_markdownLineEndingOrSpace(code) {
|
|
66838
|
+
return code !== null && (code < 0 || code === 32);
|
|
66911
66839
|
}
|
|
66912
66840
|
|
|
66913
66841
|
/**
|
|
66914
|
-
* Check
|
|
66842
|
+
* Check whether a character code is a markdown space.
|
|
66915
66843
|
*
|
|
66916
|
-
*
|
|
66917
|
-
*
|
|
66918
|
-
*
|
|
66919
|
-
*
|
|
66844
|
+
* A **markdown space** is the concrete character U+0020 SPACE (SP) and the
|
|
66845
|
+
* virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT).
|
|
66846
|
+
*
|
|
66847
|
+
* In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is
|
|
66848
|
+
* replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL
|
|
66849
|
+
* SPACE (VS) characters, depending on the column at which the tab occurred.
|
|
66850
|
+
*
|
|
66851
|
+
* @param {Code} code
|
|
66852
|
+
* Code.
|
|
66853
|
+
* @returns {boolean}
|
|
66854
|
+
* Whether it matches.
|
|
66920
66855
|
*/
|
|
66921
|
-
function
|
|
66922
|
-
return
|
|
66856
|
+
function mdast_util_to_markdown_node_modules_micromark_util_character_markdownSpace(code) {
|
|
66857
|
+
return code === -2 || code === -1 || code === 32;
|
|
66923
66858
|
}
|
|
66924
66859
|
|
|
66925
|
-
|
|
66860
|
+
// Size note: removing ASCII from the regex and using `asciiPunctuation` here
|
|
66861
|
+
// In fact adds to the bundle size.
|
|
66926
66862
|
/**
|
|
66927
|
-
*
|
|
66928
|
-
*
|
|
66863
|
+
* Check whether the character code represents Unicode punctuation.
|
|
66864
|
+
*
|
|
66865
|
+
* A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation,
|
|
66866
|
+
* Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf`
|
|
66867
|
+
* (Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po`
|
|
66868
|
+
* (Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII
|
|
66869
|
+
* punctuation (see `asciiPunctuation`).
|
|
66870
|
+
*
|
|
66871
|
+
* See:
|
|
66872
|
+
* **\[UNICODE]**:
|
|
66873
|
+
* [The Unicode Standard](https://www.unicode.org/versions/).
|
|
66874
|
+
* Unicode Consortium.
|
|
66875
|
+
*
|
|
66876
|
+
* @param code
|
|
66877
|
+
* Code.
|
|
66878
|
+
* @returns
|
|
66879
|
+
* Whether it matches.
|
|
66929
66880
|
*/
|
|
66930
|
-
|
|
66931
|
-
|
|
66932
|
-
|
|
66881
|
+
const mdast_util_to_markdown_node_modules_micromark_util_character_unicodePunctuation = mdast_util_to_markdown_node_modules_micromark_util_character_regexCheck(/\p{P}|\p{S}/u);
|
|
66933
66882
|
|
|
66934
66883
|
/**
|
|
66935
|
-
*
|
|
66884
|
+
* Check whether the character code represents Unicode whitespace.
|
|
66936
66885
|
*
|
|
66937
|
-
*
|
|
66938
|
-
*
|
|
66939
|
-
*
|
|
66940
|
-
*
|
|
66941
|
-
*
|
|
66942
|
-
*
|
|
66886
|
+
* Note that this does handle micromark specific markdown whitespace characters.
|
|
66887
|
+
* See `markdownLineEndingOrSpace` to check that.
|
|
66888
|
+
*
|
|
66889
|
+
* A **Unicode whitespace** is a character in the Unicode `Zs` (Separator,
|
|
66890
|
+
* Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF),
|
|
66891
|
+
* U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\[UNICODE]**).
|
|
66892
|
+
*
|
|
66893
|
+
* See:
|
|
66894
|
+
* **\[UNICODE]**:
|
|
66895
|
+
* [The Unicode Standard](https://www.unicode.org/versions/).
|
|
66896
|
+
* Unicode Consortium.
|
|
66897
|
+
*
|
|
66898
|
+
* @param code
|
|
66899
|
+
* Code.
|
|
66900
|
+
* @returns
|
|
66901
|
+
* Whether it matches.
|
|
66943
66902
|
*/
|
|
66944
|
-
|
|
66945
|
-
let literalWithBreak = false
|
|
66903
|
+
const mdast_util_to_markdown_node_modules_micromark_util_character_unicodeWhitespace = mdast_util_to_markdown_node_modules_micromark_util_character_regexCheck(/\s/);
|
|
66946
66904
|
|
|
66947
|
-
|
|
66948
|
-
|
|
66949
|
-
|
|
66950
|
-
|
|
66951
|
-
|
|
66952
|
-
|
|
66953
|
-
|
|
66954
|
-
|
|
66955
|
-
|
|
66956
|
-
|
|
66957
|
-
})
|
|
66905
|
+
/**
|
|
66906
|
+
* Create a code check from a regex.
|
|
66907
|
+
*
|
|
66908
|
+
* @param {RegExp} regex
|
|
66909
|
+
* Expression.
|
|
66910
|
+
* @returns {(code: Code) => boolean}
|
|
66911
|
+
* Check.
|
|
66912
|
+
*/
|
|
66913
|
+
function mdast_util_to_markdown_node_modules_micromark_util_character_regexCheck(regex) {
|
|
66914
|
+
return check;
|
|
66958
66915
|
|
|
66959
|
-
|
|
66960
|
-
|
|
66961
|
-
|
|
66962
|
-
|
|
66963
|
-
|
|
66916
|
+
/**
|
|
66917
|
+
* Check whether a code matches the bound regex.
|
|
66918
|
+
*
|
|
66919
|
+
* @param {Code} code
|
|
66920
|
+
* Character code.
|
|
66921
|
+
* @returns {boolean}
|
|
66922
|
+
* Whether the character code matches the bound regex.
|
|
66923
|
+
*/
|
|
66924
|
+
function check(code) {
|
|
66925
|
+
return code !== null && code > -1 && regex.test(String.fromCharCode(code));
|
|
66926
|
+
}
|
|
66964
66927
|
}
|
|
66965
|
-
|
|
66966
|
-
;// ../node_modules/mdast-util-to-markdown/lib/handle/heading.js
|
|
66928
|
+
;// ../node_modules/mdast-util-to-markdown/node_modules/micromark-util-classify-character/index.js
|
|
66967
66929
|
/**
|
|
66968
|
-
* @import {
|
|
66969
|
-
* @import {Heading, Parents} from 'mdast'
|
|
66930
|
+
* @import {Code} from 'micromark-util-types'
|
|
66970
66931
|
*/
|
|
66971
66932
|
|
|
66972
66933
|
|
|
66973
|
-
|
|
66974
|
-
|
|
66975
66934
|
/**
|
|
66976
|
-
*
|
|
66935
|
+
* Classify whether a code represents whitespace, punctuation, or something
|
|
66936
|
+
* else.
|
|
66977
66937
|
*
|
|
66978
|
-
*
|
|
66979
|
-
*
|
|
66980
|
-
*
|
|
66981
|
-
*
|
|
66982
|
-
*
|
|
66983
|
-
*
|
|
66984
|
-
*
|
|
66985
|
-
*
|
|
66986
|
-
*
|
|
66987
|
-
* Serialized markdown.
|
|
66938
|
+
* Used for attention (emphasis, strong), whose sequences can open or close
|
|
66939
|
+
* based on the class of surrounding characters.
|
|
66940
|
+
*
|
|
66941
|
+
* > 👉 **Note**: eof (`null`) is seen as whitespace.
|
|
66942
|
+
*
|
|
66943
|
+
* @param {Code} code
|
|
66944
|
+
* Code.
|
|
66945
|
+
* @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined}
|
|
66946
|
+
* Group.
|
|
66988
66947
|
*/
|
|
66989
|
-
function
|
|
66990
|
-
|
|
66991
|
-
|
|
66992
|
-
|
|
66993
|
-
if (formatHeadingAsSetext(node, state)) {
|
|
66994
|
-
const exit = state.enter('headingSetext')
|
|
66995
|
-
const subexit = state.enter('phrasing')
|
|
66996
|
-
const value = state.containerPhrasing(node, {
|
|
66997
|
-
...tracker.current(),
|
|
66998
|
-
before: '\n',
|
|
66999
|
-
after: '\n'
|
|
67000
|
-
})
|
|
67001
|
-
subexit()
|
|
67002
|
-
exit()
|
|
67003
|
-
|
|
67004
|
-
return (
|
|
67005
|
-
value +
|
|
67006
|
-
'\n' +
|
|
67007
|
-
(rank === 1 ? '=' : '-').repeat(
|
|
67008
|
-
// The whole size…
|
|
67009
|
-
value.length -
|
|
67010
|
-
// Minus the position of the character after the last EOL (or
|
|
67011
|
-
// 0 if there is none)…
|
|
67012
|
-
(Math.max(value.lastIndexOf('\r'), value.lastIndexOf('\n')) + 1)
|
|
67013
|
-
)
|
|
67014
|
-
)
|
|
67015
|
-
}
|
|
67016
|
-
|
|
67017
|
-
const sequence = '#'.repeat(rank)
|
|
67018
|
-
const exit = state.enter('headingAtx')
|
|
67019
|
-
const subexit = state.enter('phrasing')
|
|
67020
|
-
|
|
67021
|
-
// Note: for proper tracking, we should reset the output positions when there
|
|
67022
|
-
// is no content returned, because then the space is not output.
|
|
67023
|
-
// Practically, in that case, there is no content, so it doesn’t matter that
|
|
67024
|
-
// we’ve tracked one too many characters.
|
|
67025
|
-
tracker.move(sequence + ' ')
|
|
67026
|
-
|
|
67027
|
-
let value = state.containerPhrasing(node, {
|
|
67028
|
-
before: '# ',
|
|
67029
|
-
after: '\n',
|
|
67030
|
-
...tracker.current()
|
|
67031
|
-
})
|
|
67032
|
-
|
|
67033
|
-
const head = value.charCodeAt(0)
|
|
67034
|
-
|
|
67035
|
-
if (head === 9 /* `\t` */ || head === 32 /* ` ` */) {
|
|
67036
|
-
// To do: what effect has the character reference on tracking?
|
|
67037
|
-
value = encodeCharacterReference(head) + value.slice(1)
|
|
66948
|
+
function micromark_util_classify_character_classifyCharacter(code) {
|
|
66949
|
+
if (code === null || mdast_util_to_markdown_node_modules_micromark_util_character_markdownLineEndingOrSpace(code) || mdast_util_to_markdown_node_modules_micromark_util_character_unicodeWhitespace(code)) {
|
|
66950
|
+
return 1;
|
|
67038
66951
|
}
|
|
67039
|
-
|
|
67040
|
-
|
|
67041
|
-
|
|
67042
|
-
if (state.options.closeAtx) {
|
|
67043
|
-
value += ' ' + sequence
|
|
66952
|
+
if (mdast_util_to_markdown_node_modules_micromark_util_character_unicodePunctuation(code)) {
|
|
66953
|
+
return 2;
|
|
67044
66954
|
}
|
|
67045
|
-
|
|
67046
|
-
subexit()
|
|
67047
|
-
exit()
|
|
67048
|
-
|
|
67049
|
-
return value
|
|
67050
66955
|
}
|
|
67051
|
-
|
|
67052
|
-
;// ../node_modules/mdast-util-to-markdown/lib/handle/html.js
|
|
67053
|
-
/**
|
|
67054
|
-
* @import {Html} from 'mdast'
|
|
67055
|
-
*/
|
|
67056
|
-
|
|
67057
|
-
handle_html_html.peek = htmlPeek
|
|
67058
|
-
|
|
66956
|
+
;// ../node_modules/mdast-util-to-markdown/lib/util/character.js
|
|
67059
66957
|
/**
|
|
67060
|
-
*
|
|
66958
|
+
* Get the first character of a value.
|
|
67061
66959
|
*
|
|
67062
|
-
*
|
|
67063
|
-
*
|
|
66960
|
+
* Is aware of astral characters (such as emoji).
|
|
66961
|
+
*
|
|
66962
|
+
* @param {string} value
|
|
66963
|
+
* Value.
|
|
67064
66964
|
* @returns {string}
|
|
67065
|
-
*
|
|
66965
|
+
* First character; empty if `value` is empty.
|
|
67066
66966
|
*/
|
|
67067
|
-
function
|
|
67068
|
-
|
|
66967
|
+
function firstCharacter(value) {
|
|
66968
|
+
const code = value.codePointAt(0)
|
|
66969
|
+
return code === undefined ? '' : String.fromCodePoint(code)
|
|
67069
66970
|
}
|
|
67070
66971
|
|
|
67071
66972
|
/**
|
|
67072
|
-
*
|
|
66973
|
+
* Get the last character of a value.
|
|
67073
66974
|
*
|
|
66975
|
+
* Is aware of astral characters (such as emoji).
|
|
66976
|
+
*
|
|
66977
|
+
* @param {string} value
|
|
66978
|
+
* Value.
|
|
67074
66979
|
* @returns {string}
|
|
67075
|
-
*
|
|
66980
|
+
* Last character; empty if `value` is empty.
|
|
67076
66981
|
*/
|
|
67077
|
-
function
|
|
67078
|
-
|
|
66982
|
+
function lastCharacter(value) {
|
|
66983
|
+
// Only a surrogate pair gives a code point above the BMP.
|
|
66984
|
+
const code = value.codePointAt(value.length - 2)
|
|
66985
|
+
return code !== undefined && code > 0xff_ff
|
|
66986
|
+
? value.slice(-2)
|
|
66987
|
+
: value.slice(-1)
|
|
67079
66988
|
}
|
|
67080
66989
|
|
|
67081
|
-
;// ../node_modules/mdast-util-to-markdown/lib/
|
|
66990
|
+
;// ../node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
|
|
67082
66991
|
/**
|
|
67083
|
-
*
|
|
67084
|
-
*
|
|
66992
|
+
* Encode a code point as a character reference.
|
|
66993
|
+
*
|
|
66994
|
+
* @param {number} code
|
|
66995
|
+
* Code point to encode.
|
|
66996
|
+
* @returns {string}
|
|
66997
|
+
* Encoded character reference.
|
|
67085
66998
|
*/
|
|
66999
|
+
function encodeCharacterReference(code) {
|
|
67000
|
+
return '&#x' + code.toString(16).toUpperCase() + ';'
|
|
67001
|
+
}
|
|
67086
67002
|
|
|
67003
|
+
;// ../node_modules/mdast-util-to-markdown/lib/util/encode-info.js
|
|
67004
|
+
/**
|
|
67005
|
+
* @import {EncodeSides} from '../types.js'
|
|
67006
|
+
*/
|
|
67087
67007
|
|
|
67088
67008
|
|
|
67089
|
-
handle_image_image.peek = imagePeek
|
|
67090
67009
|
|
|
67091
67010
|
/**
|
|
67092
|
-
*
|
|
67011
|
+
* Check whether to encode (as a character reference) the characters
|
|
67012
|
+
* surrounding an attention run.
|
|
67093
67013
|
*
|
|
67094
|
-
*
|
|
67095
|
-
*
|
|
67096
|
-
*
|
|
67097
|
-
*
|
|
67014
|
+
* Which characters are around an attention run influence whether it works or
|
|
67015
|
+
* not.
|
|
67016
|
+
*
|
|
67017
|
+
* See <https://github.com/orgs/syntax-tree/discussions/60> for more info.
|
|
67018
|
+
* See this markdown in a particular renderer to see what works:
|
|
67019
|
+
*
|
|
67020
|
+
* ```markdown
|
|
67021
|
+
* | | A (letter inside) | B (punctuation inside) | C (whitespace inside) | D (nothing inside) |
|
|
67022
|
+
* | ----------------------- | ----------------- | ---------------------- | --------------------- | ------------------ |
|
|
67023
|
+
* | 1 (letter outside) | x*y*z | x*.*z | x* *z | x**z |
|
|
67024
|
+
* | 2 (punctuation outside) | .*y*. | .*.*. | .* *. | .**. |
|
|
67025
|
+
* | 3 (whitespace outside) | x *y* z | x *.* z | x * * z | x ** z |
|
|
67026
|
+
* | 4 (nothing outside) | *x* | *.* | * * | ** |
|
|
67027
|
+
* ```
|
|
67028
|
+
*
|
|
67029
|
+
* @param {number} outside
|
|
67030
|
+
* Code point on the outer side of the run.
|
|
67031
|
+
* @param {number} inside
|
|
67032
|
+
* Code point on the inner side of the run.
|
|
67033
|
+
* @param {string} marker
|
|
67034
|
+
* Marker of the run.
|
|
67035
|
+
* Underscores are handled more strictly (they form less often) than
|
|
67036
|
+
* asterisks.
|
|
67037
|
+
* @returns {EncodeSides}
|
|
67038
|
+
* Whether to encode characters.
|
|
67039
|
+
*/
|
|
67040
|
+
// Important: punctuation must never be encoded.
|
|
67041
|
+
// Punctuation is solely used by markdown constructs.
|
|
67042
|
+
// And by encoding itself.
|
|
67043
|
+
// Encoding them will break constructs or double encode things.
|
|
67044
|
+
function encodeInfo(outside, inside, marker) {
|
|
67045
|
+
const outsideKind = micromark_util_classify_character_classifyCharacter(outside)
|
|
67046
|
+
const insideKind = micromark_util_classify_character_classifyCharacter(inside)
|
|
67047
|
+
|
|
67048
|
+
// Letter outside:
|
|
67049
|
+
if (outsideKind === undefined) {
|
|
67050
|
+
return insideKind === undefined
|
|
67051
|
+
? // Letter inside:
|
|
67052
|
+
// we have to encode *both* letters for `_` as it is looser.
|
|
67053
|
+
// it already forms for `*` (and GFMs `~`).
|
|
67054
|
+
marker === '_'
|
|
67055
|
+
? {inside: true, outside: true}
|
|
67056
|
+
: {inside: false, outside: false}
|
|
67057
|
+
: insideKind === 1
|
|
67058
|
+
? // Whitespace inside: encode both (letter, whitespace).
|
|
67059
|
+
{inside: true, outside: true}
|
|
67060
|
+
: // Punctuation inside: encode outer (letter)
|
|
67061
|
+
{inside: false, outside: true}
|
|
67062
|
+
}
|
|
67063
|
+
|
|
67064
|
+
// Whitespace outside:
|
|
67065
|
+
if (outsideKind === 1) {
|
|
67066
|
+
return insideKind === undefined
|
|
67067
|
+
? // Letter inside: already forms.
|
|
67068
|
+
{inside: false, outside: false}
|
|
67069
|
+
: insideKind === 1
|
|
67070
|
+
? // Whitespace inside: encode both (whitespace).
|
|
67071
|
+
{inside: true, outside: true}
|
|
67072
|
+
: // Punctuation inside: already forms.
|
|
67073
|
+
{inside: false, outside: false}
|
|
67074
|
+
}
|
|
67075
|
+
|
|
67076
|
+
// Punctuation outside:
|
|
67077
|
+
return insideKind === undefined
|
|
67078
|
+
? // Letter inside: already forms.
|
|
67079
|
+
{inside: false, outside: false}
|
|
67080
|
+
: insideKind === 1
|
|
67081
|
+
? // Whitespace inside: encode inner (whitespace).
|
|
67082
|
+
{inside: true, outside: false}
|
|
67083
|
+
: // Punctuation inside: already forms.
|
|
67084
|
+
{inside: false, outside: false}
|
|
67085
|
+
}
|
|
67086
|
+
|
|
67087
|
+
;// ../node_modules/mdast-util-to-markdown/node_modules/micromark-util-html-tag-name/index.js
|
|
67088
|
+
/**
|
|
67089
|
+
* List of lowercase HTML “block” tag names.
|
|
67090
|
+
*
|
|
67091
|
+
* The list, when parsing HTML (flow), results in more relaxed rules (condition
|
|
67092
|
+
* 6).
|
|
67093
|
+
* Because they are known blocks, the HTML-like syntax doesn’t have to be
|
|
67094
|
+
* strictly parsed.
|
|
67095
|
+
* For tag names not in this list, a more strict algorithm (condition 7) is used
|
|
67096
|
+
* to detect whether the HTML-like syntax is seen as HTML (flow) or not.
|
|
67097
|
+
*
|
|
67098
|
+
* This is copied from:
|
|
67099
|
+
* <https://spec.commonmark.org/0.30/#html-blocks>.
|
|
67100
|
+
*
|
|
67101
|
+
* > 👉 **Note**: `search` was added in `CommonMark@0.31`.
|
|
67102
|
+
*/
|
|
67103
|
+
const micromark_util_html_tag_name_htmlBlockNames = [
|
|
67104
|
+
'address',
|
|
67105
|
+
'article',
|
|
67106
|
+
'aside',
|
|
67107
|
+
'base',
|
|
67108
|
+
'basefont',
|
|
67109
|
+
'blockquote',
|
|
67110
|
+
'body',
|
|
67111
|
+
'caption',
|
|
67112
|
+
'center',
|
|
67113
|
+
'col',
|
|
67114
|
+
'colgroup',
|
|
67115
|
+
'dd',
|
|
67116
|
+
'details',
|
|
67117
|
+
'dialog',
|
|
67118
|
+
'dir',
|
|
67119
|
+
'div',
|
|
67120
|
+
'dl',
|
|
67121
|
+
'dt',
|
|
67122
|
+
'fieldset',
|
|
67123
|
+
'figcaption',
|
|
67124
|
+
'figure',
|
|
67125
|
+
'footer',
|
|
67126
|
+
'form',
|
|
67127
|
+
'frame',
|
|
67128
|
+
'frameset',
|
|
67129
|
+
'h1',
|
|
67130
|
+
'h2',
|
|
67131
|
+
'h3',
|
|
67132
|
+
'h4',
|
|
67133
|
+
'h5',
|
|
67134
|
+
'h6',
|
|
67135
|
+
'head',
|
|
67136
|
+
'header',
|
|
67137
|
+
'hr',
|
|
67138
|
+
'html',
|
|
67139
|
+
'iframe',
|
|
67140
|
+
'legend',
|
|
67141
|
+
'li',
|
|
67142
|
+
'link',
|
|
67143
|
+
'main',
|
|
67144
|
+
'menu',
|
|
67145
|
+
'menuitem',
|
|
67146
|
+
'nav',
|
|
67147
|
+
'noframes',
|
|
67148
|
+
'ol',
|
|
67149
|
+
'optgroup',
|
|
67150
|
+
'option',
|
|
67151
|
+
'p',
|
|
67152
|
+
'param',
|
|
67153
|
+
'search',
|
|
67154
|
+
'section',
|
|
67155
|
+
'summary',
|
|
67156
|
+
'table',
|
|
67157
|
+
'tbody',
|
|
67158
|
+
'td',
|
|
67159
|
+
'tfoot',
|
|
67160
|
+
'th',
|
|
67161
|
+
'thead',
|
|
67162
|
+
'title',
|
|
67163
|
+
'tr',
|
|
67164
|
+
'track',
|
|
67165
|
+
'ul'
|
|
67166
|
+
]
|
|
67167
|
+
|
|
67168
|
+
/**
|
|
67169
|
+
* List of lowercase HTML “raw” tag names.
|
|
67170
|
+
*
|
|
67171
|
+
* The list, when parsing HTML (flow), results in HTML that can include lines
|
|
67172
|
+
* without exiting, until a closing tag also in this list is found (condition
|
|
67173
|
+
* 1).
|
|
67174
|
+
*
|
|
67175
|
+
* This module is copied from:
|
|
67176
|
+
* <https://spec.commonmark.org/0.30/#html-blocks>.
|
|
67177
|
+
*
|
|
67178
|
+
* > 👉 **Note**: `textarea` was added in `CommonMark@0.30`.
|
|
67179
|
+
*/
|
|
67180
|
+
const micromark_util_html_tag_name_htmlRawNames = ['pre', 'script', 'style', 'textarea']
|
|
67181
|
+
|
|
67182
|
+
;// ../node_modules/mdast-util-to-markdown/lib/util/html-kind.js
|
|
67183
|
+
|
|
67184
|
+
|
|
67185
|
+
|
|
67186
|
+
/**
|
|
67187
|
+
* @typedef {1 | 2 | 3 | 4 | 5 | 6 | 7} Kind
|
|
67188
|
+
* Kind of HTML (flow) element.
|
|
67189
|
+
*/
|
|
67190
|
+
|
|
67191
|
+
/**
|
|
67192
|
+
* Infer the kind of HTML that `value` is.
|
|
67193
|
+
*
|
|
67194
|
+
* This works on valid trees as produced by `micromark`.
|
|
67195
|
+
* Kinds:
|
|
67196
|
+
*
|
|
67197
|
+
* 1. raw
|
|
67198
|
+
* 2. comment
|
|
67199
|
+
* 3. instruction
|
|
67200
|
+
* 4. declaration
|
|
67201
|
+
* 5. cdata
|
|
67202
|
+
* 6. block
|
|
67203
|
+
* 7. other
|
|
67204
|
+
*
|
|
67205
|
+
* See: <https://spec.commonmark.org/0.31.2/#html-blocks>.
|
|
67206
|
+
*
|
|
67207
|
+
* @param {string} value
|
|
67208
|
+
* HTML.
|
|
67209
|
+
* @returns {Kind | undefined}
|
|
67210
|
+
* Kind; `undefined` if unknown.
|
|
67211
|
+
*/
|
|
67212
|
+
function htmlKind(value) {
|
|
67213
|
+
if (value.charCodeAt(0) !== 60 /* `<` */) return
|
|
67214
|
+
|
|
67215
|
+
const next = value.charCodeAt(1)
|
|
67216
|
+
|
|
67217
|
+
if (next === 33 /* `!` */) {
|
|
67218
|
+
const code = value.charCodeAt(2)
|
|
67219
|
+
if (code === 45 /* `-` */) return 2
|
|
67220
|
+
if (code === 91 /* `[` */) return 5
|
|
67221
|
+
if (mdast_util_to_markdown_node_modules_micromark_util_character_asciiAlpha(code)) return 4
|
|
67222
|
+
return
|
|
67223
|
+
}
|
|
67224
|
+
|
|
67225
|
+
if (next === 63 /* `?` */) return 3
|
|
67226
|
+
|
|
67227
|
+
const closing = next === 47 /* `/` */
|
|
67228
|
+
const start = closing ? 2 : 1
|
|
67229
|
+
let end = start
|
|
67230
|
+
let code = value.charCodeAt(end)
|
|
67231
|
+
|
|
67232
|
+
if (!mdast_util_to_markdown_node_modules_micromark_util_character_asciiAlpha(code)) return
|
|
67233
|
+
|
|
67234
|
+
while (code === 45 /* `-` */ || mdast_util_to_markdown_node_modules_micromark_util_character_asciiAlphanumeric(code)) {
|
|
67235
|
+
code = value.charCodeAt(++end)
|
|
67236
|
+
}
|
|
67237
|
+
|
|
67238
|
+
const name = value.slice(start, end).toLowerCase()
|
|
67239
|
+
|
|
67240
|
+
if (!closing && code !== 47 /* `/` */ && micromark_util_html_tag_name_htmlRawNames.includes(name)) {
|
|
67241
|
+
return 1
|
|
67242
|
+
}
|
|
67243
|
+
|
|
67244
|
+
return micromark_util_html_tag_name_htmlBlockNames.includes(name) ? 6 : 7
|
|
67245
|
+
}
|
|
67246
|
+
|
|
67247
|
+
;// ../node_modules/mdast-util-to-markdown/lib/util/container-phrasing.js
|
|
67248
|
+
/**
|
|
67249
|
+
* @import {Attention, Handle, Info, State, Tracker} from 'mdast-util-to-markdown'
|
|
67250
|
+
* @import {PhrasingParents} from '../types.js'
|
|
67251
|
+
*/
|
|
67252
|
+
|
|
67253
|
+
|
|
67254
|
+
|
|
67255
|
+
|
|
67256
|
+
|
|
67257
|
+
|
|
67258
|
+
|
|
67259
|
+
|
|
67260
|
+
/**
|
|
67261
|
+
* Markers for builtin attention (emphasis, strong) to whether they are stricter:
|
|
67262
|
+
* whether they cannot open and close inside words.
|
|
67263
|
+
*
|
|
67264
|
+
* Builtin runs pair following CommonMark rules for emphasis and strong:
|
|
67265
|
+
* they are split,
|
|
67266
|
+
* using one or two markers at a time,
|
|
67267
|
+
* with the rule of 3.
|
|
67268
|
+
* Other markers pair like GFM strikethrough:
|
|
67269
|
+
* whole runs pair with a run of the same size.
|
|
67270
|
+
*
|
|
67271
|
+
* @type {Map<string, boolean>}
|
|
67272
|
+
*/
|
|
67273
|
+
const builtins = new Map([
|
|
67274
|
+
['*', false],
|
|
67275
|
+
['_', true]
|
|
67276
|
+
])
|
|
67277
|
+
|
|
67278
|
+
/**
|
|
67279
|
+
* @typedef AttentionResult
|
|
67280
|
+
* Attention, of which the sequence is chosen later.
|
|
67281
|
+
* @property {Array<Item>} children
|
|
67282
|
+
* Serialized children.
|
|
67283
|
+
* @property {Array<string>} sequences
|
|
67284
|
+
* Sequences that can be used, in order of preference.
|
|
67285
|
+
*/
|
|
67286
|
+
|
|
67287
|
+
/**
|
|
67288
|
+
* @typedef Improvement
|
|
67289
|
+
* Improvement of attention sequences.
|
|
67290
|
+
* @property {Map<AttentionResult, string>} chosen
|
|
67291
|
+
* Chosen sequences for each attention.
|
|
67292
|
+
* @property {Array<Token>} tokens
|
|
67293
|
+
* Tokens involved in the improvement.
|
|
67294
|
+
* @property {Mistake | undefined} mistake
|
|
67295
|
+
* Mistake that led to this improvement, if any.
|
|
67296
|
+
*/
|
|
67297
|
+
|
|
67298
|
+
/**
|
|
67299
|
+
* @typedef {AttentionResult | string} Item
|
|
67300
|
+
* Serialized phrasing.
|
|
67301
|
+
*/
|
|
67302
|
+
|
|
67303
|
+
/**
|
|
67304
|
+
* @typedef Mistake
|
|
67305
|
+
* Sequence that does not form its attention.
|
|
67306
|
+
* @property {Array<AttentionResult>} attention
|
|
67307
|
+
* Attention to try other sequences for.
|
|
67308
|
+
* @property {number} index
|
|
67309
|
+
* Index of the token.
|
|
67310
|
+
*/
|
|
67311
|
+
|
|
67312
|
+
/**
|
|
67313
|
+
* @typedef Run
|
|
67314
|
+
* Sequences next to each other with the same marker.
|
|
67315
|
+
* @property {boolean} close
|
|
67316
|
+
* Whether it can close.
|
|
67317
|
+
* @property {number} end
|
|
67318
|
+
* Index after the last marker not used (to open).
|
|
67319
|
+
* @property {Array<Token>} markers
|
|
67320
|
+
* Sequence of each marker.
|
|
67321
|
+
* @property {boolean} open
|
|
67322
|
+
* Whether it can open.
|
|
67323
|
+
* @property {boolean} split
|
|
67324
|
+
* Whether it can be split (built-in attention).
|
|
67325
|
+
* @property {number} start
|
|
67326
|
+
* Index of the first marker not used (to close).
|
|
67327
|
+
* @property {Array<Token>} tokens
|
|
67328
|
+
* Sequences.
|
|
67329
|
+
*/
|
|
67330
|
+
|
|
67331
|
+
/**
|
|
67332
|
+
* @typedef Token
|
|
67333
|
+
* Rendered phrasing.
|
|
67334
|
+
* @property {AttentionResult | undefined} attention
|
|
67335
|
+
* Attention, if this is one of its sequences.
|
|
67336
|
+
* @property {string} value
|
|
67337
|
+
* Value.
|
|
67338
|
+
*/
|
|
67339
|
+
|
|
67340
|
+
/**
|
|
67341
|
+
* Get candidates for a mistake:
|
|
67342
|
+
* attention to try other sequences for,
|
|
67343
|
+
* later first.
|
|
67344
|
+
*
|
|
67345
|
+
* @param {Array<Token>} tokens
|
|
67346
|
+
* Tokens.
|
|
67347
|
+
* @param {Array<Token>} involved
|
|
67348
|
+
* Sequences involved in the mistake.
|
|
67349
|
+
* @param {Map<Token, Run>} runOf
|
|
67350
|
+
* Run of each sequence.
|
|
67351
|
+
* @returns {Array<AttentionResult>}
|
|
67352
|
+
* Candidates.
|
|
67353
|
+
*/
|
|
67354
|
+
function candidates(tokens, involved, runOf) {
|
|
67355
|
+
/** @type {Set<AttentionResult | undefined>} */
|
|
67356
|
+
const related = new Set()
|
|
67357
|
+
|
|
67358
|
+
// The attention involved, and attention in runs with its sequences.
|
|
67359
|
+
for (const token of tokens) {
|
|
67360
|
+
const siblings = runOf.get(token)
|
|
67361
|
+
if (
|
|
67362
|
+
siblings &&
|
|
67363
|
+
token.attention &&
|
|
67364
|
+
involved.some((d) => d.attention === token.attention)
|
|
67365
|
+
) {
|
|
67366
|
+
for (const sibling of siblings.tokens) {
|
|
67367
|
+
related.add(sibling.attention)
|
|
67368
|
+
}
|
|
67369
|
+
}
|
|
67370
|
+
}
|
|
67371
|
+
|
|
67372
|
+
/** @type {Array<AttentionResult>} */
|
|
67373
|
+
const ordered = []
|
|
67374
|
+
|
|
67375
|
+
for (const token of tokens) {
|
|
67376
|
+
if (token.attention && related.delete(token.attention)) {
|
|
67377
|
+
ordered.push(token.attention)
|
|
67378
|
+
}
|
|
67379
|
+
}
|
|
67380
|
+
|
|
67381
|
+
// Later first: attention that opens later is inner or next.
|
|
67382
|
+
ordered.reverse()
|
|
67383
|
+
return ordered
|
|
67384
|
+
}
|
|
67385
|
+
|
|
67386
|
+
/**
|
|
67387
|
+
* Check whether sequences form their attention, like `micromark`.
|
|
67388
|
+
*
|
|
67389
|
+
* Sequences of `*` and `_` pair like emphasis and strong in CommonMark,
|
|
67390
|
+
* others like strikethrough in GFM.
|
|
67391
|
+
*
|
|
67392
|
+
* @param {Array<Token>} tokens
|
|
67393
|
+
* Tokens.
|
|
67394
|
+
* @param {string} before
|
|
67395
|
+
* Characters before.
|
|
67396
|
+
* @param {string} after
|
|
67397
|
+
* Characters after.
|
|
67398
|
+
* @returns {Mistake | undefined}
|
|
67399
|
+
* First mistake, if any.
|
|
67400
|
+
*/
|
|
67401
|
+
function check(tokens, before, after) {
|
|
67402
|
+
/** @type {Array<Run>} */
|
|
67403
|
+
const runs = []
|
|
67404
|
+
/** @type {Map<Token, Array<Token>>} */
|
|
67405
|
+
const wrong = new Map()
|
|
67406
|
+
/** @type {Map<Token, Run>} */
|
|
67407
|
+
const runOf = new Map()
|
|
67408
|
+
let index = 0
|
|
67409
|
+
|
|
67410
|
+
while (index < tokens.length) {
|
|
67411
|
+
if (!tokens[index].attention) {
|
|
67412
|
+
index++
|
|
67413
|
+
continue
|
|
67414
|
+
}
|
|
67415
|
+
|
|
67416
|
+
const marker = tokens[index].value.charAt(0)
|
|
67417
|
+
const strict = builtins.get(marker)
|
|
67418
|
+
let end = index + 1
|
|
67419
|
+
|
|
67420
|
+
while (
|
|
67421
|
+
end < tokens.length &&
|
|
67422
|
+
tokens[end].attention &&
|
|
67423
|
+
tokens[end].value.charAt(0) === marker
|
|
67424
|
+
) {
|
|
67425
|
+
end++
|
|
67426
|
+
}
|
|
67427
|
+
|
|
67428
|
+
const head = index ? tokens[index - 1].value : before
|
|
67429
|
+
const previous = micromark_util_classify_character_classifyCharacter(head.charCodeAt(head.length - 1))
|
|
67430
|
+
const next = micromark_util_classify_character_classifyCharacter(
|
|
67431
|
+
(end < tokens.length ? tokens[end].value : after).charCodeAt(0)
|
|
67432
|
+
)
|
|
67433
|
+
const open = !next || (next === 2 && Boolean(previous))
|
|
67434
|
+
const close = !previous || (previous === 2 && Boolean(next))
|
|
67435
|
+
/** @type {Run} */
|
|
67436
|
+
const run = {
|
|
67437
|
+
tokens: tokens.slice(index, end),
|
|
67438
|
+
markers: [],
|
|
67439
|
+
start: 0,
|
|
67440
|
+
end: 0,
|
|
67441
|
+
// Underscores are strict, they cannot open or close inside words.
|
|
67442
|
+
open: strict ? open && (Boolean(previous) || !close) : open,
|
|
67443
|
+
close: strict ? close && (Boolean(next) || !open) : close,
|
|
67444
|
+
// All builtins can split runs.
|
|
67445
|
+
split: strict !== undefined
|
|
67446
|
+
}
|
|
67447
|
+
|
|
67448
|
+
for (const token of run.tokens) {
|
|
67449
|
+
// Every sequence is wrong until it pairs with its other sequence.
|
|
67450
|
+
wrong.set(token, [...run.tokens])
|
|
67451
|
+
runOf.set(token, run)
|
|
67452
|
+
let size = token.value.length
|
|
67453
|
+
while (size--) run.markers.push(token)
|
|
67454
|
+
}
|
|
67455
|
+
|
|
67456
|
+
run.end = run.markers.length
|
|
67457
|
+
runs.push(run)
|
|
67458
|
+
index = end
|
|
67459
|
+
}
|
|
67460
|
+
|
|
67461
|
+
pair(runs, wrong)
|
|
67462
|
+
|
|
67463
|
+
index = -1
|
|
67464
|
+
|
|
67465
|
+
while (++index < tokens.length) {
|
|
67466
|
+
const involved = wrong.get(tokens[index])
|
|
67467
|
+
if (involved) return {attention: candidates(tokens, involved, runOf), index}
|
|
67468
|
+
}
|
|
67469
|
+
}
|
|
67470
|
+
|
|
67471
|
+
/**
|
|
67472
|
+
* Serialize the children of a parent that contains phrasing children.
|
|
67473
|
+
*
|
|
67474
|
+
* @param {PhrasingParents} parent
|
|
67475
|
+
* Parent of phrasing nodes.
|
|
67098
67476
|
* @param {State} state
|
|
67099
|
-
* Info passed around.
|
|
67477
|
+
* Info passed around about the current state.
|
|
67100
67478
|
* @param {Info} info
|
|
67101
|
-
* Info on
|
|
67479
|
+
* Info on where we are in the document we are generating.
|
|
67102
67480
|
* @returns {string}
|
|
67103
|
-
* Serialized
|
|
67481
|
+
* Serialized result.
|
|
67104
67482
|
*/
|
|
67105
|
-
function
|
|
67106
|
-
|
|
67107
|
-
|
|
67108
|
-
|
|
67109
|
-
|
|
67110
|
-
|
|
67111
|
-
|
|
67112
|
-
|
|
67113
|
-
|
|
67483
|
+
function containerPhrasing(parent, state, info) {
|
|
67484
|
+
return container_phrasing_serialize(phrasing(parent, state, info), info.before, info.after)
|
|
67485
|
+
}
|
|
67486
|
+
|
|
67487
|
+
/**
|
|
67488
|
+
* Encode the first or last character of tokens as a character reference,
|
|
67489
|
+
* if it is text.
|
|
67490
|
+
*
|
|
67491
|
+
* @param {Array<Token>} tokens
|
|
67492
|
+
* Tokens.
|
|
67493
|
+
* @param {boolean} start
|
|
67494
|
+
* Whether to encode the first or last character.
|
|
67495
|
+
* @returns {undefined}
|
|
67496
|
+
* Nothing.
|
|
67497
|
+
*/
|
|
67498
|
+
function container_phrasing_encode(tokens, start) {
|
|
67499
|
+
const token = tokens[start ? 0 : tokens.length - 1]
|
|
67500
|
+
|
|
67501
|
+
if (!token || token.attention) return
|
|
67502
|
+
|
|
67503
|
+
const character = start
|
|
67504
|
+
? firstCharacter(token.value)
|
|
67505
|
+
: lastCharacter(token.value)
|
|
67506
|
+
const reference = encodeCharacterReference(
|
|
67507
|
+
/** @type {number} */ (character.codePointAt(0))
|
|
67114
67508
|
)
|
|
67115
|
-
value += tracker.move('](')
|
|
67116
67509
|
|
|
67117
|
-
|
|
67510
|
+
if (start) {
|
|
67511
|
+
token.value = reference + token.value.slice(character.length)
|
|
67512
|
+
} else {
|
|
67513
|
+
let value = token.value.slice(0, token.value.length - character.length)
|
|
67514
|
+
let escapes = 0
|
|
67118
67515
|
|
|
67119
|
-
|
|
67120
|
-
|
|
67121
|
-
|
|
67122
|
-
|
|
67123
|
-
|
|
67124
|
-
|
|
67125
|
-
|
|
67126
|
-
|
|
67127
|
-
|
|
67128
|
-
|
|
67516
|
+
while (value.charCodeAt(value.length - 1 - escapes) === 92 /* `\` */) {
|
|
67517
|
+
escapes++
|
|
67518
|
+
}
|
|
67519
|
+
|
|
67520
|
+
// Odd number would escape the `&` again.
|
|
67521
|
+
if (escapes % 2) value += '\\'
|
|
67522
|
+
token.value = value + reference
|
|
67523
|
+
}
|
|
67524
|
+
}
|
|
67525
|
+
|
|
67526
|
+
/**
|
|
67527
|
+
* Try other sequences for the candidates of a mistake and use the first that
|
|
67528
|
+
* moves the mistake further.
|
|
67529
|
+
*
|
|
67530
|
+
* @param {Array<Item>} items
|
|
67531
|
+
* Items.
|
|
67532
|
+
* @param {Map<AttentionResult, string>} chosen
|
|
67533
|
+
* Sequences to use instead of preferred sequences.
|
|
67534
|
+
* @param {Mistake} mistake
|
|
67535
|
+
* Mistake.
|
|
67536
|
+
* @param {string} before
|
|
67537
|
+
* Characters before.
|
|
67538
|
+
* @param {string} after
|
|
67539
|
+
* Characters after.
|
|
67540
|
+
* @returns {Improvement | undefined}
|
|
67541
|
+
* Result if better.
|
|
67542
|
+
*/
|
|
67543
|
+
function improve(items, chosen, mistake, before, after) {
|
|
67544
|
+
for (const attention of mistake.attention) {
|
|
67545
|
+
const current = chosen.get(attention) || attention.sequences[0]
|
|
67546
|
+
|
|
67547
|
+
for (const sequence of attention.sequences) {
|
|
67548
|
+
if (sequence === current) continue
|
|
67549
|
+
const trial = new Map(chosen)
|
|
67550
|
+
trial.set(attention, sequence)
|
|
67551
|
+
const tokens = render(items, trial, before, after)
|
|
67552
|
+
const next = check(tokens, before, after)
|
|
67553
|
+
|
|
67554
|
+
if (!next || next.index > mistake.index) {
|
|
67555
|
+
return {chosen: trial, mistake: next, tokens}
|
|
67556
|
+
}
|
|
67557
|
+
}
|
|
67558
|
+
}
|
|
67559
|
+
}
|
|
67560
|
+
|
|
67561
|
+
/**
|
|
67562
|
+
* Pair runs like `micromark` and mark sequences that do form their attention
|
|
67563
|
+
* as fine.
|
|
67564
|
+
*
|
|
67565
|
+
* Each pair uses markers from the end of an opener and the start of a closer.
|
|
67566
|
+
* It forms the intended attention if those markers are exactly the whole
|
|
67567
|
+
* opening and closing sequence of one attention.
|
|
67568
|
+
* Otherwise attention is mixed up:
|
|
67569
|
+
* either sequences of different attention pair,
|
|
67570
|
+
* part of a sequence is used (such as `**` of strong as `*`),
|
|
67571
|
+
* or several sequences are used together (such as `*` and `*` as `**`).
|
|
67572
|
+
* Then the sequences involved are recorded with each other.
|
|
67573
|
+
*
|
|
67574
|
+
* @param {Array<Run>} runs
|
|
67575
|
+
* Runs.
|
|
67576
|
+
* @param {Map<Token, Array<Token>>} wrong
|
|
67577
|
+
* Sequences that are wrong, with the sequences involved.
|
|
67578
|
+
* @returns {undefined}
|
|
67579
|
+
* Nothing, `wrong` is changed.
|
|
67580
|
+
*/
|
|
67581
|
+
function pair(runs, wrong) {
|
|
67582
|
+
/** @type {Map<string, Array<Run>>} */
|
|
67583
|
+
const openersByMarker = new Map()
|
|
67584
|
+
|
|
67585
|
+
for (const closer of runs) {
|
|
67586
|
+
const marker = closer.tokens[0].value.charAt(0)
|
|
67587
|
+
let openers = openersByMarker.get(marker)
|
|
67588
|
+
|
|
67589
|
+
if (!openers) {
|
|
67590
|
+
openers = []
|
|
67591
|
+
openersByMarker.set(marker, openers)
|
|
67592
|
+
}
|
|
67593
|
+
|
|
67594
|
+
let open = closer.close ? openers.length : 0
|
|
67595
|
+
|
|
67596
|
+
while (open-- && closer.start < closer.end) {
|
|
67597
|
+
const opener = openers[open]
|
|
67598
|
+
const openerSize = opener.end - opener.start
|
|
67599
|
+
const closerSize = closer.end - closer.start
|
|
67600
|
+
|
|
67601
|
+
if (
|
|
67602
|
+
closer.split
|
|
67603
|
+
? // The rule of 3, on the sizes that are left.
|
|
67604
|
+
(opener.close || closer.open) &&
|
|
67605
|
+
closerSize % 3 &&
|
|
67606
|
+
!((openerSize + closerSize) % 3)
|
|
67607
|
+
: // Others pair whole runs of the same size.
|
|
67608
|
+
openerSize !== opener.markers.length || openerSize !== closerSize
|
|
67609
|
+
) {
|
|
67610
|
+
continue
|
|
67611
|
+
}
|
|
67612
|
+
|
|
67613
|
+
const size = closer.split
|
|
67614
|
+
? openerSize > 1 && closerSize > 1
|
|
67615
|
+
? 2
|
|
67616
|
+
: 1
|
|
67617
|
+
: closerSize
|
|
67618
|
+
const opening = opener.markers.slice(opener.end - size, opener.end)
|
|
67619
|
+
const closing = closer.markers.slice(closer.start, closer.start + size)
|
|
67620
|
+
const openToken = opening[0]
|
|
67621
|
+
const closeToken = closing[0]
|
|
67622
|
+
|
|
67623
|
+
if (
|
|
67624
|
+
// Whole sequences:
|
|
67625
|
+
// the markers of a sequence are next to each other,
|
|
67626
|
+
// so if the first and last marker are of one sequence of that size,
|
|
67627
|
+
// all markers are exactly that sequence.
|
|
67628
|
+
openToken === opening[size - 1] &&
|
|
67629
|
+
openToken.value.length === size &&
|
|
67630
|
+
closeToken === closing[size - 1] &&
|
|
67631
|
+
closeToken.value.length === size &&
|
|
67632
|
+
// Of the same attention, so its opening and closing sequence.
|
|
67633
|
+
openToken.attention === closeToken.attention
|
|
67634
|
+
) {
|
|
67635
|
+
wrong.delete(openToken)
|
|
67636
|
+
wrong.delete(closeToken)
|
|
67637
|
+
} else {
|
|
67638
|
+
const involved = [...new Set([...opening, ...closing])]
|
|
67639
|
+
// Add to what is involved already: a sequence can be in several pairs.
|
|
67640
|
+
for (const token of involved) {
|
|
67641
|
+
const list = wrong.get(token)
|
|
67642
|
+
if (list) list.push(...involved)
|
|
67643
|
+
}
|
|
67644
|
+
}
|
|
67645
|
+
|
|
67646
|
+
opener.end -= size
|
|
67647
|
+
closer.start += size
|
|
67648
|
+
|
|
67649
|
+
if (opener.start === opener.end) openers.splice(open, 1)
|
|
67650
|
+
|
|
67651
|
+
// Search again from the start, as this run may close more.
|
|
67652
|
+
open = openers.length
|
|
67653
|
+
}
|
|
67654
|
+
|
|
67655
|
+
if (closer.open && closer.start < closer.end) openers.push(closer)
|
|
67656
|
+
}
|
|
67657
|
+
}
|
|
67658
|
+
|
|
67659
|
+
/**
|
|
67660
|
+
* Get the sequences that can be used for attention, in order of preference.
|
|
67661
|
+
*
|
|
67662
|
+
* @param {string} type
|
|
67663
|
+
* Node type.
|
|
67664
|
+
* @param {Array<string>} markers
|
|
67665
|
+
* Markers.
|
|
67666
|
+
* @param {Array<number>} sizes
|
|
67667
|
+
* Sizes.
|
|
67668
|
+
* @returns {Array<string>}
|
|
67669
|
+
* Sequences.
|
|
67670
|
+
*/
|
|
67671
|
+
function attentionSequences(type, markers, sizes) {
|
|
67672
|
+
if (markers.length === 0) {
|
|
67673
|
+
throw new Error(
|
|
67674
|
+
'Cannot serialize `' +
|
|
67675
|
+
type +
|
|
67676
|
+
'` as attention without markers, expected one or more markers'
|
|
67129
67677
|
)
|
|
67130
|
-
|
|
67131
|
-
|
|
67132
|
-
|
|
67133
|
-
|
|
67134
|
-
|
|
67135
|
-
|
|
67136
|
-
|
|
67137
|
-
after: node.title ? ' ' : ')',
|
|
67138
|
-
...tracker.current()
|
|
67139
|
-
})
|
|
67678
|
+
}
|
|
67679
|
+
|
|
67680
|
+
if (sizes.length === 0) {
|
|
67681
|
+
throw new Error(
|
|
67682
|
+
'Cannot serialize `' +
|
|
67683
|
+
type +
|
|
67684
|
+
'` as attention without sizes, expected one or more sizes'
|
|
67140
67685
|
)
|
|
67141
67686
|
}
|
|
67142
67687
|
|
|
67143
|
-
|
|
67688
|
+
for (const size of sizes) {
|
|
67689
|
+
if (!Number.isSafeInteger(size) || size < 1) {
|
|
67690
|
+
throw new Error(
|
|
67691
|
+
'Cannot serialize `' +
|
|
67692
|
+
type +
|
|
67693
|
+
'` as attention with `' +
|
|
67694
|
+
size +
|
|
67695
|
+
'` as size, expected positive integer'
|
|
67696
|
+
)
|
|
67697
|
+
}
|
|
67698
|
+
}
|
|
67144
67699
|
|
|
67145
|
-
|
|
67146
|
-
|
|
67147
|
-
|
|
67148
|
-
|
|
67149
|
-
|
|
67150
|
-
|
|
67151
|
-
|
|
67152
|
-
|
|
67700
|
+
/** @type {Array<string>} */
|
|
67701
|
+
const sequences = []
|
|
67702
|
+
|
|
67703
|
+
for (const marker of markers) {
|
|
67704
|
+
if (marker.length !== 1) {
|
|
67705
|
+
throw new Error(
|
|
67706
|
+
'Cannot serialize `' +
|
|
67707
|
+
type +
|
|
67708
|
+
'` as attention with `' +
|
|
67709
|
+
marker +
|
|
67710
|
+
'` as marker, expected a single ascii character'
|
|
67711
|
+
)
|
|
67712
|
+
}
|
|
67713
|
+
|
|
67714
|
+
if (!mdast_util_to_markdown_node_modules_micromark_util_character_asciiPunctuation(marker.charCodeAt(0))) {
|
|
67715
|
+
throw new Error(
|
|
67716
|
+
'Cannot serialize `' +
|
|
67717
|
+
type +
|
|
67718
|
+
'` as attention with `' +
|
|
67719
|
+
marker +
|
|
67720
|
+
'` as marker, expected ascii punctuation'
|
|
67721
|
+
)
|
|
67722
|
+
}
|
|
67723
|
+
|
|
67724
|
+
for (const size of sizes) {
|
|
67725
|
+
sequences.push(marker.repeat(size))
|
|
67726
|
+
}
|
|
67727
|
+
}
|
|
67728
|
+
|
|
67729
|
+
return sequences
|
|
67730
|
+
}
|
|
67731
|
+
|
|
67732
|
+
/**
|
|
67733
|
+
* Serialize the children of a parent that contains phrasing children,
|
|
67734
|
+
* keeping attention separate,
|
|
67735
|
+
* so that its markers can be chosen later.
|
|
67736
|
+
*
|
|
67737
|
+
* @param {PhrasingParents} parent
|
|
67738
|
+
* Parent of phrasing nodes.
|
|
67739
|
+
* @param {State} state
|
|
67740
|
+
* Info passed around about the current state.
|
|
67741
|
+
* @param {Info} info
|
|
67742
|
+
* Info on where we are in the document we are generating.
|
|
67743
|
+
* @returns {Array<Item>}
|
|
67744
|
+
* Items.
|
|
67745
|
+
*/
|
|
67746
|
+
function phrasing(parent, state, info) {
|
|
67747
|
+
const indexStack = state.indexStack
|
|
67748
|
+
const children = parent.children || []
|
|
67749
|
+
/** @type {Array<Item>} */
|
|
67750
|
+
const results = []
|
|
67751
|
+
let index = -1
|
|
67752
|
+
let before = info.before
|
|
67753
|
+
|
|
67754
|
+
indexStack.push(-1)
|
|
67755
|
+
let tracker = state.createTracker(info)
|
|
67756
|
+
|
|
67757
|
+
while (++index < children.length) {
|
|
67758
|
+
const child = children[index]
|
|
67759
|
+
/** @type {string} */
|
|
67760
|
+
let after
|
|
67761
|
+
|
|
67762
|
+
indexStack[indexStack.length - 1] = index
|
|
67763
|
+
|
|
67764
|
+
if (index + 1 < children.length) {
|
|
67765
|
+
/** @type {Handle} */
|
|
67766
|
+
// @ts-expect-error: hush, it’s actually a `zwitch`.
|
|
67767
|
+
let handle = state.handle.handlers[children[index + 1].type]
|
|
67768
|
+
// @ts-expect-error: hush, it’s actually a `zwitch`.
|
|
67769
|
+
if (handle && handle.peek) handle = handle.peek
|
|
67770
|
+
after = handle
|
|
67771
|
+
? firstCharacter(
|
|
67772
|
+
handle(children[index + 1], parent, state, {
|
|
67773
|
+
before: '',
|
|
67774
|
+
after: '',
|
|
67775
|
+
...tracker.current()
|
|
67776
|
+
})
|
|
67777
|
+
)
|
|
67778
|
+
: ''
|
|
67779
|
+
} else {
|
|
67780
|
+
after = info.after
|
|
67781
|
+
}
|
|
67782
|
+
|
|
67783
|
+
// In some cases, html (text) can be found in phrasing right after an eol.
|
|
67784
|
+
// When we’d serialize that, it could be seen as html (flow): all its kinds
|
|
67785
|
+
// except 7 can interrupt a paragraph.
|
|
67786
|
+
// As we can’t escape or so to prevent it from happening,
|
|
67787
|
+
// we take a somewhat reasonable approach:
|
|
67788
|
+
// replace that eol with a space.
|
|
67789
|
+
// See: <https://github.com/syntax-tree/mdast-util-to-markdown/issues/15>
|
|
67790
|
+
const previous = results[results.length - 1]
|
|
67791
|
+
|
|
67792
|
+
if (
|
|
67793
|
+
typeof previous === 'string' &&
|
|
67794
|
+
(before === '\r' || before === '\n') &&
|
|
67795
|
+
child.type === 'html' &&
|
|
67796
|
+
htmlKind(child.value) !== 7
|
|
67797
|
+
) {
|
|
67798
|
+
results[results.length - 1] = previous.replace(/(\r?\n|\r)$/, ' ')
|
|
67799
|
+
before = ' '
|
|
67800
|
+
|
|
67801
|
+
// To do: does this work to reset tracker?
|
|
67802
|
+
tracker = state.createTracker(info)
|
|
67803
|
+
tracker.move(container_phrasing_serialize(results, info.before, info.after))
|
|
67804
|
+
}
|
|
67805
|
+
|
|
67806
|
+
/** @type {(Handle & {attention?: Attention | undefined}) | undefined} */
|
|
67807
|
+
// @ts-expect-error: hush, it’s actually a `zwitch`.
|
|
67808
|
+
const handle = state.handle.handlers[child.type]
|
|
67809
|
+
|
|
67810
|
+
if (handle && handle.attention) {
|
|
67811
|
+
const item = attentionItem(
|
|
67812
|
+
/** @type {PhrasingParents} */ (child),
|
|
67813
|
+
handle.attention,
|
|
67814
|
+
state,
|
|
67815
|
+
tracker
|
|
67816
|
+
)
|
|
67817
|
+
results.push(item)
|
|
67818
|
+
before = lastCharacter(item.sequences[0])
|
|
67819
|
+
} else {
|
|
67820
|
+
const value = state.handle(child, parent, state, {
|
|
67821
|
+
...tracker.current(),
|
|
67822
|
+
after,
|
|
67823
|
+
before
|
|
67153
67824
|
})
|
|
67154
|
-
|
|
67155
|
-
|
|
67156
|
-
|
|
67825
|
+
|
|
67826
|
+
if (!value) continue
|
|
67827
|
+
tracker.move(value)
|
|
67828
|
+
results.push(value)
|
|
67829
|
+
before = lastCharacter(value)
|
|
67830
|
+
}
|
|
67157
67831
|
}
|
|
67158
67832
|
|
|
67159
|
-
|
|
67833
|
+
indexStack.pop()
|
|
67834
|
+
|
|
67835
|
+
return results
|
|
67836
|
+
}
|
|
67837
|
+
|
|
67838
|
+
/**
|
|
67839
|
+
* Serialize a node as attention,
|
|
67840
|
+
* with its sequence chosen later.
|
|
67841
|
+
*
|
|
67842
|
+
* @param {PhrasingParents} node
|
|
67843
|
+
* Node.
|
|
67844
|
+
* @param {Attention} attention
|
|
67845
|
+
* Attention of the node.
|
|
67846
|
+
* @param {State} state
|
|
67847
|
+
* Info passed around about the current state.
|
|
67848
|
+
* @param {Tracker} tracker
|
|
67849
|
+
* Tracker.
|
|
67850
|
+
* @returns {AttentionResult}
|
|
67851
|
+
* Attention.
|
|
67852
|
+
*/
|
|
67853
|
+
function attentionItem(node, attention, state, tracker) {
|
|
67854
|
+
const {construct, markers, sizes} = attention(node, state)
|
|
67855
|
+
const sequences = attentionSequences(node.type, markers, sizes)
|
|
67856
|
+
const sequence = sequences[0]
|
|
67857
|
+
const exit = state.enter(construct)
|
|
67858
|
+
tracker.move(sequence)
|
|
67859
|
+
const children = phrasing(node, state, {
|
|
67860
|
+
...tracker.current(),
|
|
67861
|
+
before: sequence,
|
|
67862
|
+
after: sequence
|
|
67863
|
+
})
|
|
67864
|
+
tracker.move(container_phrasing_serialize(children, sequence, sequence))
|
|
67865
|
+
tracker.move(sequence)
|
|
67160
67866
|
exit()
|
|
67867
|
+
return {children, sequences}
|
|
67868
|
+
}
|
|
67161
67869
|
|
|
67162
|
-
|
|
67870
|
+
/**
|
|
67871
|
+
* Render items with sequences;
|
|
67872
|
+
* encoding characters around attention where needed.
|
|
67873
|
+
*
|
|
67874
|
+
* @param {Array<Item>} items
|
|
67875
|
+
* Serialized phrasing.
|
|
67876
|
+
* @param {Map<AttentionResult, string>} chosen
|
|
67877
|
+
* Sequences to use instead of preferred sequences.
|
|
67878
|
+
* @param {string} before
|
|
67879
|
+
* Characters before.
|
|
67880
|
+
* @param {string} after
|
|
67881
|
+
* Characters after.
|
|
67882
|
+
* @returns {Array<Token>}
|
|
67883
|
+
* Tokens.
|
|
67884
|
+
*/
|
|
67885
|
+
function render(items, chosen, before, after) {
|
|
67886
|
+
/** @type {Array<Token>} */
|
|
67887
|
+
const tokens = []
|
|
67888
|
+
/** @type {string | undefined} */
|
|
67889
|
+
let encodeAfter
|
|
67890
|
+
let previous = lastCharacter(before)
|
|
67891
|
+
let index = -1
|
|
67892
|
+
|
|
67893
|
+
while (++index < items.length) {
|
|
67894
|
+
const item = items[index]
|
|
67895
|
+
|
|
67896
|
+
if (typeof item === 'string') {
|
|
67897
|
+
/** @type {Token} */
|
|
67898
|
+
const token = {value: item, attention: undefined}
|
|
67899
|
+
|
|
67900
|
+
// If attention before had to encode the character after it, encode it.
|
|
67901
|
+
if (encodeAfter && encodeAfter === firstCharacter(item)) {
|
|
67902
|
+
container_phrasing_encode([token], true)
|
|
67903
|
+
}
|
|
67904
|
+
|
|
67905
|
+
encodeAfter = undefined
|
|
67906
|
+
tokens.push(token)
|
|
67907
|
+
if (token.value) previous = lastCharacter(token.value)
|
|
67908
|
+
continue
|
|
67909
|
+
}
|
|
67910
|
+
|
|
67911
|
+
const sequence = chosen.get(item) || item.sequences[0]
|
|
67912
|
+
const marker = sequence.charAt(0)
|
|
67913
|
+
const next = items[index + 1]
|
|
67914
|
+
const outsideBefore = previous
|
|
67915
|
+
const outsideAfter = firstCharacter(
|
|
67916
|
+
next === undefined
|
|
67917
|
+
? after
|
|
67918
|
+
: typeof next === 'string'
|
|
67919
|
+
? next
|
|
67920
|
+
: chosen.get(next) || next.sequences[0]
|
|
67921
|
+
)
|
|
67922
|
+
const inside = render(item.children, chosen, sequence, sequence)
|
|
67923
|
+
const head = inside.length > 0 ? inside[0].value : ''
|
|
67924
|
+
const open = encodeInfo(
|
|
67925
|
+
outsideBefore.charCodeAt(outsideBefore.length - 1),
|
|
67926
|
+
head.charCodeAt(0),
|
|
67927
|
+
marker
|
|
67928
|
+
)
|
|
67929
|
+
|
|
67930
|
+
if (open.inside) container_phrasing_encode(inside, true)
|
|
67931
|
+
|
|
67932
|
+
const tail =
|
|
67933
|
+
inside.length > 0 ? lastCharacter(inside[inside.length - 1].value) : ''
|
|
67934
|
+
const close = encodeInfo(
|
|
67935
|
+
outsideAfter.charCodeAt(0),
|
|
67936
|
+
tail.charCodeAt(tail.length - 1),
|
|
67937
|
+
marker
|
|
67938
|
+
)
|
|
67939
|
+
|
|
67940
|
+
if (close.inside) container_phrasing_encode(inside, false)
|
|
67941
|
+
|
|
67942
|
+
if (open.outside && outsideBefore !== '\n' && outsideBefore !== '\r') {
|
|
67943
|
+
container_phrasing_encode(tokens, false)
|
|
67944
|
+
}
|
|
67945
|
+
|
|
67946
|
+
if (close.outside) encodeAfter = outsideAfter
|
|
67947
|
+
|
|
67948
|
+
tokens.push({value: sequence, attention: item}, ...inside, {
|
|
67949
|
+
value: sequence,
|
|
67950
|
+
attention: item
|
|
67951
|
+
})
|
|
67952
|
+
previous = sequence.charAt(sequence.length - 1)
|
|
67953
|
+
}
|
|
67954
|
+
|
|
67955
|
+
return tokens
|
|
67163
67956
|
}
|
|
67164
67957
|
|
|
67165
67958
|
/**
|
|
67166
|
-
*
|
|
67959
|
+
* Serialize phrasing with attention.
|
|
67960
|
+
*
|
|
67961
|
+
* Whether attention forms depends on everything around it.
|
|
67962
|
+
* This checks that it does and tries other sequences if not.
|
|
67167
67963
|
*
|
|
67964
|
+
* @param {Array<Item>} items
|
|
67965
|
+
* Phrasing items.
|
|
67966
|
+
* @param {string} before
|
|
67967
|
+
* Characters before.
|
|
67968
|
+
* @param {string} after
|
|
67969
|
+
* Characters after.
|
|
67168
67970
|
* @returns {string}
|
|
67169
|
-
*
|
|
67971
|
+
* Serialized markdown.
|
|
67170
67972
|
*/
|
|
67171
|
-
function
|
|
67172
|
-
|
|
67973
|
+
function container_phrasing_serialize(items, before, after) {
|
|
67974
|
+
/** @type {Map<AttentionResult, string>} */
|
|
67975
|
+
let chosen = new Map()
|
|
67976
|
+
const initial = render(items, chosen, before, after)
|
|
67977
|
+
let tokens = initial
|
|
67978
|
+
let mistake = check(tokens, before, after)
|
|
67979
|
+
|
|
67980
|
+
while (mistake) {
|
|
67981
|
+
const next = improve(items, chosen, mistake, before, after)
|
|
67982
|
+
|
|
67983
|
+
if (!next) {
|
|
67984
|
+
tokens = initial
|
|
67985
|
+
break
|
|
67986
|
+
}
|
|
67987
|
+
|
|
67988
|
+
chosen = next.chosen
|
|
67989
|
+
tokens = next.tokens
|
|
67990
|
+
mistake = next.mistake
|
|
67991
|
+
}
|
|
67992
|
+
|
|
67993
|
+
// Join the tokens.
|
|
67994
|
+
let result = ''
|
|
67995
|
+
for (const token of tokens) result += token.value
|
|
67996
|
+
return result
|
|
67173
67997
|
}
|
|
67174
67998
|
|
|
67175
|
-
;// ../node_modules/mdast-util-to-markdown/lib/handle/
|
|
67999
|
+
;// ../node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
|
|
67176
68000
|
/**
|
|
67177
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
67178
|
-
* @import {
|
|
68001
|
+
* @import {AttentionInfo, Info, State} from 'mdast-util-to-markdown'
|
|
68002
|
+
* @import {Emphasis, Parents} from 'mdast'
|
|
67179
68003
|
*/
|
|
67180
68004
|
|
|
67181
|
-
|
|
68005
|
+
|
|
68006
|
+
|
|
68007
|
+
|
|
68008
|
+
emphasis_emphasis.attention = emphasis_attention
|
|
68009
|
+
emphasis_emphasis.peek = peek
|
|
67182
68010
|
|
|
67183
68011
|
/**
|
|
67184
|
-
* Serialize an
|
|
68012
|
+
* Serialize an emphasis node.
|
|
67185
68013
|
*
|
|
67186
|
-
*
|
|
68014
|
+
* Attention is properly handled by `containerPhrasing`.
|
|
68015
|
+
*
|
|
68016
|
+
* @param {Emphasis} node
|
|
67187
68017
|
* Node to serialize.
|
|
67188
68018
|
* @param {Parents | undefined} _
|
|
67189
68019
|
* Parent node.
|
|
@@ -67194,209 +68024,213 @@ image_reference_imageReference.peek = imageReferencePeek
|
|
|
67194
68024
|
* @returns {string}
|
|
67195
68025
|
* Serialized markdown.
|
|
67196
68026
|
*/
|
|
67197
|
-
function
|
|
67198
|
-
const
|
|
67199
|
-
const
|
|
67200
|
-
|
|
67201
|
-
const tracker = state.createTracker(info)
|
|
67202
|
-
let value = tracker.move('![')
|
|
67203
|
-
const alt = state.safe(node.alt, {
|
|
67204
|
-
before: value,
|
|
67205
|
-
after: ']',
|
|
67206
|
-
...tracker.current()
|
|
67207
|
-
})
|
|
67208
|
-
value += tracker.move(alt + '][')
|
|
67209
|
-
|
|
67210
|
-
subexit()
|
|
67211
|
-
// Hide that we’re in phrasing as things like attention or code cannot form
|
|
67212
|
-
// in references.
|
|
67213
|
-
// Character escapes and references *do* work.
|
|
67214
|
-
// It is important to know about other constructs, such as table cells.
|
|
67215
|
-
const stack = state.stack
|
|
67216
|
-
state.stack = stack.filter(function (d) {
|
|
67217
|
-
return d !== 'phrasing'
|
|
67218
|
-
})
|
|
67219
|
-
subexit = state.enter('reference')
|
|
67220
|
-
// Note: for proper tracking, we should reset the output positions when we end
|
|
67221
|
-
// up making a `shortcut` reference, because then there is no brace output.
|
|
67222
|
-
// Practically, in that case, there is no content, so it doesn’t matter that
|
|
67223
|
-
// we’ve tracked one too many characters.
|
|
67224
|
-
const reference = state.safe(state.associationId(node), {
|
|
67225
|
-
before: value,
|
|
67226
|
-
after: ']',
|
|
67227
|
-
...tracker.current()
|
|
67228
|
-
})
|
|
67229
|
-
subexit()
|
|
67230
|
-
state.stack = stack
|
|
68027
|
+
function emphasis_emphasis(node, _, state, info) {
|
|
68028
|
+
const exit = state.enter('phrasing')
|
|
68029
|
+
const item = attentionItem(node, emphasis_attention, state, state.createTracker(info))
|
|
68030
|
+
const value = container_phrasing_serialize([item], info.before, info.after)
|
|
67231
68031
|
exit()
|
|
68032
|
+
return value
|
|
68033
|
+
}
|
|
67232
68034
|
|
|
67233
|
-
|
|
67234
|
-
|
|
67235
|
-
|
|
67236
|
-
|
|
67237
|
-
|
|
67238
|
-
|
|
67239
|
-
|
|
68035
|
+
/**
|
|
68036
|
+
* Serialize an emphasis node as attention.
|
|
68037
|
+
*
|
|
68038
|
+
* @param {Emphasis} _
|
|
68039
|
+
* Node to serialize.
|
|
68040
|
+
* @param {State} state
|
|
68041
|
+
* Info passed around.
|
|
68042
|
+
* @returns {AttentionInfo}
|
|
68043
|
+
* Info on how to serialize the node.
|
|
68044
|
+
*/
|
|
68045
|
+
function emphasis_attention(_, state) {
|
|
68046
|
+
const marker = checkEmphasis(state)
|
|
68047
|
+
return {
|
|
68048
|
+
construct: 'emphasis',
|
|
68049
|
+
markers: marker === '*' ? ['*', '_'] : ['_', '*'],
|
|
68050
|
+
sizes: [1]
|
|
67240
68051
|
}
|
|
67241
|
-
|
|
67242
|
-
return value
|
|
67243
68052
|
}
|
|
67244
68053
|
|
|
67245
68054
|
/**
|
|
67246
68055
|
* Peek at this node.
|
|
67247
68056
|
*
|
|
68057
|
+
* @param {Emphasis} _
|
|
68058
|
+
* Node to serialize.
|
|
68059
|
+
* @param {Parents | undefined} _1
|
|
68060
|
+
* Parent node.
|
|
68061
|
+
* @param {State} state
|
|
68062
|
+
* Info passed around.
|
|
67248
68063
|
* @returns {string}
|
|
67249
68064
|
* Start of the serialized markdown.
|
|
67250
68065
|
*/
|
|
67251
|
-
function
|
|
67252
|
-
return '
|
|
68066
|
+
function peek(_, _1, state) {
|
|
68067
|
+
return state.options.emphasis || '*'
|
|
67253
68068
|
}
|
|
67254
68069
|
|
|
67255
|
-
;// ../node_modules/mdast-util-to-markdown/lib/
|
|
68070
|
+
;// ../node_modules/mdast-util-to-markdown/node_modules/mdast-util-to-string/lib/index.js
|
|
67256
68071
|
/**
|
|
67257
|
-
* @
|
|
67258
|
-
*
|
|
68072
|
+
* @typedef {import('mdast').Nodes} Nodes
|
|
68073
|
+
*
|
|
68074
|
+
* @typedef Options
|
|
68075
|
+
* Configuration (optional).
|
|
68076
|
+
* @property {boolean | null | undefined} [includeImageAlt=true]
|
|
68077
|
+
* Whether to use `alt` for `image`s (default: `true`).
|
|
68078
|
+
* @property {boolean | null | undefined} [includeHtml=true]
|
|
68079
|
+
* Whether to use `value` of HTML (default: `true`).
|
|
67259
68080
|
*/
|
|
67260
68081
|
|
|
67261
|
-
|
|
68082
|
+
/** @type {Options} */
|
|
68083
|
+
const node_modules_mdast_util_to_string_lib_emptyOptions = {}
|
|
67262
68084
|
|
|
67263
68085
|
/**
|
|
67264
|
-
*
|
|
68086
|
+
* Get the text content of a node or list of nodes.
|
|
67265
68087
|
*
|
|
67266
|
-
*
|
|
67267
|
-
*
|
|
67268
|
-
*
|
|
67269
|
-
*
|
|
67270
|
-
*
|
|
67271
|
-
*
|
|
68088
|
+
* Prefers the node’s plain-text fields, otherwise serializes its children,
|
|
68089
|
+
* and if the given value is an array, serialize the nodes in it.
|
|
68090
|
+
*
|
|
68091
|
+
* @param {unknown} [value]
|
|
68092
|
+
* Thing to serialize, typically `Node`.
|
|
68093
|
+
* @param {Options | null | undefined} [options]
|
|
68094
|
+
* Configuration (optional).
|
|
67272
68095
|
* @returns {string}
|
|
67273
|
-
* Serialized
|
|
68096
|
+
* Serialized `value`.
|
|
67274
68097
|
*/
|
|
67275
|
-
function
|
|
67276
|
-
|
|
67277
|
-
|
|
67278
|
-
|
|
68098
|
+
function node_modules_mdast_util_to_string_lib_toString(value, options) {
|
|
68099
|
+
const settings = options || node_modules_mdast_util_to_string_lib_emptyOptions
|
|
68100
|
+
const includeImageAlt =
|
|
68101
|
+
typeof settings.includeImageAlt === 'boolean'
|
|
68102
|
+
? settings.includeImageAlt
|
|
68103
|
+
: true
|
|
68104
|
+
const includeHtml =
|
|
68105
|
+
typeof settings.includeHtml === 'boolean' ? settings.includeHtml : true
|
|
67279
68106
|
|
|
67280
|
-
|
|
67281
|
-
|
|
67282
|
-
// If there are two in a row, use one.
|
|
67283
|
-
while (new RegExp('(^|[^`])' + sequence + '([^`]|$)').test(value)) {
|
|
67284
|
-
sequence += '`'
|
|
67285
|
-
}
|
|
68107
|
+
return node_modules_mdast_util_to_string_lib_one(value, includeImageAlt, includeHtml)
|
|
68108
|
+
}
|
|
67286
68109
|
|
|
67287
|
-
|
|
67288
|
-
|
|
67289
|
-
|
|
67290
|
-
|
|
67291
|
-
|
|
67292
|
-
|
|
67293
|
-
|
|
67294
|
-
|
|
68110
|
+
/**
|
|
68111
|
+
* One node or several nodes.
|
|
68112
|
+
*
|
|
68113
|
+
* @param {unknown} value
|
|
68114
|
+
* Thing to serialize.
|
|
68115
|
+
* @param {boolean} includeImageAlt
|
|
68116
|
+
* Include image `alt`s.
|
|
68117
|
+
* @param {boolean} includeHtml
|
|
68118
|
+
* Include HTML.
|
|
68119
|
+
* @returns {string}
|
|
68120
|
+
* Serialized node.
|
|
68121
|
+
*/
|
|
68122
|
+
function node_modules_mdast_util_to_string_lib_one(value, includeImageAlt, includeHtml) {
|
|
68123
|
+
if (mdast_util_to_string_lib_node(value)) {
|
|
68124
|
+
if ('value' in value) {
|
|
68125
|
+
return value.type === 'html' && !includeHtml ? '' : value.value
|
|
68126
|
+
}
|
|
67295
68127
|
|
|
67296
|
-
|
|
67297
|
-
|
|
67298
|
-
|
|
67299
|
-
// result in an ATX heading.
|
|
67300
|
-
// We can’t escape characters in `inlineCode`, but because eols are
|
|
67301
|
-
// transformed to spaces when going from markdown to HTML anyway, we can swap
|
|
67302
|
-
// them out.
|
|
67303
|
-
while (++index < state.unsafe.length) {
|
|
67304
|
-
const pattern = state.unsafe[index]
|
|
67305
|
-
const expression = state.compilePattern(pattern)
|
|
68128
|
+
if (includeImageAlt && 'alt' in value && value.alt) {
|
|
68129
|
+
return value.alt
|
|
68130
|
+
}
|
|
67306
68131
|
|
|
67307
|
-
|
|
67308
|
-
|
|
67309
|
-
|
|
67310
|
-
|
|
68132
|
+
if ('children' in value) {
|
|
68133
|
+
return node_modules_mdast_util_to_string_lib_all(value.children, includeImageAlt, includeHtml)
|
|
68134
|
+
}
|
|
68135
|
+
}
|
|
67311
68136
|
|
|
67312
|
-
|
|
67313
|
-
|
|
68137
|
+
if (Array.isArray(value)) {
|
|
68138
|
+
return node_modules_mdast_util_to_string_lib_all(value, includeImageAlt, includeHtml)
|
|
68139
|
+
}
|
|
67314
68140
|
|
|
67315
|
-
|
|
67316
|
-
|
|
68141
|
+
return ''
|
|
68142
|
+
}
|
|
67317
68143
|
|
|
67318
|
-
|
|
67319
|
-
|
|
67320
|
-
|
|
67321
|
-
|
|
67322
|
-
|
|
67323
|
-
|
|
67324
|
-
|
|
68144
|
+
/**
|
|
68145
|
+
* Serialize a list of nodes.
|
|
68146
|
+
*
|
|
68147
|
+
* @param {Array<unknown>} values
|
|
68148
|
+
* Thing to serialize.
|
|
68149
|
+
* @param {boolean} includeImageAlt
|
|
68150
|
+
* Include image `alt`s.
|
|
68151
|
+
* @param {boolean} includeHtml
|
|
68152
|
+
* Include HTML.
|
|
68153
|
+
* @returns {string}
|
|
68154
|
+
* Serialized nodes.
|
|
68155
|
+
*/
|
|
68156
|
+
function node_modules_mdast_util_to_string_lib_all(values, includeImageAlt, includeHtml) {
|
|
68157
|
+
/** @type {Array<string>} */
|
|
68158
|
+
const result = []
|
|
68159
|
+
let index = -1
|
|
67325
68160
|
|
|
67326
|
-
|
|
67327
|
-
|
|
68161
|
+
while (++index < values.length) {
|
|
68162
|
+
result[index] = node_modules_mdast_util_to_string_lib_one(values[index], includeImageAlt, includeHtml)
|
|
67328
68163
|
}
|
|
67329
68164
|
|
|
67330
|
-
return
|
|
68165
|
+
return result.join('')
|
|
67331
68166
|
}
|
|
67332
68167
|
|
|
67333
68168
|
/**
|
|
67334
|
-
*
|
|
68169
|
+
* Check if `value` looks like a node.
|
|
67335
68170
|
*
|
|
67336
|
-
* @
|
|
67337
|
-
*
|
|
68171
|
+
* @param {unknown} value
|
|
68172
|
+
* Thing.
|
|
68173
|
+
* @returns {value is Nodes}
|
|
68174
|
+
* Whether `value` is a node.
|
|
67338
68175
|
*/
|
|
67339
|
-
function
|
|
67340
|
-
return '
|
|
68176
|
+
function mdast_util_to_string_lib_node(value) {
|
|
68177
|
+
return Boolean(value && typeof value === 'object')
|
|
67341
68178
|
}
|
|
67342
68179
|
|
|
67343
|
-
;// ../node_modules/mdast-util-to-markdown/lib/util/format-
|
|
68180
|
+
;// ../node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
|
|
67344
68181
|
/**
|
|
67345
68182
|
* @import {State} from 'mdast-util-to-markdown'
|
|
67346
|
-
* @import {
|
|
68183
|
+
* @import {Heading} from 'mdast'
|
|
67347
68184
|
*/
|
|
67348
68185
|
|
|
67349
68186
|
|
|
67350
68187
|
|
|
68188
|
+
|
|
67351
68189
|
/**
|
|
67352
|
-
* Checks if a
|
|
68190
|
+
* Checks if a heading can be formatted as a setext heading.
|
|
67353
68191
|
*
|
|
67354
|
-
* @param {
|
|
68192
|
+
* @param {Heading} node
|
|
67355
68193
|
* Node to check.
|
|
67356
68194
|
* @param {State} state
|
|
67357
68195
|
* Info passed around.
|
|
67358
68196
|
* @returns {boolean}
|
|
67359
|
-
* Whether the
|
|
68197
|
+
* Whether the heading can be formatted as a setext heading.
|
|
67360
68198
|
*/
|
|
67361
|
-
function
|
|
67362
|
-
|
|
68199
|
+
function formatHeadingAsSetext(node, state) {
|
|
68200
|
+
let literalWithBreak = false
|
|
68201
|
+
|
|
68202
|
+
// Look for literals with a line break.
|
|
68203
|
+
// Note that this also
|
|
68204
|
+
visit(node, function (node) {
|
|
68205
|
+
if (
|
|
68206
|
+
('value' in node && /\r?\n|\r/.test(node.value)) ||
|
|
68207
|
+
node.type === 'break'
|
|
68208
|
+
) {
|
|
68209
|
+
literalWithBreak = true
|
|
68210
|
+
return (/* inlined export .EXIT */false)
|
|
68211
|
+
}
|
|
68212
|
+
})
|
|
67363
68213
|
|
|
67364
68214
|
return Boolean(
|
|
67365
|
-
!
|
|
67366
|
-
|
|
67367
|
-
|
|
67368
|
-
// And there’s no title…
|
|
67369
|
-
!node.title &&
|
|
67370
|
-
// And the content of `node` is a single text node…
|
|
67371
|
-
node.children &&
|
|
67372
|
-
node.children.length === 1 &&
|
|
67373
|
-
node.children[0].type === 'text' &&
|
|
67374
|
-
// And if the url is the same as the content…
|
|
67375
|
-
(raw === node.url || 'mailto:' + raw === node.url) &&
|
|
67376
|
-
// And that starts w/ a protocol…
|
|
67377
|
-
/^[a-z][+\-.a-z]+:/i.test(node.url) &&
|
|
67378
|
-
// And that doesn’t contain ASCII control codes (character escapes and
|
|
67379
|
-
// references don’t work), space, or angle brackets…
|
|
67380
|
-
!/[\0- <>\u007F]/.test(node.url)
|
|
68215
|
+
(!node.depth || node.depth < 3) &&
|
|
68216
|
+
node_modules_mdast_util_to_string_lib_toString(node) &&
|
|
68217
|
+
(state.options.setext || literalWithBreak)
|
|
67381
68218
|
)
|
|
67382
68219
|
}
|
|
67383
68220
|
|
|
67384
|
-
;// ../node_modules/mdast-util-to-markdown/lib/handle/
|
|
68221
|
+
;// ../node_modules/mdast-util-to-markdown/lib/handle/heading.js
|
|
67385
68222
|
/**
|
|
67386
68223
|
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
67387
|
-
* @import {
|
|
67388
|
-
* @import {Exit} from '../types.js'
|
|
68224
|
+
* @import {Heading, Parents} from 'mdast'
|
|
67389
68225
|
*/
|
|
67390
68226
|
|
|
67391
68227
|
|
|
67392
68228
|
|
|
67393
68229
|
|
|
67394
|
-
handle_link_link.peek = linkPeek
|
|
67395
|
-
|
|
67396
68230
|
/**
|
|
67397
|
-
* Serialize a
|
|
68231
|
+
* Serialize a heading node.
|
|
67398
68232
|
*
|
|
67399
|
-
* @param {
|
|
68233
|
+
* @param {Heading} node
|
|
67400
68234
|
* Node to serialize.
|
|
67401
68235
|
* @param {Parents | undefined} _
|
|
67402
68236
|
* Parent node.
|
|
@@ -67407,47 +68241,134 @@ handle_link_link.peek = linkPeek
|
|
|
67407
68241
|
* @returns {string}
|
|
67408
68242
|
* Serialized markdown.
|
|
67409
68243
|
*/
|
|
67410
|
-
function
|
|
67411
|
-
const
|
|
67412
|
-
const suffix = quote === '"' ? 'Quote' : 'Apostrophe'
|
|
68244
|
+
function heading_heading(node, _, state, info) {
|
|
68245
|
+
const rank = Math.max(Math.min(6, node.depth || 1), 1)
|
|
67413
68246
|
const tracker = state.createTracker(info)
|
|
67414
68247
|
|
|
67415
|
-
if (
|
|
67416
|
-
|
|
67417
|
-
|
|
67418
|
-
|
|
67419
|
-
|
|
67420
|
-
|
|
67421
|
-
|
|
67422
|
-
state.stack = stack.filter(function (d) {
|
|
67423
|
-
return d !== 'phrasing'
|
|
68248
|
+
if (formatHeadingAsSetext(node, state)) {
|
|
68249
|
+
const exit = state.enter('headingSetext')
|
|
68250
|
+
const subexit = state.enter('phrasing')
|
|
68251
|
+
const value = state.containerPhrasing(node, {
|
|
68252
|
+
...tracker.current(),
|
|
68253
|
+
before: '\n',
|
|
68254
|
+
after: '\n'
|
|
67424
68255
|
})
|
|
67425
|
-
|
|
67426
|
-
let value = tracker.move('<')
|
|
67427
|
-
value += tracker.move(
|
|
67428
|
-
state.containerPhrasing(node, {
|
|
67429
|
-
before: value,
|
|
67430
|
-
after: '>',
|
|
67431
|
-
...tracker.current()
|
|
67432
|
-
})
|
|
67433
|
-
)
|
|
67434
|
-
value += tracker.move('>')
|
|
68256
|
+
subexit()
|
|
67435
68257
|
exit()
|
|
67436
|
-
|
|
67437
|
-
return
|
|
68258
|
+
|
|
68259
|
+
return (
|
|
68260
|
+
value +
|
|
68261
|
+
'\n' +
|
|
68262
|
+
(rank === 1 ? '=' : '-').repeat(
|
|
68263
|
+
// The whole size…
|
|
68264
|
+
value.length -
|
|
68265
|
+
// Minus the position of the character after the last EOL (or
|
|
68266
|
+
// 0 if there is none)…
|
|
68267
|
+
(Math.max(value.lastIndexOf('\r'), value.lastIndexOf('\n')) + 1)
|
|
68268
|
+
)
|
|
68269
|
+
)
|
|
67438
68270
|
}
|
|
67439
68271
|
|
|
67440
|
-
const
|
|
68272
|
+
const sequence = '#'.repeat(rank)
|
|
68273
|
+
const exit = state.enter('headingAtx')
|
|
68274
|
+
const subexit = state.enter('phrasing')
|
|
68275
|
+
|
|
68276
|
+
// Note: for proper tracking, we should reset the output positions when there
|
|
68277
|
+
// is no content returned, because then the space is not output.
|
|
68278
|
+
// Practically, in that case, there is no content, so it doesn’t matter that
|
|
68279
|
+
// we’ve tracked one too many characters.
|
|
68280
|
+
tracker.move(sequence + ' ')
|
|
68281
|
+
|
|
68282
|
+
let value = state.containerPhrasing(node, {
|
|
68283
|
+
before: '# ',
|
|
68284
|
+
after: '\n',
|
|
68285
|
+
...tracker.current()
|
|
68286
|
+
})
|
|
68287
|
+
|
|
68288
|
+
const head = value.charCodeAt(0)
|
|
68289
|
+
|
|
68290
|
+
if (head === 9 /* `\t` */ || head === 32 /* ` ` */) {
|
|
68291
|
+
// To do: what effect has the character reference on tracking?
|
|
68292
|
+
value = encodeCharacterReference(head) + value.slice(1)
|
|
68293
|
+
}
|
|
68294
|
+
|
|
68295
|
+
value = value ? sequence + ' ' + value : sequence
|
|
68296
|
+
|
|
68297
|
+
if (state.options.closeAtx) {
|
|
68298
|
+
value += ' ' + sequence
|
|
68299
|
+
}
|
|
68300
|
+
|
|
68301
|
+
subexit()
|
|
68302
|
+
exit()
|
|
68303
|
+
|
|
68304
|
+
return value
|
|
68305
|
+
}
|
|
68306
|
+
|
|
68307
|
+
;// ../node_modules/mdast-util-to-markdown/lib/handle/html.js
|
|
68308
|
+
/**
|
|
68309
|
+
* @import {Html} from 'mdast'
|
|
68310
|
+
*/
|
|
68311
|
+
|
|
68312
|
+
handle_html_html.peek = htmlPeek
|
|
68313
|
+
|
|
68314
|
+
/**
|
|
68315
|
+
* Serialize an HTML node.
|
|
68316
|
+
*
|
|
68317
|
+
* @param {Html} node
|
|
68318
|
+
* Node to serialize.
|
|
68319
|
+
* @returns {string}
|
|
68320
|
+
* Serialized markdown.
|
|
68321
|
+
*/
|
|
68322
|
+
function handle_html_html(node) {
|
|
68323
|
+
return node.value || ''
|
|
68324
|
+
}
|
|
68325
|
+
|
|
68326
|
+
/**
|
|
68327
|
+
* Peek at this node.
|
|
68328
|
+
*
|
|
68329
|
+
* @returns {string}
|
|
68330
|
+
* Start of the serialized markdown.
|
|
68331
|
+
*/
|
|
68332
|
+
function htmlPeek() {
|
|
68333
|
+
return '<'
|
|
68334
|
+
}
|
|
68335
|
+
|
|
68336
|
+
;// ../node_modules/mdast-util-to-markdown/lib/handle/image.js
|
|
68337
|
+
/**
|
|
68338
|
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
68339
|
+
* @import {Image, Parents} from 'mdast'
|
|
68340
|
+
*/
|
|
68341
|
+
|
|
68342
|
+
|
|
68343
|
+
|
|
68344
|
+
handle_image_image.peek = imagePeek
|
|
68345
|
+
|
|
68346
|
+
/**
|
|
68347
|
+
* Serialize an image node.
|
|
68348
|
+
*
|
|
68349
|
+
* @param {Image} node
|
|
68350
|
+
* Node to serialize.
|
|
68351
|
+
* @param {Parents | undefined} _
|
|
68352
|
+
* Parent node.
|
|
68353
|
+
* @param {State} state
|
|
68354
|
+
* Info passed around.
|
|
68355
|
+
* @param {Info} info
|
|
68356
|
+
* Info on surrounding context.
|
|
68357
|
+
* @returns {string}
|
|
68358
|
+
* Serialized markdown.
|
|
68359
|
+
*/
|
|
68360
|
+
function handle_image_image(node, _, state, info) {
|
|
68361
|
+
const quote = checkQuote(state)
|
|
68362
|
+
const suffix = quote === '"' ? 'Quote' : 'Apostrophe'
|
|
68363
|
+
const exit = state.enter('image')
|
|
67441
68364
|
let subexit = state.enter('label')
|
|
67442
|
-
|
|
68365
|
+
const tracker = state.createTracker(info)
|
|
68366
|
+
let value = tracker.move('
|
|
67448
|
-
})
|
|
68368
|
+
state.safe(node.alt, {before: value, after: ']', ...tracker.current()})
|
|
67449
68369
|
)
|
|
67450
68370
|
value += tracker.move('](')
|
|
68371
|
+
|
|
67451
68372
|
subexit()
|
|
67452
68373
|
|
|
67453
68374
|
if (
|
|
@@ -67490,6 +68411,375 @@ function handle_link_link(node, _, state, info) {
|
|
|
67490
68411
|
subexit()
|
|
67491
68412
|
}
|
|
67492
68413
|
|
|
68414
|
+
value += tracker.move(')')
|
|
68415
|
+
exit()
|
|
68416
|
+
|
|
68417
|
+
return value
|
|
68418
|
+
}
|
|
68419
|
+
|
|
68420
|
+
/**
|
|
68421
|
+
* Peek at this node.
|
|
68422
|
+
*
|
|
68423
|
+
* @returns {string}
|
|
68424
|
+
* Start of the serialized markdown.
|
|
68425
|
+
*/
|
|
68426
|
+
function imagePeek() {
|
|
68427
|
+
return '!'
|
|
68428
|
+
}
|
|
68429
|
+
|
|
68430
|
+
;// ../node_modules/mdast-util-to-markdown/lib/handle/image-reference.js
|
|
68431
|
+
/**
|
|
68432
|
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
68433
|
+
* @import {ImageReference, Parents} from 'mdast'
|
|
68434
|
+
*/
|
|
68435
|
+
|
|
68436
|
+
image_reference_imageReference.peek = imageReferencePeek
|
|
68437
|
+
|
|
68438
|
+
/**
|
|
68439
|
+
* Serialize an image reference node.
|
|
68440
|
+
*
|
|
68441
|
+
* @param {ImageReference} node
|
|
68442
|
+
* Node to serialize.
|
|
68443
|
+
* @param {Parents | undefined} _
|
|
68444
|
+
* Parent node.
|
|
68445
|
+
* @param {State} state
|
|
68446
|
+
* Info passed around.
|
|
68447
|
+
* @param {Info} info
|
|
68448
|
+
* Info on surrounding context.
|
|
68449
|
+
* @returns {string}
|
|
68450
|
+
* Serialized markdown.
|
|
68451
|
+
*/
|
|
68452
|
+
function image_reference_imageReference(node, _, state, info) {
|
|
68453
|
+
const type = node.referenceType
|
|
68454
|
+
const exit = state.enter('imageReference')
|
|
68455
|
+
let subexit = state.enter('label')
|
|
68456
|
+
const tracker = state.createTracker(info)
|
|
68457
|
+
let value = tracker.move('![')
|
|
68458
|
+
const alt = state.safe(node.alt, {
|
|
68459
|
+
before: value,
|
|
68460
|
+
after: ']',
|
|
68461
|
+
...tracker.current()
|
|
68462
|
+
})
|
|
68463
|
+
value += tracker.move(alt + '][')
|
|
68464
|
+
|
|
68465
|
+
subexit()
|
|
68466
|
+
// Hide that we’re in phrasing as things like attention or code cannot form
|
|
68467
|
+
// in references.
|
|
68468
|
+
// Character escapes and references *do* work.
|
|
68469
|
+
// It is important to know about other constructs, such as table cells.
|
|
68470
|
+
const stack = state.stack
|
|
68471
|
+
state.stack = stack.filter(function (d) {
|
|
68472
|
+
return d !== 'phrasing'
|
|
68473
|
+
})
|
|
68474
|
+
subexit = state.enter('reference')
|
|
68475
|
+
// Note: for proper tracking, we should reset the output positions when we end
|
|
68476
|
+
// up making a `shortcut` reference, because then there is no brace output.
|
|
68477
|
+
// Practically, in that case, there is no content, so it doesn’t matter that
|
|
68478
|
+
// we’ve tracked one too many characters.
|
|
68479
|
+
const reference = state.safe(state.associationId(node), {
|
|
68480
|
+
before: value,
|
|
68481
|
+
after: ']',
|
|
68482
|
+
...tracker.current()
|
|
68483
|
+
})
|
|
68484
|
+
subexit()
|
|
68485
|
+
state.stack = stack
|
|
68486
|
+
exit()
|
|
68487
|
+
|
|
68488
|
+
if (type === 'full' || !alt || alt !== reference) {
|
|
68489
|
+
value += tracker.move(reference + ']')
|
|
68490
|
+
} else if (type === 'shortcut') {
|
|
68491
|
+
// Remove the unwanted `[`.
|
|
68492
|
+
value = value.slice(0, -1)
|
|
68493
|
+
} else {
|
|
68494
|
+
value += tracker.move(']')
|
|
68495
|
+
}
|
|
68496
|
+
|
|
68497
|
+
return value
|
|
68498
|
+
}
|
|
68499
|
+
|
|
68500
|
+
/**
|
|
68501
|
+
* Peek at this node.
|
|
68502
|
+
*
|
|
68503
|
+
* @returns {string}
|
|
68504
|
+
* Start of the serialized markdown.
|
|
68505
|
+
*/
|
|
68506
|
+
function imageReferencePeek() {
|
|
68507
|
+
return '!'
|
|
68508
|
+
}
|
|
68509
|
+
|
|
68510
|
+
;// ../node_modules/mdast-util-to-markdown/lib/handle/inline-code.js
|
|
68511
|
+
/**
|
|
68512
|
+
* @import {State} from 'mdast-util-to-markdown'
|
|
68513
|
+
* @import {InlineCode, Parents} from 'mdast'
|
|
68514
|
+
*/
|
|
68515
|
+
|
|
68516
|
+
inline_code_inlineCode.peek = inlineCodePeek
|
|
68517
|
+
|
|
68518
|
+
/**
|
|
68519
|
+
* Serialize an inline code node.
|
|
68520
|
+
*
|
|
68521
|
+
* @param {InlineCode} node
|
|
68522
|
+
* Node to serialize.
|
|
68523
|
+
* @param {Parents | undefined} _
|
|
68524
|
+
* Parent node.
|
|
68525
|
+
* @param {State} state
|
|
68526
|
+
* Info passed around.
|
|
68527
|
+
* @returns {string}
|
|
68528
|
+
* Serialized markdown.
|
|
68529
|
+
*/
|
|
68530
|
+
function inline_code_inlineCode(node, _, state) {
|
|
68531
|
+
let value = node.value || ''
|
|
68532
|
+
let sequence = '`'
|
|
68533
|
+
let index = -1
|
|
68534
|
+
|
|
68535
|
+
// If there is a single grave accent on its own in the code, use a fence of
|
|
68536
|
+
// two.
|
|
68537
|
+
// If there are two in a row, use one.
|
|
68538
|
+
while (new RegExp('(^|[^`])' + sequence + '([^`]|$)').test(value)) {
|
|
68539
|
+
sequence += '`'
|
|
68540
|
+
}
|
|
68541
|
+
|
|
68542
|
+
// If this is not just spaces or eols (tabs don’t count), and either the
|
|
68543
|
+
// first or last character are a space, eol, or tick, then pad with spaces.
|
|
68544
|
+
if (
|
|
68545
|
+
/[^\n\r ]/.test(value) &&
|
|
68546
|
+
((/^[\n\r ]/.test(value) && /[\n\r ]$/.test(value)) || /^`|`$/.test(value))
|
|
68547
|
+
) {
|
|
68548
|
+
value = ' ' + value + ' '
|
|
68549
|
+
}
|
|
68550
|
+
|
|
68551
|
+
// We have a potential problem: certain characters after eols could result in
|
|
68552
|
+
// blocks being seen.
|
|
68553
|
+
// For example, if someone injected the string `'\n# b'`, then that would
|
|
68554
|
+
// result in an ATX heading.
|
|
68555
|
+
// We can’t escape characters in `inlineCode`, but because eols are
|
|
68556
|
+
// transformed to spaces when going from markdown to HTML anyway, we can swap
|
|
68557
|
+
// them out.
|
|
68558
|
+
while (++index < state.unsafe.length) {
|
|
68559
|
+
const pattern = state.unsafe[index]
|
|
68560
|
+
const expression = state.compilePattern(pattern)
|
|
68561
|
+
|
|
68562
|
+
// Only look for `atBreak`s.
|
|
68563
|
+
// Btw: note that `atBreak` patterns will always start the regex at LF or
|
|
68564
|
+
// CR.
|
|
68565
|
+
if (!pattern.atBreak) continue
|
|
68566
|
+
|
|
68567
|
+
/** @type {RegExpExecArray | null} */
|
|
68568
|
+
let match
|
|
68569
|
+
|
|
68570
|
+
while ((match = expression.exec(value))) {
|
|
68571
|
+
let position = match.index
|
|
68572
|
+
|
|
68573
|
+
// Support CRLF (patterns only look for one of the characters).
|
|
68574
|
+
if (
|
|
68575
|
+
value.charCodeAt(position) === 10 /* `\n` */ &&
|
|
68576
|
+
value.charCodeAt(position - 1) === 13 /* `\r` */
|
|
68577
|
+
) {
|
|
68578
|
+
position--
|
|
68579
|
+
}
|
|
68580
|
+
|
|
68581
|
+
value = value.slice(0, position) + ' ' + value.slice(match.index + 1)
|
|
68582
|
+
}
|
|
68583
|
+
}
|
|
68584
|
+
|
|
68585
|
+
return sequence + value + sequence
|
|
68586
|
+
}
|
|
68587
|
+
|
|
68588
|
+
/**
|
|
68589
|
+
* Peek at this node.
|
|
68590
|
+
*
|
|
68591
|
+
* @returns {string}
|
|
68592
|
+
* Start of the serialized markdown.
|
|
68593
|
+
*/
|
|
68594
|
+
function inlineCodePeek() {
|
|
68595
|
+
return '`'
|
|
68596
|
+
}
|
|
68597
|
+
|
|
68598
|
+
;// ../node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.js
|
|
68599
|
+
/**
|
|
68600
|
+
* @import {State} from 'mdast-util-to-markdown'
|
|
68601
|
+
* @import {Link} from 'mdast'
|
|
68602
|
+
*/
|
|
68603
|
+
|
|
68604
|
+
|
|
68605
|
+
|
|
68606
|
+
/**
|
|
68607
|
+
* Checks if a link can be formatted as an autolink.
|
|
68608
|
+
*
|
|
68609
|
+
* @param {Link} node
|
|
68610
|
+
* Node to check.
|
|
68611
|
+
* @param {State} state
|
|
68612
|
+
* Info passed around.
|
|
68613
|
+
* @returns {boolean}
|
|
68614
|
+
* Whether the link can be formatted as an autolink.
|
|
68615
|
+
*/
|
|
68616
|
+
function formatLinkAsAutolink(node, state) {
|
|
68617
|
+
const raw = node_modules_mdast_util_to_string_lib_toString(node)
|
|
68618
|
+
|
|
68619
|
+
return Boolean(
|
|
68620
|
+
!state.options.resourceLink &&
|
|
68621
|
+
// If there’s a url…
|
|
68622
|
+
node.url &&
|
|
68623
|
+
// And there’s no title…
|
|
68624
|
+
!node.title &&
|
|
68625
|
+
// And the content of `node` is a single text node…
|
|
68626
|
+
node.children &&
|
|
68627
|
+
node.children.length === 1 &&
|
|
68628
|
+
node.children[0].type === 'text' &&
|
|
68629
|
+
// And if the url is the same as the content…
|
|
68630
|
+
(raw === node.url || 'mailto:' + raw === node.url) &&
|
|
68631
|
+
// And that starts w/ a protocol…
|
|
68632
|
+
/^[a-z][+\-.a-z]+:/i.test(node.url) &&
|
|
68633
|
+
// And that doesn’t contain ASCII control codes (character escapes and
|
|
68634
|
+
// references don’t work), space, or angle brackets…
|
|
68635
|
+
!/[\0- <>\u007F]/.test(node.url)
|
|
68636
|
+
)
|
|
68637
|
+
}
|
|
68638
|
+
|
|
68639
|
+
;// ../node_modules/mdast-util-to-markdown/lib/handle/link.js
|
|
68640
|
+
/**
|
|
68641
|
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
68642
|
+
* @import {Link, Parents} from 'mdast'
|
|
68643
|
+
* @import {Exit} from '../types.js'
|
|
68644
|
+
*/
|
|
68645
|
+
|
|
68646
|
+
|
|
68647
|
+
|
|
68648
|
+
|
|
68649
|
+
handle_link_link.peek = linkPeek
|
|
68650
|
+
|
|
68651
|
+
/**
|
|
68652
|
+
* Serialize a link node.
|
|
68653
|
+
*
|
|
68654
|
+
* @param {Link} node
|
|
68655
|
+
* Node to serialize.
|
|
68656
|
+
* @param {Parents | undefined} _
|
|
68657
|
+
* Parent node.
|
|
68658
|
+
* @param {State} state
|
|
68659
|
+
* Info passed around.
|
|
68660
|
+
* @param {Info} info
|
|
68661
|
+
* Info on surrounding context.
|
|
68662
|
+
* @returns {string}
|
|
68663
|
+
* Serialized markdown.
|
|
68664
|
+
*/
|
|
68665
|
+
function handle_link_link(node, _, state, info) {
|
|
68666
|
+
const quote = checkQuote(state)
|
|
68667
|
+
const suffix = quote === '"' ? 'Quote' : 'Apostrophe'
|
|
68668
|
+
const tracker = state.createTracker(info)
|
|
68669
|
+
|
|
68670
|
+
if (formatLinkAsAutolink(node, state)) {
|
|
68671
|
+
// Hide that we’re in phrasing as things like attention or code cannot form
|
|
68672
|
+
// in autolinks.
|
|
68673
|
+
// Character escapes also don’t work (nor character references),
|
|
68674
|
+
// but that is a different matter, which `safe.js` handles for `autolink`.
|
|
68675
|
+
// It is important to know about other constructs, such as table cells.
|
|
68676
|
+
const stack = state.stack
|
|
68677
|
+
state.stack = stack.filter(function (d) {
|
|
68678
|
+
return d !== 'phrasing'
|
|
68679
|
+
})
|
|
68680
|
+
const exit = state.enter('autolink')
|
|
68681
|
+
let value = tracker.move('<')
|
|
68682
|
+
value += tracker.move(
|
|
68683
|
+
state.containerPhrasing(node, {
|
|
68684
|
+
before: value,
|
|
68685
|
+
after: '>',
|
|
68686
|
+
...tracker.current()
|
|
68687
|
+
})
|
|
68688
|
+
)
|
|
68689
|
+
value += tracker.move('>')
|
|
68690
|
+
exit()
|
|
68691
|
+
state.stack = stack
|
|
68692
|
+
return value
|
|
68693
|
+
}
|
|
68694
|
+
|
|
68695
|
+
const exit = state.enter('link')
|
|
68696
|
+
let subexit = state.enter('label')
|
|
68697
|
+
let value = tracker.move('[')
|
|
68698
|
+
const text = state.containerPhrasing(node, {
|
|
68699
|
+
before: value,
|
|
68700
|
+
after: '](',
|
|
68701
|
+
...tracker.current()
|
|
68702
|
+
})
|
|
68703
|
+
value += tracker.move(text)
|
|
68704
|
+
subexit()
|
|
68705
|
+
value += tracker.move('](')
|
|
68706
|
+
|
|
68707
|
+
// A link could accidentally turn into a definition in certain contexts:
|
|
68708
|
+
// at the start of a line, without title, when its text has a `]` that
|
|
68709
|
+
// cannot be escaped (such as in code).
|
|
68710
|
+
//
|
|
68711
|
+
// We can prevent that with an empty title:
|
|
68712
|
+
//
|
|
68713
|
+
// ```
|
|
68714
|
+
// [`a]:`](b)
|
|
68715
|
+
// ```
|
|
68716
|
+
//
|
|
68717
|
+
// …is a definition with `` `](b) `` as its destination.
|
|
68718
|
+
//
|
|
68719
|
+
// Using:
|
|
68720
|
+
//
|
|
68721
|
+
// ```
|
|
68722
|
+
// [`a]:`](b "")
|
|
68723
|
+
// ```
|
|
68724
|
+
//
|
|
68725
|
+
// …instead fixes it.
|
|
68726
|
+
//
|
|
68727
|
+
// Control characters or whitespace in the url need an enclosed destination,
|
|
68728
|
+
// which also prevents this.
|
|
68729
|
+
const enclose = /[\0- \u007F]/.test(node.url)
|
|
68730
|
+
const last = info.before.charAt(info.before.length - 1)
|
|
68731
|
+
let title = node.title || undefined
|
|
68732
|
+
|
|
68733
|
+
if (!title && !enclose && (last === '\n' || last === '\r')) {
|
|
68734
|
+
let index = 0
|
|
68735
|
+
|
|
68736
|
+
while (index < text.length && text.charCodeAt(index) !== 93 /* `]` */) {
|
|
68737
|
+
index += text.charCodeAt(index) === 92 /* `\` */ ? 2 : 1
|
|
68738
|
+
}
|
|
68739
|
+
|
|
68740
|
+
if (text.charCodeAt(index + 1) === 58 /* `:` */) title = ''
|
|
68741
|
+
}
|
|
68742
|
+
|
|
68743
|
+
if (
|
|
68744
|
+
// If there’s no url but there is a title…
|
|
68745
|
+
(!node.url && typeof title === 'string') ||
|
|
68746
|
+
// If there are control characters or whitespace.
|
|
68747
|
+
enclose
|
|
68748
|
+
) {
|
|
68749
|
+
subexit = state.enter('destinationLiteral')
|
|
68750
|
+
value += tracker.move('<')
|
|
68751
|
+
value += tracker.move(
|
|
68752
|
+
state.safe(node.url, {before: value, after: '>', ...tracker.current()})
|
|
68753
|
+
)
|
|
68754
|
+
value += tracker.move('>')
|
|
68755
|
+
} else {
|
|
68756
|
+
// No whitespace, raw is prettier.
|
|
68757
|
+
subexit = state.enter('destinationRaw')
|
|
68758
|
+
value += tracker.move(
|
|
68759
|
+
state.safe(node.url, {
|
|
68760
|
+
before: value,
|
|
68761
|
+
after: typeof title === 'string' ? ' ' : ')',
|
|
68762
|
+
...tracker.current()
|
|
68763
|
+
})
|
|
68764
|
+
)
|
|
68765
|
+
}
|
|
68766
|
+
|
|
68767
|
+
subexit()
|
|
68768
|
+
|
|
68769
|
+
if (typeof title === 'string') {
|
|
68770
|
+
subexit = state.enter(`title${suffix}`)
|
|
68771
|
+
value += tracker.move(' ' + quote)
|
|
68772
|
+
value += tracker.move(
|
|
68773
|
+
state.safe(title, {
|
|
68774
|
+
before: value,
|
|
68775
|
+
after: quote,
|
|
68776
|
+
...tracker.current()
|
|
68777
|
+
})
|
|
68778
|
+
)
|
|
68779
|
+
value += tracker.move(quote)
|
|
68780
|
+
subexit()
|
|
68781
|
+
}
|
|
68782
|
+
|
|
67493
68783
|
value += tracker.move(')')
|
|
67494
68784
|
|
|
67495
68785
|
exit()
|
|
@@ -67976,7 +69266,7 @@ function paragraph_paragraph(node, _, state, info) {
|
|
|
67976
69266
|
* Whether `value` is phrasing content.
|
|
67977
69267
|
*/
|
|
67978
69268
|
|
|
67979
|
-
const
|
|
69269
|
+
const lib_phrasing =
|
|
67980
69270
|
/** @type {(node?: unknown) => node is Exclude<PhrasingContent, Html>} */
|
|
67981
69271
|
(
|
|
67982
69272
|
convert([
|
|
@@ -68029,7 +69319,7 @@ const phrasing =
|
|
|
68029
69319
|
function handle_root_root(node, _, state, info) {
|
|
68030
69320
|
// Note: `html` nodes are ambiguous.
|
|
68031
69321
|
const hasPhrasing = node.children.some(function (d) {
|
|
68032
|
-
return
|
|
69322
|
+
return lib_phrasing(d)
|
|
68033
69323
|
})
|
|
68034
69324
|
|
|
68035
69325
|
if (!hasPhrasing) return state.containerFlow(node, info)
|
|
@@ -68075,6 +69365,7 @@ function checkStrong(state) {
|
|
|
68075
69365
|
|
|
68076
69366
|
|
|
68077
69367
|
|
|
69368
|
+
|
|
68078
69369
|
strong_strong.attention = strong_attention
|
|
68079
69370
|
strong_strong.peek = strong_peek
|
|
68080
69371
|
|
|
@@ -68096,7 +69387,8 @@ strong_strong.peek = strong_peek
|
|
|
68096
69387
|
*/
|
|
68097
69388
|
function strong_strong(node, _, state, info) {
|
|
68098
69389
|
const exit = state.enter('phrasing')
|
|
68099
|
-
const
|
|
69390
|
+
const item = attentionItem(node, strong_attention, state, state.createTracker(info))
|
|
69391
|
+
const value = container_phrasing_serialize([item], info.before, info.after)
|
|
68100
69392
|
exit()
|
|
68101
69393
|
return value
|
|
68102
69394
|
}
|
|
@@ -68159,7 +69451,7 @@ function strong_peek(_, _1, state) {
|
|
|
68159
69451
|
function handle_text_text(node, parent, state, info) {
|
|
68160
69452
|
/* c8 ignore next -- parent always passed */
|
|
68161
69453
|
const siblings = parent ? parent.children : []
|
|
68162
|
-
const index =
|
|
69454
|
+
const index = state.indexStack[state.indexStack.length - 1]
|
|
68163
69455
|
|
|
68164
69456
|
return state.safe(node.value, {
|
|
68165
69457
|
...info,
|
|
@@ -71394,7 +72686,7 @@ function micromark_extension_gfm_strikethrough_node_modules_micromark_util_chara
|
|
|
71394
72686
|
* @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined}
|
|
71395
72687
|
* Group.
|
|
71396
72688
|
*/
|
|
71397
|
-
function
|
|
72689
|
+
function node_modules_micromark_util_classify_character_classifyCharacter(code) {
|
|
71398
72690
|
if (code === null || micromark_extension_gfm_strikethrough_node_modules_micromark_util_character_markdownLineEndingOrSpace(code) || micromark_extension_gfm_strikethrough_node_modules_micromark_util_character_unicodeWhitespace(code)) {
|
|
71399
72691
|
return 1;
|
|
71400
72692
|
}
|
|
@@ -71562,7 +72854,7 @@ function gfmStrikethrough(options) {
|
|
|
71562
72854
|
|
|
71563
72855
|
/** @type {State} */
|
|
71564
72856
|
function more(code) {
|
|
71565
|
-
const before =
|
|
72857
|
+
const before = node_modules_micromark_util_classify_character_classifyCharacter(previous);
|
|
71566
72858
|
if (code === 126) {
|
|
71567
72859
|
// If this is the third marker, exit.
|
|
71568
72860
|
if (size > 1) return nok(code);
|
|
@@ -71572,7 +72864,7 @@ function gfmStrikethrough(options) {
|
|
|
71572
72864
|
}
|
|
71573
72865
|
if (size < 2 && !single) return nok(code);
|
|
71574
72866
|
const token = effects.exit('strikethroughSequenceTemporary');
|
|
71575
|
-
const after =
|
|
72867
|
+
const after = node_modules_micromark_util_classify_character_classifyCharacter(code);
|
|
71576
72868
|
token._open = !after || after === 2 && Boolean(before);
|
|
71577
72869
|
token._close = !before || before === 2 && Boolean(after);
|
|
71578
72870
|
return ok(code);
|
|
@@ -74856,15 +76148,6 @@ var defaultRehypePlugins = [rehypeSlug, rehypeAutolinkHeadings, rehype_ignore_li
|
|
|
74856
76148
|
ref: ref
|
|
74857
76149
|
}));
|
|
74858
76150
|
}));
|
|
74859
|
-
;// ../node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js
|
|
74860
|
-
function _taggedTemplateLiteral(e, t) {
|
|
74861
|
-
return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, {
|
|
74862
|
-
raw: {
|
|
74863
|
-
value: Object.freeze(t)
|
|
74864
|
-
}
|
|
74865
|
-
}));
|
|
74866
|
-
}
|
|
74867
|
-
|
|
74868
76151
|
;// ../node_modules/hast-util-from-html/lib/errors.js
|
|
74869
76152
|
/**
|
|
74870
76153
|
* @typedef ErrorInfo
|
|
@@ -76096,7 +77379,7 @@ const commentEntitySubset = ['<', '>']
|
|
|
76096
77379
|
* @param {Comment} node
|
|
76097
77380
|
* Node to handle.
|
|
76098
77381
|
* @param {number | undefined} _1
|
|
76099
|
-
* Index of `node` in `parent
|
|
77382
|
+
* Index of `node` in `parent`.
|
|
76100
77383
|
* @param {Parents | undefined} _2
|
|
76101
77384
|
* Parent of `node`.
|
|
76102
77385
|
* @param {State} state
|
|
@@ -76118,7 +77401,12 @@ function comment_comment(node, _1, _2, state) {
|
|
|
76118
77401
|
: '<!--' + node.value.replace(htmlCommentRegex, encode) + '-->'
|
|
76119
77402
|
|
|
76120
77403
|
/**
|
|
77404
|
+
* Encode a dangerous character.
|
|
77405
|
+
*
|
|
76121
77406
|
* @param {string} $0
|
|
77407
|
+
* Character.
|
|
77408
|
+
* @returns {string}
|
|
77409
|
+
* Encoded character.
|
|
76122
77410
|
*/
|
|
76123
77411
|
function encode($0) {
|
|
76124
77412
|
return stringifyEntities(
|
|
@@ -76142,7 +77430,7 @@ function comment_comment(node, _1, _2, state) {
|
|
|
76142
77430
|
* @param {Doctype} _1
|
|
76143
77431
|
* Node to handle.
|
|
76144
77432
|
* @param {number | undefined} _2
|
|
76145
|
-
* Index of `node` in `parent
|
|
77433
|
+
* Index of `node` in `parent`.
|
|
76146
77434
|
* @param {Parents | undefined} _3
|
|
76147
77435
|
* Parent of `node`.
|
|
76148
77436
|
* @param {State} state
|
|
@@ -76176,6 +77464,9 @@ const emptyChildren = []
|
|
|
76176
77464
|
* Factory to check siblings in a direction.
|
|
76177
77465
|
*
|
|
76178
77466
|
* @param {number} increment
|
|
77467
|
+
* Direction.
|
|
77468
|
+
* @returns {typeof sibling}
|
|
77469
|
+
* Check.
|
|
76179
77470
|
*/
|
|
76180
77471
|
function siblings(increment) {
|
|
76181
77472
|
return sibling
|
|
@@ -76227,7 +77518,6 @@ function siblings(increment) {
|
|
|
76227
77518
|
* Parent of element.
|
|
76228
77519
|
* @returns {boolean}
|
|
76229
77520
|
* Whether to omit a tag.
|
|
76230
|
-
*
|
|
76231
77521
|
*/
|
|
76232
77522
|
|
|
76233
77523
|
const omission_own = {}.hasOwnProperty
|
|
@@ -76399,7 +77689,9 @@ function closing_p(_, index, parent) {
|
|
|
76399
77689
|
parent.tagName === 'ins' ||
|
|
76400
77690
|
parent.tagName === 'map' ||
|
|
76401
77691
|
parent.tagName === 'noscript' ||
|
|
76402
|
-
parent.tagName === 'video'
|
|
77692
|
+
parent.tagName === 'video' ||
|
|
77693
|
+
// Custom element.
|
|
77694
|
+
parent.tagName.includes('-'))
|
|
76403
77695
|
)
|
|
76404
77696
|
}
|
|
76405
77697
|
|
|
@@ -76436,8 +77728,8 @@ function dt(_, index, parent) {
|
|
|
76436
77728
|
const next = siblingAfter(parent, index)
|
|
76437
77729
|
return Boolean(
|
|
76438
77730
|
next &&
|
|
76439
|
-
|
|
76440
|
-
|
|
77731
|
+
next.type === 'element' &&
|
|
77732
|
+
(next.tagName === 'dt' || next.tagName === 'dd')
|
|
76441
77733
|
)
|
|
76442
77734
|
}
|
|
76443
77735
|
|
|
@@ -76537,8 +77829,8 @@ function thead(_, index, parent) {
|
|
|
76537
77829
|
const next = siblingAfter(parent, index)
|
|
76538
77830
|
return Boolean(
|
|
76539
77831
|
next &&
|
|
76540
|
-
|
|
76541
|
-
|
|
77832
|
+
next.type === 'element' &&
|
|
77833
|
+
(next.tagName === 'tbody' || next.tagName === 'tfoot')
|
|
76542
77834
|
)
|
|
76543
77835
|
}
|
|
76544
77836
|
|
|
@@ -76721,7 +78013,6 @@ function opening_body(node) {
|
|
|
76721
78013
|
*/
|
|
76722
78014
|
function colgroup(node, index, parent) {
|
|
76723
78015
|
const previous = siblingBefore(parent, index)
|
|
76724
|
-
const head = siblingAfter(node, -1, true)
|
|
76725
78016
|
|
|
76726
78017
|
// Previous colgroup was already omitted.
|
|
76727
78018
|
if (
|
|
@@ -76734,6 +78025,8 @@ function colgroup(node, index, parent) {
|
|
|
76734
78025
|
return false
|
|
76735
78026
|
}
|
|
76736
78027
|
|
|
78028
|
+
const head = siblingAfter(node, -1, true)
|
|
78029
|
+
|
|
76737
78030
|
return Boolean(head && head.type === 'element' && head.tagName === 'col')
|
|
76738
78031
|
}
|
|
76739
78032
|
|
|
@@ -76751,7 +78044,6 @@ function colgroup(node, index, parent) {
|
|
|
76751
78044
|
*/
|
|
76752
78045
|
function opening_tbody(node, index, parent) {
|
|
76753
78046
|
const previous = siblingBefore(parent, index)
|
|
76754
|
-
const head = siblingAfter(node, -1)
|
|
76755
78047
|
|
|
76756
78048
|
// Previous table section was already omitted.
|
|
76757
78049
|
if (
|
|
@@ -76764,6 +78056,8 @@ function opening_tbody(node, index, parent) {
|
|
|
76764
78056
|
return false
|
|
76765
78057
|
}
|
|
76766
78058
|
|
|
78059
|
+
const head = siblingAfter(node, -1)
|
|
78060
|
+
|
|
76767
78061
|
return Boolean(head && head.type === 'element' && head.tagName === 'tr')
|
|
76768
78062
|
}
|
|
76769
78063
|
|
|
@@ -76813,13 +78107,20 @@ const constants = {
|
|
|
76813
78107
|
]
|
|
76814
78108
|
}
|
|
76815
78109
|
|
|
78110
|
+
/**
|
|
78111
|
+
* SVG elements whose content is HTML.
|
|
78112
|
+
*
|
|
78113
|
+
* @type {ReadonlySet<string>}
|
|
78114
|
+
*/
|
|
78115
|
+
const htmlIntegrationPoints = new Set(['desc', 'foreignObject', 'title'])
|
|
78116
|
+
|
|
76816
78117
|
/**
|
|
76817
78118
|
* Serialize an element node.
|
|
76818
78119
|
*
|
|
76819
78120
|
* @param {Element} node
|
|
76820
78121
|
* Node to handle.
|
|
76821
78122
|
* @param {number | undefined} index
|
|
76822
|
-
* Index of `node` in `parent
|
|
78123
|
+
* Index of `node` in `parent`.
|
|
76823
78124
|
* @param {Parents | undefined} parent
|
|
76824
78125
|
* Parent of `node`.
|
|
76825
78126
|
* @param {State} state
|
|
@@ -76828,7 +78129,7 @@ const constants = {
|
|
|
76828
78129
|
* Serialized node.
|
|
76829
78130
|
*/
|
|
76830
78131
|
function element_element(node, index, parent, state) {
|
|
76831
|
-
const schema = state
|
|
78132
|
+
const {schema} = state
|
|
76832
78133
|
const omit = schema.space === 'svg' ? false : state.settings.omitOptionalTags
|
|
76833
78134
|
let selfClosing =
|
|
76834
78135
|
schema.space === 'svg'
|
|
@@ -76836,8 +78137,6 @@ function element_element(node, index, parent, state) {
|
|
|
76836
78137
|
: state.settings.voids.includes(node.tagName.toLowerCase())
|
|
76837
78138
|
/** @type {Array<string>} */
|
|
76838
78139
|
const parts = []
|
|
76839
|
-
/** @type {string} */
|
|
76840
|
-
let last
|
|
76841
78140
|
|
|
76842
78141
|
if (schema.space === 'html' && node.tagName === 'svg') {
|
|
76843
78142
|
state.schema = property_information_svg
|
|
@@ -76845,6 +78144,12 @@ function element_element(node, index, parent, state) {
|
|
|
76845
78144
|
|
|
76846
78145
|
const attributes = element_serializeAttributes(state, node.properties)
|
|
76847
78146
|
|
|
78147
|
+
// HTML integration points is HTML.
|
|
78148
|
+
// See: <https://html.spec.whatwg.org/#html-integration-point>.
|
|
78149
|
+
if (state.schema.space === 'svg' && htmlIntegrationPoints.has(node.tagName)) {
|
|
78150
|
+
state.schema = property_information_html
|
|
78151
|
+
}
|
|
78152
|
+
|
|
76848
78153
|
const content = state.all(
|
|
76849
78154
|
schema.space === 'html' && node.tagName === 'template' ? node.content : node
|
|
76850
78155
|
)
|
|
@@ -76866,7 +78171,7 @@ function element_element(node, index, parent, state) {
|
|
|
76866
78171
|
selfClosing &&
|
|
76867
78172
|
(schema.space === 'svg' || state.settings.closeSelfClosing)
|
|
76868
78173
|
) {
|
|
76869
|
-
last = attributes.charAt(attributes.length - 1)
|
|
78174
|
+
const last = attributes.charAt(attributes.length - 1)
|
|
76870
78175
|
if (
|
|
76871
78176
|
!state.settings.tightSelfClosing ||
|
|
76872
78177
|
last === '/' ||
|
|
@@ -76891,9 +78196,14 @@ function element_element(node, index, parent, state) {
|
|
|
76891
78196
|
}
|
|
76892
78197
|
|
|
76893
78198
|
/**
|
|
78199
|
+
* Serialize all attributes.
|
|
78200
|
+
*
|
|
76894
78201
|
* @param {State} state
|
|
78202
|
+
* Info passed around about the current state.
|
|
76895
78203
|
* @param {Properties | null | undefined} properties
|
|
78204
|
+
* Properties.
|
|
76896
78205
|
* @returns {string}
|
|
78206
|
+
* Serialized attributes.
|
|
76897
78207
|
*/
|
|
76898
78208
|
function element_serializeAttributes(state, properties) {
|
|
76899
78209
|
/** @type {Array<string>} */
|
|
@@ -76926,19 +78236,22 @@ function element_serializeAttributes(state, properties) {
|
|
|
76926
78236
|
}
|
|
76927
78237
|
|
|
76928
78238
|
/**
|
|
78239
|
+
* Serialize an attribute.
|
|
78240
|
+
*
|
|
76929
78241
|
* @param {State} state
|
|
78242
|
+
* Info passed around about the current state.
|
|
76930
78243
|
* @param {string} key
|
|
78244
|
+
* Property name.
|
|
76931
78245
|
* @param {Properties[keyof Properties]} value
|
|
78246
|
+
* Property value.
|
|
76932
78247
|
* @returns {string}
|
|
78248
|
+
* Serialized attribute.
|
|
76933
78249
|
*/
|
|
76934
78250
|
function serializeAttribute(state, key, value) {
|
|
76935
78251
|
const info = find(state.schema, key)
|
|
76936
78252
|
const x =
|
|
76937
78253
|
state.settings.allowParseErrors && state.schema.space === 'html' ? 0 : 1
|
|
76938
78254
|
const y = state.settings.allowDangerousCharacters ? 0 : 1
|
|
76939
|
-
let quote = state.quote
|
|
76940
|
-
/** @type {string | undefined} */
|
|
76941
|
-
let result
|
|
76942
78255
|
|
|
76943
78256
|
if (info.overloadedBoolean && (value === info.attribute || value === '')) {
|
|
76944
78257
|
value = true
|
|
@@ -76995,6 +78308,9 @@ function serializeAttribute(state, key, value) {
|
|
|
76995
78308
|
|
|
76996
78309
|
if (state.settings.collapseEmptyAttributes && !value) return name
|
|
76997
78310
|
|
|
78311
|
+
/** @type {string | undefined} */
|
|
78312
|
+
let result
|
|
78313
|
+
|
|
76998
78314
|
// Check unquoted value.
|
|
76999
78315
|
if (state.settings.preferUnquoted) {
|
|
77000
78316
|
result = stringifyEntities(
|
|
@@ -77009,6 +78325,8 @@ function serializeAttribute(state, key, value) {
|
|
|
77009
78325
|
// If we don’t want unquoted, or if `value` contains character references when
|
|
77010
78326
|
// unquoted…
|
|
77011
78327
|
if (result !== value) {
|
|
78328
|
+
let {quote} = state
|
|
78329
|
+
|
|
77012
78330
|
// If the alternative is less common than `quote`, switch.
|
|
77013
78331
|
if (
|
|
77014
78332
|
state.settings.quoteSmart &&
|
|
@@ -77052,7 +78370,7 @@ const textEntitySubset = ['<', '&']
|
|
|
77052
78370
|
* @param {Raw | Text} node
|
|
77053
78371
|
* Node to handle.
|
|
77054
78372
|
* @param {number | undefined} _
|
|
77055
|
-
* Index of `node` in `parent
|
|
78373
|
+
* Index of `node` in `parent`.
|
|
77056
78374
|
* @param {Parents | undefined} parent
|
|
77057
78375
|
* Parent of `node`.
|
|
77058
78376
|
* @param {State} state
|
|
@@ -77089,7 +78407,7 @@ function lib_handle_text_text(node, _, parent, state) {
|
|
|
77089
78407
|
* @param {Raw} node
|
|
77090
78408
|
* Node to handle.
|
|
77091
78409
|
* @param {number | undefined} index
|
|
77092
|
-
* Index of `node` in `parent
|
|
78410
|
+
* Index of `node` in `parent`.
|
|
77093
78411
|
* @param {Parents | undefined} parent
|
|
77094
78412
|
* Parent of `node`.
|
|
77095
78413
|
* @param {State} state
|
|
@@ -77115,7 +78433,7 @@ function raw_raw(node, index, parent, state) {
|
|
|
77115
78433
|
* @param {Root} node
|
|
77116
78434
|
* Node to handle.
|
|
77117
78435
|
* @param {number | undefined} _1
|
|
77118
|
-
* Index of `node` in `parent
|
|
78436
|
+
* Index of `node` in `parent`.
|
|
77119
78437
|
* @param {Parents | undefined} _2
|
|
77120
78438
|
* Parent of `node`.
|
|
77121
78439
|
* @param {State} state
|
|
@@ -77166,7 +78484,7 @@ function invalid(node) {
|
|
|
77166
78484
|
* Fail when a node with an unknown type is found in the tree.
|
|
77167
78485
|
*
|
|
77168
78486
|
* @param {unknown} node_
|
|
77169
|
-
*
|
|
78487
|
+
* Unknown node.
|
|
77170
78488
|
* @returns {never}
|
|
77171
78489
|
* Never.
|
|
77172
78490
|
*/
|
|
@@ -77208,7 +78526,7 @@ function handle_unknown(node_) {
|
|
|
77208
78526
|
* > 👉 **Note**: intentionally creates parse errors in markup (how parse
|
|
77209
78527
|
* > errors are handled is well defined, so this works but isn’t pretty).
|
|
77210
78528
|
* @property {boolean | null | undefined} [bogusComments=false]
|
|
77211
|
-
* Use “bogus comments” instead of comments to save
|
|
78529
|
+
* Use “bogus comments” instead of comments to save bytes: `<?charlie>`
|
|
77212
78530
|
* instead of `<!--charlie-->` (default: `false`).
|
|
77213
78531
|
*
|
|
77214
78532
|
* > 👉 **Note**: intentionally creates parse errors in markup (how parse
|
|
@@ -77259,13 +78577,16 @@ function handle_unknown(node_) {
|
|
|
77259
78577
|
* @property {Space | null | undefined} [space='html']
|
|
77260
78578
|
* When an `<svg>` element is found in the HTML space, this package already
|
|
77261
78579
|
* automatically switches to and from the SVG space when entering and exiting
|
|
77262
|
-
* it
|
|
78580
|
+
* it, and goes to HTML inside `desc`, `foreignObject`, and `title`
|
|
78581
|
+
* (default: `'html'`).
|
|
77263
78582
|
*
|
|
77264
78583
|
* > 👉 **Note**: hast is not XML.
|
|
77265
78584
|
* > It supports SVG as embedded in HTML.
|
|
77266
78585
|
* > It does not support the features available in XML.
|
|
77267
78586
|
* > Passing SVG might break but fragments of modern SVG should be fine.
|
|
77268
78587
|
* > Use [`xast`][xast] if you need to support SVG as XML.
|
|
78588
|
+
*
|
|
78589
|
+
* [xast]: https://github.com/syntax-tree/xast
|
|
77269
78590
|
* @property {boolean | null | undefined} [tightAttributes=false]
|
|
77270
78591
|
* Join attributes together, without whitespace, if possible: get
|
|
77271
78592
|
* `class="a b"title="c d"` instead of `class="a b" title="c d"` to save
|
|
@@ -77353,12 +78674,13 @@ const lib_emptyChildren = []
|
|
|
77353
78674
|
function toHtml(tree, options) {
|
|
77354
78675
|
const options_ = options || hast_util_to_html_lib_emptyOptions
|
|
77355
78676
|
const quote = options_.quote || '"'
|
|
77356
|
-
const alternative = quote === '"' ? "'" : '"'
|
|
77357
78677
|
|
|
77358
78678
|
if (quote !== '"' && quote !== "'") {
|
|
77359
78679
|
throw new Error('Invalid quote `' + quote + '`, expected `\'` or `"`')
|
|
77360
78680
|
}
|
|
77361
78681
|
|
|
78682
|
+
const alternative = quote === '"' ? "'" : '"'
|
|
78683
|
+
|
|
77362
78684
|
/** @type {State} */
|
|
77363
78685
|
const state = {
|
|
77364
78686
|
one: hast_util_to_html_lib_one,
|
|
@@ -77403,7 +78725,7 @@ function toHtml(tree, options) {
|
|
|
77403
78725
|
* @param {Nodes} node
|
|
77404
78726
|
* Node to handle.
|
|
77405
78727
|
* @param {number | undefined} index
|
|
77406
|
-
* Index of `node` in `parent
|
|
78728
|
+
* Index of `node` in `parent`.
|
|
77407
78729
|
* @param {Parents | undefined} parent
|
|
77408
78730
|
* Parent of `node`.
|
|
77409
78731
|
* @returns {string}
|
|
@@ -77421,6 +78743,7 @@ function hast_util_to_html_lib_one(node, index, parent) {
|
|
|
77421
78743
|
* @param {Parents | undefined} parent
|
|
77422
78744
|
* Parent whose children to serialize.
|
|
77423
78745
|
* @returns {string}
|
|
78746
|
+
* Serialized children.
|
|
77424
78747
|
*/
|
|
77425
78748
|
function hast_util_to_html_lib_all(parent) {
|
|
77426
78749
|
/** @type {Array<string>} */
|
|
@@ -77549,17 +78872,35 @@ function _objectSpread2(e) {
|
|
|
77549
78872
|
|
|
77550
78873
|
;// ./src/Context.tsx
|
|
77551
78874
|
function reducer(state,action){return _objectSpread2(_objectSpread2({},state),action);}var EditorContext=/*#__PURE__*/(external_root_React_commonjs2_react_commonjs_react_amd_react_default()().createContext)({markdown:''});
|
|
77552
|
-
;// ./src/components/TextArea/
|
|
77553
|
-
var
|
|
77554
|
-
|
|
77555
|
-
|
|
77556
|
-
|
|
77557
|
-
|
|
77558
|
-
|
|
77559
|
-
|
|
77560
|
-
|
|
78875
|
+
;// ./src/components/TextArea/splitBlocks.ts
|
|
78876
|
+
var FENCE_OPEN=/^```/;var FENCE_CLOSE=/^```\r?\n?$/;var BLANK_LINE=/^[ \t]*\r?\n?$/;var FRONT_MATTER_FENCE=/^---\r?\n?$/;/**
|
|
78877
|
+
* Splits markdown into blocks that Prism's markdown grammar highlights the same way
|
|
78878
|
+
* on their own as it does in the full document, so unchanged blocks can be cached.
|
|
78879
|
+
* Joining the returned blocks always yields the original string.
|
|
78880
|
+
*
|
|
78881
|
+
* A block ends where a run of blank lines starts, so each block keeps its leading blank
|
|
78882
|
+
* lines (indented code needs them). No split happens inside a ``` fence, front matter or
|
|
78883
|
+
* multiline markup or link references, or right before a `---` line, which Prism
|
|
78884
|
+
* would read as front matter. Whitespace-only lines stay in their block because
|
|
78885
|
+
* Prism's inline emphasis can span them.
|
|
78886
|
+
* Fences follow Prism's rule, not CommonMark's, so the split matches what Prism sees.
|
|
78887
|
+
*/function splitBlocks(markdown){var lines=markdown.match(/[^\n]*\n|[^\n]+$/g)||[];var blocks=[];var current='';var pendingSplit=-1;var inFence=false;var inFrontMatter=/^(?:\s*[\r\n])?---(?:\r?\n|$)/.test(markdown);var frontMatterStarted=false;var syntax={end:'',quote:'',brackets:0,subset:0};var previousIsBlank=true;lines.forEach(function(line){var isBlank=BLANK_LINE.test(line);var canSplit=!inFence&&!inFrontMatter&&!syntax.end&&!syntax.brackets;if(/^\r?\n$/.test(line)&&!previousIsBlank&&canSplit){pendingSplit=current.length;}if(!isBlank&&pendingSplit>0){if(!FRONT_MATTER_FENCE.test(line)){blocks.push(current.slice(0,pendingSplit));current=current.slice(pendingSplit);}pendingSplit=-1;}current+=line;previousIsBlank=isBlank;if(inFrontMatter){if(FRONT_MATTER_FENCE.test(line)){inFrontMatter=!frontMatterStarted;frontMatterStarted=true;}return;}if(inFence){inFence=!FENCE_CLOSE.test(line);return;}if(!syntax.end&&FENCE_OPEN.test(line)){inFence=true;return;}updateSyntax(line,syntax);});if(current){blocks.push(current);}return blocks;}// Keep potential multiline Prism tokens together. Unclosed syntax conservatively
|
|
78888
|
+
// keeps the rest of the document in one block until the user closes it.
|
|
78889
|
+
function updateSyntax(line,state){var reference=false;for(var i=0;i<line.length;i++){var _char=line[i];if(state.end&&state.end!=='>'){var end=line.indexOf(state.end,i);if(end===-1)return;i=end+state.end.length-1;state.end='';continue;}if(state.end==='>'){if(state.quote){if(_char===state.quote)state.quote='';}else if(_char==='"'||_char==="'"){state.quote=_char;}else if(_char==='['){state.subset++;}else if(_char===']'&&state.subset){state.subset--;}else if(_char==='>'&&!state.subset){state.end='';}continue;}if(_char==='\\'){i++;}else if(_char==='<'&&/[a-z!?/]/i.test(line[i+1]||'')){state.end=line.startsWith('<!--',i)?'-->':line.startsWith('<![CDATA[',i)?']]>':line.startsWith('<?',i)?'?>':'>';}else if(_char==='['){state.brackets++;}else if(_char===']'){state.brackets=Math.max(0,state.brackets-1);reference=line[i+1]===':';}else if(reference&&(_char==='"'||_char==="'"||_char==='(')){state.end=_char==='('?')':_char;}}}
|
|
78890
|
+
;// ./src/components/TextArea/Markdown.factory.tsx
|
|
78891
|
+
/**
|
|
78892
|
+
* Prism's markdown grammar takes quadratic time on long lines, so a single base64 image
|
|
78893
|
+
* line can block the editor for minutes. Blocks with such a line are shown uncoloured.
|
|
78894
|
+
*/var MAX_HIGHLIGHT_LINE_LENGTH=1000;function html2Escape(sHtml){return sHtml.replace(/[<&"]/g,function(c){return{'<':'<','>':'>','&':'&','"':'"'}[c];});}function hasLongLine(text){var lineStart=0;while(lineStart<=text.length){var lineEnd=text.indexOf('\n',lineStart);var end=lineEnd===-1?text.length:lineEnd;if(end-lineStart>MAX_HIGHLIGHT_LINE_LENGTH){return true;}lineStart=end+1;}return false;}function getCodeInnerHtml(html){var codeStart=html.indexOf('<code');var contentStart=html.indexOf('>',codeStart)+1;var contentEnd=html.lastIndexOf('</code>');return html.slice(contentStart,contentEnd);}var MarkdownBlock=/*#__PURE__*/(external_root_React_commonjs2_react_commonjs_react_amd_react_default()().memo)(function MarkdownBlock(props){return/*#__PURE__*/(external_root_React_commonjs2_react_commonjs_react_amd_react_default()().createElement)('span',{dangerouslySetInnerHTML:{__html:props.html}});});function createMarkdown(rehypePrism){var processor=rehype().data('settings',{fragment:true})// https://github.com/uiwjs/react-md-editor/issues/593
|
|
77561
78895
|
// @ts-ignore
|
|
77562
|
-
.use(
|
|
78896
|
+
.use(rehypePrism,{ignoreMissing:true});function highlightBlock(block){var escaped=html2Escape(block);if(hasLongLine(block)){return escaped;}try{var html=processor.processSync("<pre><code class=\"language-markdown\">".concat(escaped,"</code></pre>")).toString();return getCodeInnerHtml(html);}catch(error){return escaped;}}/**
|
|
78897
|
+
* Highlighting runs per block, and blocks whose text did not change reuse their cached
|
|
78898
|
+
* HTML and DOM, so typing in a large document only re-highlights the edited block.
|
|
78899
|
+
* https://github.com/uiwjs/react-md-editor/issues/620
|
|
78900
|
+
*/return function Markdown(props){var prefixCls=props.prefixCls;var _useContext=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useContext)(EditorContext),_useContext$markdown=_useContext.markdown,markdown=_useContext$markdown===void 0?'':_useContext$markdown,highlightEnable=_useContext.highlightEnable,dispatch=_useContext.dispatch;var preRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(null);var cacheRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(new Map());var nextIdRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(0);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useEffect)(function(){if(preRef.current&&dispatch){dispatch({textareaPre:preRef.current});}// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78901
|
+
},[]);var blocks=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){if(!highlightEnable){cacheRef.current=new Map();return[];}var cache=new Map();var occurrences=new Map();var result=splitBlocks(markdown).map(function(block){var highlighted=cacheRef.current.get(block)||cache.get(block);if(!highlighted){highlighted={id:nextIdRef.current++,html:highlightBlock(block)};}cache.set(block,highlighted);var occurrence=occurrences.get(block)||0;occurrences.set(block,occurrence+1);return{key:"".concat(highlighted.id,"-").concat(occurrence),html:highlighted.html};});cacheRef.current=cache;return result;},[markdown,highlightEnable]);if(!markdown){return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("pre",{ref:preRef,className:"".concat(prefixCls,"-text-pre wmde-markdown-color")});}return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{className:"wmde-markdown-color",children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("pre",{ref:preRef,className:"language-markdown ".concat(prefixCls,"-text-pre wmde-markdown-color"),children:highlightEnable?/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)("code",{className:"language-markdown code-highlight",children:[blocks.map(function(block){return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(MarkdownBlock,{html:block.html},block.key);}),'\n']}):/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("code",{className:"language-markdown",children:"".concat(markdown,"\n")})})});};}
|
|
78902
|
+
;// ./src/components/TextArea/Markdown.tsx
|
|
78903
|
+
/* harmony default export */ const TextArea_Markdown = (createMarkdown(index_es_f));
|
|
77563
78904
|
;// ../node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
|
|
77564
78905
|
|
|
77565
78906
|
function _objectWithoutProperties(e, t) {
|
|
@@ -77819,7 +79160,7 @@ var factory_excluded=["prefixCls","className","onScroll","renderTextarea"];funct
|
|
|
77819
79160
|
},[]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useEffect)(function(){if(textRef.current&&dispatch){var commandOrchestrator=new TextAreaCommandOrchestrator(textRef.current);executeRef.current=commandOrchestrator;dispatch({textarea:textRef.current,commandOrchestrator:commandOrchestrator});}// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77820
79161
|
},[]);var textStyle=MarkdownComponent&&highlightEnable?{}:{WebkitTextFillColor:'initial',overflow:'auto'};var inputProps=_objectSpread2({},otherProps);if(!inputProps['aria-label']&&!inputProps['aria-labelledby']&&!inputProps.id&&!inputProps.title){inputProps['aria-label']='Markdown editor';}return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{ref:warp,className:"".concat(prefixCls,"-area ").concat(className||''),onScroll:onScroll,children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{className:"".concat(prefixCls,"-text"),style:useMinHeight?{minHeight:minHeight}:undefined,children:renderTextarea?(/*#__PURE__*/(external_root_React_commonjs2_react_commonjs_react_amd_react_default()().cloneElement)(renderTextarea(_objectSpread2(_objectSpread2({},inputProps),{},{value:markdown,autoComplete:'off',spellCheck:'false',autoCapitalize:'off',className:"".concat(prefixCls,"-text-input"),style:{WebkitTextFillColor:'inherit',overflow:'auto'}}),{dispatch:dispatch,onChange:otherProps.onChange,shortcuts:shortcutsHandle,useContext:{commands:commands,extraCommands:extraCommands,commandOrchestrator:executeRef.current}}),{ref:textRef})):/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)((external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().Fragment),{children:[MarkdownComponent&&highlightEnable&&/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(MarkdownComponent,{prefixCls:prefixCls}),/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(Textarea,_objectSpread2(_objectSpread2({prefixCls:prefixCls},inputProps),{},{style:textStyle}))]})})});};}
|
|
77821
79162
|
;// ./src/components/TextArea/index.tsx
|
|
77822
|
-
/* harmony default export */ const components_TextArea = (createTextArea({Markdown:
|
|
79163
|
+
/* harmony default export */ const components_TextArea = (createTextArea({Markdown:TextArea_Markdown,useMinHeight:true}));
|
|
77823
79164
|
;// ../node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
|
|
77824
79165
|
function _arrayWithHoles(r) {
|
|
77825
79166
|
if (Array.isArray(r)) return r;
|
|
@@ -77889,7 +79230,15 @@ document.body.style.overflow=originalOverflow.current;}}},[fullscreen,originalOv
|
|
|
77889
79230
|
var DragBar_DragBar=function DragBar(props){var _ref=props||{},prefixCls=_ref.prefixCls,onChange=_ref.onChange;var $dom=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(null);var dragRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)();var heightRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(props.height);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useEffect)(function(){if(heightRef.current!==props.height){heightRef.current=props.height;}},[props.height]);function handleMouseMove(event){if(dragRef.current){var _changedTouches$;var clientY=event.clientY||((_changedTouches$=event.changedTouches[0])===null||_changedTouches$===void 0?void 0:_changedTouches$.clientY);var newHeight=dragRef.current.height+clientY-dragRef.current.dragY;if(newHeight>=props.minHeight&&newHeight<=props.maxHeight){onChange&&onChange(dragRef.current.height+(clientY-dragRef.current.dragY));}}}function handleMouseUp(){var _$dom$current,_$dom$current2;dragRef.current=undefined;document.removeEventListener('mousemove',handleMouseMove);document.removeEventListener('mouseup',handleMouseUp);(_$dom$current=$dom.current)===null||_$dom$current===void 0?void 0:_$dom$current.removeEventListener('touchmove',handleMouseMove);(_$dom$current2=$dom.current)===null||_$dom$current2===void 0?void 0:_$dom$current2.removeEventListener('touchend',handleMouseUp);}function handleMouseDown(event){var _changedTouches$2,_$dom$current3,_$dom$current4;event.preventDefault();var clientY=event.clientY||((_changedTouches$2=event.changedTouches[0])===null||_changedTouches$2===void 0?void 0:_changedTouches$2.clientY);dragRef.current={height:heightRef.current,dragY:clientY};document.addEventListener('mousemove',handleMouseMove);document.addEventListener('mouseup',handleMouseUp);(_$dom$current3=$dom.current)===null||_$dom$current3===void 0?void 0:_$dom$current3.addEventListener('touchmove',handleMouseMove,{passive:false});(_$dom$current4=$dom.current)===null||_$dom$current4===void 0?void 0:_$dom$current4.addEventListener('touchend',handleMouseUp,{passive:false});};(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useEffect)(function(){if(document){var _$dom$current5,_$dom$current6;(_$dom$current5=$dom.current)===null||_$dom$current5===void 0?void 0:_$dom$current5.addEventListener('touchstart',handleMouseDown,{passive:false});(_$dom$current6=$dom.current)===null||_$dom$current6===void 0?void 0:_$dom$current6.addEventListener('mousedown',handleMouseDown);}return function(){if(document){var _$dom$current7;(_$dom$current7=$dom.current)===null||_$dom$current7===void 0?void 0:_$dom$current7.removeEventListener('touchstart',handleMouseDown);document.removeEventListener('mousemove',handleMouseMove);}};// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77890
79231
|
},[]);var svg=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("svg",{viewBox:"0 0 512 512",height:"100%",children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("path",{fill:"currentColor",d:"M304 256c0 26.5-21.5 48-48 48s-48-21.5-48-48 21.5-48 48-48 48 21.5 48 48zm120-48c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48zm-336 0c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z"})});},[]);return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{className:"".concat(prefixCls,"-bar"),ref:$dom,children:svg});};/* harmony default export */ const components_DragBar = (DragBar_DragBar);
|
|
77891
79232
|
;// ./src/Editor.factory.tsx
|
|
77892
|
-
var Editor_factory_excluded=["prefixCls","className","value","commands","commandsFilter","direction","extraCommands","height","enableScroll","visibleDragbar","highlightEnable","preview","fullscreen","overflow","previewOptions","textareaProps","id","name","required","disabled","readOnly","placeholder","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-errormessage","maxHeight","minHeight","autoFocus","autoFocusEnd","tabSize","defaultTabEnable","onChange","onStatistics","onHeightChange","hideToolbar","toolbarBottom","components","renderTextarea"];function setGroupPopFalse(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};Object.keys(data).forEach(function(keyname){data[keyname]=false;});return data;}
|
|
79233
|
+
var Editor_factory_excluded=["renderMsRef"],Editor_factory_excluded2=["prefixCls","className","value","commands","commandsFilter","direction","extraCommands","height","enableScroll","visibleDragbar","highlightEnable","preview","fullscreen","overflow","previewOptions","textareaProps","id","name","required","disabled","readOnly","placeholder","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-errormessage","maxHeight","minHeight","autoFocus","autoFocusEnd","tabSize","defaultTabEnable","onChange","onStatistics","onHeightChange","hideToolbar","toolbarBottom","components","renderTextarea"];function setGroupPopFalse(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};Object.keys(data).forEach(function(keyname){data[keyname]=false;});return data;}var DEFAULT_PREVIEW_OPTIONS={};/**
|
|
79234
|
+
* Lets the preview render after the textarea on React 18+, so typing in a large
|
|
79235
|
+
* document stays responsive. Older React versions render it right away, as before.
|
|
79236
|
+
*/var useDeferredValue=((external_root_React_commonjs2_react_commonjs_react_amd_react_default()()).useDeferredValue)||function(value){return value;};var useIsomorphicLayoutEffect=typeof window==='undefined'?(external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useEffect):(external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useLayoutEffect);var SLOW_PREVIEW_MS=50;var MAX_PREVIEW_DELAY_MS=500;/**
|
|
79237
|
+
* Keeps the preview in step with every keystroke while it renders fast. Once a preview
|
|
79238
|
+
* render takes longer than SLOW_PREVIEW_MS, it waits for a pause in typing as long as
|
|
79239
|
+
* that render (at most MAX_PREVIEW_DELAY_MS) before updating.
|
|
79240
|
+
* https://github.com/uiwjs/react-md-editor/issues/620
|
|
79241
|
+
*/function usePreviewSource(markdown,previewRenderMs){var _useReducer=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useReducer)(function(count){return count+1;},0),_useReducer2=_slicedToArray(_useReducer,2),rerender=_useReducer2[1];var shownRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(markdown);if(previewRenderMs.current<SLOW_PREVIEW_MS){shownRef.current=markdown;};(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useEffect)(function(){if(shownRef.current===markdown){return;}var delay=Math.min(previewRenderMs.current,MAX_PREVIEW_DELAY_MS);var timer=setTimeout(function(){shownRef.current=markdown;rerender();},delay);return function(){return clearTimeout(timer);};},[markdown,previewRenderMs]);return shownRef.current;}function createMDEditor(options){var MarkdownPreview=options.MarkdownPreview,TextArea=options.TextArea;var PreviewComponent=MarkdownPreview;var TextAreaComponent=TextArea;function TimedPreview(props){var renderMsRef=props.renderMsRef,previewProps=_objectWithoutProperties(props,Editor_factory_excluded);var renderStart=performance.now();useIsomorphicLayoutEffect(function(){renderMsRef.current=performance.now()-renderStart;});return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(PreviewComponent,_objectSpread2({},previewProps));}var InternalMDEditor=/*#__PURE__*/(external_root_React_commonjs2_react_commonjs_react_amd_react_default()().forwardRef)(function(props,ref){var _ref=props||{},_ref$prefixCls=_ref.prefixCls,prefixCls=_ref$prefixCls===void 0?'w-md-editor':_ref$prefixCls,className=_ref.className,propsValue=_ref.value,_ref$commands=_ref.commands,commands=_ref$commands===void 0?commands_getCommands():_ref$commands,commandsFilter=_ref.commandsFilter,direction=_ref.direction,_ref$extraCommands=_ref.extraCommands,extraCommands=_ref$extraCommands===void 0?getExtraCommands():_ref$extraCommands,_ref$height=_ref.height,height=_ref$height===void 0?200:_ref$height,_ref$enableScroll=_ref.enableScroll,enableScroll=_ref$enableScroll===void 0?true:_ref$enableScroll,_ref$visibleDragbar=_ref.visibleDragbar,visibleDragbar=_ref$visibleDragbar===void 0?typeof props.visiableDragbar==='boolean'?props.visiableDragbar:true:_ref$visibleDragbar,_ref$highlightEnable=_ref.highlightEnable,highlightEnable=_ref$highlightEnable===void 0?true:_ref$highlightEnable,_ref$preview=_ref.preview,previewType=_ref$preview===void 0?'live':_ref$preview,_ref$fullscreen=_ref.fullscreen,fullscreen=_ref$fullscreen===void 0?false:_ref$fullscreen,_ref$overflow=_ref.overflow,overflow=_ref$overflow===void 0?true:_ref$overflow,_ref$previewOptions=_ref.previewOptions,previewOptions=_ref$previewOptions===void 0?DEFAULT_PREVIEW_OPTIONS:_ref$previewOptions,textareaProps=_ref.textareaProps,id=_ref.id,name=_ref.name,required=_ref.required,disabled=_ref.disabled,readOnly=_ref.readOnly,placeholder=_ref.placeholder,ariaLabel=_ref['aria-label'],ariaLabelledBy=_ref['aria-labelledby'],ariaDescribedBy=_ref['aria-describedby'],ariaInvalid=_ref['aria-invalid'],ariaRequired=_ref['aria-required'],ariaErrorMessage=_ref['aria-errormessage'],_ref$maxHeight=_ref.maxHeight,maxHeight=_ref$maxHeight===void 0?1200:_ref$maxHeight,_ref$minHeight=_ref.minHeight,minHeight=_ref$minHeight===void 0?100:_ref$minHeight,autoFocus=_ref.autoFocus,_ref$autoFocusEnd=_ref.autoFocusEnd,autoFocusEnd=_ref$autoFocusEnd===void 0?false:_ref$autoFocusEnd,_ref$tabSize=_ref.tabSize,tabSize=_ref$tabSize===void 0?2:_ref$tabSize,_ref$defaultTabEnable=_ref.defaultTabEnable,defaultTabEnable=_ref$defaultTabEnable===void 0?false:_ref$defaultTabEnable,onChange=_ref.onChange,onStatistics=_ref.onStatistics,onHeightChange=_ref.onHeightChange,hideToolbar=_ref.hideToolbar,_ref$toolbarBottom=_ref.toolbarBottom,toolbarBottom=_ref$toolbarBottom===void 0?false:_ref$toolbarBottom,components=_ref.components,renderTextarea=_ref.renderTextarea,other=_objectWithoutProperties(_ref,Editor_factory_excluded2);var cmds=commands.map(function(item){return commandsFilter?commandsFilter(item,false):item;}).filter(Boolean);var extraCmds=extraCommands.map(function(item){return commandsFilter?commandsFilter(item,true):item;}).filter(Boolean);var _useReducer3=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useReducer)(reducer,{markdown:propsValue,preview:previewType,components:components,height:height,minHeight:minHeight,highlightEnable:highlightEnable,tabSize:tabSize,defaultTabEnable:defaultTabEnable,scrollTop:0,scrollTopPreview:0,commands:cmds,extraCommands:extraCmds,fullscreen:fullscreen,barPopup:{}}),_useReducer4=_slicedToArray(_useReducer3,2),state=_useReducer4[0],dispatch=_useReducer4[1];var container=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(null);var previewRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(null);var enableScrollRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(enableScroll);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useImperativeHandle)(ref,function(){return _objectSpread2(_objectSpread2({},state),{},{container:container.current,dispatch:dispatch});});(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return enableScrollRef.current=enableScroll;},[enableScroll]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useEffect)(function(){var stateInit={};if(container.current){stateInit.container=container.current||undefined;}stateInit.markdown=propsValue||'';stateInit.barPopup={};if(dispatch){dispatch(_objectSpread2(_objectSpread2({},state),stateInit));}// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77893
79242
|
},[]);var cls=[className,'wmde-markdown-var',direction?"".concat(prefixCls,"-").concat(direction):null,prefixCls,state.preview?"".concat(prefixCls,"-show-").concat(state.preview):null,state.fullscreen?"".concat(prefixCls,"-fullscreen"):null].filter(Boolean).join(' ').trim();(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return propsValue!==state.markdown&&dispatch({markdown:propsValue||''});},[propsValue,state.markdown]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77894
79243
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return previewType!==state.preview&&dispatch({preview:previewType});},[previewType]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77895
79244
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return tabSize!==state.tabSize&&dispatch({tabSize:tabSize});},[tabSize]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return highlightEnable!==state.highlightEnable&&dispatch({highlightEnable:highlightEnable});},// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -77898,7 +79247,7 @@ var Editor_factory_excluded=["prefixCls","className","value","commands","command
|
|
|
77898
79247
|
[fullscreen]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77899
79248
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return height!==state.height&&dispatch({height:height});},[height]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return height!==state.height&&onHeightChange&&onHeightChange(state.height,height,state);},[height,onHeightChange,state]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77900
79249
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return commands!==state.commands&&dispatch({commands:cmds});},[props.commands]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77901
|
-
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return extraCommands!==state.extraCommands&&dispatch({extraCommands:extraCmds});},[props.extraCommands]);var textareaDomRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)();var active=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)('preview');var initScroll=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(false);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){textareaDomRef.current=state.textareaWarp;if(state.textareaWarp){state.textareaWarp.addEventListener('mouseover',function(){active.current='text';});state.textareaWarp.addEventListener('mouseleave',function(){active.current='preview';});}},[state.textareaWarp]);var handleScroll=function handleScroll(e,type){if(!enableScrollRef.current)return;var textareaDom=textareaDomRef.current;var previewDom=previewRef.current?previewRef.current:undefined;if(!initScroll.current){active.current=type;initScroll.current=true;}if(textareaDom&&previewDom){var scale=(textareaDom.scrollHeight-textareaDom.offsetHeight)/(previewDom.scrollHeight-previewDom.offsetHeight);if(e.target===textareaDom&&active.current==='text'){previewDom.scrollTop=textareaDom.scrollTop/scale;}if(e.target===previewDom&&active.current==='preview'){textareaDom.scrollTop=previewDom.scrollTop*scale;}var scrollTop=0;if(active.current==='text'){scrollTop=textareaDom.scrollTop||0;}else if(active.current==='preview'){scrollTop=previewDom.scrollTop||0;}dispatch({scrollTop:scrollTop});}};var previewClassName="".concat(prefixCls,"-preview ").concat(previewOptions.className||'');var handlePreviewScroll=function handlePreviewScroll(e){return handleScroll(e,'preview');};var mdPreview=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{ref:previewRef,className:previewClassName,children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(
|
|
79250
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return extraCommands!==state.extraCommands&&dispatch({extraCommands:extraCmds});},[props.extraCommands]);var textareaDomRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)();var active=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)('preview');var initScroll=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(false);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){textareaDomRef.current=state.textareaWarp;if(state.textareaWarp){state.textareaWarp.addEventListener('mouseover',function(){active.current='text';});state.textareaWarp.addEventListener('mouseleave',function(){active.current='preview';});}},[state.textareaWarp]);var handleScroll=function handleScroll(e,type){if(!enableScrollRef.current)return;var textareaDom=textareaDomRef.current;var previewDom=previewRef.current?previewRef.current:undefined;if(!initScroll.current){active.current=type;initScroll.current=true;}if(textareaDom&&previewDom){var scale=(textareaDom.scrollHeight-textareaDom.offsetHeight)/(previewDom.scrollHeight-previewDom.offsetHeight);if(e.target===textareaDom&&active.current==='text'){previewDom.scrollTop=textareaDom.scrollTop/scale;}if(e.target===previewDom&&active.current==='preview'){textareaDom.scrollTop=previewDom.scrollTop*scale;}var scrollTop=0;if(active.current==='text'){scrollTop=textareaDom.scrollTop||0;}else if(active.current==='preview'){scrollTop=previewDom.scrollTop||0;}dispatch({scrollTop:scrollTop});}};var previewClassName="".concat(prefixCls,"-preview ").concat(previewOptions.className||'');var handlePreviewScroll=function handlePreviewScroll(e){return handleScroll(e,'preview');};var previewRenderMs=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(0);var previewMarkdown=useDeferredValue(usePreviewSource(state.markdown||'',previewRenderMs));var mdPreview=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{ref:previewRef,className:previewClassName,children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(TimedPreview,_objectSpread2(_objectSpread2({},previewOptions),{},{renderMsRef:previewRenderMs,onScroll:handlePreviewScroll,source:previewMarkdown}))});},[previewClassName,previewOptions,previewMarkdown]);var preview=(components===null||components===void 0?void 0:components.preview)&&(components===null||components===void 0?void 0:components.preview(state.markdown||'',state,dispatch));if(preview&&/*#__PURE__*/(external_root_React_commonjs2_react_commonjs_react_amd_react_default()().isValidElement)(preview)){mdPreview=/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{className:previewClassName,ref:previewRef,onScroll:handlePreviewScroll,children:preview});}var containerStyle=_objectSpread2(_objectSpread2({},other.style),{},{height:state.height||'100%'});var containerClick=function containerClick(){return dispatch({barPopup:_objectSpread2({},setGroupPopFalse(state.barPopup))});};var dragBarChange=function dragBarChange(newHeight){return dispatch({height:newHeight});};var changeHandle=function changeHandle(evn){onChange&&onChange(evn.target.value,evn,state);if(textareaProps&&textareaProps.onChange){textareaProps.onChange(evn);}if(state.textarea&&state.textarea instanceof HTMLTextAreaElement&&onStatistics){var obj=new TextAreaCommandOrchestrator(state.textarea);var objState=obj.getState()||{};onStatistics(_objectSpread2(_objectSpread2({},objState),{},{lineCount:evn.target.value.split('\n').length,length:evn.target.value.length}));}};return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(EditorContext.Provider,{value:_objectSpread2(_objectSpread2({},state),{},{dispatch:dispatch}),children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)("div",_objectSpread2(_objectSpread2({ref:container,className:cls},other),{},{onClick:containerClick,style:containerStyle,children:[/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToolbarVisibility,{hideToolbar:hideToolbar,toolbarBottom:toolbarBottom,prefixCls:prefixCls,overflow:overflow,placement:"top"}),/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)("div",{className:"".concat(prefixCls,"-content"),children:[/(edit|live)/.test(state.preview||'')&&/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(TextAreaComponent,_objectSpread2(_objectSpread2({className:"".concat(prefixCls,"-input"),prefixCls:prefixCls,autoFocus:autoFocus,id:id,name:name,required:required,disabled:disabled,readOnly:readOnly,placeholder:placeholder,"aria-label":ariaLabel,"aria-labelledby":ariaLabelledBy,"aria-describedby":ariaDescribedBy,"aria-invalid":ariaInvalid,"aria-required":ariaRequired,"aria-errormessage":ariaErrorMessage},textareaProps),{},{onChange:changeHandle,renderTextarea:(components===null||components===void 0?void 0:components.textarea)||renderTextarea,onScroll:function onScroll(e){return handleScroll(e,'text');}})),/(live|preview)/.test(state.preview||'')&&mdPreview]}),visibleDragbar&&!state.fullscreen&&/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(components_DragBar,{prefixCls:prefixCls,height:state.height,maxHeight:maxHeight,minHeight:minHeight,onChange:dragBarChange}),/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToolbarVisibility,{hideToolbar:hideToolbar,toolbarBottom:toolbarBottom,prefixCls:prefixCls,overflow:overflow,placement:"bottom"})]}))});});var Editor=InternalMDEditor;Editor.Markdown=MarkdownPreview;Editor.displayName='MDEditor';return Editor;}
|
|
77902
79251
|
;// ./src/Editor.tsx
|
|
77903
79252
|
/* harmony default export */ const Editor = (createMDEditor({MarkdownPreview:react_markdown_preview_esm,TextArea:components_TextArea}));
|
|
77904
79253
|
;// ./src/index.less
|