2 +import { createRequire }
from 'node:module';
const require = createRequire(
import.meta.url);
2 5 import { existsSync, readdirSync, readFileSync, statSync }
from "node:fs";
10 13 }
from "node:path";
11 14 import { fileURLToPath }
from "node:url";
12 -import { marked }
from "marked";
13 -import { parse }
from "yaml";
15 -const frontmatterFence
= /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;
16 -const namePattern
= /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
17 -const scriptPattern
= /\.(?:mjs|cjs|js|ts|sh|bash|nu|py|ps1|cmd|bat)$/i;
17 +var NOT_RESOLVED
= Symbol(
"NOT_RESOLVED");
18 +function defineScalarTag(tagName, options) {
22 + implicit: options.implicit
?? false,
23 + matchByTagPrefix: options.matchByTagPrefix
?? false,
24 + implicitFirstChars: options.implicitFirstChars
?? null,
25 + resolve: options.resolve,
26 + identify: options.identify,
27 + represent: options.represent
?? ((data)
=> String(data)),
28 + representTagName: options.representTagName
?? (()
=> tagName)
31 +function defineSequenceTag(tagName, options) {
32 + const carrierIsResult
= options.finalize
=== void 0;
35 + nodeKind:
"sequence",
37 + matchByTagPrefix: options.matchByTagPrefix
?? false,
38 + create: options.create,
39 + addItem: options.addItem,
40 + finalize: options.finalize
?? ((carrier)
=> carrier),
42 + identify: options.identify,
43 + represent: options.represent
?? ((data)
=> data),
44 + representTagName: options.representTagName
?? (()
=> tagName)
47 +function defineMappingTag(tagName, options) {
48 + const carrierIsResult
= options.finalize
=== void 0;
51 + nodeKind:
"mapping",
53 + matchByTagPrefix: options.matchByTagPrefix
?? false,
54 + create: options.create,
55 + addPair: options.addPair,
59 + finalize: options.finalize
?? ((carrier)
=> carrier),
61 + identify: options.identify,
62 + represent: options.represent
?? ((data)
=> data),
63 + representTagName: options.representTagName
?? (()
=> tagName)
66 +var strTag
= defineScalarTag(
"tag:yaml.org,2002:str", {
67 + resolve: (source)
=> source,
68 + identify: (data)
=> typeof data
=== "string" 70 +var NULL_VALUES$1
= [
77 +var nullCoreTag
= defineScalarTag(
"tag:yaml.org,2002:null", {
79 + implicitFirstChars: [
85 + resolve: (source)
=> {
86 + if (
NULL_VALUES$1.indexOf(source)
!== -1)
return null;
87 + return NOT_RESOLVED;
89 + identify: (object)
=> object
=== null,
90 + represent: ()
=> "null" 92 +var nullJsonTag
= defineScalarTag(
"tag:yaml.org,2002:null", {
94 + implicitFirstChars: [
"n"],
95 + resolve: (source, isExplicit)
=> {
96 + if (source
=== "null" || isExplicit
&& source
=== "")
return null;
97 + return NOT_RESOLVED;
99 + identify: (object)
=> object
=== null,
100 + represent: ()
=> "null" 109 +var nullYaml11Tag
= defineScalarTag(
"tag:yaml.org,2002:null", {
111 + implicitFirstChars: [
117 + resolve: (source)
=> {
118 + if (
NULL_VALUES.indexOf(source)
!== -1)
return null;
119 + return NOT_RESOLVED;
121 + identify: (object)
=> object
=== null,
122 + represent: ()
=> "null" 124 +var TRUE_VALUES$2
= [
129 +var FALSE_VALUES$2
= [
134 +var boolCoreTag
= defineScalarTag(
"tag:yaml.org,2002:bool", {
136 + implicitFirstChars: [
142 + resolve: (source)
=> {
143 + if (
TRUE_VALUES$2.indexOf(source)
!== -1)
return true;
144 + if (
FALSE_VALUES$2.indexOf(source)
!== -1)
return false;
145 + return NOT_RESOLVED;
147 + identify: (object)
=> Object.
prototype.
toString.call(object)
=== "[object Boolean]",
148 + represent: (object)
=> object
? "true" : "false" 150 +var TRUE_VALUES$1
= [
"true"];
151 +var FALSE_VALUES$1
= [
"false"];
152 +var boolJsonTag
= defineScalarTag(
"tag:yaml.org,2002:bool", {
154 + implicitFirstChars: [
"t",
"f"],
155 + resolve: (source)
=> {
156 + if (
TRUE_VALUES$1.indexOf(source)
!== -1)
return true;
157 + if (
FALSE_VALUES$1.indexOf(source)
!== -1)
return false;
158 + return NOT_RESOLVED;
160 + identify: (object)
=> Object.
prototype.
toString.call(object)
=== "[object Boolean]",
161 + represent: (object)
=> object
? "true" : "false" 176 +var FALSE_VALUES
= [
189 +var boolYaml11Tag
= defineScalarTag(
"tag:yaml.org,2002:bool", {
191 + implicitFirstChars: [
203 + resolve: (source)
=> {
204 + if (
TRUE_VALUES.indexOf(source)
!== -1)
return true;
205 + if (
FALSE_VALUES.indexOf(source)
!== -1)
return false;
206 + return NOT_RESOLVED;
208 + identify: (object)
=> Object.
prototype.
toString.call(object)
=== "[object Boolean]",
209 + represent: (object)
=> object
? "true" : "false" 211 +var YAML_INTEGER_IMPLICIT_PATTERN$1
= new RegExp(
"^(?:0o[0-7]+|0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
212 +var YAML_INTEGER_EXPLICIT_PATTERN$1
= new RegExp(
"^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
213 +function parseYamlInteger$2(source) {
214 + let value
= source;
216 + if (value[
0]
=== "-" || value[
0]
=== "+") {
217 + if (value[
0]
=== "-") sign
= -1;
218 + value
= value.slice(
1);
220 + if (value.startsWith(
"0b"))
return sign
* parseInt(value.slice(
2),
2);
221 + if (value.startsWith(
"0o"))
return sign
* parseInt(value.slice(
2),
8);
222 + if (value.startsWith(
"0x"))
return sign
* parseInt(value.slice(
2),
16);
223 + return sign
* parseInt(value,
10);
225 +function resolveYamlInteger$2(source, isExplicit) {
227 + if (
!YAML_INTEGER_EXPLICIT_PATTERN$1.test(source))
return NOT_RESOLVED;
228 + }
else if (
!YAML_INTEGER_IMPLICIT_PATTERN$1.test(source))
return NOT_RESOLVED;
229 + const result
= parseYamlInteger$2(source);
230 + return Number.
isFinite(result)
? result
: NOT_RESOLVED;
232 +var intCoreTag
= defineScalarTag(
"tag:yaml.org,2002:int", {
234 + implicitFirstChars: [
239 + resolve: resolveYamlInteger$2,
240 + identify: (object)
=> Number.
isInteger(object)
&& !Object.
is(object,
-0)
&& object.
toString(
10).indexOf(
"e")
< 0,
241 + represent: (object)
=> object.
toString(
10)
243 +var YAML_INTEGER_IMPLICIT_PATTERN
= new RegExp(
"^-?(?:0|[1-9][0-9]*)$");
244 +var YAML_INTEGER_EXPLICIT_PATTERN
= new RegExp(
"^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
245 +function parseYamlInteger$1(source) {
246 + let value
= source;
248 + if (value[
0]
=== "-" || value[
0]
=== "+") {
249 + if (value[
0]
=== "-") sign
= -1;
250 + value
= value.slice(
1);
252 + if (value.startsWith(
"0b"))
return sign
* parseInt(value.slice(
2),
2);
253 + if (value.startsWith(
"0o"))
return sign
* parseInt(value.slice(
2),
8);
254 + if (value.startsWith(
"0x"))
return sign
* parseInt(value.slice(
2),
16);
255 + return sign
* parseInt(value,
10);
257 +function resolveYamlInteger$1(source, isExplicit) {
259 + if (
!YAML_INTEGER_EXPLICIT_PATTERN.test(source))
return NOT_RESOLVED;
260 + }
else if (
!YAML_INTEGER_IMPLICIT_PATTERN.test(source))
return NOT_RESOLVED;
261 + const result
= parseYamlInteger$1(source);
262 + return Number.
isFinite(result)
? result
: NOT_RESOLVED;
264 +var intJsonTag
= defineScalarTag(
"tag:yaml.org,2002:int", {
266 + implicitFirstChars: [
"-",
..."0123456789"],
267 + resolve: resolveYamlInteger$1,
268 + identify: (object)
=> Number.
isInteger(object)
&& !Object.
is(object,
-0)
&& object.
toString(
10).indexOf(
"e")
< 0,
269 + represent: (object)
=> object.
toString(
10)
271 +var YAML_INTEGER_PATTERN
= new RegExp(
"^(?:[-+]?0b[0-1_]+|[-+]?0[0-7_]+|[-+]?0x[0-9a-fA-F_]+|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+|[-+]?(?:0|[1-9][0-9_]*))$");
272 +function parseYamlInteger(source) {
273 + let value
= source.replace(
/_/g,
"");
275 + if (value[
0]
=== "-" || value[
0]
=== "+") {
276 + if (value[
0]
=== "-") sign
= -1;
277 + value
= value.slice(
1);
279 + if (value.startsWith(
"0b"))
return sign
* parseInt(value.slice(
2),
2);
280 + if (value.startsWith(
"0x"))
return sign
* parseInt(value.slice(
2),
16);
281 + if (value.includes(
":")) {
283 + for (
const part
of value.split(
":")) result
= result
* 60 + Number(part);
284 + return sign
* result;
286 + if (value
!== "0" && value[
0]
=== "0")
return sign
* parseInt(value,
8);
287 + return sign
* parseInt(value,
10);
289 +function resolveYamlInteger(source) {
290 + if (
!YAML_INTEGER_PATTERN.test(source))
return NOT_RESOLVED;
291 + const result
= parseYamlInteger(source);
292 + return Number.
isFinite(result)
? result
: NOT_RESOLVED;
294 +var intYaml11Tag
= defineScalarTag(
"tag:yaml.org,2002:int", {
296 + implicitFirstChars: [
301 + resolve: resolveYamlInteger,
302 + identify: (object)
=> Number.
isInteger(object)
&& !Object.
is(object,
-0)
&& object.
toString(
10).indexOf(
"e")
< 0,
303 + represent: (object)
=> object.
toString(
10)
305 +var YAML_FLOAT_PATTERN$1
= new RegExp(
"^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
306 +var YAML_FLOAT_SPECIAL_PATTERN$1
= new RegExp(
"^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
307 +function resolveYamlFloat$2(source) {
308 + if (
!YAML_FLOAT_PATTERN$1.test(source))
return NOT_RESOLVED;
309 + let value
= source.toLowerCase();
310 + const sign
= value[
0]
=== "-" ? -1 : 1;
311 + if (
"+-".includes(value[
0])) value
= value.slice(
1);
312 + if (value
=== ".inf")
return sign
=== 1 ? Number.
POSITIVE_INFINITY : Number.
NEGATIVE_INFINITY;
313 + if (value
=== ".nan")
return NaN;
314 + const result
= sign
* parseFloat(value);
315 + if (
Number.
isFinite(result)
|| YAML_FLOAT_SPECIAL_PATTERN$1.test(source))
return result;
316 + return NOT_RESOLVED;
318 +function representYamlFloat$2(object) {
319 + if (
isNaN(object))
return ".nan";
320 + if (object
=== Number.
POSITIVE_INFINITY)
return ".inf";
321 + if (object
=== Number.
NEGATIVE_INFINITY)
return "-.inf";
322 + if (
Object.
is(object,
-0))
return "-0.0";
323 + const result
= object.
toString(
10);
324 + return /^[-+]?[0-9]+e/.test(result)
? result.replace(
"e",
".e")
: result;
326 +var floatCoreTag
= defineScalarTag(
"tag:yaml.org,2002:float", {
328 + implicitFirstChars: [
334 + resolve: resolveYamlFloat$2,
335 + identify: (object)
=> typeof object
=== "number" && (
!Number.
isInteger(object)
|| Object.
is(object,
-0)
|| object.
toString(
10).indexOf(
"e")
>= 0),
336 + represent: representYamlFloat$2
338 +var YAML_FLOAT_IMPLICIT_PATTERN
= new RegExp(
"^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$");
339 +var YAML_FLOAT_EXPLICIT_PATTERN
= new RegExp(
"^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
340 +function resolveYamlFloat$1(source, isExplicit) {
342 + if (
!YAML_FLOAT_EXPLICIT_PATTERN.test(source))
return NOT_RESOLVED;
343 + let value
= source.toLowerCase();
344 + const sign
= value[
0]
=== "-" ? -1 : 1;
345 + if (
"+-".includes(value[
0])) value
= value.slice(
1);
346 + if (value
=== ".inf")
return sign
=== 1 ? Number.
POSITIVE_INFINITY : Number.
NEGATIVE_INFINITY;
347 + if (value
=== ".nan")
return NaN;
348 + const result2
= sign
* parseFloat(value);
349 + return Number.
isFinite(result2)
? result2
: NOT_RESOLVED;
351 + if (
!YAML_FLOAT_IMPLICIT_PATTERN.test(source))
return NOT_RESOLVED;
352 + const result
= Number(source);
353 + if (
Number.
isFinite(result))
return result;
354 + return NOT_RESOLVED;
356 +function representYamlFloat$1(object) {
357 + if (
isNaN(object))
return ".nan";
358 + if (object
=== Number.
POSITIVE_INFINITY)
return ".inf";
359 + if (object
=== Number.
NEGATIVE_INFINITY)
return "-.inf";
360 + if (
Object.
is(object,
-0))
return "-0.0";
361 + const result
= object.
toString(
10);
362 + return /^[-+]?[0-9]+e/.test(result)
? result.replace(
"e",
".e")
: result;
364 +var floatJsonTag
= defineScalarTag(
"tag:yaml.org,2002:float", {
366 + implicitFirstChars: [
"-",
..."0123456789"],
367 + resolve: resolveYamlFloat$1,
368 + identify: (object)
=> typeof object
=== "number" && (
!Number.
isInteger(object)
|| Object.
is(object,
-0)
|| object.
toString(
10).indexOf(
"e")
>= 0),
369 + represent: representYamlFloat$1
371 +var YAML_FLOAT_PATTERN
= new RegExp(
"^(?:[-+]?(?:(?:[0-9][0-9_]*)?\\.[0-9_]*)(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
372 +var YAML_FLOAT_SPECIAL_PATTERN
= new RegExp(
"^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
373 +function resolveYamlFloat(source) {
374 + if (
!YAML_FLOAT_PATTERN.test(source))
return NOT_RESOLVED;
375 + let value
= source.toLowerCase().replace(
/_/g,
"");
376 + const sign
= value[
0]
=== "-" ? -1 : 1;
377 + if (
"+-".includes(value[
0])) value
= value.slice(
1);
378 + if (value
=== ".inf")
return sign
=== 1 ? Number.
POSITIVE_INFINITY : Number.
NEGATIVE_INFINITY;
379 + if (value
=== ".nan")
return NaN;
381 + if (value.includes(
":")) {
382 + for (
const part
of value.split(
":")) result
= result
* 60 + Number(part);
384 + }
else result
= sign
* parseFloat(value);
385 + if (
Number.
isFinite(result)
|| YAML_FLOAT_SPECIAL_PATTERN.test(source))
return result;
386 + return NOT_RESOLVED;
388 +function representYamlFloat(object) {
389 + if (
isNaN(object))
return ".nan";
390 + if (object
=== Number.
POSITIVE_INFINITY)
return ".inf";
391 + if (object
=== Number.
NEGATIVE_INFINITY)
return "-.inf";
392 + if (
Object.
is(object,
-0))
return "-0.0";
393 + const result
= object.
toString(
10);
394 + return /^[-+]?[0-9]+e/.test(result)
? result.replace(
"e",
".e")
: result;
396 +var floatYaml11Tag
= defineScalarTag(
"tag:yaml.org,2002:float", {
398 + implicitFirstChars: [
404 + resolve: resolveYamlFloat,
405 + identify: (object)
=> typeof object
=== "number" && (
!Number.
isInteger(object)
|| Object.
is(object,
-0)
|| object.
toString(
10).indexOf(
"e")
>= 0),
406 + represent: representYamlFloat
408 +var mergeTag
= defineScalarTag(
"tag:yaml.org,2002:merge", {
410 + implicitFirstChars: [
"<"],
411 + resolve: (source, isExplicit)
=> {
412 + if (source
=== "<<" || isExplicit
&& source
=== "")
return "<<";
413 + return NOT_RESOLVED;
415 + identify: ()
=> false 417 +var BASE64_PATTERN
= /^[A-Za-z0-9+/]*={0,2}$/;
418 +function resolveYamlBinary(source) {
419 + const input
= source.replace(
/\s/g,
"");
420 + if (input.length
% 4 !== 0 || !BASE64_PATTERN.test(input))
return NOT_RESOLVED;
421 + const binary
= atob(input);
422 + const result
= new Uint8Array(binary.length);
423 + for (
let index
= 0; index
< binary.length; index
++) result[index]
= binary.charCodeAt(index);
426 +function representYamlBinary(object) {
428 + for (
let index
= 0; index
< object.length; index
++) binary
+= String.
fromCharCode(object[index]);
429 + return btoa(binary);
431 +var binaryTag
= defineScalarTag(
"tag:yaml.org,2002:binary", {
432 + resolve: resolveYamlBinary,
433 + identify: (object)
=> Object.
prototype.
toString.call(object)
=== "[object Uint8Array]",
434 + represent: representYamlBinary
436 +var YAML_DATE_REGEXP
= new RegExp(
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
437 +var YAML_TIMESTAMP_REGEXP
= new RegExp(
"^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");
438 +function makeUtcDate(year, month, day, hour
= 0, minute
= 0, second
= 0, fraction
= 0) {
439 + const date
= new Date(
Date.
UTC(year, month, day, hour, minute, second, fraction));
440 + date.setUTCFullYear(year, month, day);
443 +function resolveYamlTimestamp(source) {
444 + let match
= YAML_DATE_REGEXP.exec(source);
445 + if (match
=== null) match
= YAML_TIMESTAMP_REGEXP.exec(source);
446 + if (match
=== null)
return NOT_RESOLVED;
447 + const year
= +match[
1];
448 + const month
= +match[
2]
- 1;
449 + const day
= +match[
3];
451 + const date2
= makeUtcDate(year, month, day);
452 + if (date2.getUTCFullYear()
!== year
|| date2.getUTCMonth()
!== month
|| date2.getUTCDate()
!== day)
return NOT_RESOLVED;
455 + const hour
= +match[
4];
456 + const minute
= +match[
5];
457 + const second
= +match[
6];
459 + if (hour
> 23 || minute
> 59 || second
> 59)
return NOT_RESOLVED;
461 + let value
= match[
7].slice(
0,
3);
462 + while (value.length
< 3) value
+= "0";
465 + const date
= makeUtcDate(year, month, day, hour, minute, second, fraction);
466 + if (date.getUTCFullYear()
!== year
|| date.getUTCMonth()
!== month
|| date.getUTCDate()
!== day)
return NOT_RESOLVED;
468 + const offsetHour
= +match[
10];
469 + const offsetMinute
= +(match[
11]
|| 0);
470 + if (offsetHour
> 23 || offsetMinute
> 59)
return NOT_RESOLVED;
471 + const offset
= (offsetHour
* 60 + offsetMinute)
* 6e4;
472 + date.setTime(date.getTime()
- (match[
9]
=== "-" ? -offset
: offset));
476 +var timestampTag
= defineScalarTag(
"tag:yaml.org,2002:timestamp", {
478 + implicitFirstChars: [
..."0123456789"],
479 + resolve: resolveYamlTimestamp,
480 + identify: (object)
=> object
instanceof Date,
481 + represent: (object)
=> object.toISOString()
483 +var seqTag
= defineSequenceTag(
"tag:yaml.org,2002:seq", {
485 + addItem: (container, item)
=> {
486 + container.push(item);
488 + identify:
Array.
isArray 490 +function isPlainObject(data) {
491 + if (data
=== null || typeof data
!== "object" || Array.
isArray(data))
return false;
492 + const prototype
= Object.
getPrototypeOf(data);
493 + return prototype
=== null || prototype
=== Object.
prototype;
495 +function pick(object, keys) {
497 + for (
const key
of keys)
if (object[key]
!== void 0) result[key]
= object[key];
500 +var omapTag
= defineSequenceTag(
"tag:yaml.org,2002:omap", {
505 + addItem: (carrier, item)
=> {
507 + if (item
instanceof Map) {
508 + if (item.size
!== 1)
return "cannot resolve an ordered map item";
509 + key
= item.keys().next().value;
510 + }
else if (isPlainObject(item)) {
511 + const itemKeys
= Object.
keys(item);
512 + if (itemKeys.length
!== 1)
return "cannot resolve an ordered map item";
514 + }
else return "cannot resolve an ordered map item";
515 + if (carrier.seen.has(key))
return "duplicate key in ordered map";
516 + carrier.seen.add(key);
517 + carrier.list.push(item);
520 + finalize: (carrier)
=> carrier.list,
521 + identify: ()
=> false 523 +var pairsTag
= defineSequenceTag(
"tag:yaml.org,2002:pairs", {
525 + addItem: (container, item)
=> {
526 + if (item
instanceof Map) {
527 + if (item.size
!== 1)
return "cannot resolve a pairs item";
528 + container.push(item.entries().next().value);
531 + if (
Object.
prototype.
toString.call(item)
!== "[object Object]")
return "cannot resolve a pairs item";
532 + const object
= item;
533 + const keys
= Object.
keys(object);
534 + if (keys.length
!== 1)
return "cannot resolve a pairs item";
535 + container.push([keys[
0], object[keys[
0]]]);
538 + identify: ()
=> false 540 +var mapTag
= defineMappingTag(
"tag:yaml.org,2002:map", {
541 + create: ()
=> ({}),
542 + identify: isPlainObject,
543 + represent: (o)
=> {
544 + const map
= new Map();
545 + for (
const key
of Object.
keys(o)) map.set(key, o[key]);
548 + addPair: (container, key, value)
=> {
549 + if (key
!== null && typeof key
=== "object")
return "object-based map does not support complex keys";
550 + const normalizedKey
= String(key);
551 + if (normalizedKey
=== "__proto__")
Object.
defineProperty(container, normalizedKey, {
554 + configurable:
true,
557 + else container[normalizedKey]
= value;
560 + has: (container, key)
=> {
561 + if (key
!== null && typeof key
=== "object")
return false;
562 + return Object.
prototype.
hasOwnProperty.call(container,
String(key));
564 + keys: (container)
=> Object.
keys(container),
565 + get: (container, key)
=> {
566 + const normalizedKey
= String(key);
567 + if (
!Object.
prototype.
hasOwnProperty.call(container, normalizedKey))
return null;
568 + return container[normalizedKey];
571 +var setTag
= defineMappingTag(
"tag:yaml.org,2002:set", {
572 + create: ()
=> new Set(),
573 + identify: (data)
=> data
instanceof Set,
574 + represent: (data)
=> {
575 + const map
= new Map();
576 + for (
const key
of data) map.set(key,
null);
579 + addPair: (container, key, value)
=> {
580 + if (value
!== null)
return "cannot resolve a set item";
581 + container.add(key);
584 + has: (container, key)
=> container.has(key),
585 + keys: (container)
=> container.keys(),
588 +function createTagDefinitionMap() {
590 + scalar:
Object.
create(
null),
591 + sequence:
Object.
create(
null),
592 + mapping:
Object.
create(
null)
595 +function createTagDefinitionListMap() {
602 +function compileTags(tags) {
604 + for (
const tag
of tags) {
605 + let index
= result.length;
606 + for (
let previousIndex
= 0; previousIndex
< result.length; previousIndex
++) {
607 + const previous
= result[previousIndex];
608 + if (previous.nodeKind
=== tag.nodeKind
&& previous.tagName
=== tag.tagName
&& previous.matchByTagPrefix
=== tag.matchByTagPrefix) {
609 + index
= previousIndex;
613 + result[index]
= tag;
617 +var Schema
= class Schema2 {
620 + implicitScalarTags;
629 + implicitScalarByFirstChar;
630 + implicitScalarAnyFirstChar;
646 + defaultSequenceTag;
651 + constructor(tags) {
652 + const compiledTags
= compileTags(tags);
653 + const implicitScalarTags
= [];
654 + const exact
= createTagDefinitionMap();
655 + const prefix
= createTagDefinitionListMap();
656 + for (
const tag
of compiledTags) {
657 + if (tag.nodeKind
=== "scalar" && tag.implicit) {
658 + if (tag.matchByTagPrefix)
throw new Error(
"Implicit scalar tags cannot match by tag prefix");
659 + implicitScalarTags.push(tag);
661 + switch (tag.nodeKind) {
663 + if (tag.matchByTagPrefix) prefix.scalar.push(tag);
664 + else exact.scalar[tag.tagName]
= tag;
667 + if (tag.matchByTagPrefix) prefix.sequence.push(tag);
668 + else exact.sequence[tag.tagName]
= tag;
671 + if (tag.matchByTagPrefix) prefix.mapping.push(tag);
672 + else exact.mapping[tag.tagName]
= tag;
676 + const implicitScalarAnyFirstChar
= implicitScalarTags.filter((tag)
=> tag.implicitFirstChars
=== null);
677 + const keys
= new Set();
678 + for (
const tag
of implicitScalarTags)
if (tag.implicitFirstChars
!== null)
for (
const key
of tag.implicitFirstChars) keys.add(key);
679 + const implicitScalarByFirstChar
= new Map();
680 + for (
const key
of keys) implicitScalarByFirstChar.set(key, implicitScalarTags.filter((tag)
=> tag.implicitFirstChars
=== null || tag.implicitFirstChars.indexOf(key)
!== -1));
681 + const defaultScalarTag
= exact.scalar[
"tag:yaml.org,2002:str"];
682 + if (
!defaultScalarTag)
throw new Error(
"schema does not define the default scalar tag (tag:yaml.org,2002:str)");
683 + this.tags
= compiledTags;
684 + this.implicitScalarTags
= implicitScalarTags;
685 + this.implicitScalarByFirstChar
= implicitScalarByFirstChar;
686 + this.implicitScalarAnyFirstChar
= implicitScalarAnyFirstChar;
687 + this.defaultScalarTag
= defaultScalarTag;
688 + this.defaultSequenceTag
= exact.sequence[
"tag:yaml.org,2002:seq"];
689 + this.defaultMappingTag
= exact.mapping[
"tag:yaml.org,2002:map"];
690 + this.exact
= exact;
691 + this.prefix
= prefix;
694 + lookupScalarTag(tagName) {
695 + const exactTag
= this.exact.scalar[tagName];
696 + if (exactTag)
return exactTag;
697 + for (
const tag
of this.prefix.scalar)
if (tagName.startsWith(tag.tagName))
return tag;
700 + lookupSequenceTag(tagName) {
701 + const exactTag
= this.exact.sequence[tagName];
702 + if (exactTag)
return exactTag;
703 + for (
const tag
of this.prefix.sequence)
if (tagName.startsWith(tag.tagName))
return tag;
706 + lookupMappingTag(tagName) {
707 + const exactTag
= this.exact.mapping[tagName];
708 + if (exactTag)
return exactTag;
709 + for (
const tag
of this.prefix.mapping)
if (tagName.startsWith(tag.tagName))
return tag;
712 + resolveImplicitScalarTag(source) {
713 + const candidates
= this.implicitScalarByFirstChar.get(source.charAt(
0))
?? this.implicitScalarAnyFirstChar;
714 + for (
const tag2
of candidates) {
715 + const value
= tag2.resolve(source,
false, tag2.tagName);
716 + if (value
!== NOT_RESOLVED)
return {
721 + const tag
= this.defaultScalarTag;
723 + value: tag.resolve(source,
false, tag.tagName),
739 + withTags(
...tags) {
741 + for (
const tag
of tags) flatTags
= flatTags.concat(tag);
742 + return new Schema2([
...this.tags,
...flatTags]);
745 +var FAILSAFE_SCHEMA
= new Schema([
750 +var JSON_SCHEMA
= new Schema([
751 + ...FAILSAFE_SCHEMA.tags,
757 +var CORE_SCHEMA
= new Schema([
758 + ...FAILSAFE_SCHEMA.tags,
764 +var YAML11_SCHEMA
= new Schema([
765 + ...FAILSAFE_SCHEMA.tags,
777 +var DUMP_SCHEMA
= YAML11_SCHEMA.withTags({
779 + resolve: (source, isExplicit, tagName)
=> {
780 + const result
= intYaml11Tag.resolve(source, isExplicit, tagName);
781 + return result
=== NOT_RESOLVED
? intCoreTag.resolve(source, isExplicit, tagName)
: result;
785 + resolve: (source, isExplicit, tagName)
=> {
786 + const result
= floatYaml11Tag.resolve(source, isExplicit, tagName);
787 + return result
=== NOT_RESOLVED
? floatCoreTag.resolve(source, isExplicit, tagName)
: result;
790 +var realMapTag
= defineMappingTag(
"tag:yaml.org,2002:map", {
791 + create: ()
=> new Map(),
792 + addPair: (container, key, value)
=> {
793 + container.set(key, value);
796 + has: (container, key)
=> container.has(key),
797 + keys: (container)
=> container.keys(),
798 + get: (container, key)
=> container.get(key),
799 + identify: (data)
=> data
instanceof Map || isPlainObject(data),
800 + represent: (data)
=> {
801 + if (data
instanceof Map)
return data;
802 + const map
= new Map();
804 + for (
const key
of Object.
keys(obj)) map.set(key, obj[key]);
808 +function normalizeKey(key) {
809 + if (
Array.
isArray(key)) {
810 + const array
= Array.
prototype.slice.call(key);
811 + for (
let index
= 0; index
< array.length; index
++) {
812 + if (
Array.
isArray(array[index]))
return null;
813 + if (
typeof array[index]
=== "object" && Object.
prototype.
toString.call(array[index])
=== "[object Object]") array[index]
= "[object Object]";
815 + return String(array);
817 + if (
typeof key
=== "object" && Object.
prototype.
toString.call(key)
=== "[object Object]")
return "[object Object]";
818 + return String(key);
820 +var legacyMapTag
= defineMappingTag(
"tag:yaml.org,2002:map", {
821 + create: ()
=> ({}),
822 + identify: isPlainObject,
823 + represent: (o)
=> {
824 + const map
= new Map();
825 + for (
const key
of Object.
keys(o)) map.set(key, o[key]);
828 + addPair: (container, key, value)
=> {
829 + const normalizedKey
= normalizeKey(key);
830 + if (normalizedKey
=== null)
return "nested arrays are not supported inside keys";
831 + if (normalizedKey
=== "__proto__")
Object.
defineProperty(container, normalizedKey, {
834 + configurable:
true,
837 + else container[normalizedKey]
= value;
840 + has: (container, key)
=> {
841 + const normalizedKey
= normalizeKey(key);
842 + return normalizedKey
!== null && Object.
prototype.
hasOwnProperty.call(container, normalizedKey);
844 + keys: (container)
=> Object.
keys(container),
845 + get: (container, key)
=> {
846 + const normalizedKey
= String(key);
847 + if (
!Object.
prototype.
hasOwnProperty.call(container, normalizedKey))
return null;
848 + return container[normalizedKey];
851 +var DEFAULT_SNIPPET_OPTIONS
= {
857 +function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
860 + const maxHalfLength
= Math.
floor(maxLineLength
/ 2)
- 1;
861 + if (position
- lineStart
> maxHalfLength) {
863 + lineStart
= position
- maxHalfLength
+ head.length;
865 + if (lineEnd
- position
> maxHalfLength) {
867 + lineEnd
= position
+ maxHalfLength
- tail.length;
870 + str: head
+ buffer.slice(lineStart, lineEnd).replace(
/\t/g,
"\u2192")
+ tail,
871 + pos: position
- lineStart
+ head.length
874 +function padStart(string, max) {
875 + return " ".repeat(
Math.
max(max
- string.length,
0))
+ string;
877 +function makeSnippet(mark, options) {
878 + if (
!mark.buffer)
return null;
880 + ...DEFAULT_SNIPPET_OPTIONS,
883 + const re
= /\r?\n|\r|\0/g;
884 + const lineStarts
= [
0];
885 + const lineEnds
= [];
887 + let foundLineNo
= -1;
888 + while (match
= re.exec(mark.buffer)) {
889 + lineEnds.push(match.index);
890 + lineStarts.push(match.index
+ match[
0].length);
891 + if (mark.position
<= match.index
&& foundLineNo
< 0) foundLineNo
= lineStarts.length
- 2;
893 + if (foundLineNo
< 0) foundLineNo
= lineStarts.length
- 1;
895 + const lineNoLength
= Math.
min(mark.line
+ opts.linesAfter, lineEnds.length).
toString().length;
896 + const maxLineLength
= opts.maxLength
- (opts.indent
+ lineNoLength
+ 3);
897 + for (
let i
= 1; i
<= opts.linesBefore; i
++) {
898 + if (foundLineNo
- i
< 0)
break;
899 + const line2
= getLine(mark.buffer, lineStarts[foundLineNo
- i], lineEnds[foundLineNo
- i], mark.position
- (lineStarts[foundLineNo]
- lineStarts[foundLineNo
- i]), maxLineLength);
900 + result
= `${
" ".repeat(opts.indent)}${padStart((mark.line
- i
+ 1).
toString(), lineNoLength)}
| ${line2.str}
903 + const line
= getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
904 + result
+= `${
" ".repeat(opts.indent)}${padStart((mark.line
+ 1).
toString(), lineNoLength)}
| ${line.str}
906 + result
+= `${
"-".repeat(opts.indent
+ lineNoLength
+ 3 + line.pos)}
^ 908 + for (
let i
= 1; i
<= opts.linesAfter; i
++) {
909 + if (foundLineNo
+ i
>= lineEnds.length)
break;
910 + const line2
= getLine(mark.buffer, lineStarts[foundLineNo
+ i], lineEnds[foundLineNo
+ i], mark.position
- (lineStarts[foundLineNo]
- lineStarts[foundLineNo
+ i]), maxLineLength);
911 + result
+= `${
" ".repeat(opts.indent)}${padStart((mark.line
+ i
+ 1).
toString(), lineNoLength)}
| ${line2.str}
914 + return result.replace(
/\n$/,
"");
916 +function formatError(exception, compact) {
918 + if (
!exception.mark)
return exception.reason;
919 + if (exception.mark.name) where
+= `in "${exception.mark.name}
" `;
920 + where
+= `(${exception.mark.line
+ 1}
:${exception.mark.column
+ 1}
)`;
921 + if (
!compact
&& exception.mark.snippet) where
+= ` 923 +${exception.mark.snippet}
`;
924 + return `${exception.reason}
${where}
`;
926 +var YAMLException
= class YAMLException2 extends Error {
933 + constructor(reason, mark) {
935 + this.name
= "YAMLException";
936 + this.reason
= reason;
938 + this.message
= formatError(this,
false);
939 + if (
Error.captureStackTrace)
Error.captureStackTrace(this, this.constructor);
944 + toString(compact) {
945 + return `${this.name}
: ${formatError(this, compact)}
`;
951 + static throwAt(source, position, message, filename
= "") {
954 + for (
let index
= 0; index
< position; index
++) {
955 + const ch
= source.charCodeAt(index);
958 + lineStart
= index
+ 1;
959 + }
else if (ch
=== 13) {
961 + if (source.charCodeAt(index
+ 1)
=== 10) index
++;
962 + lineStart
= index
+ 1;
970 + column: position
- lineStart
972 + mark.snippet
= makeSnippet(mark);
973 + throw new YAMLException2(message, mark);
984 +var SCALAR_STYLE
= {
991 +var COLLECTION_STYLE
= {
995 +var CHOMPING_MODE
= {
1000 +var NO_RANGE$3
= -1;
1001 +function simpleEscapeSequence(c) {
1043 +var simpleEscapeCheck
= new Array(
256);
1044 +var simpleEscapeMap
= new Array(
256);
1045 +for (
let i
= 0; i
< 256; i
++) {
1046 + simpleEscapeCheck[i]
= simpleEscapeSequence(i)
? 1 : 0;
1047 + simpleEscapeMap[i]
= simpleEscapeSequence(i);
1049 +function charFromCodepoint(c) {
1050 + if (c
<= 65535)
return String.
fromCharCode(c);
1051 + return String.
fromCharCode((c
- 65536 >> 10)
+ 55296, (c
- 65536 & 1023)
+ 56320);
1053 +function fromHexCode$1(c) {
1054 + if (c
>= 48 && c
<= 57)
return c
- 48;
1055 + return (c
| 32)
- 97 + 10;
1057 +function escapedHexLen$1(c) {
1058 + if (c
=== 120)
return 2;
1059 + if (c
=== 117)
return 4;
1062 +function skipFoldedBreaks(input, position, end) {
1064 + while (position
< end) {
1065 + const ch
= input.charCodeAt(position);
1069 + }
else if (ch
=== 13) {
1072 + if (input.charCodeAt(position)
=== 10) position
++;
1073 + }
else if (ch
=== 32 || ch
=== 9) position
++;
1081 +function foldedBreaks(count) {
1082 + if (count
=== 1)
return " ";
1083 + return "\n".repeat(count
- 1);
1085 +function getPlainValue(input, start, end) {
1087 + let position
= start;
1088 + let captureStart
= start;
1089 + let captureEnd
= start;
1090 + while (position
< end) {
1091 + const ch
= input.charCodeAt(position);
1092 + if (ch
=== 10 || ch
=== 13) {
1093 + result
+= input.slice(captureStart, captureEnd);
1094 + const fold
= skipFoldedBreaks(input, position, end);
1095 + result
+= foldedBreaks(fold.breaks);
1096 + position
= captureStart
= captureEnd
= fold.position;
1099 + if (ch
!== 32 && ch
!== 9) captureEnd
= position;
1102 + return result
+ input.slice(captureStart, captureEnd);
1104 +function getSingleQuotedValue(input, start, end) {
1106 + let position
= start;
1107 + let captureStart
= start;
1108 + let captureEnd
= start;
1109 + while (position
< end) {
1110 + const ch
= input.charCodeAt(position);
1112 + result
+= input.slice(captureStart, position)
+ "'";
1114 + captureStart
= captureEnd
= position;
1115 + }
else if (ch
=== 10 || ch
=== 13) {
1116 + result
+= input.slice(captureStart, captureEnd);
1117 + const fold
= skipFoldedBreaks(input, position, end);
1118 + result
+= foldedBreaks(fold.breaks);
1119 + position
= captureStart
= captureEnd
= fold.position;
1122 + if (ch
!== 32 && ch
!== 9) captureEnd
= position;
1125 + return result
+ input.slice(captureStart, end);
1127 +function getDoubleQuotedValue(input, start, end) {
1129 + let position
= start;
1130 + let captureStart
= start;
1131 + let captureEnd
= start;
1132 + while (position
< end) {
1133 + const ch
= input.charCodeAt(position);
1135 + result
+= input.slice(captureStart, position);
1137 + const escaped
= input.charCodeAt(position);
1138 + if (escaped
=== 10 || escaped
=== 13) position
= skipFoldedBreaks(input, position, end).position;
1139 + else if (escaped
< 256 && simpleEscapeCheck[escaped]) {
1140 + result
+= simpleEscapeMap[escaped];
1143 + let hexLength
= escapedHexLen$1(escaped);
1144 + let hexResult
= 0;
1145 + for (; hexLength
> 0; hexLength
--) {
1147 + const digit
= fromHexCode$1(input.charCodeAt(position));
1148 + hexResult
= (hexResult
<< 4)
+ digit;
1150 + result
+= charFromCodepoint(hexResult);
1153 + captureStart
= captureEnd
= position;
1154 + }
else if (ch
=== 10 || ch
=== 13) {
1155 + result
+= input.slice(captureStart, captureEnd);
1156 + const fold
= skipFoldedBreaks(input, position, end);
1157 + result
+= foldedBreaks(fold.breaks);
1158 + position
= captureStart
= captureEnd
= fold.position;
1161 + if (ch
!== 32 && ch
!== 9) captureEnd
= position;
1164 + return result
+ input.slice(captureStart, end);
1166 +function getBlockValue(input, start, end, indent, chomping, folded) {
1167 + const textIndent
= indent
< 0 ? 0 : indent;
1168 + const region
= input.slice(start, end).replace(
/\r\n?/g,
"\n");
1169 + const lines
= region
=== "" ? []
: (region.endsWith(
"\n")
? region.slice(
0,
-1)
: region).split(
"\n");
1171 + let didReadContent
= false;
1172 + let emptyLines
= 0;
1173 + let atMoreIndented
= false;
1174 + for (
const line
of lines) {
1176 + while (column
< textIndent
&& line.charCodeAt(column)
=== 32) column
++;
1177 + if (indent
< 0 || column
>= line.length) {
1181 + const content
= line.slice(textIndent);
1182 + const first
= content.charCodeAt(
0);
1183 + if (folded)
if (first
=== 32 || first
=== 9) {
1184 + atMoreIndented
= true;
1185 + result
+= "\n".repeat(didReadContent
? 1 + emptyLines
: emptyLines);
1186 + }
else if (atMoreIndented) {
1187 + atMoreIndented
= false;
1188 + result
+= "\n".repeat(emptyLines
+ 1);
1189 + }
else if (emptyLines
=== 0) {
1190 + if (didReadContent) result
+= " ";
1191 + }
else result
+= "\n".repeat(emptyLines);
1192 + else result
+= "\n".repeat(didReadContent
? 1 + emptyLines
: emptyLines);
1193 + result
+= content;
1194 + didReadContent
= true;
1197 + if (chomping
=== CHOMPING_MODE.KEEP) result
+= "\n".repeat(didReadContent
? 1 + emptyLines
: emptyLines);
1198 + else if (chomping
!== CHOMPING_MODE.STRIP) {
1199 + if (didReadContent) result
+= "\n";
1203 +function getScalarValue(input, scalar) {
1204 + if (scalar.valueStart
=== NO_RANGE$3)
return "";
1205 + const { valueStart, valueEnd }
= scalar;
1206 + if (scalar.fast)
return input.slice(valueStart, valueEnd);
1207 + switch (scalar.style) {
1208 + case SCALAR_STYLE.SINGLE_QUOTED:
1209 + return getSingleQuotedValue(input, valueStart, valueEnd);
1210 + case SCALAR_STYLE.DOUBLE_QUOTED:
1211 + return getDoubleQuotedValue(input, valueStart, valueEnd);
1212 + case SCALAR_STYLE.LITERAL_BLOCK:
1213 + return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping,
false);
1214 + case SCALAR_STYLE.FOLDED_BLOCK:
1215 + return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping,
true);
1217 + return getPlainValue(input, valueStart, valueEnd);
1220 +var DEFAULT_TAG_HANDLERS
= Object.
assign(
Object.
create(
null), {
1222 + "!!":
"tag:yaml.org,2002:" 1224 +function tagNameFull(rawTag, tagHandlers) {
1225 + if (rawTag.startsWith(
"!<")
&& rawTag.endsWith(
">"))
return decodeURIComponent(rawTag.slice(
2,
-1));
1226 + const handleEnd
= rawTag.indexOf(
"!",
1);
1227 + const handle
= handleEnd
=== -1 ? "!" : rawTag.slice(
0, handleEnd
+ 1);
1228 + const prefix
= tagHandlers
?.[handle]
?? DEFAULT_TAG_HANDLERS[handle]
?? handle;
1229 + return decodeURIComponent(prefix)
+ decodeURIComponent(rawTag.slice(handle.length));
1231 +var NO_RANGE$2
= -1;
1232 +var MERGE_TAG_NAME
= "tag:yaml.org,2002:merge";
1233 +var DEFAULT_CONSTRUCTOR_OPTIONS
= {
1235 + schema: CORE_SCHEMA,
1237 + maxTotalMergeKeys:
1e4,
1240 +function eventPosition$1(event) {
1241 + if (
"tagStart" in event
&& event.tagStart
!== NO_RANGE$2)
return event.tagStart;
1242 + if (
"anchorStart" in event
&& event.anchorStart
!== NO_RANGE$2)
return event.anchorStart;
1243 + if (
"valueStart" in event
&& event.valueStart
!== NO_RANGE$2)
return event.valueStart;
1244 + if (
"start" in event)
return event.start;
1247 +function throwError$1(state, message) {
1248 + YAMLException.throwAt(state.source, state.position, message, state.filename);
1250 +function finalizeCollection(state, position, tag, carrier) {
1252 + return tag.finalize(carrier);
1254 + if (error
instanceof YAMLException)
throw error;
1255 + YAMLException.throwAt(state.source, position, error
instanceof Error ? error.message
: String(error), state.filename);
1258 +function constructScalar(state, event) {
1259 + const source
= getScalarValue(state.source, event);
1260 + const rawTag
= event.tagStart
=== NO_RANGE$2
? "" : state.source.slice(event.tagStart, event.tagEnd);
1261 + const strTag2
= state.schema.defaultScalarTag;
1262 + if (rawTag
!== "") {
1263 + if (rawTag
=== "!")
return {
1267 + const tagName
= tagNameFull(rawTag, state.tagHandlers);
1268 + const scalarTag
= state.schema.lookupScalarTag(tagName);
1270 + const result
= scalarTag.resolve(source,
true, tagName);
1271 + if (result
=== NOT_RESOLVED) throwError$1(state,
`cannot resolve a node with !<${tagName}
> explicit tag`);
1277 + const collectionTagDef
= state.schema.lookupMappingTag(tagName)
?? state.schema.lookupSequenceTag(tagName);
1278 + if (collectionTagDef) {
1279 + if (source
!== "") throwError$1(state,
`cannot resolve a node with !<${tagName}
> explicit tag`);
1280 + const carrier
= collectionTagDef.create(tagName);
1282 + value: collectionTagDef.carrierIsResult
? carrier
: finalizeCollection(state, state.position, collectionTagDef, carrier),
1283 + tag: collectionTagDef
1286 + throwError$1(state,
`unknown scalar tag !<${tagName}
>`);
1288 + if (event.style
=== SCALAR_STYLE.PLAIN)
return state.schema.resolveImplicitScalarTag(source);
1290 + value: strTag2.resolve(source,
false, strTag2.tagName),
1294 +function collectionTagName(state, event, defaultTagName) {
1295 + const rawTag
= event.tagStart
=== NO_RANGE$2
? "" : state.source.slice(event.tagStart, event.tagEnd);
1296 + return rawTag
=== "" || rawTag
=== "!" ? defaultTagName
: tagNameFull(rawTag, state.tagHandlers);
1298 +function isMappingTag(tag) {
1299 + return tag.nodeKind
=== "mapping";
1301 +function chargeMergeWork(state) {
1302 + state.totalMergeKeys
++;
1303 + if (state.maxTotalMergeKeys
!== -1 && state.totalMergeKeys
> state.maxTotalMergeKeys) throwError$1(state,
`merge keys exceeded maxTotalMergeKeys (${state.maxTotalMergeKeys}
)`);
1305 +function mergeKeys(state, frame, source, sourceTag) {
1306 + chargeMergeWork(state);
1307 + for (
const sourceKey
of sourceTag.keys(source)) {
1308 + chargeMergeWork(state);
1309 + if (frame.tag.has(frame.value, sourceKey))
continue;
1310 + const err
= frame.tag.addPair(frame.value, sourceKey, sourceTag.get(source, sourceKey));
1311 + if (err) throwError$1(state, err);
1312 + frame.overridable
??= new Set();
1313 + frame.overridable.add(sourceKey);
1316 +function mergeSource(state, frame, source, sourceTag) {
1317 + state.position
= frame.keyPosition;
1318 + if (isMappingTag(sourceTag)) mergeKeys(state, frame, source, sourceTag);
1319 + else if (sourceTag.nodeKind
=== "sequence" && Array.
isArray(source)) {
1320 + if (source.length
> 100) throwError$1(state,
"abnormal merge sequence size");
1321 + for (
const element
of source) {
1322 + const elementTag
= state.nodeTags.get(element);
1323 + if (
!elementTag) throwError$1(state,
"cannot merge mappings; the provided source object is unacceptable");
1324 + mergeKeys(state, frame, element, elementTag);
1326 + }
else throwError$1(state,
"cannot merge mappings; the provided source object is unacceptable");
1328 +function addMappingValue(state, frame, key, value, tag) {
1329 + state.position
= frame.keyPosition;
1330 + if (frame.keyIsMerge) {
1331 + mergeSource(state, frame, value, tag);
1334 + if (
!state.json
&& frame.tag.has(frame.value, key)
&& !frame.overridable
?.has(key)) throwError$1(state,
"duplicated mapping key");
1335 + const err
= frame.tag.addPair(frame.value, key, value);
1336 + if (err) throwError$1(state, err);
1337 + frame.overridable
?.delete(key);
1339 +function addValue(state, value, tag) {
1340 + const frame
= state.frames[state.frames.length
- 1];
1341 + if (frame.kind
=== "document") {
1342 + frame.value
= value;
1343 + frame.hasValue
= true;
1344 + }
else if (frame.kind
=== "sequence") {
1345 + if (isMappingTag(tag)) state.nodeTags.set(value, tag);
1346 + const err
= frame.tag.addItem(frame.value, value, frame.index
++);
1347 + if (err) throwError$1(state, err);
1348 + }
else if (frame.hasKey) {
1349 + const key
= frame.key;
1350 + frame.key
= void 0;
1351 + frame.hasKey
= false;
1352 + addMappingValue(state, frame, key, value, tag);
1354 + frame.key
= value;
1355 + frame.keyPosition
= state.position;
1356 + frame.hasKey
= true;
1357 + frame.keyIsMerge
= tag.tagName
=== MERGE_TAG_NAME;
1360 +function storeAnchor(state, event, value, tag, isValueFinal) {
1361 + if (event.anchorStart
!== NO_RANGE$2) {
1367 + state.anchors.set(state.source.slice(event.anchorStart, event.anchorEnd), anchor);
1372 +function constructFromEvents(events, options) {
1374 + ...DEFAULT_CONSTRUCTOR_OPTIONS,
1381 + anchors:
new Map(),
1382 + nodeTags:
new Map(),
1383 + tagHandlers:
Object.
create(
null),
1384 + totalMergeKeys:
0,
1387 + while (state.eventIndex
< state.events.length) {
1388 + const event
= state.events[state.eventIndex
++];
1389 + state.position
= eventPosition$1(event);
1390 + switch (event.type) {
1391 + case EVENT_ID.DOCUMENT:
1392 + state.anchors
= new Map();
1393 + state.nodeTags
= new Map();
1394 + state.aliasCount
= 0;
1395 + state.tagHandlers
= Object.
create(
null);
1396 + for (
const directive
of event.directives)
if (directive.kind
=== "tag") state.tagHandlers[directive.handle]
= directive.prefix;
1397 + state.frames.push({
1399 + position: state.position,
1404 + case EVENT_ID.SCALAR: {
1405 + const { value, tag }
= constructScalar(state, event);
1406 + storeAnchor(state, event, value, tag,
true);
1407 + addValue(state, value, tag);
1410 + case EVENT_ID.SEQUENCE: {
1411 + const tagName
= collectionTagName(state, event,
"tag:yaml.org,2002:seq");
1412 + const tag
= state.schema.lookupSequenceTag(tagName);
1413 + if (
!tag) throwError$1(state,
`unknown sequence tag !<${tagName}
>`);
1414 + const value
= tag.create(tagName);
1415 + const anchor
= storeAnchor(state, event, value, tag, tag.carrierIsResult);
1416 + state.frames.push({
1418 + position: state.position,
1426 + case EVENT_ID.MAPPING: {
1427 + const tagName
= collectionTagName(state, event,
"tag:yaml.org,2002:map");
1428 + const tag
= state.schema.lookupMappingTag(tagName);
1429 + if (
!tag) throwError$1(state,
`unknown mapping tag !<${tagName}
>`);
1430 + const value
= tag.create(tagName);
1431 + const anchor
= storeAnchor(state, event, value, tag, tag.carrierIsResult);
1432 + state.frames.push({
1434 + position: state.position,
1439 + keyPosition: state.position,
1441 + keyIsMerge:
false,
1446 + case EVENT_ID.ALIAS: {
1447 + if (state.maxAliases
!== -1 && ++state.aliasCount
> state.maxAliases) throwError$1(state,
`aliases exceeded maxAliases (${state.maxAliases}
)`);
1448 + const name
= state.source.slice(event.anchorStart, event.anchorEnd);
1449 + const anchor
= state.anchors.get(name);
1450 + if (
!anchor) throwError$1(state,
`unidentified alias "${name}
"`);
1451 + if (
!anchor.isValueFinal) throwError$1(state,
`recursive alias "${name}
" is not supported for tag ${anchor.tag.tagName}
because it uses finalize()`);
1452 + addValue(state, anchor.value, anchor.tag);
1455 + case EVENT_ID.POP: {
1456 + const frame
= state.frames.pop();
1457 + if (frame.kind
=== "mapping" && frame.hasKey) {
1458 + state.position
= frame.keyPosition;
1459 + throwError$1(state,
"incomplete mapping pair in event stream");
1461 + if (frame.kind
=== "document") state.documents.push(frame.value);
1463 + const value
= frame.tag.carrierIsResult
? frame.value
: finalizeCollection(state, frame.position, frame.tag, frame.value);
1464 + if (frame.anchor) {
1465 + frame.anchor.value
= value;
1466 + frame.anchor.isValueFinal
= true;
1468 + addValue(state, value, frame.tag);
1474 + return state.documents;
1476 +var NO_RANGE$1
= -1;
1477 +var HAS_OWN
= Object.
prototype.
hasOwnProperty;
1478 +var CONTEXT_FLOW_IN
= 1;
1479 +var CONTEXT_FLOW_OUT
= 2;
1480 +var CONTEXT_BLOCK_IN
= 3;
1481 +var CONTEXT_BLOCK_OUT
= 4;
1482 +var PATTERN_NON_PRINTABLE
= /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
1483 +var PATTERN_FLOW_INDICATORS
= /[,\[\]{}]/;
1484 +var PATTERN_TAG_HANDLE
= /^(?:!|!!|![0-9A-Za-z-]+!)$/;
1485 +var NS_URI_CHAR
= String.
raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`;
1486 +var NS_TAG_CHAR
= String.
raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`;
1487 +var PATTERN_TAG_URI
= new RegExp(
`^(?:${NS_URI_CHAR}
)*$`);
1488 +var PATTERN_TAG_SUFFIX
= new RegExp(
`^(?:${NS_TAG_CHAR}
)+$`);
1489 +var PATTERN_TAG_PREFIX
= new RegExp(
`^(?:!(?:${NS_URI_CHAR}
)*|${NS_TAG_CHAR}
(?:${NS_URI_CHAR}
)*)$`);
1490 +var DEFAULT_PARSER_OPTIONS
= {
1494 +function addDocumentEvent(state, explicitStart, explicitEnd) {
1495 + state.events.push({
1496 + type:
EVENT_ID.DOCUMENT,
1499 + directives: state.directives
1502 +function addSequenceEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
1503 + state.events.push({
1504 + type:
EVENT_ID.SEQUENCE,
1513 +function addMappingEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
1514 + state.events.push({
1515 + type:
EVENT_ID.MAPPING,
1524 +function insertFlowPairMappingEvent(state, snapshot) {
1525 + state.events.splice(snapshot.eventsLength,
0, {
1526 + type:
EVENT_ID.MAPPING,
1527 + start: snapshot.position,
1528 + anchorStart: NO_RANGE$1,
1529 + anchorEnd: NO_RANGE$1,
1530 + tagStart: NO_RANGE$1,
1531 + tagEnd: NO_RANGE$1,
1532 + style:
COLLECTION_STYLE.FLOW
1535 +function addScalarEvent(state, valueStart, valueEnd, anchorStart, anchorEnd, tagStart, tagEnd, style, chomping
= CHOMPING_MODE.CLIP, indent
= -1, fast
= false) {
1536 + state.events.push({
1537 + type:
EVENT_ID.SCALAR,
1550 +function addAliasEvent(state, anchorStart, anchorEnd) {
1551 + state.events.push({
1552 + type:
EVENT_ID.ALIAS,
1557 +function addPopEvent(state) {
1558 + state.events.push({ type:
EVENT_ID.POP });
1560 +function addEmptyScalarEvent(state) {
1561 + addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1,
SCALAR_STYLE.PLAIN);
1563 +function emptyProperties() {
1565 + anchorStart: NO_RANGE$1,
1566 + anchorEnd: NO_RANGE$1,
1567 + tagStart: NO_RANGE$1,
1568 + tagEnd: NO_RANGE$1
1571 +function snapshotState(state) {
1573 + position: state.position,
1575 + lineStart: state.lineStart,
1576 + lineIndent: state.lineIndent,
1577 + firstTabInLine: state.firstTabInLine,
1578 + eventsLength: state.events.length
1581 +function restoreState(state, snapshot) {
1582 + state.position
= snapshot.position;
1583 + state.line
= snapshot.line;
1584 + state.lineStart
= snapshot.lineStart;
1585 + state.lineIndent
= snapshot.lineIndent;
1586 + state.firstTabInLine
= snapshot.firstTabInLine;
1587 + state.events.length
= snapshot.eventsLength;
1589 +function throwError(state, message) {
1590 + YAMLException.throwAt(state.input.slice(
0, state.length), state.position, message, state.filename);
1592 +function isEol(c) {
1593 + return c
=== 10 || c
=== 13;
1595 +function isWhiteSpace(c) {
1596 + return c
=== 9 || c
=== 32;
1598 +function isWsOrEol(c) {
1599 + return isWhiteSpace(c)
|| isEol(c);
1601 +function isWsOrEolOrEnd(c) {
1602 + return c
=== 0 || isWsOrEol(c);
1604 +function isFlowIndicator(c) {
1605 + return c
=== 44 || c
=== 91 || c
=== 93 || c
=== 123 || c
=== 125;
1607 +function fromDecimalCode(c) {
1608 + return c
>= 48 && c
<= 57 ? c
- 48 : -1;
1610 +function fromHexCode(c) {
1611 + if (c
>= 48 && c
<= 57)
return c
- 48;
1612 + const lc
= c
| 32;
1613 + if (lc
>= 97 && lc
<= 102)
return lc
- 97 + 10;
1616 +function escapedHexLen(c) {
1617 + if (c
=== 120)
return 2;
1618 + if (c
=== 117)
return 4;
1619 + if (c
=== 85)
return 8;
1622 +function isSimpleEscape(c) {
1623 + return c
=== 48 || c
=== 97 || c
=== 98 || c
=== 116 || c
=== 9 || c
=== 110 || c
=== 118 || c
=== 102 || c
=== 114 || c
=== 101 || c
=== 32 || c
=== 34 || c
=== 47 || c
=== 92 || c
=== 78 || c
=== 95 || c
=== 76 || c
=== 80;
1625 +function consumeLineBreak(state) {
1626 + if (state.input.charCodeAt(state.position)
=== 10) state.position
++;
1629 + if (state.input.charCodeAt(state.position)
=== 10) state.position
++;
1632 + state.lineStart
= state.position;
1633 + state.lineIndent
= 0;
1634 + state.firstTabInLine
= -1;
1636 +function skipSeparationSpace(state, allowComments) {
1637 + let lineBreaks
= 0;
1638 + let ch
= state.input.charCodeAt(state.position);
1639 + let hasSeparation
= state.position
=== state.lineStart
|| isWsOrEol(state.input.charCodeAt(state.position
- 1));
1640 + while (ch
!== 0) {
1641 + while (isWhiteSpace(ch)) {
1642 + hasSeparation
= true;
1643 + if (ch
=== 9 && state.firstTabInLine
=== -1) state.firstTabInLine
= state.position;
1644 + ch
= state.input.charCodeAt(
++state.position);
1646 + if (allowComments
&& hasSeparation
&& ch
=== 35)
do 1647 + ch
= state.input.charCodeAt(
++state.position);
1648 + while (
!isEol(ch)
&& ch
!== 0);
1649 + if (
!isEol(ch))
break;
1650 + consumeLineBreak(state);
1652 + hasSeparation
= true;
1653 + ch
= state.input.charCodeAt(state.position);
1654 + while (ch
=== 32) {
1655 + state.lineIndent
++;
1656 + ch
= state.input.charCodeAt(
++state.position);
1659 + return lineBreaks;
1661 +function testDocumentSeparator(state, position
= state.position) {
1662 + const ch
= state.input.charCodeAt(position);
1663 + if ((ch
=== 45 || ch
=== 46)
&& ch
=== state.input.charCodeAt(position
+ 1)
&& ch
=== state.input.charCodeAt(position
+ 2)) {
1664 + const following
= state.input.charCodeAt(position
+ 3);
1665 + return following
=== 0 || isWsOrEol(following);
1669 +function skipByteOrderMark(state) {
1670 + if (state.position
=== state.lineStart
&& state.input.charCodeAt(state.position)
=== 65279) {
1672 + state.lineStart
= state.position;
1675 +function testDocumentBoundary(state) {
1676 + if (state.position
!== state.lineStart)
return false;
1677 + if (testDocumentSeparator(state))
return true;
1678 + if (state.input.charCodeAt(state.position)
!== 65279)
return false;
1679 + const snapshot
= snapshotState(state);
1680 + skipByteOrderMark(state);
1681 + skipSeparationSpace(state,
true);
1682 + const ch
= state.input.charCodeAt(state.position);
1683 + const result
= state.position
=== state.lineStart
&& (ch
=== 37 || ch
=== 45 && testDocumentSeparator(state));
1684 + restoreState(state, snapshot);
1687 +function skipUntilLineEnd(state) {
1688 + let ch
= state.input.charCodeAt(state.position);
1689 + while (ch
!== 0 && !isEol(ch)) ch
= state.input.charCodeAt(
++state.position);
1691 +function checkPrintable(state, start, end) {
1692 + if (
PATTERN_NON_PRINTABLE.test(state.input.slice(start, end))) throwError(state,
"the stream contains non-printable characters");
1694 +function readTagProperty(state, props, inFlow) {
1695 + if (state.input.charCodeAt(state.position)
!== 33)
return false;
1696 + if (props.tagStart
!== NO_RANGE$1) throwError(state,
"duplication of a tag property");
1697 + const start
= state.position;
1698 + let isVerbatim
= false;
1699 + let isNamed
= false;
1700 + let tagHandle
= "!";
1701 + let ch
= state.input.charCodeAt(
++state.position);
1703 + isVerbatim
= true;
1704 + ch
= state.input.charCodeAt(
++state.position);
1705 + }
else if (ch
=== 33) {
1708 + ch
= state.input.charCodeAt(
++state.position);
1710 + let suffixStart
= state.position;
1713 + while (ch
!== 0 && ch
!== 62) ch
= state.input.charCodeAt(
++state.position);
1714 + if (ch
!== 62) throwError(state,
"unexpected end of the stream within a verbatim tag");
1715 + tagName
= state.input.slice(suffixStart, state.position);
1718 + while (ch
!== 0 && !isWsOrEol(ch)
&& !(inFlow
&& isFlowIndicator(ch))) {
1719 + if (ch
=== 33)
if (
!isNamed) {
1720 + tagHandle
= state.input.slice(suffixStart
- 1, state.position
+ 1);
1721 + if (
!PATTERN_TAG_HANDLE.test(tagHandle)) throwError(state,
"named tag handle cannot contain such characters");
1723 + suffixStart
= state.position
+ 1;
1724 + }
else throwError(state,
"tag suffix cannot contain exclamation marks");
1725 + ch
= state.input.charCodeAt(
++state.position);
1727 + tagName
= state.input.slice(suffixStart, state.position);
1728 + if (
PATTERN_FLOW_INDICATORS.test(tagName)) throwError(state,
"tag suffix cannot contain flow indicator characters");
1730 + if (tagName
&& !(isVerbatim
? PATTERN_TAG_URI.test(tagName)
: PATTERN_TAG_SUFFIX.test(tagName))) throwError(state,
`tag name cannot contain such characters: ${tagName}
`);
1731 + if (
!isVerbatim
&& tagHandle
!== "!" && tagHandle
!== "!!" && !HAS_OWN.call(state.tagHandlers, tagHandle)) throwError(state,
`undeclared tag handle "${tagHandle}
"`);
1732 + props.tagStart
= start;
1733 + props.tagEnd
= state.position;
1736 +function readAnchorProperty(state, props) {
1737 + if (state.input.charCodeAt(state.position)
!== 38)
return false;
1738 + if (props.anchorStart
!== NO_RANGE$1) throwError(state,
"duplication of an anchor property");
1740 + const start
= state.position;
1741 + while (state.input.charCodeAt(state.position)
!== 0 && !isWsOrEol(state.input.charCodeAt(state.position))
&& !isFlowIndicator(state.input.charCodeAt(state.position))) state.position
++;
1742 + if (state.position
=== start) throwError(state,
"name of an anchor node must contain at least one character");
1743 + props.anchorStart
= start;
1744 + props.anchorEnd
= state.position;
1747 +function readAlias(state, props) {
1748 + if (state.input.charCodeAt(state.position)
!== 42)
return false;
1749 + if (props.anchorStart
!== NO_RANGE$1
|| props.tagStart
!== NO_RANGE$1) throwError(state,
"alias node should not have any properties");
1751 + const start
= state.position;
1752 + while (state.input.charCodeAt(state.position)
!== 0 && !isWsOrEol(state.input.charCodeAt(state.position))
&& !isFlowIndicator(state.input.charCodeAt(state.position))) state.position
++;
1753 + if (state.position
=== start) throwError(state,
"name of an alias node must contain at least one character");
1754 + addAliasEvent(state, start, state.position);
1757 +function readFlowScalarBreak(state, nodeIndent) {
1758 + skipSeparationSpace(state,
false);
1759 + if (state.lineIndent
< nodeIndent) throwError(state,
"deficient indentation");
1761 +function readSingleQuotedScalar(state, nodeIndent, props) {
1762 + if (state.input.charCodeAt(state.position)
!== 39)
return false;
1764 + const start
= state.position;
1765 + let simple
= true;
1766 + while (state.input.charCodeAt(state.position)
!== 0) {
1767 + const ch
= state.input.charCodeAt(state.position);
1769 + if (state.input.charCodeAt(state.position
+ 1)
=== 39) {
1771 + state.position
+= 2;
1774 + const end
= state.position;
1776 + addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
SCALAR_STYLE.SINGLE_QUOTED,
CHOMPING_MODE.CLIP,
-1, simple);
1781 + readFlowScalarBreak(state, nodeIndent);
1782 + }
else if (state.position
=== state.lineStart
&& testDocumentSeparator(state)) throwError(state,
"unexpected end of the document within a single quoted scalar");
1783 + else if (ch
!== 9 && ch
< 32) throwError(state,
"expected valid JSON character");
1784 + else state.position
++;
1786 + throwError(state,
"unexpected end of the stream within a single quoted scalar");
1788 +function readDoubleQuotedScalar(state, nodeIndent, props) {
1789 + if (state.input.charCodeAt(state.position)
!== 34)
return false;
1791 + const start
= state.position;
1792 + let simple
= true;
1793 + while (state.input.charCodeAt(state.position)
!== 0) {
1794 + const ch
= state.input.charCodeAt(state.position);
1796 + const end
= state.position;
1798 + addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
SCALAR_STYLE.DOUBLE_QUOTED,
CHOMPING_MODE.CLIP,
-1, simple);
1803 + const escaped
= state.input.charCodeAt(
++state.position);
1804 + if (isEol(escaped)) readFlowScalarBreak(state, nodeIndent);
1805 + else if (isSimpleEscape(escaped)) state.position
++;
1807 + let hexLength
= escapedHexLen(escaped);
1808 + if (hexLength
=== 0) throwError(state,
"unknown escape sequence");
1809 + while (hexLength
-- > 0) {
1811 + if (fromHexCode(state.input.charCodeAt(state.position))
< 0) throwError(state,
"expected hexadecimal character");
1815 + }
else if (isEol(ch)) {
1817 + readFlowScalarBreak(state, nodeIndent);
1818 + }
else if (state.position
=== state.lineStart
&& testDocumentSeparator(state)) throwError(state,
"unexpected end of the document within a double quoted scalar");
1819 + else if (ch
!== 9 && ch
< 32) throwError(state,
"expected valid JSON character");
1820 + else state.position
++;
1822 + throwError(state,
"unexpected end of the stream within a double quoted scalar");
1824 +function readBlockScalar(state, parentIndent, props) {
1825 + const ch
= state.input.charCodeAt(state.position);
1826 + let chomping
= CHOMPING_MODE.CLIP;
1828 + let detectedIndent
= false;
1829 + if (ch
!== 124 && ch
!== 62)
return false;
1830 + const style
= ch
=== 124 ? SCALAR_STYLE.LITERAL_BLOCK
: SCALAR_STYLE.FOLDED_BLOCK;
1832 + while (state.input.charCodeAt(state.position)
!== 0) {
1833 + const current
= state.input.charCodeAt(state.position);
1834 + const digit
= fromDecimalCode(current);
1835 + if (current
=== 43 || current
=== 45) {
1836 + if (chomping
!== CHOMPING_MODE.CLIP) throwError(state,
"repeat of a chomping mode identifier");
1837 + chomping
= current
=== 43 ? CHOMPING_MODE.KEEP
: CHOMPING_MODE.STRIP;
1839 + }
else if (digit
>= 0) {
1840 + if (digit
=== 0) throwError(state,
"bad explicit indentation width of a block scalar; it cannot be less than one");
1841 + if (detectedIndent) throwError(state,
"repeat of an indentation width identifier");
1842 + indent
= parentIndent
+ digit
- 1;
1843 + detectedIndent
= true;
1847 + let hadWhitespace
= false;
1848 + while (isWhiteSpace(state.input.charCodeAt(state.position))) {
1849 + hadWhitespace
= true;
1852 + if (hadWhitespace
&& state.input.charCodeAt(state.position)
=== 35) skipUntilLineEnd(state);
1853 + if (isEol(state.input.charCodeAt(state.position))) consumeLineBreak(state);
1854 + else if (state.input.charCodeAt(state.position)
!== 0) throwError(state,
"a line break is expected");
1855 + let contentIndent
= detectedIndent
? indent
: -1;
1856 + let maxLeadingIndent
= 0;
1857 + const valueStart
= state.position;
1858 + let valueEnd
= state.position;
1859 + while (state.input.charCodeAt(state.position)
!== 0) {
1860 + const linePosition
= state.position;
1862 + while (state.input.charCodeAt(linePosition
+ column)
=== 32) column
++;
1863 + const first
= state.input.charCodeAt(linePosition
+ column);
1864 + if (first
=== 0) {
1865 + if (contentIndent
>= 0) {
1866 + if (column
> contentIndent) valueEnd
= linePosition
+ column;
1867 + }
else if (column
> 0) valueEnd
= linePosition
+ column;
1870 + if (testDocumentBoundary(state))
break;
1871 + if (
!detectedIndent
&& contentIndent
=== -1 && isEol(first)) maxLeadingIndent
= Math.
max(maxLeadingIndent, column);
1872 + if (
!detectedIndent
&& contentIndent
=== -1 && !isEol(first)) {
1873 + if (first
=== 9 && column
< parentIndent) {
1874 + state.position
= linePosition
+ column;
1875 + throwError(state,
"tab characters must not be used in indentation");
1877 + if (column
< maxLeadingIndent) {
1878 + state.position
= linePosition
+ column;
1879 + throwError(state,
"bad indentation of a mapping entry");
1882 + if (contentIndent
=== -1 && first
!== 0 && !isEol(first)
&& column
< parentIndent) {
1883 + state.lineIndent
= column;
1884 + state.position
= linePosition
+ column;
1887 + if (
!detectedIndent
&& first
!== 0 && !isEol(first)
&& contentIndent
=== -1) contentIndent
= column;
1888 + const requiredIndent
= contentIndent
=== -1 ? parentIndent
+ 1 : contentIndent;
1889 + if (first
!== 0 && !isEol(first)
&& column
< requiredIndent) {
1890 + state.lineIndent
= column;
1891 + state.position
= linePosition
+ column;
1894 + skipUntilLineEnd(state);
1895 + valueEnd
= state.position;
1896 + if (isEol(state.input.charCodeAt(state.position))) {
1897 + consumeLineBreak(state);
1898 + valueEnd
= state.position;
1901 + checkPrintable(state, valueStart, valueEnd);
1902 + addScalarEvent(state, valueStart, valueEnd, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, style, chomping, contentIndent);
1905 +function canStartPlainScalar(state, nodeContext) {
1906 + const ch
= state.input.charCodeAt(state.position);
1907 + const inFlow
= nodeContext
=== CONTEXT_FLOW_IN;
1908 + if (ch
=== 0 || isWsOrEol(ch)
|| ch
=== 35 || ch
=== 38 || ch
=== 42 || ch
=== 33 || ch
=== 124 || ch
=== 62 || ch
=== 39 || ch
=== 34 || ch
=== 37 || ch
=== 64 || ch
=== 96 || inFlow
&& isFlowIndicator(ch))
return false;
1909 + if (ch
=== 63 || ch
=== 45) {
1910 + const following
= state.input.charCodeAt(state.position
+ 1);
1911 + if (isWsOrEolOrEnd(following)
|| inFlow
&& isFlowIndicator(following))
return false;
1915 +function readPlainScalar(state, nodeIndent, nodeContext, props) {
1916 + if (
!canStartPlainScalar(state, nodeContext))
return false;
1917 + const start
= state.position;
1918 + let end
= state.position;
1919 + let ch
= state.input.charCodeAt(state.position);
1920 + const inFlow
= nodeContext
=== CONTEXT_FLOW_IN;
1921 + let multiline
= false;
1922 + while (ch
!== 0) {
1923 + if (testDocumentBoundary(state))
break;
1925 + const following
= state.input.charCodeAt(state.position
+ 1);
1926 + if (isWsOrEolOrEnd(following)
|| inFlow
&& isFlowIndicator(following))
break;
1927 + }
else if (ch
=== 35) {
1928 + if (isWsOrEol(state.input.charCodeAt(state.position
- 1)))
break;
1929 + }
else if (inFlow
&& isFlowIndicator(ch))
break;
1930 + else if (isEol(ch)) {
1931 + const savedPosition
= state.position;
1932 + const savedLine
= state.line;
1933 + const savedLineStart
= state.lineStart;
1934 + const savedLineIndent
= state.lineIndent;
1935 + skipSeparationSpace(state,
false);
1936 + if (state.lineIndent
>= nodeIndent) {
1938 + ch
= state.input.charCodeAt(state.position);
1941 + state.position
= savedPosition;
1942 + state.line
= savedLine;
1943 + state.lineStart
= savedLineStart;
1944 + state.lineIndent
= savedLineIndent;
1947 + if (
!isWhiteSpace(ch)) end
= state.position
+ 1;
1948 + ch
= state.input.charCodeAt(
++state.position);
1950 + if (end
=== start)
return false;
1951 + checkPrintable(state, start, end);
1952 + addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
SCALAR_STYLE.PLAIN,
CHOMPING_MODE.CLIP,
-1,
!multiline);
1955 +function skipFlowSeparationSpace(state, nodeIndent) {
1956 + const startLine
= state.line;
1957 + skipSeparationSpace(state,
true);
1958 + if (state.line
> startLine
&& state.lineIndent
< nodeIndent
|| state.firstTabInLine
!== -1 && state.lineIndent
< nodeIndent) throwError(state,
"deficient indentation");
1960 +function readFlowCollection(state, nodeIndent, props) {
1961 + const ch
= state.input.charCodeAt(state.position);
1962 + const isMapping
= ch
=== 123;
1963 + const start
= state.position;
1964 + let readNext
= true;
1965 + if (ch
!== 91 && ch
!== 123)
return false;
1966 + const terminator
= isMapping
? 125 : 93;
1967 + if (isMapping) addMappingEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
COLLECTION_STYLE.FLOW);
1968 + else addSequenceEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
COLLECTION_STYLE.FLOW);
1970 + while (state.input.charCodeAt(state.position)
!== 0) {
1971 + skipFlowSeparationSpace(state, nodeIndent);
1972 + let ch2
= state.input.charCodeAt(state.position);
1973 + if (ch2
=== terminator) {
1975 + addPopEvent(state);
1977 + }
else if (
!readNext) throwError(state,
"missed comma between flow collection entries");
1978 + else if (ch2
=== 44) throwError(state,
"expected the node content, but found ','");
1979 + let isPair
= false;
1980 + let isExplicitPair
= false;
1981 + if (ch2
=== 63 && isWsOrEol(state.input.charCodeAt(state.position
+ 1))) {
1982 + isPair
= isExplicitPair
= true;
1983 + state.position
+= 1;
1984 + skipFlowSeparationSpace(state, nodeIndent);
1986 + const entryLine
= state.line;
1987 + const entryStart
= snapshotState(state);
1988 + const keyWasRead
= parseNode(state, nodeIndent, CONTEXT_FLOW_IN,
false,
true);
1989 + skipFlowSeparationSpace(state, nodeIndent);
1990 + ch2
= state.input.charCodeAt(state.position);
1991 + if ((isMapping
|| isExplicitPair
|| state.line
=== entryLine)
&& ch2
=== 58) {
1994 + skipFlowSeparationSpace(state, nodeIndent);
1996 + insertFlowPairMappingEvent(state, entryStart);
1997 + if (
!keyWasRead) addEmptyScalarEvent(state);
1998 + }
else if (
!keyWasRead) addEmptyScalarEvent(state);
1999 + if (
!parseNode(state, nodeIndent, CONTEXT_FLOW_IN,
false,
true)) addEmptyScalarEvent(state);
2000 + skipFlowSeparationSpace(state, nodeIndent);
2001 + if (
!isMapping) addPopEvent(state);
2002 + }
else if (isMapping
&& isPair) {
2003 + if (
!keyWasRead) addEmptyScalarEvent(state);
2004 + addEmptyScalarEvent(state);
2005 + }
else if (isMapping) addEmptyScalarEvent(state);
2006 + else if (isPair) {
2007 + insertFlowPairMappingEvent(state, entryStart);
2008 + if (
!keyWasRead) addEmptyScalarEvent(state);
2009 + addEmptyScalarEvent(state);
2010 + addPopEvent(state);
2012 + ch2
= state.input.charCodeAt(state.position);
2016 + }
else readNext
= false;
2018 + throwError(state,
"unexpected end of the stream within a flow collection");
2020 +function readBlockSequence(state, nodeIndent, props) {
2021 + if (state.firstTabInLine
!== -1 || state.input.charCodeAt(state.position)
!== 45 || !isWsOrEolOrEnd(state.input.charCodeAt(state.position
+ 1)))
return false;
2022 + addSequenceEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
COLLECTION_STYLE.BLOCK);
2023 + while (state.input.charCodeAt(state.position)
=== 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position
+ 1))) {
2024 + if (state.firstTabInLine
!== -1) {
2025 + state.position
= state.firstTabInLine;
2026 + throwError(state,
"tab characters must not be used in indentation");
2028 + const entryLine
= state.line;
2030 + const hadBreak
= skipSeparationSpace(state,
true)
> 0;
2031 + if (state.firstTabInLine
!== -1 && state.input.charCodeAt(state.position)
=== 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position
+ 1))) throwError(state,
"bad indentation of a sequence entry");
2032 + if (hadBreak
&& state.lineIndent
<= nodeIndent) addEmptyScalarEvent(state);
2033 + else parseNode(state, nodeIndent, CONTEXT_BLOCK_IN,
false,
true);
2034 + skipSeparationSpace(state,
true);
2035 + if (state.lineIndent
< nodeIndent
|| state.position
>= state.length)
break;
2036 + if (state.lineIndent
> nodeIndent) throwError(state,
"bad indentation of a sequence entry");
2037 + if (state.line
=== entryLine
&& state.input.charCodeAt(state.position)
=== 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position
+ 1))) throwError(state,
"bad indentation of a sequence entry");
2039 + addPopEvent(state);
2042 +function readBlockMapping(state, nodeIndent, flowIndent, props) {
2043 + let atExplicitKey
= false;
2044 + let detected
= false;
2045 + let mappingOpened
= false;
2046 + let pendingExplicitKey
= false;
2047 + if (state.firstTabInLine
!== -1)
return false;
2048 + let ch
= state.input.charCodeAt(state.position);
2049 + while (ch
!== 0) {
2050 + if (
!atExplicitKey
&& state.firstTabInLine
!== -1) {
2051 + state.position
= state.firstTabInLine;
2052 + throwError(state,
"tab characters must not be used in indentation");
2054 + const following
= state.input.charCodeAt(state.position
+ 1);
2055 + const entryLine
= state.line;
2056 + if ((ch
=== 63 || ch
=== 58)
&& isWsOrEolOrEnd(following)) {
2057 + if (
!mappingOpened) {
2058 + addMappingEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
COLLECTION_STYLE.BLOCK);
2059 + mappingOpened
= true;
2062 + if (atExplicitKey) addEmptyScalarEvent(state);
2064 + atExplicitKey
= true;
2065 + }
else if (atExplicitKey) atExplicitKey
= false;
2067 + addEmptyScalarEvent(state);
2069 + atExplicitKey
= false;
2071 + state.position
+= 1;
2072 + pendingExplicitKey
= true;
2074 + if (atExplicitKey) {
2075 + addEmptyScalarEvent(state);
2076 + atExplicitKey
= false;
2078 + const beforeKey
= snapshotState(state);
2079 + if (
!parseNode(state, flowIndent, CONTEXT_FLOW_OUT,
false,
true))
break;
2080 + if (state.line
=== entryLine) {
2081 + ch
= state.input.charCodeAt(state.position);
2082 + while (isWhiteSpace(ch)) ch
= state.input.charCodeAt(
++state.position);
2084 + ch
= state.input.charCodeAt(
++state.position);
2085 + if (
!isWsOrEolOrEnd(ch)) throwError(state,
"a whitespace character is expected after the key-value separator within a block mapping");
2086 + if (
!mappingOpened) {
2087 + restoreState(state, beforeKey);
2088 + addMappingEvent(state, beforeKey.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
COLLECTION_STYLE.BLOCK);
2089 + mappingOpened
= true;
2090 + parseNode(state, flowIndent, CONTEXT_FLOW_OUT,
false,
true);
2091 + ch
= state.input.charCodeAt(state.position);
2092 + while (isWhiteSpace(ch)) ch
= state.input.charCodeAt(
++state.position);
2096 + atExplicitKey
= false;
2097 + pendingExplicitKey
= false;
2098 + }
else if (detected) throwError(state,
"expected ':' after a mapping key");
2100 + if (props.anchorStart
!== NO_RANGE$1
|| props.tagStart
!== NO_RANGE$1) {
2101 + restoreState(state, beforeKey);
2106 + }
else if (detected) throwError(state,
"can not read a block mapping entry; a multiline key may not be an implicit key");
2108 + if (props.anchorStart
!== NO_RANGE$1
|| props.tagStart
!== NO_RANGE$1) {
2109 + restoreState(state, beforeKey);
2115 + if (parseNode(state, nodeIndent, CONTEXT_BLOCK_OUT,
true, pendingExplicitKey)) pendingExplicitKey
= false;
2116 + if (
!atExplicitKey) {
2117 + if (pendingExplicitKey) {
2118 + addEmptyScalarEvent(state);
2119 + pendingExplicitKey
= false;
2122 + skipSeparationSpace(state,
true);
2123 + ch
= state.input.charCodeAt(state.position);
2124 + if ((state.line
=== entryLine
|| state.lineIndent
> nodeIndent)
&& ch
!== 0) throwError(state,
"bad indentation of a mapping entry");
2125 + else if (state.lineIndent
< nodeIndent)
break;
2127 + if (
!detected)
return false;
2128 + if (atExplicitKey) addEmptyScalarEvent(state);
2129 + if (mappingOpened) addPopEvent(state);
2132 +function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact, allowPropertyMapping
= true) {
2133 + if (state.depth
>= state.maxDepth) throwError(state,
`nesting exceeded maxDepth (${state.maxDepth}
)`);
2135 + let indentStatus
= 1;
2136 + let atNewLine
= false;
2137 + let hasContent
= false;
2138 + let propertyStart
= null;
2139 + const props
= emptyProperties();
2140 + let allowBlockScalars
= nodeContext
=== CONTEXT_BLOCK_OUT
|| nodeContext
=== CONTEXT_BLOCK_IN;
2141 + let allowBlockCollections
= allowBlockScalars;
2142 + const allowBlockStyles
= allowBlockScalars;
2143 + if (allowToSeek
&& skipSeparationSpace(state,
true)) {
2145 + if (state.lineIndent
> parentIndent) indentStatus
= 1;
2146 + else if (state.lineIndent
=== parentIndent) indentStatus
= 0;
2147 + else indentStatus
= -1;
2149 + if (indentStatus
=== 1)
while (
true) {
2150 + const ch
= state.input.charCodeAt(state.position);
2151 + const propertyState
= snapshotState(state);
2152 + if (atNewLine
&& indentStatus
!== 1 && (ch
=== 33 || ch
=== 38))
break;
2153 + if (atNewLine
&& allowBlockStyles
&& (props.tagStart
!== NO_RANGE$1
|| props.anchorStart
!== NO_RANGE$1)
&& (ch
=== 33 || ch
=== 38)) {
2154 + const fallbackState
= snapshotState(state);
2155 + const flowIndent
= parentIndent
+ 1;
2156 + if (readBlockMapping(state, state.position
- state.lineStart, flowIndent, props)
&& state.events[fallbackState.eventsLength]
?.type
=== EVENT_ID.MAPPING) {
2160 + restoreState(state, fallbackState);
2162 + if (atNewLine
&& (ch
=== 33 && props.tagStart
!== NO_RANGE$1
|| ch
=== 38 && props.anchorStart
!== NO_RANGE$1))
break;
2163 + if (
!readTagProperty(state, props, nodeContext
=== CONTEXT_FLOW_IN)
&& !readAnchorProperty(state, props))
break;
2164 + if (propertyStart
=== null) propertyStart
= propertyState;
2165 + if (skipSeparationSpace(state,
true)) {
2167 + allowBlockCollections
= allowBlockStyles;
2168 + if (state.lineIndent
> parentIndent) indentStatus
= 1;
2169 + else if (state.lineIndent
=== parentIndent) indentStatus
= 0;
2170 + else indentStatus
= -1;
2171 + }
else allowBlockCollections
= false;
2173 + if (allowBlockCollections) allowBlockCollections
= atNewLine
|| allowCompact;
2174 + if (indentStatus
=== 1 || nodeContext
=== CONTEXT_BLOCK_OUT) {
2175 + const flowIndent
= nodeContext
=== CONTEXT_FLOW_IN
|| nodeContext
=== CONTEXT_FLOW_OUT
? parentIndent
: parentIndent
+ 1;
2176 + const blockIndent
= state.position
- state.lineStart;
2177 + if (indentStatus
=== 1)
if (allowBlockCollections
&& (readBlockSequence(state, blockIndent, props)
|| readBlockMapping(state, blockIndent, flowIndent, props))
|| readFlowCollection(state, flowIndent, props)) hasContent
= true;
2179 + const ch
= state.input.charCodeAt(state.position);
2180 + if (propertyStart
!== null && allowPropertyMapping
&& allowBlockStyles
&& !allowBlockCollections
&& ch
!== 124 && ch
!== 62) {
2181 + const fallbackState
= snapshotState(state);
2182 + const propertyIndent
= propertyStart.position
- propertyStart.lineStart;
2183 + restoreState(state, propertyStart);
2184 + if (readBlockMapping(state, propertyIndent, flowIndent, emptyProperties())
&& state.events[fallbackState.eventsLength]
?.type
=== EVENT_ID.MAPPING) hasContent
= true;
2185 + else restoreState(state, fallbackState);
2187 + if (
!hasContent
&& (allowBlockScalars
&& readBlockScalar(state, flowIndent, props)
|| readSingleQuotedScalar(state, flowIndent, props)
|| readDoubleQuotedScalar(state, flowIndent, props)
|| readAlias(state, props)
|| readPlainScalar(state, flowIndent, nodeContext, props))) hasContent
= true;
2189 + else if (indentStatus
=== 0) hasContent
= allowBlockCollections
&& readBlockSequence(state, blockIndent, props);
2191 + allowBlockScalars
= allowBlockScalars
&& !hasContent;
2192 + if (
!hasContent
&& (props.anchorStart
!== NO_RANGE$1
|| props.tagStart
!== NO_RANGE$1
|| allowBlockScalars)) {
2193 + addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
SCALAR_STYLE.PLAIN);
2194 + hasContent
= true;
2197 + return hasContent
|| props.anchorStart
!== NO_RANGE$1
|| props.tagStart
!== NO_RANGE$1;
2199 +function readDirective(state) {
2200 + if (state.lineIndent
> 0 || state.input.charCodeAt(state.position)
!== 37)
return false;
2202 + const nameStart
= state.position;
2203 + while (state.input.charCodeAt(state.position)
!== 0 && !isWsOrEol(state.input.charCodeAt(state.position))) state.position
++;
2204 + const name
= state.input.slice(nameStart, state.position);
2206 + if (name.length
=== 0) throwError(state,
"directive name must not be less than one character in length");
2207 + while (state.input.charCodeAt(state.position)
!== 0 && !isEol(state.input.charCodeAt(state.position))) {
2208 + while (isWhiteSpace(state.input.charCodeAt(state.position))) state.position
++;
2209 + if (state.input.charCodeAt(state.position)
=== 35 || isEol(state.input.charCodeAt(state.position))
|| state.input.charCodeAt(state.position)
=== 0)
break;
2210 + const start
= state.position;
2211 + while (state.input.charCodeAt(state.position)
!== 0 && !isWsOrEol(state.input.charCodeAt(state.position))) state.position
++;
2212 + args.push(state.input.slice(start, state.position));
2214 + if (isEol(state.input.charCodeAt(state.position))) consumeLineBreak(state);
2215 + if (name
=== "YAML") {
2216 + if (state.directives.some((directive)
=> directive.kind
=== "yaml")) throwError(state,
"duplication of %YAML directive");
2217 + if (args.length
!== 1) throwError(state,
"YAML directive accepts exactly one argument");
2218 + const match
= /^([0-9]+)\.([0-9]+)$/.exec(args[
0]);
2219 + if (match
=== null) throwError(state,
"ill-formed argument of the YAML directive");
2220 + if (
parseInt(match[
1],
10)
!== 1) throwError(state,
"unacceptable YAML version of the document");
2221 + state.directives.push({
2225 + }
else if (name
=== "TAG") {
2226 + if (args.length
!== 2) throwError(state,
"TAG directive accepts exactly two arguments");
2227 + const [handle, prefix]
= args;
2228 + if (
!PATTERN_TAG_HANDLE.test(handle)) throwError(state,
"ill-formed tag handle (first argument) of the TAG directive");
2229 + if (
HAS_OWN.call(state.tagHandlers, handle)) throwError(state,
`there is a previously declared suffix for "${handle}
" tag handle`);
2230 + if (
!PATTERN_TAG_PREFIX.test(prefix)) throwError(state,
"ill-formed tag prefix (second argument) of the TAG directive");
2231 + state.tagHandlers[handle]
= prefix;
2232 + state.directives.push({
2240 +function readDocument(state) {
2241 + state.directives
= [];
2242 + state.tagHandlers
= Object.
create(
null);
2243 + let hasDirectives
= false;
2244 + skipSeparationSpace(state,
true);
2245 + while (readDirective(state)) {
2246 + hasDirectives
= true;
2247 + skipSeparationSpace(state,
true);
2249 + let explicitStart
= false;
2250 + let explicitEnd
= false;
2251 + let allowCompact
= true;
2252 + if (state.lineIndent
=== 0 && state.input.charCodeAt(state.position)
=== 45 && state.input.charCodeAt(state.position
+ 1)
=== 45 && state.input.charCodeAt(state.position
+ 2)
=== 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position
+ 3))) {
2253 + explicitStart
= true;
2254 + const markerLine
= state.line;
2255 + state.position
+= 3;
2256 + skipSeparationSpace(state,
true);
2257 + allowCompact
= state.line
> markerLine;
2258 + }
else if (hasDirectives) throwError(state,
"directives end mark is expected");
2259 + const documentEventIndex
= state.events.length;
2260 + if (
!explicitStart
&& state.position
=== state.lineStart
&& state.input.charCodeAt(state.position)
=== 46 && testDocumentSeparator(state)) {
2261 + state.position
+= 3;
2262 + skipSeparationSpace(state,
true);
2265 + addDocumentEvent(state, explicitStart,
false);
2266 + if (
!parseNode(state, state.lineIndent
- 1, CONTEXT_BLOCK_OUT,
false, allowCompact, allowCompact)) addEmptyScalarEvent(state);
2267 + skipSeparationSpace(state,
true);
2268 + if (state.position
=== state.lineStart
&& testDocumentSeparator(state)) {
2269 + explicitEnd
= state.input.charCodeAt(state.position)
=== 46;
2270 + if (explicitEnd) {
2271 + const markerLine
= state.line;
2272 + state.position
+= 3;
2273 + skipSeparationSpace(state,
true);
2274 + if (state.line
=== markerLine
&& state.position
< state.length) throwError(state,
"end of the stream or a document separator is expected");
2277 + const documentEvent
= state.events[documentEventIndex];
2278 + if (documentEvent
?.type
=== EVENT_ID.DOCUMENT) documentEvent.explicitEnd
= explicitEnd;
2279 + addPopEvent(state);
2280 + if (
!explicitEnd
&& state.position
< state.length
&& !testDocumentBoundary(state)) throwError(state,
"end of the stream or a document separator is expected");
2282 +function parseEvents(input, options) {
2283 + const length
= input.length;
2285 + ...DEFAULT_PARSER_OPTIONS,
2287 + input:
`${input}
\0`,
2293 + firstTabInLine:
-1,
2296 + tagHandlers:
Object.
create(
null),
2299 + const nullpos
= input.indexOf(
"\0");
2300 + if (nullpos
!== -1)
YAMLException.throwAt(input, nullpos,
"null byte is not allowed in input", state.filename);
2301 + while (state.position
< state.length) {
2302 + skipByteOrderMark(state);
2303 + skipSeparationSpace(state,
true);
2304 + if (state.position
>= state.length)
break;
2305 + const documentStart
= state.position;
2306 + readDocument(state);
2307 + if (state.position
=== documentStart)
2308 + throwError(state,
"can not read a document");
2310 + return state.events;
2312 +var DEFAULT_LOAD_OPTIONS
= {
2313 + ...DEFAULT_PARSER_OPTIONS,
2314 + ...DEFAULT_CONSTRUCTOR_OPTIONS
2316 +function loadDocuments(input, options
= {}) {
2318 + ...DEFAULT_LOAD_OPTIONS,
2321 + const source
= String(input);
2322 + const PARSER_OPT_KEYS
= Object.
keys(DEFAULT_PARSER_OPTIONS);
2323 + const CONSTRUCTOR_OPT_KEYS
= Object.
keys(DEFAULT_CONSTRUCTOR_OPTIONS);
2324 + return constructFromEvents(parseEvents(source, pick(opts, PARSER_OPT_KEYS)), {
2325 + ...pick(opts, CONSTRUCTOR_OPT_KEYS),
2329 +function load(input, options) {
2330 + const documents
= loadDocuments(input, options);
2331 + if (documents.length
=== 0)
throw new YAMLException(
"expected a document, but the input is empty");
2332 + if (documents.length
=== 1)
return documents[
0];
2333 + throw new YAMLException(
"expected a single document in the stream, but found more");
2335 +function hasBit(mask, bit) {
2336 + return (mask
& 1 << bit)
!== 0;
2338 +var DEFAULT_SCALAR_STYLE_RULES
= {
2339 + applyQuoteFlowKeysOption,
2340 + doubleQuoteForInvisibles,
2341 + doubleQuoteWhitespaceOnly,
2342 + applyForceQuotesOption,
2343 + tryLongOrMultilineAsBlock,
2344 + quoteInvalidPlain,
2345 + fallbackToDoubleQuoted
2347 +function _preferredQuotedStyle(layout) {
2348 + if (layout.presenterOptions.quoteStyle
=== "single" && hasBit(layout.allowedStylesMask,
SCALAR_STYLE.SINGLE_QUOTED))
return SCALAR_STYLE.SINGLE_QUOTED;
2349 + return SCALAR_STYLE.DOUBLE_QUOTED;
2351 +function applyQuoteFlowKeysOption(layout) {
2352 + if (
!layout.presenterOptions.quoteFlowKeys)
return;
2353 + if (
!layout.isKey
|| !layout.flowOnly
|| layout.style
!== SCALAR_STYLE.PLAIN)
return;
2354 + layout.style
= SCALAR_STYLE.DOUBLE_QUOTED;
2356 +function doubleQuoteForInvisibles(layout) {
2357 + if (layout.style
=== SCALAR_STYLE.PLAIN
&& /[\t\x7F-\xA0\u2028\u2029\uFEFF\uFFFE\uFFFF]/.test(layout.node.value)) layout.style
= SCALAR_STYLE.DOUBLE_QUOTED;
2359 +function doubleQuoteWhitespaceOnly(layout) {
2360 + if (layout.style
=== SCALAR_STYLE.PLAIN
&& /^\s+$/.test(layout.node.value)) layout.style
= SCALAR_STYLE.DOUBLE_QUOTED;
2362 +function applyForceQuotesOption(layout) {
2363 + if (
!layout.presenterOptions.forceQuotes)
return;
2364 + if (layout.isKey
|| layout.style
!== SCALAR_STYLE.PLAIN)
return;
2365 + layout.style
= layout.node.value.includes(
"\n")
? SCALAR_STYLE.DOUBLE_QUOTED
: _preferredQuotedStyle(layout);
2367 +function tryLongOrMultilineAsBlock(layout) {
2368 + if (layout.style
!== SCALAR_STYLE.PLAIN
|| layout.isKey)
return;
2369 + const value
= layout.node.value;
2370 + const multiline
= value.indexOf(
"\n")
!== -1;
2371 + if (
!hasBit(layout.allowedStylesMask,
SCALAR_STYLE.LITERAL_BLOCK)) {
2372 + if (multiline) layout.style
= SCALAR_STYLE.DOUBLE_QUOTED;
2375 + const w2
= layout.presenterOptions.lineWidth;
2377 + if (multiline) layout.style
= SCALAR_STYLE.LITERAL_BLOCK;
2380 + const availableWidth
= Math.
max(
Math.
min(w2,
40), w2
- layout.shiftOfContent);
2382 + let shouldFold
= false;
2383 + while (position
<= value.length) {
2384 + let lineEnd
= value.length;
2385 + const nextLineBreak
= value.indexOf(
"\n", position);
2386 + if (nextLineBreak
!== -1) lineEnd
= nextLineBreak;
2387 + const line
= value.slice(position, lineEnd);
2388 + if (line.length
> availableWidth
&& line[
0]
!== " " && / [^ \t]/.test(line)) shouldFold
= true;
2389 + if (nextLineBreak
=== -1)
break;
2390 + position
= nextLineBreak
+ 1;
2392 + if (shouldFold) layout.style
= SCALAR_STYLE.FOLDED_BLOCK;
2393 + else if (multiline) layout.style
= SCALAR_STYLE.LITERAL_BLOCK;
2395 +function quoteInvalidPlain(layout) {
2396 + if (layout.style
=== SCALAR_STYLE.PLAIN
&& !hasBit(layout.allowedStylesMask,
SCALAR_STYLE.PLAIN)) layout.style
= _preferredQuotedStyle(layout);
2398 +function fallbackToDoubleQuoted(layout) {
2399 + if (
!hasBit(layout.allowedStylesMask, layout.style)) layout.style
= SCALAR_STYLE.DOUBLE_QUOTED;
2401 +var SRC_C_PRINTABLE
= "[\\x09\\x0A\\x0D\\x20-\\x7E\\x85\\xA0-\\uD7FF\\uE000-\\uFFFD\\u{10000}-\\u{10FFFF}]";
2402 +var SRC_B_CHAR
= "[\\n\\r]";
2403 +var SRC_C_BYTE_ORDER_MARK
= "\\uFEFF";
2404 +var SRC_S_WHITE
= "[ \\t]";
2405 +var SRC_NB_CHAR
= `(?:(?!(?:${SRC_B_CHAR}
|${SRC_C_BYTE_ORDER_MARK}
))${SRC_C_PRINTABLE}
)`;
2406 +var SRC_NS_CHAR
= `(?:(?!${SRC_S_WHITE}
)${SRC_NB_CHAR}
)`;
2407 +var SRC_NB_JSON
= "[\\x09\\x20-\\uD7FF\\uE000-\\uFFFF\\u{10000}-\\u{10FFFF}]";
2408 +var SRC_C_INDICATOR
= "[-?:,\\[\\]{}#&*!|>'\"%@`]";
2409 +var SRC_C_FLOW_INDICATOR
= "[,\\[\\]{}]";
2410 +var SRC_NS_PLAIN_SAFE_FLOW_OUT
= SRC_NS_CHAR;
2411 +var SRC_NS_PLAIN_SAFE_FLOW_IN
= `(?:(?!${SRC_C_FLOW_INDICATOR}
)${SRC_NS_CHAR}
)`;
2412 +var SRC_NS_PLAIN_FIRST_FLOW_OUT
= `(?:(?:(?!${SRC_C_INDICATOR}
)${SRC_NS_CHAR}
)|[?:-](?=${SRC_NS_PLAIN_SAFE_FLOW_OUT}
))`;
2413 +var SRC_NS_PLAIN_FIRST_FLOW_IN
= `(?:(?:(?!${SRC_C_INDICATOR}
)${SRC_NS_CHAR}
)|[?:-](?=${SRC_NS_PLAIN_SAFE_FLOW_IN}
))`;
2414 +var SRC_NS_PLAIN_CHAR_FLOW_OUT
= `(?:(?:(?![:#])${SRC_NS_PLAIN_SAFE_FLOW_OUT}
)|:(?=${SRC_NS_PLAIN_SAFE_FLOW_OUT}
))#*`;
2415 +var SRC_NS_PLAIN_CHAR_FLOW_IN
= `(?:(?:(?![:#])${SRC_NS_PLAIN_SAFE_FLOW_IN}
)|:(?=${SRC_NS_PLAIN_SAFE_FLOW_IN}
))#*`;
2416 +var SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT
= `(?:${SRC_S_WHITE}
*${SRC_NS_PLAIN_CHAR_FLOW_OUT}
)*`;
2417 +var SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN
= `(?:${SRC_S_WHITE}
*${SRC_NS_PLAIN_CHAR_FLOW_IN}
)*`;
2418 +var SRC_NS_PLAIN_ONE_LINE_FLOW_OUT
= `${SRC_NS_PLAIN_FIRST_FLOW_OUT}
#*${SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT}
`;
2419 +var SRC_NS_PLAIN_ONE_LINE_FLOW_IN
= `${SRC_NS_PLAIN_FIRST_FLOW_IN}
#*${SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN}
`;
2420 +var SRC_NS_PLAIN_ONE_LINE_BLOCK_KEY
= SRC_NS_PLAIN_ONE_LINE_FLOW_OUT;
2421 +var SRC_NS_PLAIN_ONE_LINE_FLOW_KEY
= SRC_NS_PLAIN_ONE_LINE_FLOW_IN;
2422 +var SRC_S_NS_PLAIN_NEXT_LINE_FLOW_OUT
= `\\n+${SRC_NS_PLAIN_CHAR_FLOW_OUT}${SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT}
`;
2423 +var SRC_S_NS_PLAIN_NEXT_LINE_FLOW_IN
= `\\n+${SRC_NS_PLAIN_CHAR_FLOW_IN}${SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN}
`;
2424 +var SRC_NS_PLAIN_MULTI_LINE_FLOW_OUT
= `${SRC_NS_PLAIN_ONE_LINE_FLOW_OUT}
(?:${SRC_S_NS_PLAIN_NEXT_LINE_FLOW_OUT}
)*`;
2425 +var SRC_NS_PLAIN_MULTI_LINE_FLOW_IN
= `${SRC_NS_PLAIN_ONE_LINE_FLOW_IN}
(?:${SRC_S_NS_PLAIN_NEXT_LINE_FLOW_IN}
)*`;
2426 +var NS_PLAIN_FLOW_OUT
= new RegExp(
`^(?:${SRC_NS_PLAIN_MULTI_LINE_FLOW_OUT}
)$`,
"u");
2427 +var NS_PLAIN_FLOW_IN
= new RegExp(
`^(?:${SRC_NS_PLAIN_MULTI_LINE_FLOW_IN}
)$`,
"u");
2428 +var NS_PLAIN_BLOCK_KEY
= new RegExp(
`^(?:${SRC_NS_PLAIN_ONE_LINE_BLOCK_KEY}
)$`,
"u");
2429 +var NS_PLAIN_FLOW_KEY
= new RegExp(
`^(?:${SRC_NS_PLAIN_ONE_LINE_FLOW_KEY}
)$`,
"u");
2430 +var NB_SINGLE_ONE_LINE
= new RegExp(
`^(?:${SRC_NB_JSON}
)*$`,
"u");
2431 +var NB_SINGLE_MULTI_LINE
= new RegExp(
`^(?:${SRC_NB_JSON}
|\\n)*$`,
"u");
2432 +var BLOCK_SCALAR_CONTENT
= new RegExp(
`^(?:${SRC_NB_CHAR}
|\\n)*$`,
"u");
2433 +var DEFAULT_PRESENTER_OPTIONS
= {
2435 + seqNoIndent:
false,
2436 + seqInlineFirst:
true,
2438 + flowBracketPadding:
false,
2439 + flowSkipCommaSpace:
false,
2440 + flowSkipColonSpace:
false,
2441 + quoteFlowKeys:
false,
2442 + quoteStyle:
"single",
2443 + forceQuotes:
false,
2444 + scalarStyleRules:
Object.
keys(DEFAULT_SCALAR_STYLE_RULES).map((name)
=> Reflect.
get(DEFAULT_SCALAR_STYLE_RULES, name)),
2445 + tagBeforeAnchor:
false 2447 +var DEFAULT_DUMP_OPTIONS
= {
2448 + ...DEFAULT_PRESENTER_OPTIONS,
2449 + schema: DUMP_SCHEMA,
2450 + skipInvalid:
false,
2454 + transform: ()
=> {
2457 +var EVENT_DOCUMENT
= EVENT_ID.DOCUMENT;
2458 +var EVENT_SEQUENCE
= EVENT_ID.SEQUENCE;
2459 +var EVENT_MAPPING
= EVENT_ID.MAPPING;
2460 +var EVENT_SCALAR
= EVENT_ID.SCALAR;
2461 +var EVENT_ALIAS
= EVENT_ID.ALIAS;
2462 +var EVENT_POP
= EVENT_ID.POP;
2463 +var SCALAR_STYLE_PLAIN
= SCALAR_STYLE.PLAIN;
2464 +var SCALAR_STYLE_SINGLE_QUOTED
= SCALAR_STYLE.SINGLE_QUOTED;
2465 +var SCALAR_STYLE_DOUBLE_QUOTED
= SCALAR_STYLE.DOUBLE_QUOTED;
2466 +var SCALAR_STYLE_LITERAL_BLOCK
= SCALAR_STYLE.LITERAL_BLOCK;
2467 +var SCALAR_STYLE_FOLDED_BLOCK
= SCALAR_STYLE.FOLDED_BLOCK;
2468 +var COLLECTION_STYLE_BLOCK
= COLLECTION_STYLE.BLOCK;
2469 +var COLLECTION_STYLE_FLOW
= COLLECTION_STYLE.FLOW;
2470 +var CHOMPING_CLIP
= CHOMPING_MODE.CLIP;
2471 +var CHOMPING_STRIP
= CHOMPING_MODE.STRIP;
2472 +var CHOMPING_KEEP
= CHOMPING_MODE.KEEP;
2476 + return { async:
false, breaks:
false, extensions:
null, gfm:
true, hooks:
null, pedantic:
false, renderer:
null, silent:
false, tokenizer:
null, walkTokens:
null };
2482 +var _
= {
exec: ()
=> null };
2486 + let n
= Math.
max(
0,
Math.
min(
3, t
- 1)), s
= e[n];
2487 + return s
|| (s
= l3(n), e[n]
= s)
, s;
2490 +function d(l3, e
= "") {
2491 + let t
= typeof l3
== "string" ? l3
: l3.source, n
= {
replace: (s, r)
=> {
2492 + let i
= typeof r
== "string" ? r
: r.source;
2493 + return i
= i.replace(m.caret,
"$1")
, t
= t.replace(s, i)
, n;
2494 + },
getRegex: ()
=> new RegExp(t, e) };
2497 +var Te
= ((l3
= "")
=> {
2499 + return !!new RegExp(
"(?<=1)(?<!1)" + l3);
2504 +var m
= { codeRemoveIndent:
/^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace:
/\\([\[\]])/g, indentCodeCompensation:
/^(\s+)(?:```)/, beginningSpace:
/^\s+/, endingHash:
/#$/, startingSpaceChar:
/^ /, endingSpaceChar:
/ $/, nonSpaceChar:
/[^ ]/, newLineCharGlobal:
/\n/g, tabCharGlobal:
/\t/g, multipleSpaceGlobal:
/\s+/g, blankLine:
/^[ \t]*$/, doubleBlankLine:
/\n[ \t]*\n[ \t]*$/, blockquoteStart:
/^ {0,3}>/, blockquoteSetextReplace:
/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2:
/^ {0,3}>[ \t]?/gm, listReplaceNesting:
/^ {1,4}(?=( {4})*[^ ])/g, listIsTask:
/^\[[ xX]\] +\S/, listReplaceTask:
/^\[[ xX]\] +/, listTaskCheckbox:
/\[[ xX]\]/, anyLine:
/\n.*\n/, hrefBrackets:
/^<(.*)>$/, tableDelimiter:
/[:|]/, tableAlignChars:
/^\||\| *$/g, tableRowBlankLine:
/\n[ \t]*$/, tableAlignRight:
/^ *-+: *$/, tableAlignCenter:
/^ *:-+: *$/, tableAlignLeft:
/^ *:-+ *$/, startATag:
/^<a /i, endATag:
/^<\/a>/i, startPreScriptTag:
/^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag:
/^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket:
/^</, endAngleBracket:
/>$/, pedanticHrefTitle:
/^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric:
/[\p{L}\p{N}]/u, escapeTest:
/[&<>"']/, escapeReplace:
/[&<>"']/g, escapeTestNoEncode:
/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode:
/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret:
/(^|[^\[])\^/g, percentDecode:
/%25/g, findPipe:
/\|/g, splitPipe:
/ \|/, slashPipe:
/\\\|/g, carriageReturn:
/\r\n|\r/g, spaceLine:
/^ +$/gm, notSpaceStart:
/^\S*/, endingNewline:
/\n$/,
listItemRegex: (l3)
=> new RegExp(
`^( {0,3}${l3}
)((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: E((l3)
=> new RegExp(
`^ {0,${l3}
}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: E((l3)
=> new RegExp(
`^ {0,${l3}
}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: E((l3)
=> new RegExp(
`^ {0,${l3}
}(?:\`\`\`|~~~)`)), headingBeginRegex: E((l3)
=> new RegExp(
`^ {0,${l3}
}#`)), htmlBeginRegex: E((l3)
=> new RegExp(
`^ {0,${l3}
}<(?:[a-z].*>|!--)`,
"i")), blockquoteBeginRegex: E((l3)
=> new RegExp(
`^ {0,${l3}
}>`)) };
2505 +var Oe
= /^(?:[ \t]*(?:\n|$))+/;
2506 +var we
= /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
2507 +var ye
= /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
2508 +var B
= /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
2509 +var Pe
= /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
2510 +var j
= / {0,3}(?:[*+-]|\d{1,9}[.)])/;
2511 +var oe
= /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
2512 +var ae
= d(oe).replace(
/bull/g, j).replace(
/blockCode/g,
/(?: {4}| {0,3}\t)/).replace(
/fences/g,
/ {0,3}(?:`{3,}|~{3,})/).replace(
/blockquote/g,
/ {0,3}>/).replace(
/heading/g,
/ {0,3}#{1,6}/).replace(
/html/g,
/ {0,3}<[^\n>]+>\n/).replace(
/\|table/g,
"").getRegex();
2513 +var Se
= d(oe).replace(
/bull/g, j).replace(
/blockCode/g,
/(?: {4}| {0,3}\t)/).replace(
/fences/g,
/ {0,3}(?:`{3,}|~{3,})/).replace(
/blockquote/g,
/ {0,3}>/).replace(
/heading/g,
/ {0,3}#{1,6}/).replace(
/html/g,
/ {0,3}<[^\n>]+>\n/).replace(
/table/g,
/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
2514 +var F
= /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
2515 +var $e
= /^[^\n]+/;
2516 +var U
= /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
2517 +var Le
= d(
/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(
"label", U).replace(
"title",
/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
2518 +var _e
= d(
/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(
/bull/g, j).getRegex();
2519 +var H
= "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
2520 +var K
= /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
2521 +var ze
= d(
"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))",
"i").replace(
"comment", K).replace(
"tag", H).replace(
"attribute",
/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
2522 +var le
= d(F).replace(
"hr", B).replace(
"heading",
" {0,3}#{1,6}(?:\\s|$)").replace(
"|lheading",
"").replace(
"|table",
"").replace(
"blockquote",
" {0,3}>").replace(
"fences",
" {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(
"list",
" {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace(
"html",
"</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace(
"tag", H).getRegex();
2523 +var Me
= d(
/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(
"paragraph", le).getRegex();
2524 +var W
= { blockquote: Me, code: we, def: Le, fences: ye, heading: Pe, hr: B, html: ze, lheading: ae, list: _e, newline: Oe, paragraph: le, table: _, text: $e };
2525 +var se
= d(
"^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace(
"hr", B).replace(
"heading",
" {0,3}#{1,6}(?:\\s|$)").replace(
"blockquote",
" {0,3}>").replace(
"code",
"(?: {4}| {0,3} )[^\\n]").replace(
"fences",
" {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(
"list",
" {0,3}(?:[*+-]|1[.)])[ \\t]").replace(
"html",
"</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace(
"tag", H).getRegex();
2526 +var Ee
= {
...W, lheading: Se, table: se, paragraph: d(F).replace(
"hr", B).replace(
"heading",
" {0,3}#{1,6}(?:\\s|$)").replace(
"|lheading",
"").replace(
"table", se).replace(
"blockquote",
" {0,3}>").replace(
"fences",
" {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(
"list",
" {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace(
"html",
"</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace(
"tag", H).getRegex() };
2527 +var Ie
= {
...W, html: d(
`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(
"comment", K).replace(
/tag/g,
"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def:
/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading:
/^(#{1,6})(.*)(?:\n+|$)/, fences: _, lheading:
/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(F).replace(
"hr", B).replace(
"heading",
` *#{1,6} *[^ 2528 +]`).replace(
"lheading", ae).replace(
"|table",
"").replace(
"blockquote",
" {0,3}>").replace(
"|fences",
"").replace(
"|list",
"").replace(
"|html",
"").replace(
"|tag",
"").getRegex() };
2529 +var Ae
= /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
2530 +var Ce
= /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
2531 +var ue
= /^( {2,}|\\)\n(?!\s*$)/;
2532 +var Be
= /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
2533 +var I
= /[\p{P}\p{S}]/u;
2534 +var Z
= /[\s\p{P}\p{S}]/u;
2535 +var X
= /[^\s\p{P}\p{S}]/u;
2536 +var De
= d(
/^((?![*_])punctSpace)/,
"u").replace(
/punctSpace/g, Z).getRegex();
2537 +var pe
= /(?!~)[\p{P}\p{S}]/u;
2538 +var qe
= /(?!~)[\s\p{P}\p{S}]/u;
2539 +var ve
= /(?:[^\s\p{P}\p{S}]|~)/u;
2540 +var He
= d(
/link|precode-code|html/,
"g").replace(
"link",
/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(
"precode-", Te
? "(?<!`)()" : "(^^|[^`])").replace(
"code",
/(?<b>`+)[^`]+\k<b>(?!`)/).replace(
"html",
/<(?! )[^<>]*?>/).getRegex();
2541 +var ce
= /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
2542 +var Ze
= d(ce,
"u").replace(
/punct/g, I).getRegex();
2543 +var Ge
= d(ce,
"u").replace(
/punct/g, pe).getRegex();
2544 +var he
= "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
2545 +var Ne
= d(he,
"gu").replace(
/notPunctSpace/g, X).replace(
/punctSpace/g, Z).replace(
/punct/g, I).getRegex();
2546 +var Qe
= d(he,
"gu").replace(
/notPunctSpace/g, ve).replace(
/punctSpace/g, qe).replace(
/punct/g, pe).getRegex();
2547 +var je
= d(
"^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
"gu").replace(
/notPunctSpace/g, X).replace(
/punctSpace/g, Z).replace(
/punct/g, I).getRegex();
2548 +var Fe
= d(
/^~~?(?:((?!~)punct)|[^\s~])/,
"u").replace(
/punct/g, I).getRegex();
2549 +var Ue
= "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
2550 +var Ke
= d(Ue,
"gu").replace(
/notPunctSpace/g, X).replace(
/punctSpace/g, Z).replace(
/punct/g, I).getRegex();
2551 +var We
= d(
/\\(punct)/,
"gu").replace(
/punct/g, I).getRegex();
2552 +var Xe
= d(
/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(
"scheme",
/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(
"email",
/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
2553 +var Je
= d(K).replace(
"(?:-->|$)",
"-->").getRegex();
2554 +var Ve
= d(
"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace(
"comment", Je).replace(
"attribute",
/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
2555 +var v
= /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
2556 +var Ye
= d(
/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(
"label", v).replace(
"href",
/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(
"title",
/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
2557 +var ke
= d(
/^!?\[(label)\]\[(ref)\]/).replace(
"label", v).replace(
"ref", U).getRegex();
2558 +var de
= d(
/^!?\[(ref)\](?:\[\])?/).replace(
"ref", U).getRegex();
2559 +var et
= d(
"reflink|nolink(?!\\()",
"g").replace(
"reflink", ke).replace(
"nolink", de).getRegex();
2560 +var ie
= /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
2561 +var J
= { _backpedal: _, anyPunctuation: We, autolink: Xe, blockSkip: He, br: ue, code: Ce, del: _, delLDelim: _, delRDelim: _, emStrongLDelim: Ze, emStrongRDelimAst: Ne, emStrongRDelimUnd: je, escape: Ae, link: Ye, nolink: de, punctuation: De, reflink: ke, reflinkSearch: et, tag: Ve, text: Be, url: _ };
2562 +var tt
= {
...J, link: d(
/^!?\[(label)\]\((.*?)\)/).replace(
"label", v).getRegex(), reflink: d(
/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(
"label", v).getRegex() };
2563 +var Q
= {
...J, emStrongRDelimAst: Qe, emStrongLDelim: Ge, delLDelim: Fe, delRDelim: Ke, url: d(
/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(
"protocol", ie).replace(
"email",
/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal:
/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del:
/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(
/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(
"protocol", ie).getRegex() };
2564 +var nt
= {
...Q, br: d(ue).replace(
"{2,}",
"*").getRegex(), text: d(
Q.text).replace(
"\\b_",
"\\b_| {2,}\\n").replace(
/\{2,\}/g,
"*").getRegex() };
2565 +var D
= { normal: W, gfm: Ee, pedantic: Ie };
2566 +var A
= { normal: J, gfm: Q, breaks: nt, pedantic: tt };
2567 +var rt
= {
"&":
"&",
"<":
"<",
">":
">",
'"':
""",
"'":
"'" };
2568 +var ge = (l3)
=> rt[l3];
2569 +function O(l3, e) {
2571 + if (m.escapeTest.test(l3))
return l3.replace(m.escapeReplace, ge);
2572 + }
else if (m.escapeTestNoEncode.test(l3))
return l3.replace(m.escapeReplaceNoEncode, ge);
2577 + l3
= encodeURI(l3).replace(m.percentDecode,
"%");
2583 +function Y(l3, e) {
2584 + let t
= l3.replace(m.findPipe, (r, i, o)
=> {
2585 + let u
= false, a
= i;
2586 + for (;
--a
>= 0 && o[a]
=== "\\"; ) u
= !u;
2587 + return u
? "|" : " |";
2588 + }), n
= t.split(m.splitPipe), s
= 0;
2589 + if (n[
0].trim()
|| n.shift()
, n.length
> 0 && !n.at(
-1)
?.trim()
&& n.pop()
, e)
if (n.length
> e) n.splice(e);
2590 + else for (; n.length
< e; ) n.push(
"");
2591 + for (; s
< n.length; s
++) n[s]
= n[s].trim().replace(m.slashPipe,
"|");
2594 +function $(l3, e, t) {
2595 + let n
= l3.length;
2596 + if (n
=== 0)
return "";
2599 + let r
= l3.charAt(n
- s
- 1);
2600 + if (r
=== e
&& !t) s
++;
2601 + else if (r
!== e
&& t) s
++;
2604 + return l3.slice(
0, n
- s);
2607 + let e
= l3.split(
` 2608 +`), t
= e.length
- 1;
2609 + for (; t
>= 0 && m.blankLine.test(e[t]); ) t
--;
2610 + return e.length
- t
<= 2 ? l3
: e.slice(
0, t
+ 1).join(
` 2613 +function fe(l3, e) {
2614 + if (l3.indexOf(e[
1])
=== -1)
return -1;
2616 + for (
let n
= 0; n
< l3.length; n
++)
if (l3[n]
=== "\\") n
++;
2617 + else if (l3[n]
=== e[
0]) t
++;
2618 + else if (l3[n]
=== e[
1]
&& (t
--, t
< 0))
return n;
2619 + return t
> 0 ? -2 : -1;
2621 +function me(l3, e
= 0) {
2622 + let t
= e, n
= "";
2623 + for (
let s
of l3)
if (s
=== " ") {
2624 + let r
= 4 - t
% 4;
2625 + n
+= " ".repeat(r)
, t
+= r;
2626 + }
else n
+= s
, t
++;
2629 +function xe(l3, e, t, n, s) {
2630 + let r
= e.href, i
= e.title
|| null, o
= l3[
1].replace(s.other.outputLinkReplace,
"$1");
2631 + n.state.inLink
= true;
2632 + let u
= { type: l3[
0].charAt(
0)
=== "!" ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: n.inlineTokens(o) };
2633 + return n.state.inLink
= false, u;
2635 +function st(l3, e, t) {
2636 + let n
= l3.match(t.other.indentCodeCompensation);
2637 + if (n
=== null)
return e;
2641 + let i
= r.match(t.other.beginningSpace);
2642 + if (i
=== null)
return r;
2644 + return o.length
>= s.length
? r.slice(s.length)
: r;
2653 + this.options
= e
|| T;
2656 + let t
= this.rules.block.newline.exec(e);
2657 + if (t
&& t[
0].length
> 0)
return { type:
"space", raw: t[
0] };
2660 + let t
= this.rules.block.code.exec(e);
2662 + let n
= this.options.pedantic
? t[
0]
: ee(t[
0]), s
= n.replace(this.rules.other.codeRemoveIndent,
"");
2663 + return { type:
"code", raw: n, codeBlockStyle:
"indented", text: s };
2667 + let t
= this.rules.block.fences.exec(e);
2669 + let n
= t[
0], s
= st(n, t[
3]
|| "", this.rules);
2670 + return { type:
"code", raw: n, lang: t[
2]
? t[
2].trim().replace(this.rules.inline.anyPunctuation,
"$1")
: t[
2], text: s };
2674 + let t
= this.rules.block.heading.exec(e);
2676 + let n
= t[
2].trim();
2677 + if (this.rules.other.endingHash.test(n)) {
2678 + let s
= $(n,
"#");
2679 + (this.options.pedantic
|| !s
|| this.rules.other.endingSpaceChar.test(s))
&& (n
= s.trim());
2681 + return { type:
"heading", raw: $(t[
0],
` 2682 +`), depth: t[
1].length, text: n, tokens: this.lexer.inline(n) };
2686 + let t
= this.rules.block.hr.exec(e);
2687 + if (t)
return { type:
"hr", raw: $(t[
0],
` 2691 + let t
= this.rules.block.blockquote.exec(e);
2695 +`), s
= "", r
= "", i
= [];
2696 + for (; n.length
> 0; ) {
2697 + let o
= false, u
= [], a;
2698 + for (a
= 0; a
< n.length; a
++)
if (this.rules.other.blockquoteStart.test(n[a])) u.push(n[a])
, o
= true;
2699 + else if (
!o) u.push(n[a]);
2703 +`), p
= c.replace(this.rules.other.blockquoteSetextReplace,
` 2704 + $1`).replace(this.rules.other.blockquoteSetextReplace2,
"");
2706 +${c}
` : c
, r
= r
? `${r}
2708 + let k
= this.lexer.state.top;
2709 + if (this.lexer.state.top
= true, this.lexer.blockTokens(p, i,
true)
, this.lexer.state.top
= k
, n.length
=== 0)
break;
2711 + if (h
?.type
=== "code")
break;
2712 + if (h
?.type
=== "blockquote") {
2713 + let R
= h, f
= R.raw
+ ` 2715 +`), S
= this.blockquote(f);
2716 + i[i.length
- 1]
= S
, s
= s.substring(
0, s.length
- R.raw.length)
+ S.raw
, r
= r.substring(
0, r.length
- R.text.length)
+ S.text;
2718 + }
else if (h
?.type
=== "list") {
2719 + let R
= h, f
= R.raw
+ ` 2721 +`), S
= this.list(f);
2722 + i[i.length
- 1]
= S
, s
= s.substring(
0, s.length
- h.raw.length)
+ S.raw
, r
= r.substring(
0, r.length
- R.raw.length)
+ S.raw
, n
= f.substring(i.at(
-1).raw.length).split(
` 2727 + return { type:
"blockquote", raw: s, tokens: i, text: r };
2731 + let t
= this.rules.block.list.exec(e);
2733 + let n
= t[
1].trim(), s
= n.length
> 1, r
= { type:
"list", raw:
"", ordered: s, start: s
? +n.slice(
0,
-1)
: "", loose:
false, items: [] };
2734 + n
= s
? `\\d{1,9}\\${n.slice(
-1)}
` : `\\${n}
`, this.options.pedantic
&& (n
= s
? n
: "[*+-]");
2735 + let i
= this.rules.other.listItemRegex(n), o
= false;
2737 + let a
= false, c
= "", p
= "";
2738 + if (
!(t
= i.exec(e))
|| this.rules.block.hr.test(e))
break;
2739 + c
= t[
0]
, e
= e.substring(c.length);
2740 + let k
= me(t[
2].split(
` 2741 +`,
1)[
0], t[
1].length), h
= e.split(
` 2742 +`,
1)[
0], R
= !k.trim(), f
= 0;
2743 + if (this.options.pedantic
? (f
= 2, p
= k.trimStart())
: R
? f
= t[
1].length
+ 1 : (f
= k.search(this.rules.other.nonSpaceChar), f
= f
> 4 ? 1 : f, p
= k.slice(f), f
+= t[
1].length)
, R
&& this.rules.other.blankLine.test(h)
&& (c
+= h
+ ` 2744 +`, e
= e.substring(h.length
+ 1), a
= true)
, !a) {
2745 + let S
= this.rules.other.nextBulletRegex(f), te
= this.rules.other.hrRegex(f), ne
= this.rules.other.fencesBeginRegex(f), re
= this.rules.other.headingBeginRegex(f), be
= this.rules.other.htmlBeginRegex(f), Re
= this.rules.other.blockquoteBeginRegex(f);
2749 + if (h
= G
, this.options.pedantic
? (h
= h.replace(this.rules.other.listReplaceNesting,
" "), C
= h)
: C
= h.replace(this.rules.other.tabCharGlobal,
" ")
, ne.test(h)
|| re.test(h)
|| be.test(h)
|| Re.test(h)
|| S.test(h)
|| te.test(h))
break;
2750 + if (
C.search(this.rules.other.nonSpaceChar)
>= f
|| !h.trim()) p
+= ` 2753 + if (R
|| k.replace(this.rules.other.tabCharGlobal,
" ").search(this.rules.other.nonSpaceChar)
>= 4 || ne.test(k)
|| re.test(k)
|| te.test(k))
break;
2757 + R
= !h.trim()
, c
+= G
+ ` 2758 +`, e
= e.substring(
G.length
+ 1)
, k
= C.slice(f);
2761 + r.loose
|| (o
? r.loose
= true : this.rules.other.doubleBlankLine.test(c)
&& (o
= true))
, r.items.push({ type:
"list_item", raw: c, task:
!!this.options.gfm
&& this.rules.other.listIsTask.test(p), loose:
false, text: p, tokens: [] })
, r.raw
+= c;
2763 + let u
= r.items.at(
-1);
2764 + if (u) u.raw
= u.raw.trimEnd()
, u.text
= u.text.trimEnd();
2766 + r.raw
= r.raw.trimEnd();
2767 + for (
let a
of r.items) {
2768 + this.lexer.state.top
= false, a.tokens
= this.lexer.blockTokens(a.text, []);
2769 + let c
= a.tokens[
0];
2770 + if (a.task
&& (c
?.type
=== "text" || c
?.type
=== "paragraph")) {
2771 + a.text
= a.text.replace(this.rules.other.listReplaceTask,
"")
, c.raw
= c.raw.replace(this.rules.other.listReplaceTask,
"")
, c.text
= c.text.replace(this.rules.other.listReplaceTask,
"");
2772 + for (
let k
= this.lexer.inlineQueue.length
- 1; k
>= 0; k
--)
if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[k].src)) {
2773 + this.lexer.inlineQueue[k].src
= this.lexer.inlineQueue[k].src.replace(this.rules.other.listReplaceTask,
"");
2776 + let p
= this.rules.other.listTaskCheckbox.exec(a.raw);
2778 + let k
= { type:
"checkbox", raw: p[
0]
+ " ", checked: p[
0]
!== "[ ]" };
2779 + a.checked
= k.checked
, r.loose
? a.tokens[
0]
&& [
"paragraph",
"text"].includes(a.tokens[
0].type)
&& "tokens" in a.tokens[
0]
&& a.tokens[
0].tokens
? (a.tokens[
0].raw
= k.raw
+ a.tokens[
0].raw, a.tokens[
0].text
= k.raw
+ a.tokens[
0].text, a.tokens[
0].tokens.unshift(k))
: a.tokens.unshift({ type:
"paragraph", raw: k.raw, text: k.raw, tokens: [k] })
: a.tokens.unshift(k);
2781 + }
else a.task
&& (a.task
= false);
2783 + let p
= a.tokens.filter((h)
=> h.type
=== "space"), k
= p.length
> 0 && p.some((h)
=> this.rules.other.anyLine.test(h.raw));
2787 + if (r.loose)
for (
let a
of r.items) {
2789 + for (
let c
of a.tokens) c.type
=== "text" && (c.type
= "paragraph");
2795 + let t
= this.rules.block.html.exec(e);
2798 + return { type:
"html", block:
true, raw: n, pre: t[
1]
=== "pre" || t[
1]
=== "script" || t[
1]
=== "style", text: n };
2802 + let t
= this.rules.block.def.exec(e);
2804 + let n
= t[
1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,
" "), s
= t[
2]
? t[
2].replace(this.rules.other.hrefBrackets,
"$1").replace(this.rules.inline.anyPunctuation,
"$1")
: "", r
= t[
3]
? t[
3].substring(
1, t[
3].length
- 1).replace(this.rules.inline.anyPunctuation,
"$1")
: t[
3];
2805 + return { type:
"def", tag: n, raw: $(t[
0],
` 2806 +`), href: s, title: r };
2810 + let t
= this.rules.block.table.exec(e);
2811 + if (
!t
|| !this.rules.other.tableDelimiter.test(t[
2]))
return;
2812 + let n
= Y(t[
1]), s
= t[
2].replace(this.rules.other.tableAlignChars,
"").split(
"|"), r
= t[
3]
?.trim()
? t[
3].replace(this.rules.other.tableRowBlankLine,
"").split(
` 2813 +`)
: [], i
= { type:
"table", raw: $(t[
0],
` 2814 +`), header: [], align: [], rows: [] };
2815 + if (n.length
=== s.length) {
2816 + for (
let o
of s) this.rules.other.tableAlignRight.test(o)
? i.align.push(
"right")
: this.rules.other.tableAlignCenter.test(o)
? i.align.push(
"center")
: this.rules.other.tableAlignLeft.test(o)
? i.align.push(
"left")
: i.align.push(
null);
2817 + for (
let o
= 0; o
< n.length; o
++) i.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header:
true, align: i.align[o] });
2818 + for (
let o
of r) i.rows.push(Y(o, i.header.length).map((u, a)
=> ({ text: u, tokens: this.lexer.inline(u), header:
false, align: i.align[a] })));
2823 + let t
= this.rules.block.lheading.exec(e);
2825 + let n
= t[
1].trim();
2826 + return { type:
"heading", raw: $(t[
0],
` 2827 +`), depth: t[
2].charAt(
0)
=== "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
2831 + let t
= this.rules.block.paragraph.exec(e);
2833 + let n
= t[
1].charAt(t[
1].length
- 1)
=== ` 2834 +` ? t[
1].slice(
0,
-1)
: t[
1];
2835 + return { type:
"paragraph", raw: t[
0], text: n, tokens: this.lexer.inline(n) };
2839 + let t
= this.rules.block.text.exec(e);
2840 + if (t)
return { type:
"text", raw: t[
0], text: t[
0], tokens: this.lexer.inline(t[
0]) };
2843 + let t
= this.rules.inline.escape.exec(e);
2844 + if (t)
return { type:
"escape", raw: t[
0], text: t[
1] };
2847 + let t
= this.rules.inline.tag.exec(e);
2848 + if (t)
return !this.lexer.state.inLink
&& this.rules.other.startATag.test(t[
0])
? this.lexer.state.inLink
= true : this.lexer.state.inLink
&& this.rules.other.endATag.test(t[
0])
&& (this.lexer.state.inLink
= false)
, !this.lexer.state.inRawBlock
&& this.rules.other.startPreScriptTag.test(t[
0])
? this.lexer.state.inRawBlock
= true : this.lexer.state.inRawBlock
&& this.rules.other.endPreScriptTag.test(t[
0])
&& (this.lexer.state.inRawBlock
= false)
, { type:
"html", raw: t[
0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block:
false, text: t[
0] };
2851 + let t
= this.rules.inline.link.exec(e);
2853 + let n
= t[
2].trim();
2854 + if (
!this.options.pedantic
&& this.rules.other.startAngleBracket.test(n)) {
2855 + if (
!this.rules.other.endAngleBracket.test(n))
return;
2856 + let i
= $(n.slice(
0,
-1),
"\\");
2857 + if ((n.length
- i.length)
% 2 === 0)
return;
2859 + let i
= fe(t[
2],
"()");
2860 + if (i
=== -2)
return;
2862 + let u
= (t[
0].indexOf(
"!")
=== 0 ? 5 : 4)
+ t[
1].length
+ i;
2863 + t[
2]
= t[
2].substring(
0, i)
, t[
0]
= t[
0].substring(
0, u).trim()
, t[
3]
= "";
2866 + let s
= t[
2], r
= "";
2867 + if (this.options.pedantic) {
2868 + let i
= this.rules.other.pedanticHrefTitle.exec(s);
2869 + i
&& (s
= i[
1], r
= i[
3]);
2870 + }
else r
= t[
3]
? t[
3].slice(
1,
-1)
: "";
2871 + return s
= s.trim()
, this.rules.other.startAngleBracket.test(s)
&& (this.options.pedantic
&& !this.rules.other.endAngleBracket.test(n)
? s
= s.slice(
1)
: s
= s.slice(
1,
-1))
, xe(t, { href: s
&& s.replace(this.rules.inline.anyPunctuation,
"$1"), title: r
&& r.replace(this.rules.inline.anyPunctuation,
"$1") }, t[
0], this.lexer, this.rules);
2876 + if ((n
= this.rules.inline.reflink.exec(e))
|| (n
= this.rules.inline.nolink.exec(e))) {
2877 + let s
= (n[
2]
|| n[
1]).replace(this.rules.other.multipleSpaceGlobal,
" "), r
= t[s.toLowerCase()];
2879 + let i
= n[
0].charAt(
0);
2880 + return { type:
"text", raw: i, text: i };
2882 + return xe(n, r, n[
0], this.lexer, this.rules);
2885 + emStrong(e, t, n
= "") {
2886 + let s
= this.rules.inline.emStrongLDelim.exec(e);
2887 + if (
!s
|| !s[
1]
&& !s[
2]
&& !s[
3]
&& !s[
4]
|| s[
4]
&& n.match(this.rules.other.unicodeAlphaNumeric))
return;
2888 + if (
!(s[
1]
|| s[
3]
|| "")
|| !n
|| this.rules.inline.punctuation.exec(n)) {
2889 + let i
= [
...s[
0]].length
- 1, o, u, a
= i, c
= 0, p
= s[
0][
0]
=== "*" ? this.rules.inline.emStrongRDelimAst
: this.rules.inline.emStrongRDelimUnd;
2890 + for (p.lastIndex
= 0, t
= t.slice(
-1 * e.length
+ i); (s
= p.exec(t))
!== null; ) {
2891 + if (o
= s[
1]
|| s[
2]
|| s[
3]
|| s[
4]
|| s[
5]
|| s[
6]
, !o)
continue;
2892 + if (u
= [
...o].length
, s[
3]
|| s[
4]) {
2895 + }
else if ((s[
5]
|| s[
6])
&& i
% 3 && !((i
+ u)
% 3)) {
2899 + if (a
-= u
, a
> 0)
continue;
2900 + u
= Math.
min(u, u
+ a
+ c);
2901 + let k
= [
...s[
0]][
0].length, h
= e.slice(
0, i
+ s.index
+ k
+ u);
2902 + if (
Math.
min(i, u)
% 2) {
2903 + let f
= h.slice(
1,
-1);
2904 + return { type:
"em", raw: h, text: f, tokens: this.lexer.inlineTokens(f) };
2906 + let R
= h.slice(
2,
-2);
2907 + return { type:
"strong", raw: h, text: R, tokens: this.lexer.inlineTokens(R) };
2912 + let t
= this.rules.inline.code.exec(e);
2914 + let n
= t[
2].replace(this.rules.other.newLineCharGlobal,
" "), s
= this.rules.other.nonSpaceChar.test(n), r
= this.rules.other.startingSpaceChar.test(n)
&& this.rules.other.endingSpaceChar.test(n);
2915 + return s
&& r
&& (n
= n.substring(
1, n.length
- 1))
, { type:
"codespan", raw: t[
0], text: n };
2919 + let t
= this.rules.inline.br.exec(e);
2920 + if (t)
return { type:
"br", raw: t[
0] };
2922 + del(e, t, n
= "") {
2923 + let s
= this.rules.inline.delLDelim.exec(e);
2925 + if (
!(s[
1]
|| "")
|| !n
|| this.rules.inline.punctuation.exec(n)) {
2926 + let i
= [
...s[
0]].length
- 1, o, u, a
= i, c
= this.rules.inline.delRDelim;
2927 + for (c.lastIndex
= 0, t
= t.slice(
-1 * e.length
+ i); (s
= c.exec(t))
!== null; ) {
2928 + if (o
= s[
1]
|| s[
2]
|| s[
3]
|| s[
4]
|| s[
5]
|| s[
6]
, !o
|| (u
= [
...o].length, u
!== i))
continue;
2929 + if (s[
3]
|| s[
4]) {
2933 + if (a
-= u
, a
> 0)
continue;
2934 + u
= Math.
min(u, u
+ a);
2935 + let p
= [
...s[
0]][
0].length, k
= e.slice(
0, i
+ s.index
+ p
+ u), h
= k.slice(i,
-i);
2936 + return { type:
"del", raw: k, text: h, tokens: this.lexer.inlineTokens(h) };
2941 + let t
= this.rules.inline.autolink.exec(e);
2944 + return t[
2]
=== "@" ? (n
= t[
1], s
= "mailto:" + n)
: (n
= t[
1], s
= n)
, { type:
"link", raw: t[
0], text: n, href: s, tokens: [{ type:
"text", raw: n, text: n }] };
2949 + if (t
= this.rules.inline.url.exec(e)) {
2951 + if (t[
2]
=== "@") n
= t[
0]
, s
= "mailto:" + n;
2955 + r
= t[
0]
, t[
0]
= this.rules.inline._backpedal.exec(t[
0])
?.[
0]
?? "";
2956 + while (r
!== t[
0]);
2957 + n
= t[
0]
, t[
1]
=== "www." ? s
= "http://" + t[
0]
: s
= t[
0];
2959 + return { type:
"link", raw: t[
0], text: n, href: s, tokens: [{ type:
"text", raw: n, text: n }] };
2963 + let t
= this.rules.inline.text.exec(e);
2965 + let n
= this.lexer.state.inRawBlock;
2966 + return { type:
"text", raw: t[
0], text: t[
0], escaped: n };
2977 + this.tokens
= []
, this.tokens.links
= Object.
create(
null)
, this.options
= e
|| T
, this.options.tokenizer
= this.options.tokenizer
|| new w()
, this.tokenizer
= this.options.tokenizer
, this.tokenizer.options
= this.options
, this.tokenizer.lexer
= this
, this.inlineQueue
= []
, this.state
= { inLink:
false, inRawBlock:
false, top:
true };
2978 + let t
= { other: m, block:
D.normal, inline:
A.normal };
2979 + this.options.pedantic
? (t.block
= D.pedantic, t.inline
= A.pedantic)
: this.options.gfm
&& (t.block
= D.gfm, this.options.breaks
? t.inline
= A.breaks
: t.inline
= A.gfm)
, this.tokenizer.rules
= t;
2981 + static get rules() {
2982 + return { block: D, inline: A };
2984 + static lex(e, t) {
2985 + return new l(t).lex(e);
2987 + static lexInline(e, t) {
2988 + return new l(t).inlineTokens(e);
2991 + e
= e.replace(m.carriageReturn,
` 2992 +`)
, this.blockTokens(e, this.tokens);
2993 + for (
let t
= 0; t
< this.inlineQueue.length; t
++) {
2994 + let n
= this.inlineQueue[t];
2995 + this.inlineTokens(n.src, n.tokens);
2997 + return this.inlineQueue
= []
, this.tokens;
2999 + blockTokens(e, t
= [], n
= false) {
3000 + this.tokenizer.lexer
= this
, this.options.pedantic
&& (e
= e.replace(m.tabCharGlobal,
" ").replace(m.spaceLine,
""));
3003 + if (e.length
< s) s
= e.length;
3005 + this.infiniteLoopError(e.charCodeAt(
0));
3009 + if (this.options.extensions
?.block
?.some((o)
=> (r
= o.call({ lexer: this }, e, t))
? (e
= e.substring(r.raw.length), t.push(r),
true)
: false))
continue;
3010 + if (r
= this.tokenizer.space(e)) {
3011 + e
= e.substring(r.raw.length);
3013 + r.raw.length
=== 1 && o
!== void 0 ? o.raw
+= ` 3017 + if (r
= this.tokenizer.code(e)) {
3018 + e
= e.substring(r.raw.length);
3020 + o
?.type
=== "paragraph" || o
?.type
=== "text" ? (o.raw
+= (o.raw.endsWith(
` 3022 +`)
+ r.raw, o.text
+= ` 3023 +` + r.text, this.inlineQueue.at(
-1).src
= o.text)
: t.push(r);
3026 + if (r
= this.tokenizer.fences(e)) {
3027 + e
= e.substring(r.raw.length)
, t.push(r);
3030 + if (r
= this.tokenizer.heading(e)) {
3031 + e
= e.substring(r.raw.length)
, t.push(r);
3034 + if (r
= this.tokenizer.hr(e)) {
3035 + e
= e.substring(r.raw.length)
, t.push(r);
3038 + if (r
= this.tokenizer.blockquote(e)) {
3039 + e
= e.substring(r.raw.length)
, t.push(r);
3042 + if (r
= this.tokenizer.list(e)) {
3043 + e
= e.substring(r.raw.length)
, t.push(r);
3046 + if (r
= this.tokenizer.html(e)) {
3047 + e
= e.substring(r.raw.length)
, t.push(r);
3050 + if (r
= this.tokenizer.def(e)) {
3051 + e
= e.substring(r.raw.length);
3053 + o
?.type
=== "paragraph" || o
?.type
=== "text" ? (o.raw
+= (o.raw.endsWith(
` 3055 +`)
+ r.raw, o.text
+= ` 3056 +` + r.raw, this.inlineQueue.at(
-1).src
= o.text)
: this.tokens.links[r.tag]
|| (this.tokens.links[r.tag]
= { href: r.href, title: r.title }, t.push(r));
3059 + if (r
= this.tokenizer.table(e)) {
3060 + e
= e.substring(r.raw.length)
, t.push(r);
3063 + if (r
= this.tokenizer.lheading(e)) {
3064 + e
= e.substring(r.raw.length)
, t.push(r);
3068 + if (this.options.extensions
?.startBlock) {
3069 + let o
= 1 / 0, u
= e.slice(
1), a;
3070 + this.options.extensions.startBlock.forEach((c)
=> {
3071 + a
= c.call({ lexer: this }, u)
, typeof a
== "number" && a
>= 0 && (o
= Math.
min(o, a));
3072 + })
, o
< 1 / 0 && o
>= 0 && (i
= e.substring(
0, o
+ 1));
3074 + if (this.state.top
&& (r
= this.tokenizer.paragraph(i))) {
3076 + n
&& o
?.type
=== "paragraph" ? (o.raw
+= (o.raw.endsWith(
` 3078 +`)
+ r.raw, o.text
+= ` 3079 +` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(
-1).src
= o.text)
: t.push(r)
, n
= i.length
!== e.length
, e
= e.substring(r.raw.length);
3082 + if (r
= this.tokenizer.text(e)) {
3083 + e
= e.substring(r.raw.length);
3085 + o
?.type
=== "text" ? (o.raw
+= (o.raw.endsWith(
` 3087 +`)
+ r.raw, o.text
+= ` 3088 +` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(
-1).src
= o.text)
: t.push(r);
3092 + this.infiniteLoopError(e.charCodeAt(
0));
3096 + return this.state.top
= true, t;
3098 + inline(e, t
= []) {
3099 + return this.inlineQueue.push({ src: e, tokens: t })
, t;
3101 + inlineTokens(e, t
= []) {
3102 + this.tokenizer.lexer
= this;
3103 + let n
= e, s
= null;
3104 + if (this.tokens.links) {
3105 + let a
= Object.
keys(this.tokens.links);
3106 + if (a.length
> 0)
for (; (s
= this.tokenizer.rules.inline.reflinkSearch.exec(n))
!== null; ) a.includes(s[
0].slice(s[
0].lastIndexOf(
"[")
+ 1,
-1))
&& (n
= n.slice(
0, s.index)
+ "[" + "a".repeat(s[
0].length
- 2)
+ "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
3108 + for (; (s
= this.tokenizer.rules.inline.anyPunctuation.exec(n))
!== null; ) n
= n.slice(
0, s.index)
+ "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
3110 + for (; (s
= this.tokenizer.rules.inline.blockSkip.exec(n))
!== null; ) r
= s[
2]
? s[
2].length
: 0, n
= n.slice(
0, s.index
+ r)
+ "[" + "a".repeat(s[
0].length
- r
- 2)
+ "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
3111 + n
= this.options.hooks
?.emStrongMask
?.call({ lexer: this }, n)
?? n;
3112 + let i
= false, o
= "", u
= 1 / 0;
3114 + if (e.length
< u) u
= e.length;
3116 + this.infiniteLoopError(e.charCodeAt(
0));
3119 + i
|| (o
= "")
, i
= false;
3121 + if (this.options.extensions
?.inline
?.some((p)
=> (a
= p.call({ lexer: this }, e, t))
? (e
= e.substring(a.raw.length), t.push(a),
true)
: false))
continue;
3122 + if (a
= this.tokenizer.escape(e)) {
3123 + e
= e.substring(a.raw.length)
, t.push(a);
3126 + if (a
= this.tokenizer.tag(e)) {
3127 + e
= e.substring(a.raw.length)
, t.push(a);
3130 + if (a
= this.tokenizer.link(e)) {
3131 + e
= e.substring(a.raw.length)
, t.push(a);
3134 + if (a
= this.tokenizer.reflink(e, this.tokens.links)) {
3135 + e
= e.substring(a.raw.length);
3137 + a.type
=== "text" && p
?.type
=== "text" ? (p.raw
+= a.raw, p.text
+= a.text)
: t.push(a);
3140 + if (a
= this.tokenizer.emStrong(e, n, o)) {
3141 + e
= e.substring(a.raw.length)
, t.push(a);
3144 + if (a
= this.tokenizer.codespan(e)) {
3145 + e
= e.substring(a.raw.length)
, t.push(a);
3148 + if (a
= this.tokenizer.br(e)) {
3149 + e
= e.substring(a.raw.length)
, t.push(a);
3152 + if (a
= this.tokenizer.del(e, n, o)) {
3153 + e
= e.substring(a.raw.length)
, t.push(a);
3156 + if (a
= this.tokenizer.autolink(e)) {
3157 + e
= e.substring(a.raw.length)
, t.push(a);
3160 + if (
!this.state.inLink
&& (a
= this.tokenizer.url(e))) {
3161 + e
= e.substring(a.raw.length)
, t.push(a);
3165 + if (this.options.extensions
?.startInline) {
3166 + let p
= 1 / 0, k
= e.slice(
1), h;
3167 + this.options.extensions.startInline.forEach((R)
=> {
3168 + h
= R.call({ lexer: this }, k)
, typeof h
== "number" && h
>= 0 && (p
= Math.
min(p, h));
3169 + })
, p
< 1 / 0 && p
>= 0 && (c
= e.substring(
0, p
+ 1));
3171 + if (a
= this.tokenizer.inlineText(c)) {
3172 + e
= e.substring(a.raw.length)
, a.raw.slice(
-1)
!== "_" && (o
= a.raw.slice(
-1))
, i
= true;
3174 + p
?.type
=== "text" ? (p.raw
+= a.raw, p.text
+= a.text)
: t.push(a);
3178 + this.infiniteLoopError(e.charCodeAt(
0));
3184 + infiniteLoopError(e) {
3185 + let t
= "Infinite loop on byte: " + e;
3186 + if (this.options.silent)
console.
error(t);
3187 + else throw new Error(t);
3194 + this.options
= e
|| T;
3199 + code({ text: e, lang: t, escaped: n }) {
3200 + let s
= (t
|| "").match(m.notSpaceStart)
?.[
0], r
= e.replace(m.endingNewline,
"")
+ ` 3202 + return s
? '<pre><code class="language-' + O(s)
+ '">' + (n
? r
: O(r,
true))
+ `</code></pre> 3203 +` : "<pre><code>" + (n
? r
: O(r,
true))
+ `</code></pre> 3206 + blockquote({ tokens: e }) {
3207 + return `<blockquote> 3208 +${this.parser.parse(e)}
</blockquote> 3211 + html({ text: e }) {
3217 + heading({ tokens: e, depth: t }) {
3218 + return `<h${t}
>${this.parser.parseInline(e)}
</h${t}
> 3226 + let t
= e.ordered, n
= e.start, s
= "";
3227 + for (
let o
= 0; o
< e.items.length; o
++) {
3228 + let u
= e.items[o];
3229 + s
+= this.listitem(u);
3231 + let r
= t
? "ol" : "ul", i
= t
&& n
!== 1 ? ' start="' + n
+ '"' : "";
3232 + return "<" + r
+ i
+ `> 3233 +` + s
+ "</" + r
+ `> 3237 + return `<li>${this.parser.parse(e.tokens)}
</li> 3240 + checkbox({ checked: e }) {
3241 + return "<input " + (e
? 'checked="" ' : "")
+ 'disabled="" type="checkbox"> ';
3243 + paragraph({ tokens: e }) {
3244 + return `<p>${this.parser.parseInline(e)}
</p> 3248 + let t
= "", n
= "";
3249 + for (
let r
= 0; r
< e.header.length; r
++) n
+= this.tablecell(e.header[r]);
3250 + t
+= this.tablerow({ text: n });
3252 + for (
let r
= 0; r
< e.rows.length; r
++) {
3253 + let i
= e.rows[r];
3255 + for (
let o
= 0; o
< i.length; o
++) n
+= this.tablecell(i[o]);
3256 + s
+= this.tablerow({ text: n });
3258 + return s
&& (s
= `<tbody>${s}
</tbody>`)
, `<table> 3264 + tablerow({ text: e }) {
3270 + let t
= this.parser.parseInline(e.tokens), n
= e.header
? "th" : "td";
3271 + return (e.align
? `<${n}
align="${e.align}
">` : `<${n}
>`)
+ t
+ `</${n}
> 3274 + strong({ tokens: e }) {
3275 + return `<strong>${this.parser.parseInline(e)}
</strong>`;
3277 + em({ tokens: e }) {
3278 + return `<em>${this.parser.parseInline(e)}
</em>`;
3280 + codespan({ text: e }) {
3281 + return `<code>${O(e,
true)}
</code>`;
3286 + del({ tokens: e }) {
3287 + return `<del>${this.parser.parseInline(e)}
</del>`;
3289 + link({ href: e, title: t, tokens: n }) {
3290 + let s
= this.parser.parseInline(n), r
= V(e);
3291 + if (r
=== null)
return s;
3293 + let i
= '<a href="' + e
+ '"';
3294 + return t
&& (i
+= ' title="' + O(t)
+ '"')
, i
+= ">" + s
+ "</a>", i;
3296 + image({ href: e, title: t, text: n, tokens: s }) {
3297 + s
&& (n
= this.parser.parseInline(s, this.parser.textRenderer));
3299 + if (r
=== null)
return O(n);
3301 + let i
= `<img src="${e}
" alt="${O(n)}
"`;
3302 + return t
&& (i
+= ` title="${O(t)}
"`)
, i
+= ">", i;
3305 + return "tokens" in e
&& e.tokens
? this.parser.parseInline(e.tokens)
: "escaped" in e
&& e.escaped
? e.text
: O(e.text);
3309 + strong({ text: e }) {
3315 + codespan({ text: e }) {
3318 + del({ text: e }) {
3321 + html({ text: e }) {
3324 + text({ text: e }) {
3327 + link({ text: e }) {
3330 + image({ text: e }) {
3336 + checkbox({ raw: e }) {
3345 + this.options
= e
|| T
, this.options.renderer
= this.options.renderer
|| new y()
, this.renderer
= this.options.renderer
, this.renderer.options
= this.options
, this.renderer.parser
= this
, this.textRenderer
= new L();
3347 + static parse(e, t) {
3348 + return new l2(t).parse(e);
3350 + static parseInline(e, t) {
3351 + return new l2(t).parseInline(e);
3354 + this.renderer.parser
= this;
3356 + for (
let n
= 0; n
< e.length; n
++) {
3358 + if (this.options.extensions
?.renderers
?.[s.type]) {
3359 + let i
= s, o
= this.options.extensions.renderers[i.type].call({ parser: this }, i);
3360 + if (o
!== false || ![
"space",
"hr",
"heading",
"code",
"table",
"blockquote",
"list",
"html",
"def",
"paragraph",
"text"].includes(i.type)) {
3368 + t
+= this.renderer.space(r);
3372 + t
+= this.renderer.hr(r);
3376 + t
+= this.renderer.heading(r);
3380 + t
+= this.renderer.code(r);
3384 + t
+= this.renderer.table(r);
3387 + case "blockquote": {
3388 + t
+= this.renderer.blockquote(r);
3392 + t
+= this.renderer.list(r);
3395 + case "checkbox": {
3396 + t
+= this.renderer.checkbox(r);
3400 + t
+= this.renderer.html(r);
3404 + t
+= this.renderer.def(r);
3407 + case "paragraph": {
3408 + t
+= this.renderer.paragraph(r);
3412 + t
+= this.renderer.text(r);
3416 + let i
= 'Token with "' + r.type
+ '" type was not found.';
3417 + if (this.options.silent)
return console.
error(i)
, "";
3418 + throw new Error(i);
3424 + parseInline(e, t
= this.renderer) {
3425 + this.renderer.parser
= this;
3427 + for (
let s
= 0; s
< e.length; s
++) {
3429 + if (this.options.extensions
?.renderers
?.[r.type]) {
3430 + let o
= this.options.extensions.renderers[r.type].call({ parser: this }, r);
3431 + if (o
!== false || ![
"escape",
"html",
"link",
"image",
"strong",
"em",
"codespan",
"br",
"del",
"text"].includes(r.type)) {
3454 + case "checkbox": {
3455 + n
+= t.checkbox(i);
3466 + case "codespan": {
3467 + n
+= t.codespan(i);
3483 + let o
= 'Token with "' + i.type
+ '" type was not found.';
3484 + if (this.options.silent)
return console.
error(o)
, "";
3485 + throw new Error(o);
3496 + this.options
= e
|| T;
3498 + static passThroughHooks
= new Set([
"preprocess",
"postprocess",
"processAllTokens",
"emStrongMask"]);
3499 + static passThroughHooksRespectAsync
= new Set([
"preprocess",
"postprocess",
"processAllTokens"]);
3506 + processAllTokens(e) {
3512 + provideLexer(e
= this.block) {
3513 + return e
? x.lex
: x.lexInline;
3515 + provideParser(e
= this.block) {
3516 + return e
? b.parse
: b.parseInline;
3521 + options
= this.setOptions;
3522 + parse
= this.parseMarkdown(
true);
3523 + parseInline
= this.parseMarkdown(
false);
3530 + constructor(
...e) {
3533 + walkTokens(e, t) {
3535 + for (
let s
of e)
switch (n
= n.concat(t.call(this, s))
, s.type) {
3538 + for (
let i
of r.header) n
= n.concat(this.walkTokens(i.tokens, t));
3539 + for (
let i
of r.rows)
for (
let o
of i) n
= n.concat(this.walkTokens(o.tokens, t));
3544 + n
= n.concat(this.walkTokens(r.items, t));
3549 + this.defaults.extensions
?.childTokens
?.[r.type]
? this.defaults.extensions.childTokens[r.type].forEach((i)
=> {
3550 + let o
= r[i].flat(
1 / 0);
3551 + n
= n.concat(this.walkTokens(o, t));
3552 + })
: r.tokens
&& (n
= n.concat(this.walkTokens(r.tokens, t)));
3558 + let t
= this.defaults.extensions
|| { renderers: {}, childTokens: {} };
3559 + return e.forEach((n)
=> {
3561 + if (s.async
= this.defaults.async
|| s.async
|| false, n.extensions
&& (n.extensions.forEach((r)
=> {
3562 + if (
!r.name)
throw new Error(
"extension name required");
3563 + if (
"renderer" in r) {
3564 + let i
= t.renderers[r.name];
3565 + i
? t.renderers[r.name]
= function(
...o) {
3566 + let u
= r.renderer.apply(this, o);
3567 + return u
=== false && (u
= i.apply(this, o))
, u;
3568 + }
: t.renderers[r.name]
= r.renderer;
3570 + if (
"tokenizer" in r) {
3571 + if (
!r.level
|| r.level
!== "block" && r.level
!== "inline")
throw new Error(
"extension level must be 'block' or 'inline'");
3572 + let i
= t[r.level];
3573 + i
? i.unshift(r.tokenizer)
: t[r.level]
= [r.tokenizer]
, r.start
&& (r.level
=== "block" ? t.startBlock
? t.startBlock.push(r.start)
: t.startBlock
= [r.start]
: r.level
=== "inline" && (t.startInline
? t.startInline.push(r.start)
: t.startInline
= [r.start]));
3575 + "childTokens" in r
&& r.childTokens
&& (t.childTokens[r.name]
= r.childTokens);
3576 + }), s.extensions
= t)
, n.renderer) {
3577 + let r
= this.defaults.renderer
|| new y(this.defaults);
3578 + for (
let i
in n.renderer) {
3579 + if (
!(i
in r))
throw new Error(
`renderer '${i}
' does not exist`);
3580 + if ([
"options",
"parser"].includes(i))
continue;
3581 + let o
= i, u
= n.renderer[o], a
= r[o];
3582 + r[o]
= (
...c)
=> {
3583 + let p
= u.apply(r, c);
3584 + return p
=== false && (p
= a.apply(r, c))
, p
|| "";
3589 + if (n.tokenizer) {
3590 + let r
= this.defaults.tokenizer
|| new w(this.defaults);
3591 + for (
let i
in n.tokenizer) {
3592 + if (
!(i
in r))
throw new Error(
`tokenizer '${i}
' does not exist`);
3593 + if ([
"options",
"rules",
"lexer"].includes(i))
continue;
3594 + let o
= i, u
= n.tokenizer[o], a
= r[o];
3595 + r[o]
= (
...c)
=> {
3596 + let p
= u.apply(r, c);
3597 + return p
=== false && (p
= a.apply(r, c))
, p;
3603 + let r
= this.defaults.hooks
|| new P();
3604 + for (
let i
in n.hooks) {
3605 + if (
!(i
in r))
throw new Error(
`hook '${i}
' does not exist`);
3606 + if ([
"options",
"block"].includes(i))
continue;
3607 + let o
= i, u
= n.hooks[o], a
= r[o];
3608 + P.passThroughHooks.has(i)
? r[o]
= (c)
=> {
3609 + if (this.defaults.async
&& P.passThroughHooksRespectAsync.has(i))
return (
async ()
=> {
3610 + let k
= await u.call(r, c);
3611 + return a.call(r, k);
3613 + let p
= u.call(r, c);
3614 + return a.call(r, p);
3615 + }
: r[o]
= (
...c)
=> {
3616 + if (this.defaults.async)
return (
async ()
=> {
3617 + let k
= await u.apply(r, c);
3618 + return k
=== false && (k
= await a.apply(r, c))
, k;
3620 + let p
= u.apply(r, c);
3621 + return p
=== false && (p
= a.apply(r, c))
, p;
3626 + if (n.walkTokens) {
3627 + let r
= this.defaults.walkTokens, i
= n.walkTokens;
3628 + s.
walkTokens = function(o) {
3630 + return u.push(i.call(this, o))
, r
&& (u
= u.concat(r.call(this, o)))
, u;
3633 + this.defaults
= {
...this.defaults,
...s };
3637 + return this.defaults
= {
...this.defaults,
...e }
, this;
3640 + return x.lex(e, t
?? this.defaults);
3643 + return b.parse(e, t
?? this.defaults);
3645 + parseMarkdown(e) {
3646 + return (n, s)
=> {
3647 + let r
= {
...s }, i
= {
...this.defaults,
...r }, o
= this.onError(
!!i.silent,
!!i.async);
3648 + if (this.defaults.async
=== true && r.async
=== false)
return o(
new Error(
"marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
3649 + if (
typeof n
> "u" || n
=== null)
return o(
new Error(
"marked(): input parameter is undefined or null"));
3650 + if (
typeof n
!= "string")
return o(
new Error(
"marked(): input parameter is of type " + Object.
prototype.
toString.call(n)
+ ", string expected"));
3651 + if (i.hooks
&& (i.hooks.options
= i, i.hooks.block
= e)
, i.async)
return (
async ()
=> {
3652 + let u
= i.hooks
? await i.hooks.preprocess(n)
: n, c
= await (i.hooks
? await i.hooks.provideLexer(e)
: e
? x.lex
: x.lexInline)(u, i), p
= i.hooks
? await i.hooks.processAllTokens(c)
: c;
3653 + i.walkTokens
&& await Promise.
all(this.walkTokens(p, i.walkTokens));
3654 + let h
= await (i.hooks
? await i.hooks.provideParser(e)
: e
? b.parse
: b.parseInline)(p, i);
3655 + return i.hooks
? await i.hooks.postprocess(h)
: h;
3658 + i.hooks
&& (n
= i.hooks.preprocess(n));
3659 + let a
= (i.hooks
? i.hooks.provideLexer(e)
: e
? x.lex
: x.lexInline)(n, i);
3660 + i.hooks
&& (a
= i.hooks.processAllTokens(a))
, i.walkTokens
&& this.walkTokens(a, i.walkTokens);
3661 + let p
= (i.hooks
? i.hooks.provideParser(e)
: e
? b.parse
: b.parseInline)(a, i);
3662 + return i.hooks
&& (p
= i.hooks.postprocess(p))
, p;
3670 + if (n.message
+= ` 3671 +Please report this to https://github.com/markedjs/marked.`, e) {
3672 + let s
= "<p>An error occurred:</p><pre>" + O(n.message
+ "",
true)
+ "</pre>";
3673 + return t
? Promise.
resolve(s)
: s;
3675 + if (t)
return Promise.
reject(n);
3681 +function g(l3, e) {
3682 + return z.parse(l3, e);
3684 +g.options
= g.
setOptions = function(l3) {
3685 + return z.setOptions(l3)
, g.defaults
= z.defaults
, N(g.defaults)
, g;
3689 +g.
use = function(
...l3) {
3690 + return z.use(
...l3)
, g.defaults
= z.defaults
, N(g.defaults)
, g;
3692 +g.
walkTokens = function(l3, e) {
3693 + return z.walkTokens(l3, e);
3695 +g.parseInline
= z.parseInline;
3697 +g.parser
= b.parse;
3699 +g.TextRenderer
= L;
3705 +var Ft
= g.options;
3706 +var Ut
= g.setOptions;
3708 +var Wt
= g.walkTokens;
3709 +var Xt
= g.parseInline;
3714 +var frontmatterFence
= /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;
3715 +var namePattern
= /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
3716 +var scriptPattern
= /\.(?:mjs|cjs|js|ts|sh|bash|nu|py|ps1|cmd|bat)$/i;
19 3717 function filesUnder(dir) {
20 - return readdirSync(dir, { withFileTypes:
true }).flatMap((entry)
=> {
21 - if (entry.name
=== "node_modules" || entry.name
=== ".git")
return [];
22 - const path
= join(dir, entry.name);
23 - if (entry.isDirectory())
return filesUnder(path);
24 - return entry.isFile()
? [path]
: [];
3718 + return readdirSync(dir, { withFileTypes:
true }).flatMap((entry)
=> {
3719 + if (entry.name
=== "node_modules" || entry.name
=== ".git")
return [];
3720 + const path
= join(dir, entry.name);
3721 + if (entry.isDirectory())
return filesUnder(path);
3722 + return entry.isFile()
? [path]
: [];
28 -export function checkSkill(directory) {
29 - const root
= resolve(directory);
30 - if (
!statSync(root).isDirectory())
31 - throw new Error(
"Expected a skill directory");
32 - const skill
= join(root,
"SKILL.md");
33 - const text
= readFileSync(skill,
"utf8");
35 - const add = (path, code, message)
=> 37 - path: relative(root, path).split(
"\\").join(
"/"),
41 - const fence
= text.match(frontmatterFence);
45 - "frontmatter.fence",
46 - "Expected opening and closing YAML frontmatter fences",
51 - data
= parse(fence[
1]);
56 - "Invalid YAML frontmatter, keys, or aliases",
59 - if (data
!== undefined) {
60 - if (
!data
|| typeof data
!== "object" || Array.
isArray(data)) {
61 - add(skill,
"frontmatter.mapping",
"Frontmatter must be a YAML mapping");
63 - const { name, description }
= data;
65 - typeof name
!== "string" || 67 - !namePattern.test(name)
72 - "Name must be 1-64 lowercase letters/digits with single internal hyphens",
74 - }
else if (name
!== basename(root)) {
78 - "Name must match directory for Agent Skills portability",
82 - typeof description
!== "string" || 83 - !description.trim()
|| 84 - description.length
> 1024 88 - "description.invalid",
89 - "Description must be a non-empty string of at most 1024 characters",
92 - const invocation
= data[
"disable-model-invocation"];
93 - if (invocation
!== undefined && typeof invocation
!== "boolean") {
96 - "invocation.invalid",
97 - "disable-model-invocation must be a boolean when present",
104 - const files
= filesUnder(root).sort();
105 - for (
const file
of files.filter((path)
=> path.endsWith(
".md"))) {
106 - const body
= readFileSync(file,
"utf8").replace(frontmatterFence,
"");
107 - marked.walkTokens(marked.lexer(body), (token)
=> {
108 - if (token.type
!== "link" && token.type
!== "image")
return;
109 - const href
= token.href;
112 - /^[a-z][a-z\d+.-]*:|^[#/?\\]/i.test(href)
|| 118 - target
= decodeURIComponent(href.split(
/[?#]/,
1)[
0]);
120 - add(file,
"link.encoding",
"Local link has invalid percent encoding");
123 - if (
!existsSync(resolve(dirname(file), target))) {
124 - add(file,
"link.missing",
`Missing local link target: ${href}
`);
129 - const scripted
= files.some((file)
=> scriptPattern.test(file));
130 - const packageFile
= join(root,
"package.json");
131 - if (
!existsSync(packageFile)) {
136 - "Scripted skills require package.json",
141 - manifest
= JSON.
parse(readFileSync(packageFile,
"utf8"));
145 - if (
!manifest
|| typeof manifest
!== "object" || Array.
isArray(manifest)) {
149 - "Expected a JSON object in package.json",
153 - (
typeof manifest.scripts
?.test
!== "string" || 154 - !/^node\s+--test(?:\s|$)/.test(manifest.scripts.test))
159 - "scripts.test must invoke node --test directly",
163 - if (scripted
&& !files.some((file)
=> file.endsWith(
".test.mjs"))) {
167 - "Scripted skills require at least one .test.mjs file",
170 - return { skill: root, ok: issues.length
=== 0, issues };
3725 +function checkSkill(directory) {
3726 + const root
= resolve(directory);
3727 + if (
!statSync(root).isDirectory())
3728 + throw new Error(
"Expected a skill directory");
3729 + const skill
= join(root,
"SKILL.md");
3730 + const text
= readFileSync(skill,
"utf8");
3731 + const issues
= [];
3732 + const add = (path, code, message)
=> issues.push({
3733 + path: relative(root, path).split(
"\\").join(
"/"),
3737 + const fence
= text.match(frontmatterFence);
3741 + "frontmatter.fence",
3742 + "Expected opening and closing YAML frontmatter fences" 3747 + data
= load(fence[
1]);
3751 + "frontmatter.yaml",
3752 + "Invalid YAML frontmatter, keys, or aliases" 3755 + if (data
!== void 0) {
3756 + if (
!data
|| typeof data
!== "object" || Array.
isArray(data)) {
3757 + add(skill,
"frontmatter.mapping",
"Frontmatter must be a YAML mapping");
3759 + const { name, description }
= data;
3760 + if (
typeof name
!== "string" || name.length
> 64 || !namePattern.test(name)) {
3764 + "Name must be 1-64 lowercase letters/digits with single internal hyphens" 3766 + }
else if (name
!== basename(root)) {
3770 + "Name must match directory for Agent Skills portability" 3773 + if (
typeof description
!== "string" || !description.trim()
|| description.length
> 1024) {
3776 + "description.invalid",
3777 + "Description must be a non-empty string of at most 1024 characters" 3780 + const invocation
= data[
"disable-model-invocation"];
3781 + if (invocation
!== void 0 && typeof invocation
!== "boolean") {
3784 + "invocation.invalid",
3785 + "disable-model-invocation must be a boolean when present" 3791 + const files
= filesUnder(root).sort();
3792 + for (
const file
of files.filter((path)
=> path.endsWith(
".md"))) {
3793 + const body
= readFileSync(file,
"utf8").replace(frontmatterFence,
"");
3794 + g.walkTokens(g.lexer(body), (token)
=> {
3795 + if (token.type
!== "link" && token.type
!== "image")
return;
3796 + const href
= token.href;
3797 + if (
!href
|| /^[a-z][a-z\d+.-]*:|^[#/?\\]/i.test(href)
|| isAbsolute(href))
3801 + target
= decodeURIComponent(href.split(
/[?#]/,
1)[
0]);
3803 + add(file,
"link.encoding",
"Local link has invalid percent encoding");
3806 + if (
!existsSync(resolve(dirname(file), target))) {
3807 + add(file,
"link.missing",
`Missing local link target: ${href}
`);
3811 + const scripted
= files.some((file)
=> scriptPattern.test(file));
3812 + const packageFile
= join(root,
"package.json");
3813 + if (
!existsSync(packageFile)) {
3817 + "package.missing",
3818 + "Scripted skills require package.json" 3823 + manifest
= JSON.
parse(readFileSync(packageFile,
"utf8"));
3827 + if (
!manifest
|| typeof manifest
!== "object" || Array.
isArray(manifest)) {
3831 + "Expected a JSON object in package.json" 3833 + }
else if (scripted
&& (
typeof manifest.scripts
?.test
!== "string" || !/^node\s+--test(?:\s|$)/.test(manifest.scripts.test))) {
3837 + "scripts.test must invoke node --test directly" 3841 + if (scripted
&& !files.some((file)
=> file.endsWith(
".test.mjs"))) {
3845 + "Scripted skills require at least one .test.mjs file" 3848 + return { skill: root, ok: issues.length
=== 0, issues };
175 - resolve(
process.
argv[
1])
=== fileURLToPath(
import.meta.url)
178 - if (
process.
argv.length
!== 3)
179 - throw new Error(
"Usage: node scripts/check.mjs <skill-dir>");
180 - const result
= checkSkill(
process.
argv[
2]);
181 - console.
log(
JSON.
stringify(result,
null,
2));
182 - process.
exitCode = result.ok
? 0 : 1;
184 - console.
log(
JSON.
stringify({ error: error.message }));
185 - process.
exitCode = 2;
3850 +if (
process.
argv[
1]
&& resolve(
process.
argv[
1])
=== fileURLToPath(
import.meta.url)) {
3852 + if (
process.
argv.length
!== 3)
3853 + throw new Error(
"Usage: node scripts/check.mjs <skill-dir>");
3854 + const result
= checkSkill(
process.
argv[
2]);
3855 + console.
log(
JSON.
stringify(result,
null,
2));
3856 + process.
exitCode = result.ok
? 0 : 1;
3858 + console.
log(
JSON.
stringify({ error: error.message }));
3859 + process.
exitCode = 2;