1import fs from 'fs'; 2import path$1 from 'path'; 3import { fileURLToPath, pathToFileURL } from 'url'; 4import proc from 'process'; 5import fs$1 from 'node:fs'; 6import path$2 from 'node:path'; 7import process$1 from 'node:process'; 8import { fileURLToPath as fileURLToPath$1 } from 'node:url'; 9import os from 'node:os'; 10import tty from 'node:tty'; 11 12function bail(error) { 13 if (error) { 14 throw error 15 } 16} 17 18var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 19 20function getDefaultExportFromCjs (x) { 21 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; 22} 23 24/*! 25 * Determine if an object is a Buffer 26 * 27 * @author Feross Aboukhadijeh <https://feross.org> 28 * @license MIT 29 */ 30var isBuffer = function isBuffer (obj) { 31 return obj != null && obj.constructor != null && 32 typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) 33}; 34var isBuffer$1 = getDefaultExportFromCjs(isBuffer); 35 36var hasOwn = Object.prototype.hasOwnProperty; 37var toStr = Object.prototype.toString; 38var defineProperty = Object.defineProperty; 39var gOPD = Object.getOwnPropertyDescriptor; 40var isArray = function isArray(arr) { 41 if (typeof Array.isArray === 'function') { 42 return Array.isArray(arr); 43 } 44 return toStr.call(arr) === '[object Array]'; 45}; 46var isPlainObject$1 = function isPlainObject(obj) { 47 if (!obj || toStr.call(obj) !== '[object Object]') { 48 return false; 49 } 50 var hasOwnConstructor = hasOwn.call(obj, 'constructor'); 51 var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); 52 if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { 53 return false; 54 } 55 var key; 56 for (key in obj) { } 57 return typeof key === 'undefined' || hasOwn.call(obj, key); 58}; 59var setProperty = function setProperty(target, options) { 60 if (defineProperty && options.name === '__proto__') { 61 defineProperty(target, options.name, { 62 enumerable: true, 63 configurable: true, 64 value: options.newValue, 65 writable: true 66 }); 67 } else { 68 target[options.name] = options.newValue; 69 } 70}; 71var getProperty = function getProperty(obj, name) { 72 if (name === '__proto__') { 73 if (!hasOwn.call(obj, name)) { 74 return void 0; 75 } else if (gOPD) { 76 return gOPD(obj, name).value; 77 } 78 } 79 return obj[name]; 80}; 81var extend$1 = function extend() { 82 var options, name, src, copy, copyIsArray, clone; 83 var target = arguments[0]; 84 var i = 1; 85 var length = arguments.length; 86 var deep = false; 87 if (typeof target === 'boolean') { 88 deep = target; 89 target = arguments[1] || {}; 90 i = 2; 91 } 92 if (target == null || (typeof target !== 'object' && typeof target !== 'function')) { 93 target = {}; 94 } 95 for (; i < length; ++i) { 96 options = arguments[i]; 97 if (options != null) { 98 for (name in options) { 99 src = getProperty(target, name); 100 copy = getProperty(options, name); 101 if (target !== copy) { 102 if (deep && copy && (isPlainObject$1(copy) || (copyIsArray = isArray(copy)))) { 103 if (copyIsArray) { 104 copyIsArray = false; 105 clone = src && isArray(src) ? src : []; 106 } else { 107 clone = src && isPlainObject$1(src) ? src : {}; 108 } 109 setProperty(target, { name: name, newValue: extend(deep, clone, copy) }); 110 } else if (typeof copy !== 'undefined') { 111 setProperty(target, { name: name, newValue: copy }); 112 } 113 } 114 } 115 } 116 } 117 return target; 118}; 119var extend$2 = getDefaultExportFromCjs(extend$1); 120 121function isPlainObject(value) { 122 if (typeof value !== 'object' || value === null) { 123 return false; 124 } 125 const prototype = Object.getPrototypeOf(value); 126 return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value); 127} 128 129function trough() { 130 const fns = []; 131 const pipeline = {run, use}; 132 return pipeline 133 function run(...values) { 134 let middlewareIndex = -1; 135 const callback = values.pop(); 136 if (typeof callback !== 'function') { 137 throw new TypeError('Expected function as last argument, not ' + callback) 138 } 139 next(null, ...values); 140 function next(error, ...output) { 141 const fn = fns[++middlewareIndex]; 142 let index = -1; 143 if (error) { 144 callback(error); 145 return 146 } 147 while (++index < values.length) { 148 if (output[index] === null || output[index] === undefined) { 149 output[index] = values[index]; 150 } 151 } 152 values = output; 153 if (fn) { 154 wrap(fn, next)(...output); 155 } else { 156 callback(null, ...output); 157 } 158 } 159 } 160 function use(middelware) { 161 if (typeof middelware !== 'function') { 162 throw new TypeError( 163 'Expected `middelware` to be a function, not ' + middelware 164 ) 165 } 166 fns.push(middelware); 167 return pipeline 168 } 169} 170function wrap(middleware, callback) { 171 let called; 172 return wrapped 173 function wrapped(...parameters) { 174 const fnExpectsCallback = middleware.length > parameters.length; 175 let result; 176 if (fnExpectsCallback) { 177 parameters.push(done); 178 } 179 try { 180 result = middleware.apply(this, parameters); 181 } catch (error) { 182 const exception = (error); 183 if (fnExpectsCallback && called) { 184 throw exception 185 } 186 return done(exception) 187 } 188 if (!fnExpectsCallback) { 189 if (result instanceof Promise) { 190 result.then(then, done); 191 } else if (result instanceof Error) { 192 done(result); 193 } else { 194 then(result); 195 } 196 } 197 } 198 function done(error, ...output) { 199 if (!called) { 200 called = true; 201 callback(error, ...output); 202 } 203 } 204 function then(value) { 205 done(null, value); 206 } 207} 208 209function stringifyPosition$1(value) { 210 if (!value || typeof value !== 'object') { 211 return '' 212 } 213 if ('position' in value || 'type' in value) { 214 return position$1(value.position) 215 } 216 if ('start' in value || 'end' in value) { 217 return position$1(value) 218 } 219 if ('line' in value || 'column' in value) { 220 return point$3(value) 221 } 222 return '' 223} 224function point$3(point) { 225 return index$1(point && point.line) + ':' + index$1(point && point.column) 226} 227function position$1(pos) { 228 return point$3(pos && pos.start) + '-' + point$3(pos && pos.end) 229} 230function index$1(value) { 231 return value && typeof value === 'number' ? value : 1 232} 233 234let VFileMessage$1 = class VFileMessage extends Error { 235 constructor(reason, place, origin) { 236 const parts = [null, null]; 237 let position = { 238 start: {line: null, column: null}, 239 end: {line: null, column: null} 240 }; 241 super(); 242 if (typeof place === 'string') { 243 origin = place; 244 place = undefined; 245 } 246 if (typeof origin === 'string') { 247 const index = origin.indexOf(':'); 248 if (index === -1) { 249 parts[1] = origin; 250 } else { 251 parts[0] = origin.slice(0, index); 252 parts[1] = origin.slice(index + 1); 253 } 254 } 255 if (place) { 256 if ('type' in place || 'position' in place) { 257 if (place.position) { 258 position = place.position; 259 } 260 } 261 else if ('start' in place || 'end' in place) { 262 position = place; 263 } 264 else if ('line' in place || 'column' in place) { 265 position.start = place; 266 } 267 } 268 this.name = stringifyPosition$1(place) || '1:1'; 269 this.message = typeof reason === 'object' ? reason.message : reason; 270 this.stack = ''; 271 if (typeof reason === 'object' && reason.stack) { 272 this.stack = reason.stack; 273 } 274 this.reason = this.message; 275 this.fatal; 276 this.line = position.start.line; 277 this.column = position.start.column; 278 this.position = position; 279 this.source = parts[0]; 280 this.ruleId = parts[1]; 281 this.file; 282 this.actual; 283 this.expected; 284 this.url; 285 this.note; 286 } 287}; 288VFileMessage$1.prototype.file = ''; 289VFileMessage$1.prototype.name = ''; 290VFileMessage$1.prototype.reason = ''; 291VFileMessage$1.prototype.message = ''; 292VFileMessage$1.prototype.stack = ''; 293VFileMessage$1.prototype.fatal = null; 294VFileMessage$1.prototype.column = null; 295VFileMessage$1.prototype.line = null; 296VFileMessage$1.prototype.source = null; 297VFileMessage$1.prototype.ruleId = null; 298VFileMessage$1.prototype.position = null; 299 300function isUrl$1(fileUrlOrPath) { 301 return ( 302 fileUrlOrPath !== null && 303 typeof fileUrlOrPath === 'object' && 304 fileUrlOrPath.href && 305 fileUrlOrPath.origin 306 ) 307} 308 309const order$1 = ['history', 'path', 'basename', 'stem', 'extname', 'dirname']; 310let VFile$1 = class VFile { 311 constructor(value) { 312 let options; 313 if (!value) { 314 options = {}; 315 } else if (typeof value === 'string' || buffer(value)) { 316 options = {value}; 317 } else if (isUrl$1(value)) { 318 options = {path: value}; 319 } else { 320 options = value; 321 } 322 this.data = {}; 323 this.messages = []; 324 this.history = []; 325 this.cwd = proc.cwd(); 326 this.value; 327 this.stored; 328 this.result; 329 this.map; 330 let index = -1; 331 while (++index < order$1.length) { 332 const prop = order$1[index]; 333 if ( 334 prop in options && 335 options[prop] !== undefined && 336 options[prop] !== null 337 ) { 338 this[prop] = prop === 'history' ? [...options[prop]] : options[prop]; 339 } 340 } 341 let prop; 342 for (prop in options) { 343 if (!order$1.includes(prop)) { 344 this[prop] = options[prop]; 345 } 346 } 347 } 348 get path() { 349 return this.history[this.history.length - 1] 350 } 351 set path(path) { 352 if (isUrl$1(path)) { 353 path = fileURLToPath(path); 354 } 355 assertNonEmpty$1(path, 'path'); 356 if (this.path !== path) { 357 this.history.push(path); 358 } 359 } 360 get dirname() { 361 return typeof this.path === 'string' ? path$1.dirname(this.path) : undefined 362 } 363 set dirname(dirname) { 364 assertPath$1(this.basename, 'dirname'); 365 this.path = path$1.join(dirname || '', this.basename); 366 } 367 get basename() { 368 return typeof this.path === 'string' ? path$1.basename(this.path) : undefined 369 } 370 set basename(basename) { 371 assertNonEmpty$1(basename, 'basename'); 372 assertPart$1(basename, 'basename'); 373 this.path = path$1.join(this.dirname || '', basename); 374 } 375 get extname() { 376 return typeof this.path === 'string' ? path$1.extname(this.path) : undefined 377 } 378 set extname(extname) { 379 assertPart$1(extname, 'extname'); 380 assertPath$1(this.dirname, 'extname'); 381 if (extname) { 382 if (extname.charCodeAt(0) !== 46 ) { 383 throw new Error('`extname` must start with `.`') 384 } 385 if (extname.includes('.', 1)) { 386 throw new Error('`extname` cannot contain multiple dots') 387 } 388 } 389 this.path = path$1.join(this.dirname, this.stem + (extname || '')); 390 } 391 get stem() { 392 return typeof this.path === 'string' 393 ? path$1.basename(this.path, this.extname) 394 : undefined 395 } 396 set stem(stem) { 397 assertNonEmpty$1(stem, 'stem'); 398 assertPart$1(stem, 'stem'); 399 this.path = path$1.join(this.dirname || '', stem + (this.extname || '')); 400 } 401 toString(encoding) { 402 return (this.value || '').toString(encoding || undefined) 403 } 404 message(reason, place, origin) { 405 const message = new VFileMessage$1(reason, place, origin); 406 if (this.path) { 407 message.name = this.path + ':' + message.name; 408 message.file = this.path; 409 } 410 message.fatal = false; 411 this.messages.push(message); 412 return message 413 } 414 info(reason, place, origin) { 415 const message = this.message(reason, place, origin); 416 message.fatal = null; 417 return message 418 } 419 fail(reason, place, origin) { 420 const message = this.message(reason, place, origin); 421 message.fatal = true; 422 throw message 423 } 424}; 425function assertPart$1(part, name) { 426 if (part && part.includes(path$1.sep)) { 427 throw new Error( 428 '`' + name + '` cannot be a path: did not expect `' + path$1.sep + '`' 429 ) 430 } 431} 432function assertNonEmpty$1(part, name) { 433 if (!part) { 434 throw new Error('`' + name + '` cannot be empty') 435 } 436} 437function assertPath$1(path, name) { 438 if (!path) { 439 throw new Error('Setting `' + name + '` requires `path` to be set too') 440 } 441} 442function buffer(value) { 443 return isBuffer$1(value) 444} 445 446const unified = base().freeze(); 447const own$6 = {}.hasOwnProperty; 448function base() { 449 const transformers = trough(); 450 const attachers = []; 451 let namespace = {}; 452 let frozen; 453 let freezeIndex = -1; 454 processor.data = data; 455 processor.Parser = undefined; 456 processor.Compiler = undefined; 457 processor.freeze = freeze; 458 processor.attachers = attachers; 459 processor.use = use; 460 processor.parse = parse; 461 processor.stringify = stringify; 462 processor.run = run; 463 processor.runSync = runSync; 464 processor.process = process; 465 processor.processSync = processSync; 466 return processor 467 function processor() { 468 const destination = base(); 469 let index = -1; 470 while (++index < attachers.length) { 471 destination.use(...attachers[index]); 472 } 473 destination.data(extend$2(true, {}, namespace)); 474 return destination 475 } 476 function data(key, value) { 477 if (typeof key === 'string') { 478 if (arguments.length === 2) { 479 assertUnfrozen('data', frozen); 480 namespace[key] = value; 481 return processor 482 } 483 return (own$6.call(namespace, key) && namespace[key]) || null 484 } 485 if (key) { 486 assertUnfrozen('data', frozen); 487 namespace = key; 488 return processor 489 } 490 return namespace 491 } 492 function freeze() { 493 if (frozen) { 494 return processor 495 } 496 while (++freezeIndex < attachers.length) { 497 const [attacher, ...options] = attachers[freezeIndex]; 498 if (options[0] === false) { 499 continue 500 } 501 if (options[0] === true) { 502 options[0] = undefined; 503 } 504 const transformer = attacher.call(processor, ...options); 505 if (typeof transformer === 'function') { 506 transformers.use(transformer); 507 } 508 } 509 frozen = true; 510 freezeIndex = Number.POSITIVE_INFINITY; 511 return processor 512 } 513 function use(value, ...options) { 514 let settings; 515 assertUnfrozen('use', frozen); 516 if (value === null || value === undefined) ; else if (typeof value === 'function') { 517 addPlugin(value, ...options); 518 } else if (typeof value === 'object') { 519 if (Array.isArray(value)) { 520 addList(value); 521 } else { 522 addPreset(value); 523 } 524 } else { 525 throw new TypeError('Expected usable value, not `' + value + '`') 526 } 527 if (settings) { 528 namespace.settings = Object.assign(namespace.settings || {}, settings); 529 } 530 return processor 531 function add(value) { 532 if (typeof value === 'function') { 533 addPlugin(value); 534 } else if (typeof value === 'object') { 535 if (Array.isArray(value)) { 536 const [plugin, ...options] = value; 537 addPlugin(plugin, ...options); 538 } else { 539 addPreset(value); 540 } 541 } else { 542 throw new TypeError('Expected usable value, not `' + value + '`') 543 } 544 } 545 function addPreset(result) { 546 addList(result.plugins); 547 if (result.settings) { 548 settings = Object.assign(settings || {}, result.settings); 549 } 550 } 551 function addList(plugins) { 552 let index = -1; 553 if (plugins === null || plugins === undefined) ; else if (Array.isArray(plugins)) { 554 while (++index < plugins.length) { 555 const thing = plugins[index]; 556 add(thing); 557 } 558 } else { 559 throw new TypeError('Expected a list of plugins, not `' + plugins + '`') 560 } 561 } 562 function addPlugin(plugin, value) { 563 let index = -1; 564 let entry; 565 while (++index < attachers.length) { 566 if (attachers[index][0] === plugin) { 567 entry = attachers[index]; 568 break 569 } 570 } 571 if (entry) { 572 if (isPlainObject(entry[1]) && isPlainObject(value)) { 573 value = extend$2(true, entry[1], value); 574 } 575 entry[1] = value; 576 } else { 577 attachers.push([...arguments]); 578 } 579 } 580 } 581 function parse(doc) { 582 processor.freeze(); 583 const file = vfile(doc); 584 const Parser = processor.Parser; 585 assertParser('parse', Parser); 586 if (newable(Parser, 'parse')) { 587 return new Parser(String(file), file).parse() 588 } 589 return Parser(String(file), file) 590 } 591 function stringify(node, doc) { 592 processor.freeze(); 593 const file = vfile(doc); 594 const Compiler = processor.Compiler; 595 assertCompiler('stringify', Compiler); 596 assertNode(node); 597 if (newable(Compiler, 'compile')) { 598 return new Compiler(node, file).compile() 599 } 600 return Compiler(node, file) 601 } 602 function run(node, doc, callback) { 603 assertNode(node); 604 processor.freeze(); 605 if (!callback && typeof doc === 'function') { 606 callback = doc; 607 doc = undefined; 608 } 609 if (!callback) { 610 return new Promise(executor) 611 } 612 executor(null, callback); 613 function executor(resolve, reject) { 614 transformers.run(node, vfile(doc), done); 615 function done(error, tree, file) { 616 tree = tree || node; 617 if (error) { 618 reject(error); 619 } else if (resolve) { 620 resolve(tree); 621 } else { 622 callback(null, tree, file); 623 } 624 } 625 } 626 } 627 function runSync(node, file) { 628 let result; 629 let complete; 630 processor.run(node, file, done); 631 assertDone('runSync', 'run', complete); 632 return result 633 function done(error, tree) { 634 bail(error); 635 result = tree; 636 complete = true; 637 } 638 } 639 function process(doc, callback) { 640 processor.freeze(); 641 assertParser('process', processor.Parser); 642 assertCompiler('process', processor.Compiler); 643 if (!callback) { 644 return new Promise(executor) 645 } 646 executor(null, callback); 647 function executor(resolve, reject) { 648 const file = vfile(doc); 649 processor.run(processor.parse(file), file, (error, tree, file) => { 650 if (error || !tree || !file) { 651 done(error); 652 } else { 653 const result = processor.stringify(tree, file); 654 if (result === undefined || result === null) ; else if (looksLikeAVFileValue(result)) { 655 file.value = result; 656 } else { 657 file.result = result; 658 } 659 done(error, file); 660 } 661 }); 662 function done(error, file) { 663 if (error || !file) { 664 reject(error); 665 } else if (resolve) { 666 resolve(file); 667 } else { 668 callback(null, file); 669 } 670 } 671 } 672 } 673 function processSync(doc) { 674 let complete; 675 processor.freeze(); 676 assertParser('processSync', processor.Parser); 677 assertCompiler('processSync', processor.Compiler); 678 const file = vfile(doc); 679 processor.process(file, done); 680 assertDone('processSync', 'process', complete); 681 return file 682 function done(error) { 683 complete = true; 684 bail(error); 685 } 686 } 687} 688function newable(value, name) { 689 return ( 690 typeof value === 'function' && 691 value.prototype && 692 (keys(value.prototype) || name in value.prototype) 693 ) 694} 695function keys(value) { 696 let key; 697 for (key in value) { 698 if (own$6.call(value, key)) { 699 return true 700 } 701 } 702 return false 703} 704function assertParser(name, value) { 705 if (typeof value !== 'function') { 706 throw new TypeError('Cannot `' + name + '` without `Parser`') 707 } 708} 709function assertCompiler(name, value) { 710 if (typeof value !== 'function') { 711 throw new TypeError('Cannot `' + name + '` without `Compiler`') 712 } 713} 714function assertUnfrozen(name, frozen) { 715 if (frozen) { 716 throw new Error( 717 'Cannot call `' + 718 name + 719 '` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.' 720 ) 721 } 722} 723function assertNode(node) { 724 if (!isPlainObject(node) || typeof node.type !== 'string') { 725 throw new TypeError('Expected node, got `' + node + '`') 726 } 727} 728function assertDone(name, asyncName, complete) { 729 if (!complete) { 730 throw new Error( 731 '`' + name + '` finished async. Use `' + asyncName + '` instead' 732 ) 733 } 734} 735function vfile(value) { 736 return looksLikeAVFile$1(value) ? value : new VFile$1(value) 737} 738function looksLikeAVFile$1(value) { 739 return Boolean( 740 value && 741 typeof value === 'object' && 742 'message' in value && 743 'messages' in value 744 ) 745} 746function looksLikeAVFileValue(value) { 747 return typeof value === 'string' || isBuffer$1(value) 748} 749 750const emptyOptions = {}; 751function toString(value, options) { 752 const settings = options || emptyOptions; 753 const includeImageAlt = 754 typeof settings.includeImageAlt === 'boolean' 755 ? settings.includeImageAlt 756 : true; 757 const includeHtml = 758 typeof settings.includeHtml === 'boolean' ? settings.includeHtml : true; 759 return one(value, includeImageAlt, includeHtml) 760} 761function one(value, includeImageAlt, includeHtml) { 762 if (node(value)) { 763 if ('value' in value) { 764 return value.type === 'html' && !includeHtml ? '' : value.value 765 } 766 if (includeImageAlt && 'alt' in value && value.alt) { 767 return value.alt 768 } 769 if ('children' in value) { 770 return all(value.children, includeImageAlt, includeHtml) 771 } 772 } 773 if (Array.isArray(value)) { 774 return all(value, includeImageAlt, includeHtml) 775 } 776 return '' 777} 778function all(values, includeImageAlt, includeHtml) { 779 const result = []; 780 let index = -1; 781 while (++index < values.length) { 782 result[index] = one(values[index], includeImageAlt, includeHtml); 783 } 784 return result.join('') 785} 786function node(value) { 787 return Boolean(value && typeof value === 'object') 788} 789 790function splice(list, start, remove, items) { 791 const end = list.length; 792 let chunkStart = 0; 793 let parameters; 794 if (start < 0) { 795 start = -start > end ? 0 : end + start; 796 } else { 797 start = start > end ? end : start; 798 } 799 remove = remove > 0 ? remove : 0; 800 if (items.length < 10000) { 801 parameters = Array.from(items); 802 parameters.unshift(start, remove); 803 list.splice(...parameters); 804 } else { 805 if (remove) list.splice(start, remove); 806 while (chunkStart < items.length) { 807 parameters = items.slice(chunkStart, chunkStart + 10000); 808 parameters.unshift(start, 0); 809 list.splice(...parameters); 810 chunkStart += 10000; 811 start += 10000; 812 } 813 } 814} 815function push(list, items) { 816 if (list.length > 0) { 817 splice(list, list.length, 0, items); 818 return list 819 } 820 return items 821} 822 823const hasOwnProperty = {}.hasOwnProperty; 824function combineExtensions(extensions) { 825 const all = {}; 826 let index = -1; 827 while (++index < extensions.length) { 828 syntaxExtension(all, extensions[index]); 829 } 830 return all 831} 832function syntaxExtension(all, extension) { 833 let hook; 834 for (hook in extension) { 835 const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined; 836 const left = maybe || (all[hook] = {}); 837 const right = extension[hook]; 838 let code; 839 if (right) { 840 for (code in right) { 841 if (!hasOwnProperty.call(left, code)) left[code] = []; 842 const value = right[code]; 843 constructs( 844 left[code], 845 Array.isArray(value) ? value : value ? [value] : [] 846 ); 847 } 848 } 849 } 850} 851function constructs(existing, list) { 852 let index = -1; 853 const before = []; 854 while (++index < list.length) { 855(list[index].add === 'after' ? existing : before).push(list[index]); 856 } 857 splice(existing, 0, 0, before); 858} 859 860const unicodePunctuationRegex = 861 /[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/; 862 863const asciiAlpha = regexCheck(/[A-Za-z]/); 864const asciiAlphanumeric = regexCheck(/[\dA-Za-z]/); 865const asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/); 866function asciiControl(code) { 867 return ( 868 code !== null && (code < 32 || code === 127) 869 ) 870} 871const asciiDigit = regexCheck(/\d/); 872const asciiHexDigit = regexCheck(/[\dA-Fa-f]/); 873const asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/); 874function markdownLineEnding(code) { 875 return code !== null && code < -2 876} 877function markdownLineEndingOrSpace(code) { 878 return code !== null && (code < 0 || code === 32) 879} 880function markdownSpace(code) { 881 return code === -2 || code === -1 || code === 32 882} 883const unicodePunctuation = regexCheck(unicodePunctuationRegex); 884const unicodeWhitespace = regexCheck(/\s/); 885function regexCheck(regex) { 886 return check 887 function check(code) { 888 return code !== null && regex.test(String.fromCharCode(code)) 889 } 890} 891 892function factorySpace(effects, ok, type, max) { 893 const limit = max ? max - 1 : Number.POSITIVE_INFINITY; 894 let size = 0; 895 return start 896 function start(code) { 897 if (markdownSpace(code)) { 898 effects.enter(type); 899 return prefix(code) 900 } 901 return ok(code) 902 } 903 function prefix(code) { 904 if (markdownSpace(code) && size++ < limit) { 905 effects.consume(code); 906 return prefix 907 } 908 effects.exit(type); 909 return ok(code) 910 } 911} 912 913const content$1 = { 914 tokenize: initializeContent 915}; 916function initializeContent(effects) { 917 const contentStart = effects.attempt( 918 this.parser.constructs.contentInitial, 919 afterContentStartConstruct, 920 paragraphInitial 921 ); 922 let previous; 923 return contentStart 924 function afterContentStartConstruct(code) { 925 if (code === null) { 926 effects.consume(code); 927 return 928 } 929 effects.enter('lineEnding'); 930 effects.consume(code); 931 effects.exit('lineEnding'); 932 return factorySpace(effects, contentStart, 'linePrefix') 933 } 934 function paragraphInitial(code) { 935 effects.enter('paragraph'); 936 return lineStart(code) 937 } 938 function lineStart(code) { 939 const token = effects.enter('chunkText', { 940 contentType: 'text', 941 previous 942 }); 943 if (previous) { 944 previous.next = token; 945 } 946 previous = token; 947 return data(code) 948 } 949 function data(code) { 950 if (code === null) { 951 effects.exit('chunkText'); 952 effects.exit('paragraph'); 953 effects.consume(code); 954 return 955 } 956 if (markdownLineEnding(code)) { 957 effects.consume(code); 958 effects.exit('chunkText'); 959 return lineStart 960 } 961 effects.consume(code); 962 return data 963 } 964} 965 966const document$1 = { 967 tokenize: initializeDocument 968}; 969const containerConstruct = { 970 tokenize: tokenizeContainer 971}; 972function initializeDocument(effects) { 973 const self = this; 974 const stack = []; 975 let continued = 0; 976 let childFlow; 977 let childToken; 978 let lineStartOffset; 979 return start 980 function start(code) { 981 if (continued < stack.length) { 982 const item = stack[continued]; 983 self.containerState = item[1]; 984 return effects.attempt( 985 item[0].continuation, 986 documentContinue, 987 checkNewContainers 988 )(code) 989 } 990 return checkNewContainers(code) 991 } 992 function documentContinue(code) { 993 continued++; 994 if (self.containerState._closeFlow) { 995 self.containerState._closeFlow = undefined; 996 if (childFlow) { 997 closeFlow(); 998 } 999 const indexBeforeExits = self.events.length; 1000 let indexBeforeFlow = indexBeforeExits; 1001 let point; 1002 while (indexBeforeFlow--) { 1003 if ( 1004 self.events[indexBeforeFlow][0] === 'exit' && 1005 self.events[indexBeforeFlow][1].type === 'chunkFlow' 1006 ) { 1007 point = self.events[indexBeforeFlow][1].end; 1008 break 1009 } 1010 } 1011 exitContainers(continued); 1012 let index = indexBeforeExits; 1013 while (index < self.events.length) { 1014 self.events[index][1].end = Object.assign({}, point); 1015 index++; 1016 } 1017 splice( 1018 self.events, 1019 indexBeforeFlow + 1, 1020 0, 1021 self.events.slice(indexBeforeExits) 1022 ); 1023 self.events.length = index; 1024 return checkNewContainers(code) 1025 } 1026 return start(code) 1027 } 1028 function checkNewContainers(code) { 1029 if (continued === stack.length) { 1030 if (!childFlow) { 1031 return documentContinued(code) 1032 } 1033 if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) { 1034 return flowStart(code) 1035 } 1036 self.interrupt = Boolean( 1037 childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack 1038 ); 1039 } 1040 self.containerState = {}; 1041 return effects.check( 1042 containerConstruct, 1043 thereIsANewContainer, 1044 thereIsNoNewContainer 1045 )(code) 1046 } 1047 function thereIsANewContainer(code) { 1048 if (childFlow) closeFlow(); 1049 exitContainers(continued); 1050 return documentContinued(code) 1051 } 1052 function thereIsNoNewContainer(code) { 1053 self.parser.lazy[self.now().line] = continued !== stack.length; 1054 lineStartOffset = self.now().offset; 1055 return flowStart(code) 1056 } 1057 function documentContinued(code) { 1058 self.containerState = {}; 1059 return effects.attempt( 1060 containerConstruct, 1061 containerContinue, 1062 flowStart 1063 )(code) 1064 } 1065 function containerContinue(code) { 1066 continued++; 1067 stack.push([self.currentConstruct, self.containerState]); 1068 return documentContinued(code) 1069 } 1070 function flowStart(code) { 1071 if (code === null) { 1072 if (childFlow) closeFlow(); 1073 exitContainers(0); 1074 effects.consume(code); 1075 return 1076 } 1077 childFlow = childFlow || self.parser.flow(self.now()); 1078 effects.enter('chunkFlow', { 1079 contentType: 'flow', 1080 previous: childToken, 1081 _tokenizer: childFlow 1082 }); 1083 return flowContinue(code) 1084 } 1085 function flowContinue(code) { 1086 if (code === null) { 1087 writeToChild(effects.exit('chunkFlow'), true); 1088 exitContainers(0); 1089 effects.consume(code); 1090 return 1091 } 1092 if (markdownLineEnding(code)) { 1093 effects.consume(code); 1094 writeToChild(effects.exit('chunkFlow')); 1095 continued = 0; 1096 self.interrupt = undefined; 1097 return start 1098 } 1099 effects.consume(code); 1100 return flowContinue 1101 } 1102 function writeToChild(token, eof) { 1103 const stream = self.sliceStream(token); 1104 if (eof) stream.push(null); 1105 token.previous = childToken; 1106 if (childToken) childToken.next = token; 1107 childToken = token; 1108 childFlow.defineSkip(token.start); 1109 childFlow.write(stream); 1110 if (self.parser.lazy[token.start.line]) { 1111 let index = childFlow.events.length; 1112 while (index--) { 1113 if ( 1114 childFlow.events[index][1].start.offset < lineStartOffset && 1115 (!childFlow.events[index][1].end || 1116 childFlow.events[index][1].end.offset > lineStartOffset) 1117 ) { 1118 return 1119 } 1120 } 1121 const indexBeforeExits = self.events.length; 1122 let indexBeforeFlow = indexBeforeExits; 1123 let seen; 1124 let point; 1125 while (indexBeforeFlow--) { 1126 if ( 1127 self.events[indexBeforeFlow][0] === 'exit' && 1128 self.events[indexBeforeFlow][1].type === 'chunkFlow' 1129 ) { 1130 if (seen) { 1131 point = self.events[indexBeforeFlow][1].end; 1132 break 1133 } 1134 seen = true; 1135 } 1136 } 1137 exitContainers(continued); 1138 index = indexBeforeExits; 1139 while (index < self.events.length) { 1140 self.events[index][1].end = Object.assign({}, point); 1141 index++; 1142 } 1143 splice( 1144 self.events, 1145 indexBeforeFlow + 1, 1146 0, 1147 self.events.slice(indexBeforeExits) 1148 ); 1149 self.events.length = index; 1150 } 1151 } 1152 function exitContainers(size) { 1153 let index = stack.length; 1154 while (index-- > size) { 1155 const entry = stack[index]; 1156 self.containerState = entry[1]; 1157 entry[0].exit.call(self, effects); 1158 } 1159 stack.length = size; 1160 } 1161 function closeFlow() { 1162 childFlow.write([null]); 1163 childToken = undefined; 1164 childFlow = undefined; 1165 self.containerState._closeFlow = undefined; 1166 } 1167} 1168function tokenizeContainer(effects, ok, nok) { 1169 return factorySpace( 1170 effects, 1171 effects.attempt(this.parser.constructs.document, ok, nok), 1172 'linePrefix', 1173 this.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4 1174 ) 1175} 1176 1177function classifyCharacter(code) { 1178 if ( 1179 code === null || 1180 markdownLineEndingOrSpace(code) || 1181 unicodeWhitespace(code) 1182 ) { 1183 return 1 1184 } 1185 if (unicodePunctuation(code)) { 1186 return 2 1187 } 1188} 1189 1190function resolveAll(constructs, events, context) { 1191 const called = []; 1192 let index = -1; 1193 while (++index < constructs.length) { 1194 const resolve = constructs[index].resolveAll; 1195 if (resolve && !called.includes(resolve)) { 1196 events = resolve(events, context); 1197 called.push(resolve); 1198 } 1199 } 1200 return events 1201} 1202 1203const attention = { 1204 name: 'attention', 1205 tokenize: tokenizeAttention, 1206 resolveAll: resolveAllAttention 1207}; 1208function resolveAllAttention(events, context) { 1209 let index = -1; 1210 let open; 1211 let group; 1212 let text; 1213 let openingSequence; 1214 let closingSequence; 1215 let use; 1216 let nextEvents; 1217 let offset; 1218 while (++index < events.length) { 1219 if ( 1220 events[index][0] === 'enter' && 1221 events[index][1].type === 'attentionSequence' && 1222 events[index][1]._close 1223 ) { 1224 open = index; 1225 while (open--) { 1226 if ( 1227 events[open][0] === 'exit' && 1228 events[open][1].type === 'attentionSequence' && 1229 events[open][1]._open && 1230 context.sliceSerialize(events[open][1]).charCodeAt(0) === 1231 context.sliceSerialize(events[index][1]).charCodeAt(0) 1232 ) { 1233 if ( 1234 (events[open][1]._close || events[index][1]._open) && 1235 (events[index][1].end.offset - events[index][1].start.offset) % 3 && 1236 !( 1237 (events[open][1].end.offset - 1238 events[open][1].start.offset + 1239 events[index][1].end.offset - 1240 events[index][1].start.offset) % 1241 3 1242 ) 1243 ) { 1244 continue 1245 } 1246 use = 1247 events[open][1].end.offset - events[open][1].start.offset > 1 && 1248 events[index][1].end.offset - events[index][1].start.offset > 1 1249 ? 2 1250 : 1; 1251 const start = Object.assign({}, events[open][1].end); 1252 const end = Object.assign({}, events[index][1].start); 1253 movePoint(start, -use); 1254 movePoint(end, use); 1255 openingSequence = { 1256 type: use > 1 ? 'strongSequence' : 'emphasisSequence', 1257 start, 1258 end: Object.assign({}, events[open][1].end) 1259 }; 1260 closingSequence = { 1261 type: use > 1 ? 'strongSequence' : 'emphasisSequence', 1262 start: Object.assign({}, events[index][1].start), 1263 end 1264 }; 1265 text = { 1266 type: use > 1 ? 'strongText' : 'emphasisText', 1267 start: Object.assign({}, events[open][1].end), 1268 end: Object.assign({}, events[index][1].start) 1269 }; 1270 group = { 1271 type: use > 1 ? 'strong' : 'emphasis', 1272 start: Object.assign({}, openingSequence.start), 1273 end: Object.assign({}, closingSequence.end) 1274 }; 1275 events[open][1].end = Object.assign({}, openingSequence.start); 1276 events[index][1].start = Object.assign({}, closingSequence.end); 1277 nextEvents = []; 1278 if (events[open][1].end.offset - events[open][1].start.offset) { 1279 nextEvents = push(nextEvents, [ 1280 ['enter', events[open][1], context], 1281 ['exit', events[open][1], context] 1282 ]); 1283 } 1284 nextEvents = push(nextEvents, [ 1285 ['enter', group, context], 1286 ['enter', openingSequence, context], 1287 ['exit', openingSequence, context], 1288 ['enter', text, context] 1289 ]); 1290 nextEvents = push( 1291 nextEvents, 1292 resolveAll( 1293 context.parser.constructs.insideSpan.null, 1294 events.slice(open + 1, index), 1295 context 1296 ) 1297 ); 1298 nextEvents = push(nextEvents, [ 1299 ['exit', text, context], 1300 ['enter', closingSequence, context], 1301 ['exit', closingSequence, context], 1302 ['exit', group, context] 1303 ]); 1304 if (events[index][1].end.offset - events[index][1].start.offset) { 1305 offset = 2; 1306 nextEvents = push(nextEvents, [ 1307 ['enter', events[index][1], context], 1308 ['exit', events[index][1], context] 1309 ]); 1310 } else { 1311 offset = 0; 1312 } 1313 splice(events, open - 1, index - open + 3, nextEvents); 1314 index = open + nextEvents.length - offset - 2; 1315 break 1316 } 1317 } 1318 } 1319 } 1320 index = -1; 1321 while (++index < events.length) { 1322 if (events[index][1].type === 'attentionSequence') { 1323 events[index][1].type = 'data'; 1324 } 1325 } 1326 return events 1327} 1328function tokenizeAttention(effects, ok) { 1329 const attentionMarkers = this.parser.constructs.attentionMarkers.null; 1330 const previous = this.previous; 1331 const before = classifyCharacter(previous); 1332 let marker; 1333 return start 1334 function start(code) { 1335 marker = code; 1336 effects.enter('attentionSequence'); 1337 return inside(code) 1338 } 1339 function inside(code) { 1340 if (code === marker) { 1341 effects.consume(code); 1342 return inside 1343 } 1344 const token = effects.exit('attentionSequence'); 1345 const after = classifyCharacter(code); 1346 const open = 1347 !after || (after === 2 && before) || attentionMarkers.includes(code); 1348 const close = 1349 !before || (before === 2 && after) || attentionMarkers.includes(previous); 1350 token._open = Boolean(marker === 42 ? open : open && (before || !close)); 1351 token._close = Boolean(marker === 42 ? close : close && (after || !open)); 1352 return ok(code) 1353 } 1354} 1355function movePoint(point, offset) { 1356 point.column += offset; 1357 point.offset += offset; 1358 point._bufferIndex += offset; 1359} 1360 1361const autolink = { 1362 name: 'autolink', 1363 tokenize: tokenizeAutolink 1364}; 1365function tokenizeAutolink(effects, ok, nok) { 1366 let size = 0; 1367 return start 1368 function start(code) { 1369 effects.enter('autolink'); 1370 effects.enter('autolinkMarker'); 1371 effects.consume(code); 1372 effects.exit('autolinkMarker'); 1373 effects.enter('autolinkProtocol'); 1374 return open 1375 } 1376 function open(code) { 1377 if (asciiAlpha(code)) { 1378 effects.consume(code); 1379 return schemeOrEmailAtext 1380 } 1381 return emailAtext(code) 1382 } 1383 function schemeOrEmailAtext(code) { 1384 if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) { 1385 size = 1; 1386 return schemeInsideOrEmailAtext(code) 1387 } 1388 return emailAtext(code) 1389 } 1390 function schemeInsideOrEmailAtext(code) { 1391 if (code === 58) { 1392 effects.consume(code); 1393 size = 0; 1394 return urlInside 1395 } 1396 if ( 1397 (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && 1398 size++ < 32 1399 ) { 1400 effects.consume(code); 1401 return schemeInsideOrEmailAtext 1402 } 1403 size = 0; 1404 return emailAtext(code) 1405 } 1406 function urlInside(code) { 1407 if (code === 62) { 1408 effects.exit('autolinkProtocol'); 1409 effects.enter('autolinkMarker'); 1410 effects.consume(code); 1411 effects.exit('autolinkMarker'); 1412 effects.exit('autolink'); 1413 return ok 1414 } 1415 if (code === null || code === 32 || code === 60 || asciiControl(code)) { 1416 return nok(code) 1417 } 1418 effects.consume(code); 1419 return urlInside 1420 } 1421 function emailAtext(code) { 1422 if (code === 64) { 1423 effects.consume(code); 1424 return emailAtSignOrDot 1425 } 1426 if (asciiAtext(code)) { 1427 effects.consume(code); 1428 return emailAtext 1429 } 1430 return nok(code) 1431 } 1432 function emailAtSignOrDot(code) { 1433 return asciiAlphanumeric(code) ? emailLabel(code) : nok(code) 1434 } 1435 function emailLabel(code) { 1436 if (code === 46) { 1437 effects.consume(code); 1438 size = 0; 1439 return emailAtSignOrDot 1440 } 1441 if (code === 62) { 1442 effects.exit('autolinkProtocol').type = 'autolinkEmail'; 1443 effects.enter('autolinkMarker'); 1444 effects.consume(code); 1445 effects.exit('autolinkMarker'); 1446 effects.exit('autolink'); 1447 return ok 1448 } 1449 return emailValue(code) 1450 } 1451 function emailValue(code) { 1452 if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) { 1453 const next = code === 45 ? emailValue : emailLabel; 1454 effects.consume(code); 1455 return next 1456 } 1457 return nok(code) 1458 } 1459} 1460 1461const blankLine = { 1462 tokenize: tokenizeBlankLine, 1463 partial: true 1464}; 1465function tokenizeBlankLine(effects, ok, nok) { 1466 return start 1467 function start(code) { 1468 return markdownSpace(code) 1469 ? factorySpace(effects, after, 'linePrefix')(code) 1470 : after(code) 1471 } 1472 function after(code) { 1473 return code === null || markdownLineEnding(code) ? ok(code) : nok(code) 1474 } 1475} 1476 1477const blockQuote = { 1478 name: 'blockQuote', 1479 tokenize: tokenizeBlockQuoteStart, 1480 continuation: { 1481 tokenize: tokenizeBlockQuoteContinuation 1482 }, 1483 exit: exit$1 1484}; 1485function tokenizeBlockQuoteStart(effects, ok, nok) { 1486 const self = this; 1487 return start 1488 function start(code) { 1489 if (code === 62) { 1490 const state = self.containerState; 1491 if (!state.open) { 1492 effects.enter('blockQuote', { 1493 _container: true 1494 }); 1495 state.open = true; 1496 } 1497 effects.enter('blockQuotePrefix'); 1498 effects.enter('blockQuoteMarker'); 1499 effects.consume(code); 1500 effects.exit('blockQuoteMarker'); 1501 return after 1502 } 1503 return nok(code) 1504 } 1505 function after(code) { 1506 if (markdownSpace(code)) { 1507 effects.enter('blockQuotePrefixWhitespace'); 1508 effects.consume(code); 1509 effects.exit('blockQuotePrefixWhitespace'); 1510 effects.exit('blockQuotePrefix'); 1511 return ok 1512 } 1513 effects.exit('blockQuotePrefix'); 1514 return ok(code) 1515 } 1516} 1517function tokenizeBlockQuoteContinuation(effects, ok, nok) { 1518 const self = this; 1519 return contStart 1520 function contStart(code) { 1521 if (markdownSpace(code)) { 1522 return factorySpace( 1523 effects, 1524 contBefore, 1525 'linePrefix', 1526 self.parser.constructs.disable.null.includes('codeIndented') 1527 ? undefined 1528 : 4 1529 )(code) 1530 } 1531 return contBefore(code) 1532 } 1533 function contBefore(code) { 1534 return effects.attempt(blockQuote, ok, nok)(code) 1535 } 1536} 1537function exit$1(effects) { 1538 effects.exit('blockQuote'); 1539} 1540 1541const characterEscape = { 1542 name: 'characterEscape', 1543 tokenize: tokenizeCharacterEscape 1544}; 1545function tokenizeCharacterEscape(effects, ok, nok) { 1546 return start 1547 function start(code) { 1548 effects.enter('characterEscape'); 1549 effects.enter('escapeMarker'); 1550 effects.consume(code); 1551 effects.exit('escapeMarker'); 1552 return inside 1553 } 1554 function inside(code) { 1555 if (asciiPunctuation(code)) { 1556 effects.enter('characterEscapeValue'); 1557 effects.consume(code); 1558 effects.exit('characterEscapeValue'); 1559 effects.exit('characterEscape'); 1560 return ok 1561 } 1562 return nok(code) 1563 } 1564} 1565 1566const characterEntities = { 1567 AElig: 'Æ', 1568 AMP: '&', 1569 Aacute: 'Á', 1570 Abreve: 'Ă', 1571 Acirc: 'Â', 1572 Acy: 'А', 1573 Afr: '', 1574 Agrave: 'À', 1575 Alpha: 'Α', 1576 Amacr: 'Ā', 1577 And: '⩓', 1578 Aogon: 'Ą', 1579 Aopf: '', 1580 ApplyFunction: '', 1581 Aring: 'Å', 1582 Ascr: '', 1583 Assign: '≔', 1584 Atilde: 'Ã', 1585 Auml: 'Ä', 1586 Backslash: '∖', 1587 Barv: '⫧', 1588 Barwed: '⌆', 1589 Bcy: 'Б', 1590 Because: '∵', 1591 Bernoullis: 'ℬ', 1592 Beta: 'Β', 1593 Bfr: '', 1594 Bopf: '', 1595 Breve: '˘', 1596 Bscr: 'ℬ', 1597 Bumpeq: '≎', 1598 CHcy: 'Ч', 1599 COPY: '©', 1600 Cacute: 'Ć', 1601 Cap: '⋒', 1602 CapitalDifferentialD: 'ⅅ', 1603 Cayleys: 'ℭ', 1604 Ccaron: 'Č', 1605 Ccedil: 'Ç', 1606 Ccirc: 'Ĉ', 1607 Cconint: '∰', 1608 Cdot: 'Ċ', 1609 Cedilla: '¸', 1610 CenterDot: '·', 1611 Cfr: 'ℭ', 1612 Chi: 'Χ', 1613 CircleDot: '⊙', 1614 CircleMinus: '⊖', 1615 CirclePlus: '⊕', 1616 CircleTimes: '⊗', 1617 ClockwiseContourIntegral: '∲', 1618 CloseCurlyDoubleQuote: '”', 1619 CloseCurlyQuote: '’', 1620 Colon: '∷', 1621 Colone: '⩴', 1622 Congruent: '≡', 1623 Conint: '∯', 1624 ContourIntegral: '∮', 1625 Copf: 'ℂ', 1626 Coproduct: '∐', 1627 CounterClockwiseContourIntegral: '∳', 1628 Cross: '⨯', 1629 Cscr: '', 1630 Cup: '⋓', 1631 CupCap: '≍', 1632 DD: 'ⅅ', 1633 DDotrahd: '⤑', 1634 DJcy: 'Ђ', 1635 DScy: 'Ѕ', 1636 DZcy: 'Џ', 1637 Dagger: '‡', 1638 Darr: '↡', 1639 Dashv: '⫤', 1640 Dcaron: 'Ď', 1641 Dcy: 'Д', 1642 Del: '∇', 1643 Delta: 'Δ', 1644 Dfr: '', 1645 DiacriticalAcute: '´', 1646 DiacriticalDot: '˙', 1647 DiacriticalDoubleAcute: '˝', 1648 DiacriticalGrave: '`', 1649 DiacriticalTilde: '˜', 1650 Diamond: '⋄', 1651 DifferentialD: 'ⅆ', 1652 Dopf: '', 1653 Dot: '¨', 1654 DotDot: '⃜', 1655 DotEqual: '≐', 1656 DoubleContourIntegral: '∯', 1657 DoubleDot: '¨', 1658 DoubleDownArrow: '⇓', 1659 DoubleLeftArrow: '⇐', 1660 DoubleLeftRightArrow: '⇔', 1661 DoubleLeftTee: '⫤', 1662 DoubleLongLeftArrow: '⟸', 1663 DoubleLongLeftRightArrow: '⟺', 1664 DoubleLongRightArrow: '⟹', 1665 DoubleRightArrow: '⇒', 1666 DoubleRightTee: '⊨', 1667 DoubleUpArrow: '⇑', 1668 DoubleUpDownArrow: '⇕', 1669 DoubleVerticalBar: '∥', 1670 DownArrow: '↓', 1671 DownArrowBar: '⤓', 1672 DownArrowUpArrow: '⇵', 1673 DownBreve: '̑', 1674 DownLeftRightVector: '⥐', 1675 DownLeftTeeVector: '⥞', 1676 DownLeftVector: '↽', 1677 DownLeftVectorBar: '⥖', 1678 DownRightTeeVector: '⥟', 1679 DownRightVector: '⇁', 1680 DownRightVectorBar: '⥗', 1681 DownTee: '⊤', 1682 DownTeeArrow: '↧', 1683 Downarrow: '⇓', 1684 Dscr: '', 1685 Dstrok: 'Đ', 1686 ENG: 'Ŋ', 1687 ETH: 'Ð', 1688 Eacute: 'É', 1689 Ecaron: 'Ě', 1690 Ecirc: 'Ê', 1691 Ecy: 'Э', 1692 Edot: 'Ė', 1693 Efr: '', 1694 Egrave: 'È', 1695 Element: '∈', 1696 Emacr: 'Ē', 1697 EmptySmallSquare: '◻', 1698 EmptyVerySmallSquare: '▫', 1699 Eogon: 'Ę', 1700 Eopf: '', 1701 Epsilon: 'Ε', 1702 Equal: '⩵', 1703 EqualTilde: '≂', 1704 Equilibrium: '⇌', 1705 Escr: 'ℰ', 1706 Esim: '⩳', 1707 Eta: 'Η', 1708 Euml: 'Ë', 1709 Exists: '∃', 1710 ExponentialE: 'ⅇ', 1711 Fcy: 'Ф', 1712 Ffr: '', 1713 FilledSmallSquare: '◼', 1714 FilledVerySmallSquare: '▪', 1715 Fopf: '', 1716 ForAll: '∀', 1717 Fouriertrf: 'ℱ', 1718 Fscr: 'ℱ', 1719 GJcy: 'Ѓ', 1720 GT: '>', 1721 Gamma: 'Γ', 1722 Gammad: 'Ϝ', 1723 Gbreve: 'Ğ', 1724 Gcedil: 'Ģ', 1725 Gcirc: 'Ĝ', 1726 Gcy: 'Г', 1727 Gdot: 'Ġ', 1728 Gfr: '', 1729 Gg: '⋙', 1730 Gopf: '', 1731 GreaterEqual: '≥', 1732 GreaterEqualLess: '⋛', 1733 GreaterFullEqual: '≧', 1734 GreaterGreater: '⪢', 1735 GreaterLess: '≷', 1736 GreaterSlantEqual: '⩾', 1737 GreaterTilde: '≳', 1738 Gscr: '', 1739 Gt: '≫', 1740 HARDcy: 'Ъ', 1741 Hacek: 'ˇ', 1742 Hat: '^', 1743 Hcirc: 'Ĥ', 1744 Hfr: 'ℌ', 1745 HilbertSpace: 'ℋ', 1746 Hopf: 'ℍ', 1747 HorizontalLine: '─', 1748 Hscr: 'ℋ', 1749 Hstrok: 'Ħ', 1750 HumpDownHump: '≎', 1751 HumpEqual: '≏', 1752 IEcy: 'Е', 1753 IJlig: 'IJ', 1754 IOcy: 'Ё', 1755 Iacute: 'Í', 1756 Icirc: 'Î', 1757 Icy: 'И', 1758 Idot: 'İ', 1759 Ifr: 'ℑ', 1760 Igrave: 'Ì', 1761 Im: 'ℑ', 1762 Imacr: 'Ī', 1763 ImaginaryI: 'ⅈ', 1764 Implies: '⇒', 1765 Int: '∬', 1766 Integral: '∫', 1767 Intersection: '⋂', 1768 InvisibleComma: '', 1769 InvisibleTimes: '', 1770 Iogon: 'Į', 1771 Iopf: '', 1772 Iota: 'Ι', 1773 Iscr: 'ℐ', 1774 Itilde: 'Ĩ', 1775 Iukcy: 'І', 1776 Iuml: 'Ï', 1777 Jcirc: 'Ĵ', 1778 Jcy: 'Й', 1779 Jfr: '', 1780 Jopf: '', 1781 Jscr: '', 1782 Jsercy: 'Ј', 1783 Jukcy: 'Є', 1784 KHcy: 'Х', 1785 KJcy: 'Ќ', 1786 Kappa: 'Κ', 1787 Kcedil: 'Ķ', 1788 Kcy: 'К', 1789 Kfr: '', 1790 Kopf: '', 1791 Kscr: '', 1792 LJcy: 'Љ', 1793 LT: '<', 1794 Lacute: 'Ĺ', 1795 Lambda: 'Λ', 1796 Lang: '⟪', 1797 Laplacetrf: 'ℒ', 1798 Larr: '↞', 1799 Lcaron: 'Ľ', 1800 Lcedil: 'Ļ', 1801 Lcy: 'Л', 1802 LeftAngleBracket: '⟨', 1803 LeftArrow: '←', 1804 LeftArrowBar: '⇤', 1805 LeftArrowRightArrow: '⇆', 1806 LeftCeiling: '⌈', 1807 LeftDoubleBracket: '⟦', 1808 LeftDownTeeVector: '⥡', 1809 LeftDownVector: '⇃', 1810 LeftDownVectorBar: '⥙', 1811 LeftFloor: '⌊', 1812 LeftRightArrow: '↔', 1813 LeftRightVector: '⥎', 1814 LeftTee: '⊣', 1815 LeftTeeArrow: '↤', 1816 LeftTeeVector: '⥚', 1817 LeftTriangle: '⊲', 1818 LeftTriangleBar: '⧏', 1819 LeftTriangleEqual: '⊴', 1820 LeftUpDownVector: '⥑', 1821 LeftUpTeeVector: '⥠', 1822 LeftUpVector: '↿', 1823 LeftUpVectorBar: '⥘', 1824 LeftVector: '↼', 1825 LeftVectorBar: '⥒', 1826 Leftarrow: '⇐', 1827 Leftrightarrow: '⇔', 1828 LessEqualGreater: '⋚', 1829 LessFullEqual: '≦', 1830 LessGreater: '≶', 1831 LessLess: '⪡', 1832 LessSlantEqual: '⩽', 1833 LessTilde: '≲', 1834 Lfr: '', 1835 Ll: '⋘', 1836 Lleftarrow: '⇚', 1837 Lmidot: 'Ŀ', 1838 LongLeftArrow: '⟵', 1839 LongLeftRightArrow: '⟷', 1840 LongRightArrow: '⟶', 1841 Longleftarrow: '⟸', 1842 Longleftrightarrow: '⟺', 1843 Longrightarrow: '⟹', 1844 Lopf: '', 1845 LowerLeftArrow: '↙', 1846 LowerRightArrow: '↘', 1847 Lscr: 'ℒ', 1848 Lsh: '↰', 1849 Lstrok: 'Ł', 1850 Lt: '≪', 1851 Map: '⤅', 1852 Mcy: 'М', 1853 MediumSpace: ' ', 1854 Mellintrf: 'ℳ', 1855 Mfr: '', 1856 MinusPlus: '∓', 1857 Mopf: '', 1858 Mscr: 'ℳ', 1859 Mu: 'Μ', 1860 NJcy: 'Њ', 1861 Nacute: 'Ń', 1862 Ncaron: 'Ň', 1863 Ncedil: 'Ņ', 1864 Ncy: 'Н', 1865 NegativeMediumSpace: '', 1866 NegativeThickSpace: '', 1867 NegativeThinSpace: '', 1868 NegativeVeryThinSpace: '', 1869 NestedGreaterGreater: '≫', 1870 NestedLessLess: '≪', 1871 NewLine: '\n', 1872 Nfr: '', 1873 NoBreak: '', 1874 NonBreakingSpace: ' ', 1875 Nopf: 'ℕ', 1876 Not: '⫬', 1877 NotCongruent: '≢', 1878 NotCupCap: '≭', 1879 NotDoubleVerticalBar: '∦', 1880 NotElement: '∉', 1881 NotEqual: '≠', 1882 NotEqualTilde: '≂̸', 1883 NotExists: '∄', 1884 NotGreater: '≯', 1885 NotGreaterEqual: '≱', 1886 NotGreaterFullEqual: '≧̸', 1887 NotGreaterGreater: '≫̸', 1888 NotGreaterLess: '≹', 1889 NotGreaterSlantEqual: '⩾̸', 1890 NotGreaterTilde: '≵', 1891 NotHumpDownHump: '≎̸', 1892 NotHumpEqual: '≏̸', 1893 NotLeftTriangle: '⋪', 1894 NotLeftTriangleBar: '⧏̸', 1895 NotLeftTriangleEqual: '⋬', 1896 NotLess: '≮', 1897 NotLessEqual: '≰', 1898 NotLessGreater: '≸', 1899 NotLessLess: '≪̸', 1900 NotLessSlantEqual: '⩽̸', 1901 NotLessTilde: '≴', 1902 NotNestedGreaterGreater: '⪢̸', 1903 NotNestedLessLess: '⪡̸', 1904 NotPrecedes: '⊀', 1905 NotPrecedesEqual: '⪯̸', 1906 NotPrecedesSlantEqual: '⋠', 1907 NotReverseElement: '∌', 1908 NotRightTriangle: '⋫', 1909 NotRightTriangleBar: '⧐̸', 1910 NotRightTriangleEqual: '⋭', 1911 NotSquareSubset: '⊏̸', 1912 NotSquareSubsetEqual: '⋢', 1913 NotSquareSuperset: '⊐̸', 1914 NotSquareSupersetEqual: '⋣', 1915 NotSubset: '⊂⃒', 1916 NotSubsetEqual: '⊈', 1917 NotSucceeds: '⊁', 1918 NotSucceedsEqual: '⪰̸', 1919 NotSucceedsSlantEqual: '⋡', 1920 NotSucceedsTilde: '≿̸', 1921 NotSuperset: '⊃⃒', 1922 NotSupersetEqual: '⊉', 1923 NotTilde: '≁', 1924 NotTildeEqual: '≄', 1925 NotTildeFullEqual: '≇', 1926 NotTildeTilde: '≉', 1927 NotVerticalBar: '∤', 1928 Nscr: '', 1929 Ntilde: 'Ñ', 1930 Nu: 'Ν', 1931 OElig: 'Œ', 1932 Oacute: 'Ó', 1933 Ocirc: 'Ô', 1934 Ocy: 'О', 1935 Odblac: 'Ő', 1936 Ofr: '', 1937 Ograve: 'Ò', 1938 Omacr: 'Ō', 1939 Omega: 'Ω', 1940 Omicron: 'Ο', 1941 Oopf: '', 1942 OpenCurlyDoubleQuote: '“', 1943 OpenCurlyQuote: '‘', 1944 Or: '⩔', 1945 Oscr: '', 1946 Oslash: 'Ø', 1947 Otilde: 'Õ', 1948 Otimes: '⨷', 1949 Ouml: 'Ö', 1950 OverBar: '‾', 1951 OverBrace: '⏞', 1952 OverBracket: '⎴', 1953 OverParenthesis: '⏜', 1954 PartialD: '∂', 1955 Pcy: 'П', 1956 Pfr: '', 1957 Phi: 'Φ', 1958 Pi: 'Π', 1959 PlusMinus: '±', 1960 Poincareplane: 'ℌ', 1961 Popf: 'ℙ', 1962 Pr: '⪻', 1963 Precedes: '≺', 1964 PrecedesEqual: '⪯', 1965 PrecedesSlantEqual: '≼', 1966 PrecedesTilde: '≾', 1967 Prime: '″', 1968 Product: '∏', 1969 Proportion: '∷', 1970 Proportional: '∝', 1971 Pscr: '', 1972 Psi: 'Ψ', 1973 QUOT: '"', 1974 Qfr: '', 1975 Qopf: 'ℚ', 1976 Qscr: '', 1977 RBarr: '⤐', 1978 REG: '®', 1979 Racute: 'Ŕ', 1980 Rang: '⟫', 1981 Rarr: '↠', 1982 Rarrtl: '⤖', 1983 Rcaron: 'Ř', 1984 Rcedil: 'Ŗ', 1985 Rcy: 'Р', 1986 Re: 'ℜ', 1987 ReverseElement: '∋', 1988 ReverseEquilibrium: '⇋', 1989 ReverseUpEquilibrium: '⥯', 1990 Rfr: 'ℜ', 1991 Rho: 'Ρ', 1992 RightAngleBracket: '⟩', 1993 RightArrow: '→', 1994 RightArrowBar: '⇥', 1995 RightArrowLeftArrow: '⇄', 1996 RightCeiling: '⌉', 1997 RightDoubleBracket: '⟧', 1998 RightDownTeeVector: '⥝', 1999 RightDownVector: '⇂', 2000 RightDownVectorBar: '⥕', 2001 RightFloor: '⌋', 2002 RightTee: '⊢', 2003 RightTeeArrow: '↦', 2004 RightTeeVector: '⥛', 2005 RightTriangle: '⊳', 2006 RightTriangleBar: '⧐', 2007 RightTriangleEqual: '⊵', 2008 RightUpDownVector: '⥏', 2009 RightUpTeeVector: '⥜', 2010 RightUpVector: '↾', 2011 RightUpVectorBar: '⥔', 2012 RightVector: '⇀', 2013 RightVectorBar: '⥓', 2014 Rightarrow: '⇒', 2015 Ropf: 'ℝ', 2016 RoundImplies: '⥰', 2017 Rrightarrow: '⇛', 2018 Rscr: 'ℛ', 2019 Rsh: '↱', 2020 RuleDelayed: '⧴', 2021 SHCHcy: 'Щ', 2022 SHcy: 'Ш', 2023 SOFTcy: 'Ь', 2024 Sacute: 'Ś', 2025 Sc: '⪼', 2026 Scaron: 'Š', 2027 Scedil: 'Ş', 2028 Scirc: 'Ŝ', 2029 Scy: 'С', 2030 Sfr: '', 2031 ShortDownArrow: '↓', 2032 ShortLeftArrow: '←', 2033 ShortRightArrow: '→', 2034 ShortUpArrow: '↑', 2035 Sigma: 'Σ', 2036 SmallCircle: '∘', 2037 Sopf: '', 2038 Sqrt: '√', 2039 Square: '□', 2040 SquareIntersection: '⊓', 2041 SquareSubset: '⊏', 2042 SquareSubsetEqual: '⊑', 2043 SquareSuperset: '⊐', 2044 SquareSupersetEqual: '⊒', 2045 SquareUnion: '⊔', 2046 Sscr: '', 2047 Star: '⋆', 2048 Sub: '⋐', 2049 Subset: '⋐', 2050 SubsetEqual: '⊆', 2051 Succeeds: '≻', 2052 SucceedsEqual: '⪰', 2053 SucceedsSlantEqual: '≽', 2054 SucceedsTilde: '≿', 2055 SuchThat: '∋', 2056 Sum: '∑', 2057 Sup: '⋑', 2058 Superset: '⊃', 2059 SupersetEqual: '⊇', 2060 Supset: '⋑', 2061 THORN: 'Þ', 2062 TRADE: '™', 2063 TSHcy: 'Ћ', 2064 TScy: 'Ц', 2065 Tab: '\t', 2066 Tau: 'Τ', 2067 Tcaron: 'Ť', 2068 Tcedil: 'Ţ', 2069 Tcy: 'Т', 2070 Tfr: '', 2071 Therefore: '∴', 2072 Theta: 'Θ', 2073 ThickSpace: ' ', 2074 ThinSpace: ' ', 2075 Tilde: '∼', 2076 TildeEqual: '≃', 2077 TildeFullEqual: '≅', 2078 TildeTilde: '≈', 2079 Topf: '', 2080 TripleDot: '⃛', 2081 Tscr: '', 2082 Tstrok: 'Ŧ', 2083 Uacute: 'Ú', 2084 Uarr: '↟', 2085 Uarrocir: '⥉', 2086 Ubrcy: 'Ў', 2087 Ubreve: 'Ŭ', 2088 Ucirc: 'Û', 2089 Ucy: 'У', 2090 Udblac: 'Ű', 2091 Ufr: '', 2092 Ugrave: 'Ù', 2093 Umacr: 'Ū', 2094 UnderBar: '_', 2095 UnderBrace: '⏟', 2096 UnderBracket: '⎵', 2097 UnderParenthesis: '⏝', 2098 Union: '⋃', 2099 UnionPlus: '⊎', 2100 Uogon: 'Ų', 2101 Uopf: '', 2102 UpArrow: '↑', 2103 UpArrowBar: '⤒', 2104 UpArrowDownArrow: '⇅', 2105 UpDownArrow: '↕', 2106 UpEquilibrium: '⥮', 2107 UpTee: '⊥', 2108 UpTeeArrow: '↥', 2109 Uparrow: '⇑', 2110 Updownarrow: '⇕', 2111 UpperLeftArrow: '↖', 2112 UpperRightArrow: '↗', 2113 Upsi: 'ϒ', 2114 Upsilon: 'Υ', 2115 Uring: 'Ů', 2116 Uscr: '', 2117 Utilde: 'Ũ', 2118 Uuml: 'Ü', 2119 VDash: '⊫', 2120 Vbar: '⫫', 2121 Vcy: 'В', 2122 Vdash: '⊩', 2123 Vdashl: '⫦', 2124 Vee: '⋁', 2125 Verbar: '‖', 2126 Vert: '‖', 2127 VerticalBar: '∣', 2128 VerticalLine: '|', 2129 VerticalSeparator: '❘', 2130 VerticalTilde: '≀', 2131 VeryThinSpace: ' ', 2132 Vfr: '', 2133 Vopf: '', 2134 Vscr: '', 2135 Vvdash: '⊪', 2136 Wcirc: 'Ŵ', 2137 Wedge: '⋀', 2138 Wfr: '', 2139 Wopf: '', 2140 Wscr: '', 2141 Xfr: '', 2142 Xi: 'Ξ', 2143 Xopf: '', 2144 Xscr: '', 2145 YAcy: 'Я', 2146 YIcy: 'Ї', 2147 YUcy: 'Ю', 2148 Yacute: 'Ý', 2149 Ycirc: 'Ŷ', 2150 Ycy: 'Ы', 2151 Yfr: '', 2152 Yopf: '', 2153 Yscr: '', 2154 Yuml: 'Ÿ', 2155 ZHcy: 'Ж', 2156 Zacute: 'Ź', 2157 Zcaron: 'Ž', 2158 Zcy: 'З', 2159 Zdot: 'Ż', 2160 ZeroWidthSpace: '', 2161 Zeta: 'Ζ', 2162 Zfr: 'ℨ', 2163 Zopf: 'ℤ', 2164 Zscr: '', 2165 aacute: 'á', 2166 abreve: 'ă', 2167 ac: '∾', 2168 acE: '∾̳', 2169 acd: '∿', 2170 acirc: 'â', 2171 acute: '´', 2172 acy: 'а', 2173 aelig: 'æ', 2174 af: '', 2175 afr: '', 2176 agrave: 'à', 2177 alefsym: 'ℵ', 2178 aleph: 'ℵ', 2179 alpha: 'α', 2180 amacr: 'ā', 2181 amalg: '⨿', 2182 amp: '&', 2183 and: '∧', 2184 andand: '⩕', 2185 andd: '⩜', 2186 andslope: '⩘', 2187 andv: '⩚', 2188 ang: '∠', 2189 ange: '⦤', 2190 angle: '∠', 2191 angmsd: '∡', 2192 angmsdaa: '⦨', 2193 angmsdab: '⦩', 2194 angmsdac: '⦪', 2195 angmsdad: '⦫', 2196 angmsdae: '⦬', 2197 angmsdaf: '⦭', 2198 angmsdag: '⦮', 2199 angmsdah: '⦯', 2200 angrt: '∟', 2201 angrtvb: '⊾', 2202 angrtvbd: '⦝', 2203 angsph: '∢', 2204 angst: 'Å', 2205 angzarr: '⍼', 2206 aogon: 'ą', 2207 aopf: '', 2208 ap: '≈', 2209 apE: '⩰', 2210 apacir: '⩯', 2211 ape: '≊', 2212 apid: '≋', 2213 apos: "'", 2214 approx: '≈', 2215 approxeq: '≊', 2216 aring: 'å', 2217 ascr: '', 2218 ast: '*', 2219 asymp: '≈', 2220 asympeq: '≍', 2221 atilde: 'ã', 2222 auml: 'ä', 2223 awconint: '∳', 2224 awint: '⨑', 2225 bNot: '⫭', 2226 backcong: '≌', 2227 backepsilon: '϶', 2228 backprime: '‵', 2229 backsim: '∽', 2230 backsimeq: '⋍', 2231 barvee: '⊽', 2232 barwed: '⌅', 2233 barwedge: '⌅', 2234 bbrk: '⎵', 2235 bbrktbrk: '⎶', 2236 bcong: '≌', 2237 bcy: 'б', 2238 bdquo: '„', 2239 becaus: '∵', 2240 because: '∵', 2241 bemptyv: '⦰', 2242 bepsi: '϶', 2243 bernou: 'ℬ', 2244 beta: 'β', 2245 beth: 'ℶ', 2246 between: '≬', 2247 bfr: '', 2248 bigcap: '⋂', 2249 bigcirc: '◯', 2250 bigcup: '⋃', 2251 bigodot: '⨀', 2252 bigoplus: '⨁', 2253 bigotimes: '⨂', 2254 bigsqcup: '⨆', 2255 bigstar: '★', 2256 bigtriangledown: '▽', 2257 bigtriangleup: '△', 2258 biguplus: '⨄', 2259 bigvee: '⋁', 2260 bigwedge: '⋀', 2261 bkarow: '⤍', 2262 blacklozenge: '⧫', 2263 blacksquare: '▪', 2264 blacktriangle: '▴', 2265 blacktriangledown: '▾', 2266 blacktriangleleft: '◂', 2267 blacktriangleright: '▸', 2268 blank: '␣', 2269 blk12: '▒', 2270 blk14: '░', 2271 blk34: '▓', 2272 block: '█', 2273 bne: '=⃥', 2274 bnequiv: '≡⃥', 2275 bnot: '⌐', 2276 bopf: '', 2277 bot: '⊥', 2278 bottom: '⊥', 2279 bowtie: '⋈', 2280 boxDL: '╗', 2281 boxDR: '╔', 2282 boxDl: '╖', 2283 boxDr: '╓', 2284 boxH: '═', 2285 boxHD: '╦', 2286 boxHU: '╩', 2287 boxHd: '╤', 2288 boxHu: '╧', 2289 boxUL: '╝', 2290 boxUR: '╚', 2291 boxUl: '╜', 2292 boxUr: '╙', 2293 boxV: '║', 2294 boxVH: '╬', 2295 boxVL: '╣', 2296 boxVR: '╠', 2297 boxVh: '╫', 2298 boxVl: '╢', 2299 boxVr: '╟', 2300 boxbox: '⧉', 2301 boxdL: '╕', 2302 boxdR: '╒', 2303 boxdl: '┐', 2304 boxdr: '┌', 2305 boxh: '─', 2306 boxhD: '╥', 2307 boxhU: '╨', 2308 boxhd: '┬', 2309 boxhu: '┴', 2310 boxminus: '⊟', 2311 boxplus: '⊞', 2312 boxtimes: '⊠', 2313 boxuL: '╛', 2314 boxuR: '╘', 2315 boxul: '┘', 2316 boxur: '└', 2317 boxv: '│', 2318 boxvH: '╪', 2319 boxvL: '╡', 2320 boxvR: '╞', 2321 boxvh: '┼', 2322 boxvl: '┤', 2323 boxvr: '├', 2324 bprime: '‵', 2325 breve: '˘', 2326 brvbar: '¦', 2327 bscr: '', 2328 bsemi: '⁏', 2329 bsim: '∽', 2330 bsime: '⋍', 2331 bsol: '\\', 2332 bsolb: '⧅', 2333 bsolhsub: '⟈', 2334 bull: '•', 2335 bullet: '•', 2336 bump: '≎', 2337 bumpE: '⪮', 2338 bumpe: '≏', 2339 bumpeq: '≏', 2340 cacute: 'ć', 2341 cap: '∩', 2342 capand: '⩄', 2343 capbrcup: '⩉', 2344 capcap: '⩋', 2345 capcup: '⩇', 2346 capdot: '⩀', 2347 caps: '∩︀', 2348 caret: '⁁', 2349 caron: 'ˇ', 2350 ccaps: '⩍', 2351 ccaron: 'č', 2352 ccedil: 'ç', 2353 ccirc: 'ĉ', 2354 ccups: '⩌', 2355 ccupssm: '⩐', 2356 cdot: 'ċ', 2357 cedil: '¸', 2358 cemptyv: '⦲', 2359 cent: '¢', 2360 centerdot: '·', 2361 cfr: '', 2362 chcy: 'ч', 2363 check: '✓', 2364 checkmark: '✓', 2365 chi: 'χ', 2366 cir: '○', 2367 cirE: '⧃', 2368 circ: 'ˆ', 2369 circeq: '≗', 2370 circlearrowleft: '↺', 2371 circlearrowright: '↻', 2372 circledR: '®', 2373 circledS: 'Ⓢ', 2374 circledast: '⊛', 2375 circledcirc: '⊚', 2376 circleddash: '⊝', 2377 cire: '≗', 2378 cirfnint: '⨐', 2379 cirmid: '⫯', 2380 cirscir: '⧂', 2381 clubs: '♣', 2382 clubsuit: '♣', 2383 colon: ':', 2384 colone: '≔', 2385 coloneq: '≔', 2386 comma: ',', 2387 commat: '@', 2388 comp: '∁', 2389 compfn: '∘', 2390 complement: '∁', 2391 complexes: 'ℂ', 2392 cong: '≅', 2393 congdot: '⩭', 2394 conint: '∮', 2395 copf: '', 2396 coprod: '∐', 2397 copy: '©', 2398 copysr: '℗', 2399 crarr: '↵', 2400 cross: '✗', 2401 cscr: '', 2402 csub: '⫏', 2403 csube: '⫑', 2404 csup: '⫐', 2405 csupe: '⫒', 2406 ctdot: '⋯', 2407 cudarrl: '⤸', 2408 cudarrr: '⤵', 2409 cuepr: '⋞', 2410 cuesc: '⋟', 2411 cularr: '↶', 2412 cularrp: '⤽', 2413 cup: '∪', 2414 cupbrcap: '⩈', 2415 cupcap: '⩆', 2416 cupcup: '⩊', 2417 cupdot: '⊍', 2418 cupor: '⩅', 2419 cups: '∪︀', 2420 curarr: '↷', 2421 curarrm: '⤼', 2422 curlyeqprec: '⋞', 2423 curlyeqsucc: '⋟', 2424 curlyvee: '⋎', 2425 curlywedge: '⋏', 2426 curren: '¤', 2427 curvearrowleft: '↶', 2428 curvearrowright: '↷', 2429 cuvee: '⋎', 2430 cuwed: '⋏', 2431 cwconint: '∲', 2432 cwint: '∱', 2433 cylcty: '⌭', 2434 dArr: '⇓', 2435 dHar: '⥥', 2436 dagger: '†', 2437 daleth: 'ℸ', 2438 darr: '↓', 2439 dash: '‐', 2440 dashv: '⊣', 2441 dbkarow: '⤏', 2442 dblac: '˝', 2443 dcaron: 'ď', 2444 dcy: 'д', 2445 dd: 'ⅆ', 2446 ddagger: '‡', 2447 ddarr: '⇊', 2448 ddotseq: '⩷', 2449 deg: '°', 2450 delta: 'δ', 2451 demptyv: '⦱', 2452 dfisht: '⥿', 2453 dfr: '', 2454 dharl: '⇃', 2455 dharr: '⇂', 2456 diam: '⋄', 2457 diamond: '⋄', 2458 diamondsuit: '♦', 2459 diams: '♦', 2460 die: '¨', 2461 digamma: 'ϝ', 2462 disin: '⋲', 2463 div: '÷', 2464 divide: '÷', 2465 divideontimes: '⋇', 2466 divonx: '⋇', 2467 djcy: 'ђ', 2468 dlcorn: '⌞', 2469 dlcrop: '⌍', 2470 dollar: '$', 2471 dopf: '', 2472 dot: '˙', 2473 doteq: '≐', 2474 doteqdot: '≑', 2475 dotminus: '∸', 2476 dotplus: '∔', 2477 dotsquare: '⊡', 2478 doublebarwedge: '⌆', 2479 downarrow: '↓', 2480 downdownarrows: '⇊', 2481 downharpoonleft: '⇃', 2482 downharpoonright: '⇂', 2483 drbkarow: '⤐', 2484 drcorn: '⌟', 2485 drcrop: '⌌', 2486 dscr: '', 2487 dscy: 'ѕ', 2488 dsol: '⧶', 2489 dstrok: 'đ', 2490 dtdot: '⋱', 2491 dtri: '▿', 2492 dtrif: '▾', 2493 duarr: '⇵', 2494 duhar: '⥯', 2495 dwangle: '⦦', 2496 dzcy: 'џ', 2497 dzigrarr: '⟿', 2498 eDDot: '⩷', 2499 eDot: '≑', 2500 eacute: 'é', 2501 easter: '⩮', 2502 ecaron: 'ě', 2503 ecir: '≖', 2504 ecirc: 'ê', 2505 ecolon: '≕', 2506 ecy: 'э', 2507 edot: 'ė', 2508 ee: 'ⅇ', 2509 efDot: '≒', 2510 efr: '', 2511 eg: '⪚', 2512 egrave: 'è', 2513 egs: '⪖', 2514 egsdot: '⪘', 2515 el: '⪙', 2516 elinters: '⏧', 2517 ell: 'ℓ', 2518 els: '⪕', 2519 elsdot: '⪗', 2520 emacr: 'ē', 2521 empty: '∅', 2522 emptyset: '∅', 2523 emptyv: '∅', 2524 emsp13: ' ', 2525 emsp14: ' ', 2526 emsp: ' ', 2527 eng: 'ŋ', 2528 ensp: ' ', 2529 eogon: 'ę', 2530 eopf: '', 2531 epar: '⋕', 2532 eparsl: '⧣', 2533 eplus: '⩱', 2534 epsi: 'ε', 2535 epsilon: 'ε', 2536 epsiv: 'ϵ', 2537 eqcirc: '≖', 2538 eqcolon: '≕', 2539 eqsim: '≂', 2540 eqslantgtr: '⪖', 2541 eqslantless: '⪕', 2542 equals: '=', 2543 equest: '≟', 2544 equiv: '≡', 2545 equivDD: '⩸', 2546 eqvparsl: '⧥', 2547 erDot: '≓', 2548 erarr: '⥱', 2549 escr: 'ℯ', 2550 esdot: '≐', 2551 esim: '≂', 2552 eta: 'η', 2553 eth: 'ð', 2554 euml: 'ë', 2555 euro: '€', 2556 excl: '!', 2557 exist: '∃', 2558 expectation: 'ℰ', 2559 exponentiale: 'ⅇ', 2560 fallingdotseq: '≒', 2561 fcy: 'ф', 2562 female: '♀', 2563 ffilig: 'ffi', 2564 fflig: 'ff', 2565 ffllig: 'ffl', 2566 ffr: '', 2567 filig: 'fi', 2568 fjlig: 'fj', 2569 flat: '♭', 2570 fllig: 'fl', 2571 fltns: '▱', 2572 fnof: 'ƒ', 2573 fopf: '', 2574 forall: '∀', 2575 fork: '⋔', 2576 forkv: '⫙', 2577 fpartint: '⨍', 2578 frac12: '½', 2579 frac13: '⅓', 2580 frac14: '¼', 2581 frac15: '⅕', 2582 frac16: '⅙', 2583 frac18: '⅛', 2584 frac23: '⅔', 2585 frac25: '⅖', 2586 frac34: '¾', 2587 frac35: '⅗', 2588 frac38: '⅜', 2589 frac45: '⅘', 2590 frac56: '⅚', 2591 frac58: '⅝', 2592 frac78: '⅞', 2593 frasl: '⁄', 2594 frown: '⌢', 2595 fscr: '', 2596 gE: '≧', 2597 gEl: '⪌', 2598 gacute: 'ǵ', 2599 gamma: 'γ', 2600 gammad: 'ϝ', 2601 gap: '⪆', 2602 gbreve: 'ğ', 2603 gcirc: 'ĝ', 2604 gcy: 'г', 2605 gdot: 'ġ', 2606 ge: '≥', 2607 gel: '⋛', 2608 geq: '≥', 2609 geqq: '≧', 2610 geqslant: '⩾', 2611 ges: '⩾', 2612 gescc: '⪩', 2613 gesdot: '⪀', 2614 gesdoto: '⪂', 2615 gesdotol: '⪄', 2616 gesl: '⋛︀', 2617 gesles: '⪔', 2618 gfr: '', 2619 gg: '≫', 2620 ggg: '⋙', 2621 gimel: 'ℷ', 2622 gjcy: 'ѓ', 2623 gl: '≷', 2624 glE: '⪒', 2625 gla: '⪥', 2626 glj: '⪤', 2627 gnE: '≩', 2628 gnap: '⪊', 2629 gnapprox: '⪊', 2630 gne: '⪈', 2631 gneq: '⪈', 2632 gneqq: '≩', 2633 gnsim: '⋧', 2634 gopf: '', 2635 grave: '`', 2636 gscr: 'ℊ', 2637 gsim: '≳', 2638 gsime: '⪎', 2639 gsiml: '⪐', 2640 gt: '>', 2641 gtcc: '⪧', 2642 gtcir: '⩺', 2643 gtdot: '⋗', 2644 gtlPar: '⦕', 2645 gtquest: '⩼', 2646 gtrapprox: '⪆', 2647 gtrarr: '⥸', 2648 gtrdot: '⋗', 2649 gtreqless: '⋛', 2650 gtreqqless: '⪌', 2651 gtrless: '≷', 2652 gtrsim: '≳', 2653 gvertneqq: '≩︀', 2654 gvnE: '≩︀', 2655 hArr: '⇔', 2656 hairsp: ' ', 2657 half: '½', 2658 hamilt: 'ℋ', 2659 hardcy: 'ъ', 2660 harr: '↔', 2661 harrcir: '⥈', 2662 harrw: '↭', 2663 hbar: 'ℏ', 2664 hcirc: 'ĥ', 2665 hearts: '♥', 2666 heartsuit: '♥', 2667 hellip: '…', 2668 hercon: '⊹', 2669 hfr: '', 2670 hksearow: '⤥', 2671 hkswarow: '⤦', 2672 hoarr: '⇿', 2673 homtht: '∻', 2674 hookleftarrow: '↩', 2675 hookrightarrow: '↪', 2676 hopf: '', 2677 horbar: '―', 2678 hscr: '', 2679 hslash: 'ℏ', 2680 hstrok: 'ħ', 2681 hybull: '⁃', 2682 hyphen: '‐', 2683 iacute: 'í', 2684 ic: '', 2685 icirc: 'î', 2686 icy: 'и', 2687 iecy: 'е', 2688 iexcl: '¡', 2689 iff: '⇔', 2690 ifr: '', 2691 igrave: 'ì', 2692 ii: 'ⅈ', 2693 iiiint: '⨌', 2694 iiint: '∭', 2695 iinfin: '⧜', 2696 iiota: '℩', 2697 ijlig: 'ij', 2698 imacr: 'ī', 2699 image: 'ℑ', 2700 imagline: 'ℐ', 2701 imagpart: 'ℑ', 2702 imath: 'ı', 2703 imof: '⊷', 2704 imped: 'Ƶ', 2705 in: '∈', 2706 incare: '℅', 2707 infin: '∞', 2708 infintie: '⧝', 2709 inodot: 'ı', 2710 int: '∫', 2711 intcal: '⊺', 2712 integers: 'ℤ', 2713 intercal: '⊺', 2714 intlarhk: '⨗', 2715 intprod: '⨼', 2716 iocy: 'ё', 2717 iogon: 'į', 2718 iopf: '', 2719 iota: 'ι', 2720 iprod: '⨼', 2721 iquest: '¿', 2722 iscr: '', 2723 isin: '∈', 2724 isinE: '⋹', 2725 isindot: '⋵', 2726 isins: '⋴', 2727 isinsv: '⋳', 2728 isinv: '∈', 2729 it: '', 2730 itilde: 'ĩ', 2731 iukcy: 'і', 2732 iuml: 'ï', 2733 jcirc: 'ĵ', 2734 jcy: 'й', 2735 jfr: '', 2736 jmath: 'ȷ', 2737 jopf: '', 2738 jscr: '', 2739 jsercy: 'ј', 2740 jukcy: 'є', 2741 kappa: 'κ', 2742 kappav: 'ϰ', 2743 kcedil: 'ķ', 2744 kcy: 'к', 2745 kfr: '', 2746 kgreen: 'ĸ', 2747 khcy: 'х', 2748 kjcy: 'ќ', 2749 kopf: '', 2750 kscr: '', 2751 lAarr: '⇚', 2752 lArr: '⇐', 2753 lAtail: '⤛', 2754 lBarr: '⤎', 2755 lE: '≦', 2756 lEg: '⪋', 2757 lHar: '⥢', 2758 lacute: 'ĺ', 2759 laemptyv: '⦴', 2760 lagran: 'ℒ', 2761 lambda: 'λ', 2762 lang: '⟨', 2763 langd: '⦑', 2764 langle: '⟨', 2765 lap: '⪅', 2766 laquo: '«', 2767 larr: '←', 2768 larrb: '⇤', 2769 larrbfs: '⤟', 2770 larrfs: '⤝', 2771 larrhk: '↩', 2772 larrlp: '↫', 2773 larrpl: '⤹', 2774 larrsim: '⥳', 2775 larrtl: '↢', 2776 lat: '⪫', 2777 latail: '⤙', 2778 late: '⪭', 2779 lates: '⪭︀', 2780 lbarr: '⤌', 2781 lbbrk: '❲', 2782 lbrace: '{', 2783 lbrack: '[', 2784 lbrke: '⦋', 2785 lbrksld: '⦏', 2786 lbrkslu: '⦍', 2787 lcaron: 'ľ', 2788 lcedil: 'ļ', 2789 lceil: '⌈', 2790 lcub: '{', 2791 lcy: 'л', 2792 ldca: '⤶', 2793 ldquo: '“', 2794 ldquor: '„', 2795 ldrdhar: '⥧', 2796 ldrushar: '⥋', 2797 ldsh: '↲', 2798 le: '≤', 2799 leftarrow: '←', 2800 leftarrowtail: '↢', 2801 leftharpoondown: '↽', 2802 leftharpoonup: '↼', 2803 leftleftarrows: '⇇', 2804 leftrightarrow: '↔', 2805 leftrightarrows: '⇆', 2806 leftrightharpoons: '⇋', 2807 leftrightsquigarrow: '↭', 2808 leftthreetimes: '⋋', 2809 leg: '⋚', 2810 leq: '≤', 2811 leqq: '≦', 2812 leqslant: '⩽', 2813 les: '⩽', 2814 lescc: '⪨', 2815 lesdot: '⩿', 2816 lesdoto: '⪁', 2817 lesdotor: '⪃', 2818 lesg: '⋚︀', 2819 lesges: '⪓', 2820 lessapprox: '⪅', 2821 lessdot: '⋖', 2822 lesseqgtr: '⋚', 2823 lesseqqgtr: '⪋', 2824 lessgtr: '≶', 2825 lesssim: '≲', 2826 lfisht: '⥼', 2827 lfloor: '⌊', 2828 lfr: '', 2829 lg: '≶', 2830 lgE: '⪑', 2831 lhard: '↽', 2832 lharu: '↼', 2833 lharul: '⥪', 2834 lhblk: '▄', 2835 ljcy: 'љ', 2836 ll: '≪', 2837 llarr: '⇇', 2838 llcorner: '⌞', 2839 llhard: '⥫', 2840 lltri: '◺', 2841 lmidot: 'ŀ', 2842 lmoust: '⎰', 2843 lmoustache: '⎰', 2844 lnE: '≨', 2845 lnap: '⪉', 2846 lnapprox: '⪉', 2847 lne: '⪇', 2848 lneq: '⪇', 2849 lneqq: '≨', 2850 lnsim: '⋦', 2851 loang: '⟬', 2852 loarr: '⇽', 2853 lobrk: '⟦', 2854 longleftarrow: '⟵', 2855 longleftrightarrow: '⟷', 2856 longmapsto: '⟼', 2857 longrightarrow: '⟶', 2858 looparrowleft: '↫', 2859 looparrowright: '↬', 2860 lopar: '⦅', 2861 lopf: '', 2862 loplus: '⨭', 2863 lotimes: '⨴', 2864 lowast: '∗', 2865 lowbar: '_', 2866 loz: '◊', 2867 lozenge: '◊', 2868 lozf: '⧫', 2869 lpar: '(', 2870 lparlt: '⦓', 2871 lrarr: '⇆', 2872 lrcorner: '⌟', 2873 lrhar: '⇋', 2874 lrhard: '⥭', 2875 lrm: '', 2876 lrtri: '⊿', 2877 lsaquo: '‹', 2878 lscr: '', 2879 lsh: '↰', 2880 lsim: '≲', 2881 lsime: '⪍', 2882 lsimg: '⪏', 2883 lsqb: '[', 2884 lsquo: '‘', 2885 lsquor: '‚', 2886 lstrok: 'ł', 2887 lt: '<', 2888 ltcc: '⪦', 2889 ltcir: '⩹', 2890 ltdot: '⋖', 2891 lthree: '⋋', 2892 ltimes: '⋉', 2893 ltlarr: '⥶', 2894 ltquest: '⩻', 2895 ltrPar: '⦖', 2896 ltri: '◃', 2897 ltrie: '⊴', 2898 ltrif: '◂', 2899 lurdshar: '⥊', 2900 luruhar: '⥦', 2901 lvertneqq: '≨︀', 2902 lvnE: '≨︀', 2903 mDDot: '∺', 2904 macr: '¯', 2905 male: '♂', 2906 malt: '✠', 2907 maltese: '✠', 2908 map: '↦', 2909 mapsto: '↦', 2910 mapstodown: '↧', 2911 mapstoleft: '↤', 2912 mapstoup: '↥', 2913 marker: '▮', 2914 mcomma: '⨩', 2915 mcy: 'м', 2916 mdash: '—', 2917 measuredangle: '∡', 2918 mfr: '', 2919 mho: '℧', 2920 micro: 'µ', 2921 mid: '∣', 2922 midast: '*', 2923 midcir: '⫰', 2924 middot: '·', 2925 minus: '−', 2926 minusb: '⊟', 2927 minusd: '∸', 2928 minusdu: '⨪', 2929 mlcp: '⫛', 2930 mldr: '…', 2931 mnplus: '∓', 2932 models: '⊧', 2933 mopf: '', 2934 mp: '∓', 2935 mscr: '', 2936 mstpos: '∾', 2937 mu: 'μ', 2938 multimap: '⊸', 2939 mumap: '⊸', 2940 nGg: '⋙̸', 2941 nGt: '≫⃒', 2942 nGtv: '≫̸', 2943 nLeftarrow: '⇍', 2944 nLeftrightarrow: '⇎', 2945 nLl: '⋘̸', 2946 nLt: '≪⃒', 2947 nLtv: '≪̸', 2948 nRightarrow: '⇏', 2949 nVDash: '⊯', 2950 nVdash: '⊮', 2951 nabla: '∇', 2952 nacute: 'ń', 2953 nang: '∠⃒', 2954 nap: '≉', 2955 napE: '⩰̸', 2956 napid: '≋̸', 2957 napos: 'ʼn', 2958 napprox: '≉', 2959 natur: '♮', 2960 natural: '♮', 2961 naturals: 'ℕ', 2962 nbsp: ' ', 2963 nbump: '≎̸', 2964 nbumpe: '≏̸', 2965 ncap: '⩃', 2966 ncaron: 'ň', 2967 ncedil: 'ņ', 2968 ncong: '≇', 2969 ncongdot: '⩭̸', 2970 ncup: '⩂', 2971 ncy: 'н', 2972 ndash: '–', 2973 ne: '≠', 2974 neArr: '⇗', 2975 nearhk: '⤤', 2976 nearr: '↗', 2977 nearrow: '↗', 2978 nedot: '≐̸', 2979 nequiv: '≢', 2980 nesear: '⤨', 2981 nesim: '≂̸', 2982 nexist: '∄', 2983 nexists: '∄', 2984 nfr: '', 2985 ngE: '≧̸', 2986 nge: '≱', 2987 ngeq: '≱', 2988 ngeqq: '≧̸', 2989 ngeqslant: '⩾̸', 2990 nges: '⩾̸', 2991 ngsim: '≵', 2992 ngt: '≯', 2993 ngtr: '≯', 2994 nhArr: '⇎', 2995 nharr: '↮', 2996 nhpar: '⫲', 2997 ni: '∋', 2998 nis: '⋼', 2999 nisd: '⋺', 3000 niv: '∋', 3001 njcy: 'њ', 3002 nlArr: '⇍', 3003 nlE: '≦̸', 3004 nlarr: '↚', 3005 nldr: '‥', 3006 nle: '≰', 3007 nleftarrow: '↚', 3008 nleftrightarrow: '↮', 3009 nleq: '≰', 3010 nleqq: '≦̸', 3011 nleqslant: '⩽̸', 3012 nles: '⩽̸', 3013 nless: '≮', 3014 nlsim: '≴', 3015 nlt: '≮', 3016 nltri: '⋪', 3017 nltrie: '⋬', 3018 nmid: '∤', 3019 nopf: '', 3020 not: '¬', 3021 notin: '∉', 3022 notinE: '⋹̸', 3023 notindot: '⋵̸', 3024 notinva: '∉', 3025 notinvb: '⋷', 3026 notinvc: '⋶', 3027 notni: '∌', 3028 notniva: '∌', 3029 notnivb: '⋾', 3030 notnivc: '⋽', 3031 npar: '∦', 3032 nparallel: '∦', 3033 nparsl: '⫽⃥', 3034 npart: '∂̸', 3035 npolint: '⨔', 3036 npr: '⊀', 3037 nprcue: '⋠', 3038 npre: '⪯̸', 3039 nprec: '⊀', 3040 npreceq: '⪯̸', 3041 nrArr: '⇏', 3042 nrarr: '↛', 3043 nrarrc: '⤳̸', 3044 nrarrw: '↝̸', 3045 nrightarrow: '↛', 3046 nrtri: '⋫', 3047 nrtrie: '⋭', 3048 nsc: '⊁', 3049 nsccue: '⋡', 3050 nsce: '⪰̸', 3051 nscr: '', 3052 nshortmid: '∤', 3053 nshortparallel: '∦', 3054 nsim: '≁', 3055 nsime: '≄', 3056 nsimeq: '≄', 3057 nsmid: '∤', 3058 nspar: '∦', 3059 nsqsube: '⋢', 3060 nsqsupe: '⋣', 3061 nsub: '⊄', 3062 nsubE: '⫅̸', 3063 nsube: '⊈', 3064 nsubset: '⊂⃒', 3065 nsubseteq: '⊈', 3066 nsubseteqq: '⫅̸', 3067 nsucc: '⊁', 3068 nsucceq: '⪰̸', 3069 nsup: '⊅', 3070 nsupE: '⫆̸', 3071 nsupe: '⊉', 3072 nsupset: '⊃⃒', 3073 nsupseteq: '⊉', 3074 nsupseteqq: '⫆̸', 3075 ntgl: '≹', 3076 ntilde: 'ñ', 3077 ntlg: '≸', 3078 ntriangleleft: '⋪', 3079 ntrianglelefteq: '⋬', 3080 ntriangleright: '⋫', 3081 ntrianglerighteq: '⋭', 3082 nu: 'ν', 3083 num: '#', 3084 numero: '№', 3085 numsp: ' ', 3086 nvDash: '⊭', 3087 nvHarr: '⤄', 3088 nvap: '≍⃒', 3089 nvdash: '⊬', 3090 nvge: '≥⃒', 3091 nvgt: '>⃒', 3092 nvinfin: '⧞', 3093 nvlArr: '⤂', 3094 nvle: '≤⃒', 3095 nvlt: '<⃒', 3096 nvltrie: '⊴⃒', 3097 nvrArr: '⤃', 3098 nvrtrie: '⊵⃒', 3099 nvsim: '∼⃒', 3100 nwArr: '⇖', 3101 nwarhk: '⤣', 3102 nwarr: '↖', 3103 nwarrow: '↖', 3104 nwnear: '⤧', 3105 oS: 'Ⓢ', 3106 oacute: 'ó', 3107 oast: '⊛', 3108 ocir: '⊚', 3109 ocirc: 'ô', 3110 ocy: 'о', 3111 odash: '⊝', 3112 odblac: 'ő', 3113 odiv: '⨸', 3114 odot: '⊙', 3115 odsold: '⦼', 3116 oelig: 'œ', 3117 ofcir: '⦿', 3118 ofr: '', 3119 ogon: '˛', 3120 ograve: 'ò', 3121 ogt: '⧁', 3122 ohbar: '⦵', 3123 ohm: 'Ω', 3124 oint: '∮', 3125 olarr: '↺', 3126 olcir: '⦾', 3127 olcross: '⦻', 3128 oline: '‾', 3129 olt: '⧀', 3130 omacr: 'ō', 3131 omega: 'ω', 3132 omicron: 'ο', 3133 omid: '⦶', 3134 ominus: '⊖', 3135 oopf: '', 3136 opar: '⦷', 3137 operp: '⦹', 3138 oplus: '⊕', 3139 or: '∨', 3140 orarr: '↻', 3141 ord: '⩝', 3142 order: 'ℴ', 3143 orderof: 'ℴ', 3144 ordf: 'ª', 3145 ordm: 'º', 3146 origof: '⊶', 3147 oror: '⩖', 3148 orslope: '⩗', 3149 orv: '⩛', 3150 oscr: 'ℴ', 3151 oslash: 'ø', 3152 osol: '⊘', 3153 otilde: 'õ', 3154 otimes: '⊗', 3155 otimesas: '⨶', 3156 ouml: 'ö', 3157 ovbar: '⌽', 3158 par: '∥', 3159 para: '¶', 3160 parallel: '∥', 3161 parsim: '⫳', 3162 parsl: '⫽', 3163 part: '∂', 3164 pcy: 'п', 3165 percnt: '%', 3166 period: '.', 3167 permil: '‰', 3168 perp: '⊥', 3169 pertenk: '‱', 3170 pfr: '', 3171 phi: 'φ', 3172 phiv: 'ϕ', 3173 phmmat: 'ℳ', 3174 phone: '☎', 3175 pi: 'π', 3176 pitchfork: '⋔', 3177 piv: 'ϖ', 3178 planck: 'ℏ', 3179 planckh: 'ℎ', 3180 plankv: 'ℏ', 3181 plus: '+', 3182 plusacir: '⨣', 3183 plusb: '⊞', 3184 pluscir: '⨢', 3185 plusdo: '∔', 3186 plusdu: '⨥', 3187 pluse: '⩲', 3188 plusmn: '±', 3189 plussim: '⨦', 3190 plustwo: '⨧', 3191 pm: '±', 3192 pointint: '⨕', 3193 popf: '', 3194 pound: '£', 3195 pr: '≺', 3196 prE: '⪳', 3197 prap: '⪷', 3198 prcue: '≼', 3199 pre: '⪯', 3200 prec: '≺', 3201 precapprox: '⪷', 3202 preccurlyeq: '≼', 3203 preceq: '⪯', 3204 precnapprox: '⪹', 3205 precneqq: '⪵', 3206 precnsim: '⋨', 3207 precsim: '≾', 3208 prime: '′', 3209 primes: 'ℙ', 3210 prnE: '⪵', 3211 prnap: '⪹', 3212 prnsim: '⋨', 3213 prod: '∏', 3214 profalar: '⌮', 3215 profline: '⌒', 3216 profsurf: '⌓', 3217 prop: '∝', 3218 propto: '∝', 3219 prsim: '≾', 3220 prurel: '⊰', 3221 pscr: '', 3222 psi: 'ψ', 3223 puncsp: ' ', 3224 qfr: '', 3225 qint: '⨌', 3226 qopf: '', 3227 qprime: '⁗', 3228 qscr: '', 3229 quaternions: 'ℍ', 3230 quatint: '⨖', 3231 quest: '?', 3232 questeq: '≟', 3233 quot: '"', 3234 rAarr: '⇛', 3235 rArr: '⇒', 3236 rAtail: '⤜', 3237 rBarr: '⤏', 3238 rHar: '⥤', 3239 race: '∽̱', 3240 racute: 'ŕ', 3241 radic: '√', 3242 raemptyv: '⦳', 3243 rang: '⟩', 3244 rangd: '⦒', 3245 range: '⦥', 3246 rangle: '⟩', 3247 raquo: '»', 3248 rarr: '→', 3249 rarrap: '⥵', 3250 rarrb: '⇥', 3251 rarrbfs: '⤠', 3252 rarrc: '⤳', 3253 rarrfs: '⤞', 3254 rarrhk: '↪', 3255 rarrlp: '↬', 3256 rarrpl: '⥅', 3257 rarrsim: '⥴', 3258 rarrtl: '↣', 3259 rarrw: '↝', 3260 ratail: '⤚', 3261 ratio: '∶', 3262 rationals: 'ℚ', 3263 rbarr: '⤍', 3264 rbbrk: '❳', 3265 rbrace: '}', 3266 rbrack: ']', 3267 rbrke: '⦌', 3268 rbrksld: '⦎', 3269 rbrkslu: '⦐', 3270 rcaron: 'ř', 3271 rcedil: 'ŗ', 3272 rceil: '⌉', 3273 rcub: '}', 3274 rcy: 'р', 3275 rdca: '⤷', 3276 rdldhar: '⥩', 3277 rdquo: '”', 3278 rdquor: '”', 3279 rdsh: '↳', 3280 real: 'ℜ', 3281 realine: 'ℛ', 3282 realpart: 'ℜ', 3283 reals: 'ℝ', 3284 rect: '▭', 3285 reg: '®', 3286 rfisht: '⥽', 3287 rfloor: '⌋', 3288 rfr: '', 3289 rhard: '⇁', 3290 rharu: '⇀', 3291 rharul: '⥬', 3292 rho: 'ρ', 3293 rhov: 'ϱ', 3294 rightarrow: '→', 3295 rightarrowtail: '↣', 3296 rightharpoondown: '⇁', 3297 rightharpoonup: '⇀', 3298 rightleftarrows: '⇄', 3299 rightleftharpoons: '⇌', 3300 rightrightarrows: '⇉', 3301 rightsquigarrow: '↝', 3302 rightthreetimes: '⋌', 3303 ring: '˚', 3304 risingdotseq: '≓', 3305 rlarr: '⇄', 3306 rlhar: '⇌', 3307 rlm: '', 3308 rmoust: '⎱', 3309 rmoustache: '⎱', 3310 rnmid: '⫮', 3311 roang: '⟭', 3312 roarr: '⇾', 3313 robrk: '⟧', 3314 ropar: '⦆', 3315 ropf: '', 3316 roplus: '⨮', 3317 rotimes: '⨵', 3318 rpar: ')', 3319 rpargt: '⦔', 3320 rppolint: '⨒', 3321 rrarr: '⇉', 3322 rsaquo: '›', 3323 rscr: '', 3324 rsh: '↱', 3325 rsqb: ']', 3326 rsquo: '’', 3327 rsquor: '’', 3328 rthree: '⋌', 3329 rtimes: '⋊', 3330 rtri: '▹', 3331 rtrie: '⊵', 3332 rtrif: '▸', 3333 rtriltri: '⧎', 3334 ruluhar: '⥨', 3335 rx: '℞', 3336 sacute: 'ś', 3337 sbquo: '‚', 3338 sc: '≻', 3339 scE: '⪴', 3340 scap: '⪸', 3341 scaron: 'š', 3342 sccue: '≽', 3343 sce: '⪰', 3344 scedil: 'ş', 3345 scirc: 'ŝ', 3346 scnE: '⪶', 3347 scnap: '⪺', 3348 scnsim: '⋩', 3349 scpolint: '⨓', 3350 scsim: '≿', 3351 scy: 'с', 3352 sdot: '⋅', 3353 sdotb: '⊡', 3354 sdote: '⩦', 3355 seArr: '⇘', 3356 searhk: '⤥', 3357 searr: '↘', 3358 searrow: '↘', 3359 sect: '§', 3360 semi: ';', 3361 seswar: '⤩', 3362 setminus: '∖', 3363 setmn: '∖', 3364 sext: '✶', 3365 sfr: '', 3366 sfrown: '⌢', 3367 sharp: '♯', 3368 shchcy: 'щ', 3369 shcy: 'ш', 3370 shortmid: '∣', 3371 shortparallel: '∥', 3372 shy: '', 3373 sigma: 'σ', 3374 sigmaf: 'ς', 3375 sigmav: 'ς', 3376 sim: '∼', 3377 simdot: '⩪', 3378 sime: '≃', 3379 simeq: '≃', 3380 simg: '⪞', 3381 simgE: '⪠', 3382 siml: '⪝', 3383 simlE: '⪟', 3384 simne: '≆', 3385 simplus: '⨤', 3386 simrarr: '⥲', 3387 slarr: '←', 3388 smallsetminus: '∖', 3389 smashp: '⨳', 3390 smeparsl: '⧤', 3391 smid: '∣', 3392 smile: '⌣', 3393 smt: '⪪', 3394 smte: '⪬', 3395 smtes: '⪬︀', 3396 softcy: 'ь', 3397 sol: '/', 3398 solb: '⧄', 3399 solbar: '⌿', 3400 sopf: '', 3401 spades: '♠', 3402 spadesuit: '♠', 3403 spar: '∥', 3404 sqcap: '⊓', 3405 sqcaps: '⊓︀', 3406 sqcup: '⊔', 3407 sqcups: '⊔︀', 3408 sqsub: '⊏', 3409 sqsube: '⊑', 3410 sqsubset: '⊏', 3411 sqsubseteq: '⊑', 3412 sqsup: '⊐', 3413 sqsupe: '⊒', 3414 sqsupset: '⊐', 3415 sqsupseteq: '⊒', 3416 squ: '□', 3417 square: '□', 3418 squarf: '▪', 3419 squf: '▪', 3420 srarr: '→', 3421 sscr: '', 3422 ssetmn: '∖', 3423 ssmile: '⌣', 3424 sstarf: '⋆', 3425 star: '☆', 3426 starf: '★', 3427 straightepsilon: 'ϵ', 3428 straightphi: 'ϕ', 3429 strns: '¯', 3430 sub: '⊂', 3431 subE: '⫅', 3432 subdot: '⪽', 3433 sube: '⊆', 3434 subedot: '⫃', 3435 submult: '⫁', 3436 subnE: '⫋', 3437 subne: '⊊', 3438 subplus: '⪿', 3439 subrarr: '⥹', 3440 subset: '⊂', 3441 subseteq: '⊆', 3442 subseteqq: '⫅', 3443 subsetneq: '⊊', 3444 subsetneqq: '⫋', 3445 subsim: '⫇', 3446 subsub: '⫕', 3447 subsup: '⫓', 3448 succ: '≻', 3449 succapprox: '⪸', 3450 succcurlyeq: '≽', 3451 succeq: '⪰', 3452 succnapprox: '⪺', 3453 succneqq: '⪶', 3454 succnsim: '⋩', 3455 succsim: '≿', 3456 sum: '∑', 3457 sung: '♪', 3458 sup1: '¹', 3459 sup2: '²', 3460 sup3: '³', 3461 sup: '⊃', 3462 supE: '⫆', 3463 supdot: '⪾', 3464 supdsub: '⫘', 3465 supe: '⊇', 3466 supedot: '⫄', 3467 suphsol: '⟉', 3468 suphsub: '⫗', 3469 suplarr: '⥻', 3470 supmult: '⫂', 3471 supnE: '⫌', 3472 supne: '⊋', 3473 supplus: '⫀', 3474 supset: '⊃', 3475 supseteq: '⊇', 3476 supseteqq: '⫆', 3477 supsetneq: '⊋', 3478 supsetneqq: '⫌', 3479 supsim: '⫈', 3480 supsub: '⫔', 3481 supsup: '⫖', 3482 swArr: '⇙', 3483 swarhk: '⤦', 3484 swarr: '↙', 3485 swarrow: '↙', 3486 swnwar: '⤪', 3487 szlig: 'ß', 3488 target: '⌖', 3489 tau: 'τ', 3490 tbrk: '⎴', 3491 tcaron: 'ť', 3492 tcedil: 'ţ', 3493 tcy: 'т', 3494 tdot: '⃛', 3495 telrec: '⌕', 3496 tfr: '', 3497 there4: '∴', 3498 therefore: '∴', 3499 theta: 'θ', 3500 thetasym: 'ϑ', 3501 thetav: 'ϑ', 3502 thickapprox: '≈', 3503 thicksim: '∼', 3504 thinsp: ' ', 3505 thkap: '≈', 3506 thksim: '∼', 3507 thorn: 'þ', 3508 tilde: '˜', 3509 times: '×', 3510 timesb: '⊠', 3511 timesbar: '⨱', 3512 timesd: '⨰', 3513 tint: '∭', 3514 toea: '⤨', 3515 top: '⊤', 3516 topbot: '⌶', 3517 topcir: '⫱', 3518 topf: '', 3519 topfork: '⫚', 3520 tosa: '⤩', 3521 tprime: '‴', 3522 trade: '™', 3523 triangle: '▵', 3524 triangledown: '▿', 3525 triangleleft: '◃', 3526 trianglelefteq: '⊴', 3527 triangleq: '≜', 3528 triangleright: '▹', 3529 trianglerighteq: '⊵', 3530 tridot: '◬', 3531 trie: '≜', 3532 triminus: '⨺', 3533 triplus: '⨹', 3534 trisb: '⧍', 3535 tritime: '⨻', 3536 trpezium: '⏢', 3537 tscr: '', 3538 tscy: 'ц', 3539 tshcy: 'ћ', 3540 tstrok: 'ŧ', 3541 twixt: '≬', 3542 twoheadleftarrow: '↞', 3543 twoheadrightarrow: '↠', 3544 uArr: '⇑', 3545 uHar: '⥣', 3546 uacute: 'ú', 3547 uarr: '↑', 3548 ubrcy: 'ў', 3549 ubreve: 'ŭ', 3550 ucirc: 'û', 3551 ucy: 'у', 3552 udarr: '⇅', 3553 udblac: 'ű', 3554 udhar: '⥮', 3555 ufisht: '⥾', 3556 ufr: '', 3557 ugrave: 'ù', 3558 uharl: '↿', 3559 uharr: '↾', 3560 uhblk: '▀', 3561 ulcorn: '⌜', 3562 ulcorner: '⌜', 3563 ulcrop: '⌏', 3564 ultri: '◸', 3565 umacr: 'ū', 3566 uml: '¨', 3567 uogon: 'ų', 3568 uopf: '', 3569 uparrow: '↑', 3570 updownarrow: '↕', 3571 upharpoonleft: '↿', 3572 upharpoonright: '↾', 3573 uplus: '⊎', 3574 upsi: 'υ', 3575 upsih: 'ϒ', 3576 upsilon: 'υ', 3577 upuparrows: '⇈', 3578 urcorn: '⌝', 3579 urcorner: '⌝', 3580 urcrop: '⌎', 3581 uring: 'ů', 3582 urtri: '◹', 3583 uscr: '', 3584 utdot: '⋰', 3585 utilde: 'ũ', 3586 utri: '▵', 3587 utrif: '▴', 3588 uuarr: '⇈', 3589 uuml: 'ü', 3590 uwangle: '⦧', 3591 vArr: '⇕', 3592 vBar: '⫨', 3593 vBarv: '⫩', 3594 vDash: '⊨', 3595 vangrt: '⦜', 3596 varepsilon: 'ϵ', 3597 varkappa: 'ϰ', 3598 varnothing: '∅', 3599 varphi: 'ϕ', 3600 varpi: 'ϖ', 3601 varpropto: '∝', 3602 varr: '↕', 3603 varrho: 'ϱ', 3604 varsigma: 'ς', 3605 varsubsetneq: '⊊︀', 3606 varsubsetneqq: '⫋︀', 3607 varsupsetneq: '⊋︀', 3608 varsupsetneqq: '⫌︀', 3609 vartheta: 'ϑ', 3610 vartriangleleft: '⊲', 3611 vartriangleright: '⊳', 3612 vcy: 'в', 3613 vdash: '⊢', 3614 vee: '∨', 3615 veebar: '⊻', 3616 veeeq: '≚', 3617 vellip: '⋮', 3618 verbar: '|', 3619 vert: '|', 3620 vfr: '', 3621 vltri: '⊲', 3622 vnsub: '⊂⃒', 3623 vnsup: '⊃⃒', 3624 vopf: '', 3625 vprop: '∝', 3626 vrtri: '⊳', 3627 vscr: '', 3628 vsubnE: '⫋︀', 3629 vsubne: '⊊︀', 3630 vsupnE: '⫌︀', 3631 vsupne: '⊋︀', 3632 vzigzag: '⦚', 3633 wcirc: 'ŵ', 3634 wedbar: '⩟', 3635 wedge: '∧', 3636 wedgeq: '≙', 3637 weierp: '℘', 3638 wfr: '', 3639 wopf: '', 3640 wp: '℘', 3641 wr: '≀', 3642 wreath: '≀', 3643 wscr: '', 3644 xcap: '⋂', 3645 xcirc: '◯', 3646 xcup: '⋃', 3647 xdtri: '▽', 3648 xfr: '', 3649 xhArr: '⟺', 3650 xharr: '⟷', 3651 xi: 'ξ', 3652 xlArr: '⟸', 3653 xlarr: '⟵', 3654 xmap: '⟼', 3655 xnis: '⋻', 3656 xodot: '⨀', 3657 xopf: '', 3658 xoplus: '⨁', 3659 xotime: '⨂', 3660 xrArr: '⟹', 3661 xrarr: '⟶', 3662 xscr: '', 3663 xsqcup: '⨆', 3664 xuplus: '⨄', 3665 xutri: '△', 3666 xvee: '⋁', 3667 xwedge: '⋀', 3668 yacute: 'ý', 3669 yacy: 'я', 3670 ycirc: 'ŷ', 3671 ycy: 'ы', 3672 yen: '¥', 3673 yfr: '', 3674 yicy: 'ї', 3675 yopf: '', 3676 yscr: '', 3677 yucy: 'ю', 3678 yuml: 'ÿ', 3679 zacute: 'ź', 3680 zcaron: 'ž', 3681 zcy: 'з', 3682 zdot: 'ż', 3683 zeetrf: 'ℨ', 3684 zeta: 'ζ', 3685 zfr: '', 3686 zhcy: 'ж', 3687 zigrarr: '⇝', 3688 zopf: '', 3689 zscr: '', 3690 zwj: '', 3691 zwnj: '' 3692}; 3693 3694const own$5 = {}.hasOwnProperty; 3695function decodeNamedCharacterReference(value) { 3696 return own$5.call(characterEntities, value) ? characterEntities[value] : false 3697} 3698 3699const characterReference = { 3700 name: 'characterReference', 3701 tokenize: tokenizeCharacterReference 3702}; 3703function tokenizeCharacterReference(effects, ok, nok) { 3704 const self = this; 3705 let size = 0; 3706 let max; 3707 let test; 3708 return start 3709 function start(code) { 3710 effects.enter('characterReference'); 3711 effects.enter('characterReferenceMarker'); 3712 effects.consume(code); 3713 effects.exit('characterReferenceMarker'); 3714 return open 3715 } 3716 function open(code) { 3717 if (code === 35) { 3718 effects.enter('characterReferenceMarkerNumeric'); 3719 effects.consume(code); 3720 effects.exit('characterReferenceMarkerNumeric'); 3721 return numeric 3722 } 3723 effects.enter('characterReferenceValue'); 3724 max = 31; 3725 test = asciiAlphanumeric; 3726 return value(code) 3727 } 3728 function numeric(code) { 3729 if (code === 88 || code === 120) { 3730 effects.enter('characterReferenceMarkerHexadecimal'); 3731 effects.consume(code); 3732 effects.exit('characterReferenceMarkerHexadecimal'); 3733 effects.enter('characterReferenceValue'); 3734 max = 6; 3735 test = asciiHexDigit; 3736 return value 3737 } 3738 effects.enter('characterReferenceValue'); 3739 max = 7; 3740 test = asciiDigit; 3741 return value(code) 3742 } 3743 function value(code) { 3744 if (code === 59 && size) { 3745 const token = effects.exit('characterReferenceValue'); 3746 if ( 3747 test === asciiAlphanumeric && 3748 !decodeNamedCharacterReference(self.sliceSerialize(token)) 3749 ) { 3750 return nok(code) 3751 } 3752 effects.enter('characterReferenceMarker'); 3753 effects.consume(code); 3754 effects.exit('characterReferenceMarker'); 3755 effects.exit('characterReference'); 3756 return ok 3757 } 3758 if (test(code) && size++ < max) { 3759 effects.consume(code); 3760 return value 3761 } 3762 return nok(code) 3763 } 3764} 3765 3766const nonLazyContinuation = { 3767 tokenize: tokenizeNonLazyContinuation, 3768 partial: true 3769}; 3770const codeFenced = { 3771 name: 'codeFenced', 3772 tokenize: tokenizeCodeFenced, 3773 concrete: true 3774}; 3775function tokenizeCodeFenced(effects, ok, nok) { 3776 const self = this; 3777 const closeStart = { 3778 tokenize: tokenizeCloseStart, 3779 partial: true 3780 }; 3781 let initialPrefix = 0; 3782 let sizeOpen = 0; 3783 let marker; 3784 return start 3785 function start(code) { 3786 return beforeSequenceOpen(code) 3787 } 3788 function beforeSequenceOpen(code) { 3789 const tail = self.events[self.events.length - 1]; 3790 initialPrefix = 3791 tail && tail[1].type === 'linePrefix' 3792 ? tail[2].sliceSerialize(tail[1], true).length 3793 : 0; 3794 marker = code; 3795 effects.enter('codeFenced'); 3796 effects.enter('codeFencedFence'); 3797 effects.enter('codeFencedFenceSequence'); 3798 return sequenceOpen(code) 3799 } 3800 function sequenceOpen(code) { 3801 if (code === marker) { 3802 sizeOpen++; 3803 effects.consume(code); 3804 return sequenceOpen 3805 } 3806 if (sizeOpen < 3) { 3807 return nok(code) 3808 } 3809 effects.exit('codeFencedFenceSequence'); 3810 return markdownSpace(code) 3811 ? factorySpace(effects, infoBefore, 'whitespace')(code) 3812 : infoBefore(code) 3813 } 3814 function infoBefore(code) { 3815 if (code === null || markdownLineEnding(code)) { 3816 effects.exit('codeFencedFence'); 3817 return self.interrupt 3818 ? ok(code) 3819 : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code) 3820 } 3821 effects.enter('codeFencedFenceInfo'); 3822 effects.enter('chunkString', { 3823 contentType: 'string' 3824 }); 3825 return info(code) 3826 } 3827 function info(code) { 3828 if (code === null || markdownLineEnding(code)) { 3829 effects.exit('chunkString'); 3830 effects.exit('codeFencedFenceInfo'); 3831 return infoBefore(code) 3832 } 3833 if (markdownSpace(code)) { 3834 effects.exit('chunkString'); 3835 effects.exit('codeFencedFenceInfo'); 3836 return factorySpace(effects, metaBefore, 'whitespace')(code) 3837 } 3838 if (code === 96 && code === marker) { 3839 return nok(code) 3840 } 3841 effects.consume(code); 3842 return info 3843 } 3844 function metaBefore(code) { 3845 if (code === null || markdownLineEnding(code)) { 3846 return infoBefore(code) 3847 } 3848 effects.enter('codeFencedFenceMeta'); 3849 effects.enter('chunkString', { 3850 contentType: 'string' 3851 }); 3852 return meta(code) 3853 } 3854 function meta(code) { 3855 if (code === null || markdownLineEnding(code)) { 3856 effects.exit('chunkString'); 3857 effects.exit('codeFencedFenceMeta'); 3858 return infoBefore(code) 3859 } 3860 if (code === 96 && code === marker) { 3861 return nok(code) 3862 } 3863 effects.consume(code); 3864 return meta 3865 } 3866 function atNonLazyBreak(code) { 3867 return effects.attempt(closeStart, after, contentBefore)(code) 3868 } 3869 function contentBefore(code) { 3870 effects.enter('lineEnding'); 3871 effects.consume(code); 3872 effects.exit('lineEnding'); 3873 return contentStart 3874 } 3875 function contentStart(code) { 3876 return initialPrefix > 0 && markdownSpace(code) 3877 ? factorySpace( 3878 effects, 3879 beforeContentChunk, 3880 'linePrefix', 3881 initialPrefix + 1 3882 )(code) 3883 : beforeContentChunk(code) 3884 } 3885 function beforeContentChunk(code) { 3886 if (code === null || markdownLineEnding(code)) { 3887 return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code) 3888 } 3889 effects.enter('codeFlowValue'); 3890 return contentChunk(code) 3891 } 3892 function contentChunk(code) { 3893 if (code === null || markdownLineEnding(code)) { 3894 effects.exit('codeFlowValue'); 3895 return beforeContentChunk(code) 3896 } 3897 effects.consume(code); 3898 return contentChunk 3899 } 3900 function after(code) { 3901 effects.exit('codeFenced'); 3902 return ok(code) 3903 } 3904 function tokenizeCloseStart(effects, ok, nok) { 3905 let size = 0; 3906 return startBefore 3907 function startBefore(code) { 3908 effects.enter('lineEnding'); 3909 effects.consume(code); 3910 effects.exit('lineEnding'); 3911 return start 3912 } 3913 function start(code) { 3914 effects.enter('codeFencedFence'); 3915 return markdownSpace(code) 3916 ? factorySpace( 3917 effects, 3918 beforeSequenceClose, 3919 'linePrefix', 3920 self.parser.constructs.disable.null.includes('codeIndented') 3921 ? undefined 3922 : 4 3923 )(code) 3924 : beforeSequenceClose(code) 3925 } 3926 function beforeSequenceClose(code) { 3927 if (code === marker) { 3928 effects.enter('codeFencedFenceSequence'); 3929 return sequenceClose(code) 3930 } 3931 return nok(code) 3932 } 3933 function sequenceClose(code) { 3934 if (code === marker) { 3935 size++; 3936 effects.consume(code); 3937 return sequenceClose 3938 } 3939 if (size >= sizeOpen) { 3940 effects.exit('codeFencedFenceSequence'); 3941 return markdownSpace(code) 3942 ? factorySpace(effects, sequenceCloseAfter, 'whitespace')(code) 3943 : sequenceCloseAfter(code) 3944 } 3945 return nok(code) 3946 } 3947 function sequenceCloseAfter(code) { 3948 if (code === null || markdownLineEnding(code)) { 3949 effects.exit('codeFencedFence'); 3950 return ok(code) 3951 } 3952 return nok(code) 3953 } 3954 } 3955} 3956function tokenizeNonLazyContinuation(effects, ok, nok) { 3957 const self = this; 3958 return start 3959 function start(code) { 3960 if (code === null) { 3961 return nok(code) 3962 } 3963 effects.enter('lineEnding'); 3964 effects.consume(code); 3965 effects.exit('lineEnding'); 3966 return lineStart 3967 } 3968 function lineStart(code) { 3969 return self.parser.lazy[self.now().line] ? nok(code) : ok(code) 3970 } 3971} 3972 3973const codeIndented = { 3974 name: 'codeIndented', 3975 tokenize: tokenizeCodeIndented 3976}; 3977const furtherStart = { 3978 tokenize: tokenizeFurtherStart, 3979 partial: true 3980}; 3981function tokenizeCodeIndented(effects, ok, nok) { 3982 const self = this; 3983 return start 3984 function start(code) { 3985 effects.enter('codeIndented'); 3986 return factorySpace(effects, afterPrefix, 'linePrefix', 4 + 1)(code) 3987 } 3988 function afterPrefix(code) { 3989 const tail = self.events[self.events.length - 1]; 3990 return tail && 3991 tail[1].type === 'linePrefix' && 3992 tail[2].sliceSerialize(tail[1], true).length >= 4 3993 ? atBreak(code) 3994 : nok(code) 3995 } 3996 function atBreak(code) { 3997 if (code === null) { 3998 return after(code) 3999 } 4000 if (markdownLineEnding(code)) { 4001 return effects.attempt(furtherStart, atBreak, after)(code) 4002 } 4003 effects.enter('codeFlowValue'); 4004 return inside(code) 4005 } 4006 function inside(code) { 4007 if (code === null || markdownLineEnding(code)) { 4008 effects.exit('codeFlowValue'); 4009 return atBreak(code) 4010 } 4011 effects.consume(code); 4012 return inside 4013 } 4014 function after(code) { 4015 effects.exit('codeIndented'); 4016 return ok(code) 4017 } 4018} 4019function tokenizeFurtherStart(effects, ok, nok) { 4020 const self = this; 4021 return furtherStart 4022 function furtherStart(code) { 4023 if (self.parser.lazy[self.now().line]) { 4024 return nok(code) 4025 } 4026 if (markdownLineEnding(code)) { 4027 effects.enter('lineEnding'); 4028 effects.consume(code); 4029 effects.exit('lineEnding'); 4030 return furtherStart 4031 } 4032 return factorySpace(effects, afterPrefix, 'linePrefix', 4 + 1)(code) 4033 } 4034 function afterPrefix(code) { 4035 const tail = self.events[self.events.length - 1]; 4036 return tail && 4037 tail[1].type === 'linePrefix' && 4038 tail[2].sliceSerialize(tail[1], true).length >= 4 4039 ? ok(code) 4040 : markdownLineEnding(code) 4041 ? furtherStart(code) 4042 : nok(code) 4043 } 4044} 4045 4046const codeText = { 4047 name: 'codeText', 4048 tokenize: tokenizeCodeText, 4049 resolve: resolveCodeText, 4050 previous: previous$1 4051}; 4052function resolveCodeText(events) { 4053 let tailExitIndex = events.length - 4; 4054 let headEnterIndex = 3; 4055 let index; 4056 let enter; 4057 if ( 4058 (events[headEnterIndex][1].type === 'lineEnding' || 4059 events[headEnterIndex][1].type === 'space') && 4060 (events[tailExitIndex][1].type === 'lineEnding' || 4061 events[tailExitIndex][1].type === 'space') 4062 ) { 4063 index = headEnterIndex; 4064 while (++index < tailExitIndex) { 4065 if (events[index][1].type === 'codeTextData') { 4066 events[headEnterIndex][1].type = 'codeTextPadding'; 4067 events[tailExitIndex][1].type = 'codeTextPadding'; 4068 headEnterIndex += 2; 4069 tailExitIndex -= 2; 4070 break 4071 } 4072 } 4073 } 4074 index = headEnterIndex - 1; 4075 tailExitIndex++; 4076 while (++index <= tailExitIndex) { 4077 if (enter === undefined) { 4078 if (index !== tailExitIndex && events[index][1].type !== 'lineEnding') { 4079 enter = index; 4080 } 4081 } else if ( 4082 index === tailExitIndex || 4083 events[index][1].type === 'lineEnding' 4084 ) { 4085 events[enter][1].type = 'codeTextData'; 4086 if (index !== enter + 2) { 4087 events[enter][1].end = events[index - 1][1].end; 4088 events.splice(enter + 2, index - enter - 2); 4089 tailExitIndex -= index - enter - 2; 4090 index = enter + 2; 4091 } 4092 enter = undefined; 4093 } 4094 } 4095 return events 4096} 4097function previous$1(code) { 4098 return ( 4099 code !== 96 || 4100 this.events[this.events.length - 1][1].type === 'characterEscape' 4101 ) 4102} 4103function tokenizeCodeText(effects, ok, nok) { 4104 let sizeOpen = 0; 4105 let size; 4106 let token; 4107 return start 4108 function start(code) { 4109 effects.enter('codeText'); 4110 effects.enter('codeTextSequence'); 4111 return sequenceOpen(code) 4112 } 4113 function sequenceOpen(code) { 4114 if (code === 96) { 4115 effects.consume(code); 4116 sizeOpen++; 4117 return sequenceOpen 4118 } 4119 effects.exit('codeTextSequence'); 4120 return between(code) 4121 } 4122 function between(code) { 4123 if (code === null) { 4124 return nok(code) 4125 } 4126 if (code === 32) { 4127 effects.enter('space'); 4128 effects.consume(code); 4129 effects.exit('space'); 4130 return between 4131 } 4132 if (code === 96) { 4133 token = effects.enter('codeTextSequence'); 4134 size = 0; 4135 return sequenceClose(code) 4136 } 4137 if (markdownLineEnding(code)) { 4138 effects.enter('lineEnding'); 4139 effects.consume(code); 4140 effects.exit('lineEnding'); 4141 return between 4142 } 4143 effects.enter('codeTextData'); 4144 return data(code) 4145 } 4146 function data(code) { 4147 if ( 4148 code === null || 4149 code === 32 || 4150 code === 96 || 4151 markdownLineEnding(code) 4152 ) { 4153 effects.exit('codeTextData'); 4154 return between(code) 4155 } 4156 effects.consume(code); 4157 return data 4158 } 4159 function sequenceClose(code) { 4160 if (code === 96) { 4161 effects.consume(code); 4162 size++; 4163 return sequenceClose 4164 } 4165 if (size === sizeOpen) { 4166 effects.exit('codeTextSequence'); 4167 effects.exit('codeText'); 4168 return ok(code) 4169 } 4170 token.type = 'codeTextData'; 4171 return data(code) 4172 } 4173} 4174 4175function subtokenize(events) { 4176 const jumps = {}; 4177 let index = -1; 4178 let event; 4179 let lineIndex; 4180 let otherIndex; 4181 let otherEvent; 4182 let parameters; 4183 let subevents; 4184 let more; 4185 while (++index < events.length) { 4186 while (index in jumps) { 4187 index = jumps[index]; 4188 } 4189 event = events[index]; 4190 if ( 4191 index && 4192 event[1].type === 'chunkFlow' && 4193 events[index - 1][1].type === 'listItemPrefix' 4194 ) { 4195 subevents = event[1]._tokenizer.events; 4196 otherIndex = 0; 4197 if ( 4198 otherIndex < subevents.length && 4199 subevents[otherIndex][1].type === 'lineEndingBlank' 4200 ) { 4201 otherIndex += 2; 4202 } 4203 if ( 4204 otherIndex < subevents.length && 4205 subevents[otherIndex][1].type === 'content' 4206 ) { 4207 while (++otherIndex < subevents.length) { 4208 if (subevents[otherIndex][1].type === 'content') { 4209 break 4210 } 4211 if (subevents[otherIndex][1].type === 'chunkText') { 4212 subevents[otherIndex][1]._isInFirstContentOfListItem = true; 4213 otherIndex++; 4214 } 4215 } 4216 } 4217 } 4218 if (event[0] === 'enter') { 4219 if (event[1].contentType) { 4220 Object.assign(jumps, subcontent(events, index)); 4221 index = jumps[index]; 4222 more = true; 4223 } 4224 } 4225 else if (event[1]._container) { 4226 otherIndex = index; 4227 lineIndex = undefined; 4228 while (otherIndex--) { 4229 otherEvent = events[otherIndex]; 4230 if ( 4231 otherEvent[1].type === 'lineEnding' || 4232 otherEvent[1].type === 'lineEndingBlank' 4233 ) { 4234 if (otherEvent[0] === 'enter') { 4235 if (lineIndex) { 4236 events[lineIndex][1].type = 'lineEndingBlank'; 4237 } 4238 otherEvent[1].type = 'lineEnding'; 4239 lineIndex = otherIndex; 4240 } 4241 } else { 4242 break 4243 } 4244 } 4245 if (lineIndex) { 4246 event[1].end = Object.assign({}, events[lineIndex][1].start); 4247 parameters = events.slice(lineIndex, index); 4248 parameters.unshift(event); 4249 splice(events, lineIndex, index - lineIndex + 1, parameters); 4250 } 4251 } 4252 } 4253 return !more 4254} 4255function subcontent(events, eventIndex) { 4256 const token = events[eventIndex][1]; 4257 const context = events[eventIndex][2]; 4258 let startPosition = eventIndex - 1; 4259 const startPositions = []; 4260 const tokenizer = 4261 token._tokenizer || context.parser[token.contentType](token.start); 4262 const childEvents = tokenizer.events; 4263 const jumps = []; 4264 const gaps = {}; 4265 let stream; 4266 let previous; 4267 let index = -1; 4268 let current = token; 4269 let adjust = 0; 4270 let start = 0; 4271 const breaks = [start]; 4272 while (current) { 4273 while (events[++startPosition][1] !== current) { 4274 } 4275 startPositions.push(startPosition); 4276 if (!current._tokenizer) { 4277 stream = context.sliceStream(current); 4278 if (!current.next) { 4279 stream.push(null); 4280 } 4281 if (previous) { 4282 tokenizer.defineSkip(current.start); 4283 } 4284 if (current._isInFirstContentOfListItem) { 4285 tokenizer._gfmTasklistFirstContentOfListItem = true; 4286 } 4287 tokenizer.write(stream); 4288 if (current._isInFirstContentOfListItem) { 4289 tokenizer._gfmTasklistFirstContentOfListItem = undefined; 4290 } 4291 } 4292 previous = current; 4293 current = current.next; 4294 } 4295 current = token; 4296 while (++index < childEvents.length) { 4297 if ( 4298 childEvents[index][0] === 'exit' && 4299 childEvents[index - 1][0] === 'enter' && 4300 childEvents[index][1].type === childEvents[index - 1][1].type && 4301 childEvents[index][1].start.line !== childEvents[index][1].end.line 4302 ) { 4303 start = index + 1; 4304 breaks.push(start); 4305 current._tokenizer = undefined; 4306 current.previous = undefined; 4307 current = current.next; 4308 } 4309 } 4310 tokenizer.events = []; 4311 if (current) { 4312 current._tokenizer = undefined; 4313 current.previous = undefined; 4314 } else { 4315 breaks.pop(); 4316 } 4317 index = breaks.length; 4318 while (index--) { 4319 const slice = childEvents.slice(breaks[index], breaks[index + 1]); 4320 const start = startPositions.pop(); 4321 jumps.unshift([start, start + slice.length - 1]); 4322 splice(events, start, 2, slice); 4323 } 4324 index = -1; 4325 while (++index < jumps.length) { 4326 gaps[adjust + jumps[index][0]] = adjust + jumps[index][1]; 4327 adjust += jumps[index][1] - jumps[index][0] - 1; 4328 } 4329 return gaps 4330} 4331 4332const content = { 4333 tokenize: tokenizeContent, 4334 resolve: resolveContent 4335}; 4336const continuationConstruct = { 4337 tokenize: tokenizeContinuation, 4338 partial: true 4339}; 4340function resolveContent(events) { 4341 subtokenize(events); 4342 return events 4343} 4344function tokenizeContent(effects, ok) { 4345 let previous; 4346 return chunkStart 4347 function chunkStart(code) { 4348 effects.enter('content'); 4349 previous = effects.enter('chunkContent', { 4350 contentType: 'content' 4351 }); 4352 return chunkInside(code) 4353 } 4354 function chunkInside(code) { 4355 if (code === null) { 4356 return contentEnd(code) 4357 } 4358 if (markdownLineEnding(code)) { 4359 return effects.check( 4360 continuationConstruct, 4361 contentContinue, 4362 contentEnd 4363 )(code) 4364 } 4365 effects.consume(code); 4366 return chunkInside 4367 } 4368 function contentEnd(code) { 4369 effects.exit('chunkContent'); 4370 effects.exit('content'); 4371 return ok(code) 4372 } 4373 function contentContinue(code) { 4374 effects.consume(code); 4375 effects.exit('chunkContent'); 4376 previous.next = effects.enter('chunkContent', { 4377 contentType: 'content', 4378 previous 4379 }); 4380 previous = previous.next; 4381 return chunkInside 4382 } 4383} 4384function tokenizeContinuation(effects, ok, nok) { 4385 const self = this; 4386 return startLookahead 4387 function startLookahead(code) { 4388 effects.exit('chunkContent'); 4389 effects.enter('lineEnding'); 4390 effects.consume(code); 4391 effects.exit('lineEnding'); 4392 return factorySpace(effects, prefixed, 'linePrefix') 4393 } 4394 function prefixed(code) { 4395 if (code === null || markdownLineEnding(code)) { 4396 return nok(code) 4397 } 4398 const tail = self.events[self.events.length - 1]; 4399 if ( 4400 !self.parser.constructs.disable.null.includes('codeIndented') && 4401 tail && 4402 tail[1].type === 'linePrefix' && 4403 tail[2].sliceSerialize(tail[1], true).length >= 4 4404 ) { 4405 return ok(code) 4406 } 4407 return effects.interrupt(self.parser.constructs.flow, nok, ok)(code) 4408 } 4409} 4410 4411function factoryDestination( 4412 effects, 4413 ok, 4414 nok, 4415 type, 4416 literalType, 4417 literalMarkerType, 4418 rawType, 4419 stringType, 4420 max 4421) { 4422 const limit = max || Number.POSITIVE_INFINITY; 4423 let balance = 0; 4424 return start 4425 function start(code) { 4426 if (code === 60) { 4427 effects.enter(type); 4428 effects.enter(literalType); 4429 effects.enter(literalMarkerType); 4430 effects.consume(code); 4431 effects.exit(literalMarkerType); 4432 return enclosedBefore 4433 } 4434 if (code === null || code === 32 || code === 41 || asciiControl(code)) { 4435 return nok(code) 4436 } 4437 effects.enter(type); 4438 effects.enter(rawType); 4439 effects.enter(stringType); 4440 effects.enter('chunkString', { 4441 contentType: 'string' 4442 }); 4443 return raw(code) 4444 } 4445 function enclosedBefore(code) { 4446 if (code === 62) { 4447 effects.enter(literalMarkerType); 4448 effects.consume(code); 4449 effects.exit(literalMarkerType); 4450 effects.exit(literalType); 4451 effects.exit(type); 4452 return ok 4453 } 4454 effects.enter(stringType); 4455 effects.enter('chunkString', { 4456 contentType: 'string' 4457 }); 4458 return enclosed(code) 4459 } 4460 function enclosed(code) { 4461 if (code === 62) { 4462 effects.exit('chunkString'); 4463 effects.exit(stringType); 4464 return enclosedBefore(code) 4465 } 4466 if (code === null || code === 60 || markdownLineEnding(code)) { 4467 return nok(code) 4468 } 4469 effects.consume(code); 4470 return code === 92 ? enclosedEscape : enclosed 4471 } 4472 function enclosedEscape(code) { 4473 if (code === 60 || code === 62 || code === 92) { 4474 effects.consume(code); 4475 return enclosed 4476 } 4477 return enclosed(code) 4478 } 4479 function raw(code) { 4480 if ( 4481 !balance && 4482 (code === null || code === 41 || markdownLineEndingOrSpace(code)) 4483 ) { 4484 effects.exit('chunkString'); 4485 effects.exit(stringType); 4486 effects.exit(rawType); 4487 effects.exit(type); 4488 return ok(code) 4489 } 4490 if (balance < limit && code === 40) { 4491 effects.consume(code); 4492 balance++; 4493 return raw 4494 } 4495 if (code === 41) { 4496 effects.consume(code); 4497 balance--; 4498 return raw 4499 } 4500 if (code === null || code === 32 || code === 40 || asciiControl(code)) { 4501 return nok(code) 4502 } 4503 effects.consume(code); 4504 return code === 92 ? rawEscape : raw 4505 } 4506 function rawEscape(code) { 4507 if (code === 40 || code === 41 || code === 92) { 4508 effects.consume(code); 4509 return raw 4510 } 4511 return raw(code) 4512 } 4513} 4514 4515function factoryLabel(effects, ok, nok, type, markerType, stringType) { 4516 const self = this; 4517 let size = 0; 4518 let seen; 4519 return start 4520 function start(code) { 4521 effects.enter(type); 4522 effects.enter(markerType); 4523 effects.consume(code); 4524 effects.exit(markerType); 4525 effects.enter(stringType); 4526 return atBreak 4527 } 4528 function atBreak(code) { 4529 if ( 4530 size > 999 || 4531 code === null || 4532 code === 91 || 4533 (code === 93 && !seen) || 4534 (code === 94 && 4535 !size && 4536 '_hiddenFootnoteSupport' in self.parser.constructs) 4537 ) { 4538 return nok(code) 4539 } 4540 if (code === 93) { 4541 effects.exit(stringType); 4542 effects.enter(markerType); 4543 effects.consume(code); 4544 effects.exit(markerType); 4545 effects.exit(type); 4546 return ok 4547 } 4548 if (markdownLineEnding(code)) { 4549 effects.enter('lineEnding'); 4550 effects.consume(code); 4551 effects.exit('lineEnding'); 4552 return atBreak 4553 } 4554 effects.enter('chunkString', { 4555 contentType: 'string' 4556 }); 4557 return labelInside(code) 4558 } 4559 function labelInside(code) { 4560 if ( 4561 code === null || 4562 code === 91 || 4563 code === 93 || 4564 markdownLineEnding(code) || 4565 size++ > 999 4566 ) { 4567 effects.exit('chunkString'); 4568 return atBreak(code) 4569 } 4570 effects.consume(code); 4571 if (!seen) seen = !markdownSpace(code); 4572 return code === 92 ? labelEscape : labelInside 4573 } 4574 function labelEscape(code) { 4575 if (code === 91 || code === 92 || code === 93) { 4576 effects.consume(code); 4577 size++; 4578 return labelInside 4579 } 4580 return labelInside(code) 4581 } 4582} 4583 4584function factoryTitle(effects, ok, nok, type, markerType, stringType) { 4585 let marker; 4586 return start 4587 function start(code) { 4588 if (code === 34 || code === 39 || code === 40) { 4589 effects.enter(type); 4590 effects.enter(markerType); 4591 effects.consume(code); 4592 effects.exit(markerType); 4593 marker = code === 40 ? 41 : code; 4594 return begin 4595 } 4596 return nok(code) 4597 } 4598 function begin(code) { 4599 if (code === marker) { 4600 effects.enter(markerType); 4601 effects.consume(code); 4602 effects.exit(markerType); 4603 effects.exit(type); 4604 return ok 4605 } 4606 effects.enter(stringType); 4607 return atBreak(code) 4608 } 4609 function atBreak(code) { 4610 if (code === marker) { 4611 effects.exit(stringType); 4612 return begin(marker) 4613 } 4614 if (code === null) { 4615 return nok(code) 4616 } 4617 if (markdownLineEnding(code)) { 4618 effects.enter('lineEnding'); 4619 effects.consume(code); 4620 effects.exit('lineEnding'); 4621 return factorySpace(effects, atBreak, 'linePrefix') 4622 } 4623 effects.enter('chunkString', { 4624 contentType: 'string' 4625 }); 4626 return inside(code) 4627 } 4628 function inside(code) { 4629 if (code === marker || code === null || markdownLineEnding(code)) { 4630 effects.exit('chunkString'); 4631 return atBreak(code) 4632 } 4633 effects.consume(code); 4634 return code === 92 ? escape : inside 4635 } 4636 function escape(code) { 4637 if (code === marker || code === 92) { 4638 effects.consume(code); 4639 return inside 4640 } 4641 return inside(code) 4642 } 4643} 4644 4645function factoryWhitespace(effects, ok) { 4646 let seen; 4647 return start 4648 function start(code) { 4649 if (markdownLineEnding(code)) { 4650 effects.enter('lineEnding'); 4651 effects.consume(code); 4652 effects.exit('lineEnding'); 4653 seen = true; 4654 return start 4655 } 4656 if (markdownSpace(code)) { 4657 return factorySpace( 4658 effects, 4659 start, 4660 seen ? 'linePrefix' : 'lineSuffix' 4661 )(code) 4662 } 4663 return ok(code) 4664 } 4665} 4666 4667function normalizeIdentifier(value) { 4668 return ( 4669 value 4670 .replace(/[\t\n\r ]+/g, ' ') 4671 .replace(/^ | $/g, '') 4672 .toLowerCase() 4673 .toUpperCase() 4674 ) 4675} 4676 4677const definition$1 = { 4678 name: 'definition', 4679 tokenize: tokenizeDefinition 4680}; 4681const titleBefore = { 4682 tokenize: tokenizeTitleBefore, 4683 partial: true 4684}; 4685function tokenizeDefinition(effects, ok, nok) { 4686 const self = this; 4687 let identifier; 4688 return start 4689 function start(code) { 4690 effects.enter('definition'); 4691 return before(code) 4692 } 4693 function before(code) { 4694 return factoryLabel.call( 4695 self, 4696 effects, 4697 labelAfter, 4698 nok, 4699 'definitionLabel', 4700 'definitionLabelMarker', 4701 'definitionLabelString' 4702 )(code) 4703 } 4704 function labelAfter(code) { 4705 identifier = normalizeIdentifier( 4706 self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) 4707 ); 4708 if (code === 58) { 4709 effects.enter('definitionMarker'); 4710 effects.consume(code); 4711 effects.exit('definitionMarker'); 4712 return markerAfter 4713 } 4714 return nok(code) 4715 } 4716 function markerAfter(code) { 4717 return markdownLineEndingOrSpace(code) 4718 ? factoryWhitespace(effects, destinationBefore)(code) 4719 : destinationBefore(code) 4720 } 4721 function destinationBefore(code) { 4722 return factoryDestination( 4723 effects, 4724 destinationAfter, 4725 nok, 4726 'definitionDestination', 4727 'definitionDestinationLiteral', 4728 'definitionDestinationLiteralMarker', 4729 'definitionDestinationRaw', 4730 'definitionDestinationString' 4731 )(code) 4732 } 4733 function destinationAfter(code) { 4734 return effects.attempt(titleBefore, after, after)(code) 4735 } 4736 function after(code) { 4737 return markdownSpace(code) 4738 ? factorySpace(effects, afterWhitespace, 'whitespace')(code) 4739 : afterWhitespace(code) 4740 } 4741 function afterWhitespace(code) { 4742 if (code === null || markdownLineEnding(code)) { 4743 effects.exit('definition'); 4744 self.parser.defined.push(identifier); 4745 return ok(code) 4746 } 4747 return nok(code) 4748 } 4749} 4750function tokenizeTitleBefore(effects, ok, nok) { 4751 return titleBefore 4752 function titleBefore(code) { 4753 return markdownLineEndingOrSpace(code) 4754 ? factoryWhitespace(effects, beforeMarker)(code) 4755 : nok(code) 4756 } 4757 function beforeMarker(code) { 4758 return factoryTitle( 4759 effects, 4760 titleAfter, 4761 nok, 4762 'definitionTitle', 4763 'definitionTitleMarker', 4764 'definitionTitleString' 4765 )(code) 4766 } 4767 function titleAfter(code) { 4768 return markdownSpace(code) 4769 ? factorySpace(effects, titleAfterOptionalWhitespace, 'whitespace')(code) 4770 : titleAfterOptionalWhitespace(code) 4771 } 4772 function titleAfterOptionalWhitespace(code) { 4773 return code === null || markdownLineEnding(code) ? ok(code) : nok(code) 4774 } 4775} 4776 4777const hardBreakEscape = { 4778 name: 'hardBreakEscape', 4779 tokenize: tokenizeHardBreakEscape 4780}; 4781function tokenizeHardBreakEscape(effects, ok, nok) { 4782 return start 4783 function start(code) { 4784 effects.enter('hardBreakEscape'); 4785 effects.consume(code); 4786 return after 4787 } 4788 function after(code) { 4789 if (markdownLineEnding(code)) { 4790 effects.exit('hardBreakEscape'); 4791 return ok(code) 4792 } 4793 return nok(code) 4794 } 4795} 4796 4797const headingAtx = { 4798 name: 'headingAtx', 4799 tokenize: tokenizeHeadingAtx, 4800 resolve: resolveHeadingAtx 4801}; 4802function resolveHeadingAtx(events, context) { 4803 let contentEnd = events.length - 2; 4804 let contentStart = 3; 4805 let content; 4806 let text; 4807 if (events[contentStart][1].type === 'whitespace') { 4808 contentStart += 2; 4809 } 4810 if ( 4811 contentEnd - 2 > contentStart && 4812 events[contentEnd][1].type === 'whitespace' 4813 ) { 4814 contentEnd -= 2; 4815 } 4816 if ( 4817 events[contentEnd][1].type === 'atxHeadingSequence' && 4818 (contentStart === contentEnd - 1 || 4819 (contentEnd - 4 > contentStart && 4820 events[contentEnd - 2][1].type === 'whitespace')) 4821 ) { 4822 contentEnd -= contentStart + 1 === contentEnd ? 2 : 4; 4823 } 4824 if (contentEnd > contentStart) { 4825 content = { 4826 type: 'atxHeadingText', 4827 start: events[contentStart][1].start, 4828 end: events[contentEnd][1].end 4829 }; 4830 text = { 4831 type: 'chunkText', 4832 start: events[contentStart][1].start, 4833 end: events[contentEnd][1].end, 4834 contentType: 'text' 4835 }; 4836 splice(events, contentStart, contentEnd - contentStart + 1, [ 4837 ['enter', content, context], 4838 ['enter', text, context], 4839 ['exit', text, context], 4840 ['exit', content, context] 4841 ]); 4842 } 4843 return events 4844} 4845function tokenizeHeadingAtx(effects, ok, nok) { 4846 let size = 0; 4847 return start 4848 function start(code) { 4849 effects.enter('atxHeading'); 4850 return before(code) 4851 } 4852 function before(code) { 4853 effects.enter('atxHeadingSequence'); 4854 return sequenceOpen(code) 4855 } 4856 function sequenceOpen(code) { 4857 if (code === 35 && size++ < 6) { 4858 effects.consume(code); 4859 return sequenceOpen 4860 } 4861 if (code === null || markdownLineEndingOrSpace(code)) { 4862 effects.exit('atxHeadingSequence'); 4863 return atBreak(code) 4864 } 4865 return nok(code) 4866 } 4867 function atBreak(code) { 4868 if (code === 35) { 4869 effects.enter('atxHeadingSequence'); 4870 return sequenceFurther(code) 4871 } 4872 if (code === null || markdownLineEnding(code)) { 4873 effects.exit('atxHeading'); 4874 return ok(code) 4875 } 4876 if (markdownSpace(code)) { 4877 return factorySpace(effects, atBreak, 'whitespace')(code) 4878 } 4879 effects.enter('atxHeadingText'); 4880 return data(code) 4881 } 4882 function sequenceFurther(code) { 4883 if (code === 35) { 4884 effects.consume(code); 4885 return sequenceFurther 4886 } 4887 effects.exit('atxHeadingSequence'); 4888 return atBreak(code) 4889 } 4890 function data(code) { 4891 if (code === null || code === 35 || markdownLineEndingOrSpace(code)) { 4892 effects.exit('atxHeadingText'); 4893 return atBreak(code) 4894 } 4895 effects.consume(code); 4896 return data 4897 } 4898} 4899 4900const htmlBlockNames = [ 4901 'address', 4902 'article', 4903 'aside', 4904 'base', 4905 'basefont', 4906 'blockquote', 4907 'body', 4908 'caption', 4909 'center', 4910 'col', 4911 'colgroup', 4912 'dd', 4913 'details', 4914 'dialog', 4915 'dir', 4916 'div', 4917 'dl', 4918 'dt', 4919 'fieldset', 4920 'figcaption', 4921 'figure', 4922 'footer', 4923 'form', 4924 'frame', 4925 'frameset', 4926 'h1', 4927 'h2', 4928 'h3', 4929 'h4', 4930 'h5', 4931 'h6', 4932 'head', 4933 'header', 4934 'hr', 4935 'html', 4936 'iframe', 4937 'legend', 4938 'li', 4939 'link', 4940 'main', 4941 'menu', 4942 'menuitem', 4943 'nav', 4944 'noframes', 4945 'ol', 4946 'optgroup', 4947 'option', 4948 'p', 4949 'param', 4950 'search', 4951 'section', 4952 'summary', 4953 'table', 4954 'tbody', 4955 'td', 4956 'tfoot', 4957 'th', 4958 'thead', 4959 'title', 4960 'tr', 4961 'track', 4962 'ul' 4963]; 4964const htmlRawNames = ['pre', 'script', 'style', 'textarea']; 4965 4966const htmlFlow = { 4967 name: 'htmlFlow', 4968 tokenize: tokenizeHtmlFlow, 4969 resolveTo: resolveToHtmlFlow, 4970 concrete: true 4971}; 4972const blankLineBefore = { 4973 tokenize: tokenizeBlankLineBefore, 4974 partial: true 4975}; 4976const nonLazyContinuationStart = { 4977 tokenize: tokenizeNonLazyContinuationStart, 4978 partial: true 4979}; 4980function resolveToHtmlFlow(events) { 4981 let index = events.length; 4982 while (index--) { 4983 if (events[index][0] === 'enter' && events[index][1].type === 'htmlFlow') { 4984 break 4985 } 4986 } 4987 if (index > 1 && events[index - 2][1].type === 'linePrefix') { 4988 events[index][1].start = events[index - 2][1].start; 4989 events[index + 1][1].start = events[index - 2][1].start; 4990 events.splice(index - 2, 2); 4991 } 4992 return events 4993} 4994function tokenizeHtmlFlow(effects, ok, nok) { 4995 const self = this; 4996 let marker; 4997 let closingTag; 4998 let buffer; 4999 let index; 5000 let markerB; 5001 return start 5002 function start(code) { 5003 return before(code) 5004 } 5005 function before(code) { 5006 effects.enter('htmlFlow'); 5007 effects.enter('htmlFlowData'); 5008 effects.consume(code); 5009 return open 5010 } 5011 function open(code) { 5012 if (code === 33) { 5013 effects.consume(code); 5014 return declarationOpen 5015 } 5016 if (code === 47) { 5017 effects.consume(code); 5018 closingTag = true; 5019 return tagCloseStart 5020 } 5021 if (code === 63) { 5022 effects.consume(code); 5023 marker = 3; 5024 return self.interrupt ? ok : continuationDeclarationInside 5025 } 5026 if (asciiAlpha(code)) { 5027 effects.consume(code); 5028 buffer = String.fromCharCode(code); 5029 return tagName 5030 } 5031 return nok(code) 5032 } 5033 function declarationOpen(code) { 5034 if (code === 45) { 5035 effects.consume(code); 5036 marker = 2; 5037 return commentOpenInside 5038 } 5039 if (code === 91) { 5040 effects.consume(code); 5041 marker = 5; 5042 index = 0; 5043 return cdataOpenInside 5044 } 5045 if (asciiAlpha(code)) { 5046 effects.consume(code); 5047 marker = 4; 5048 return self.interrupt ? ok : continuationDeclarationInside 5049 } 5050 return nok(code) 5051 } 5052 function commentOpenInside(code) { 5053 if (code === 45) { 5054 effects.consume(code); 5055 return self.interrupt ? ok : continuationDeclarationInside 5056 } 5057 return nok(code) 5058 } 5059 function cdataOpenInside(code) { 5060 const value = 'CDATA['; 5061 if (code === value.charCodeAt(index++)) { 5062 effects.consume(code); 5063 if (index === value.length) { 5064 return self.interrupt ? ok : continuation 5065 } 5066 return cdataOpenInside 5067 } 5068 return nok(code) 5069 } 5070 function tagCloseStart(code) { 5071 if (asciiAlpha(code)) { 5072 effects.consume(code); 5073 buffer = String.fromCharCode(code); 5074 return tagName 5075 } 5076 return nok(code) 5077 } 5078 function tagName(code) { 5079 if ( 5080 code === null || 5081 code === 47 || 5082 code === 62 || 5083 markdownLineEndingOrSpace(code) 5084 ) { 5085 const slash = code === 47; 5086 const name = buffer.toLowerCase(); 5087 if (!slash && !closingTag && htmlRawNames.includes(name)) { 5088 marker = 1; 5089 return self.interrupt ? ok(code) : continuation(code) 5090 } 5091 if (htmlBlockNames.includes(buffer.toLowerCase())) { 5092 marker = 6; 5093 if (slash) { 5094 effects.consume(code); 5095 return basicSelfClosing 5096 } 5097 return self.interrupt ? ok(code) : continuation(code) 5098 } 5099 marker = 7; 5100 return self.interrupt && !self.parser.lazy[self.now().line] 5101 ? nok(code) 5102 : closingTag 5103 ? completeClosingTagAfter(code) 5104 : completeAttributeNameBefore(code) 5105 } 5106 if (code === 45 || asciiAlphanumeric(code)) { 5107 effects.consume(code); 5108 buffer += String.fromCharCode(code); 5109 return tagName 5110 } 5111 return nok(code) 5112 } 5113 function basicSelfClosing(code) { 5114 if (code === 62) { 5115 effects.consume(code); 5116 return self.interrupt ? ok : continuation 5117 } 5118 return nok(code) 5119 } 5120 function completeClosingTagAfter(code) { 5121 if (markdownSpace(code)) { 5122 effects.consume(code); 5123 return completeClosingTagAfter 5124 } 5125 return completeEnd(code) 5126 } 5127 function completeAttributeNameBefore(code) { 5128 if (code === 47) { 5129 effects.consume(code); 5130 return completeEnd 5131 } 5132 if (code === 58 || code === 95 || asciiAlpha(code)) { 5133 effects.consume(code); 5134 return completeAttributeName 5135 } 5136 if (markdownSpace(code)) { 5137 effects.consume(code); 5138 return completeAttributeNameBefore 5139 } 5140 return completeEnd(code) 5141 } 5142 function completeAttributeName(code) { 5143 if ( 5144 code === 45 || 5145 code === 46 || 5146 code === 58 || 5147 code === 95 || 5148 asciiAlphanumeric(code) 5149 ) { 5150 effects.consume(code); 5151 return completeAttributeName 5152 } 5153 return completeAttributeNameAfter(code) 5154 } 5155 function completeAttributeNameAfter(code) { 5156 if (code === 61) { 5157 effects.consume(code); 5158 return completeAttributeValueBefore 5159 } 5160 if (markdownSpace(code)) { 5161 effects.consume(code); 5162 return completeAttributeNameAfter 5163 } 5164 return completeAttributeNameBefore(code) 5165 } 5166 function completeAttributeValueBefore(code) { 5167 if ( 5168 code === null || 5169 code === 60 || 5170 code === 61 || 5171 code === 62 || 5172 code === 96 5173 ) { 5174 return nok(code) 5175 } 5176 if (code === 34 || code === 39) { 5177 effects.consume(code); 5178 markerB = code; 5179 return completeAttributeValueQuoted 5180 } 5181 if (markdownSpace(code)) { 5182 effects.consume(code); 5183 return completeAttributeValueBefore 5184 } 5185 return completeAttributeValueUnquoted(code) 5186 } 5187 function completeAttributeValueQuoted(code) { 5188 if (code === markerB) { 5189 effects.consume(code); 5190 markerB = null; 5191 return completeAttributeValueQuotedAfter 5192 } 5193 if (code === null || markdownLineEnding(code)) { 5194 return nok(code) 5195 } 5196 effects.consume(code); 5197 return completeAttributeValueQuoted 5198 } 5199 function completeAttributeValueUnquoted(code) { 5200 if ( 5201 code === null || 5202 code === 34 || 5203 code === 39 || 5204 code === 47 || 5205 code === 60 || 5206 code === 61 || 5207 code === 62 || 5208 code === 96 || 5209 markdownLineEndingOrSpace(code) 5210 ) { 5211 return completeAttributeNameAfter(code) 5212 } 5213 effects.consume(code); 5214 return completeAttributeValueUnquoted 5215 } 5216 function completeAttributeValueQuotedAfter(code) { 5217 if (code === 47 || code === 62 || markdownSpace(code)) { 5218 return completeAttributeNameBefore(code) 5219 } 5220 return nok(code) 5221 } 5222 function completeEnd(code) { 5223 if (code === 62) { 5224 effects.consume(code); 5225 return completeAfter 5226 } 5227 return nok(code) 5228 } 5229 function completeAfter(code) { 5230 if (code === null || markdownLineEnding(code)) { 5231 return continuation(code) 5232 } 5233 if (markdownSpace(code)) { 5234 effects.consume(code); 5235 return completeAfter 5236 } 5237 return nok(code) 5238 } 5239 function continuation(code) { 5240 if (code === 45 && marker === 2) { 5241 effects.consume(code); 5242 return continuationCommentInside 5243 } 5244 if (code === 60 && marker === 1) { 5245 effects.consume(code); 5246 return continuationRawTagOpen 5247 } 5248 if (code === 62 && marker === 4) { 5249 effects.consume(code); 5250 return continuationClose 5251 } 5252 if (code === 63 && marker === 3) { 5253 effects.consume(code); 5254 return continuationDeclarationInside 5255 } 5256 if (code === 93 && marker === 5) { 5257 effects.consume(code); 5258 return continuationCdataInside 5259 } 5260 if (markdownLineEnding(code) && (marker === 6 || marker === 7)) { 5261 effects.exit('htmlFlowData'); 5262 return effects.check( 5263 blankLineBefore, 5264 continuationAfter, 5265 continuationStart 5266 )(code) 5267 } 5268 if (code === null || markdownLineEnding(code)) { 5269 effects.exit('htmlFlowData'); 5270 return continuationStart(code) 5271 } 5272 effects.consume(code); 5273 return continuation 5274 } 5275 function continuationStart(code) { 5276 return effects.check( 5277 nonLazyContinuationStart, 5278 continuationStartNonLazy, 5279 continuationAfter 5280 )(code) 5281 } 5282 function continuationStartNonLazy(code) { 5283 effects.enter('lineEnding'); 5284 effects.consume(code); 5285 effects.exit('lineEnding'); 5286 return continuationBefore 5287 } 5288 function continuationBefore(code) { 5289 if (code === null || markdownLineEnding(code)) { 5290 return continuationStart(code) 5291 } 5292 effects.enter('htmlFlowData'); 5293 return continuation(code) 5294 } 5295 function continuationCommentInside(code) { 5296 if (code === 45) { 5297 effects.consume(code); 5298 return continuationDeclarationInside 5299 } 5300 return continuation(code) 5301 } 5302 function continuationRawTagOpen(code) { 5303 if (code === 47) { 5304 effects.consume(code); 5305 buffer = ''; 5306 return continuationRawEndTag 5307 } 5308 return continuation(code) 5309 } 5310 function continuationRawEndTag(code) { 5311 if (code === 62) { 5312 const name = buffer.toLowerCase(); 5313 if (htmlRawNames.includes(name)) { 5314 effects.consume(code); 5315 return continuationClose 5316 } 5317 return continuation(code) 5318 } 5319 if (asciiAlpha(code) && buffer.length < 8) { 5320 effects.consume(code); 5321 buffer += String.fromCharCode(code); 5322 return continuationRawEndTag 5323 } 5324 return continuation(code) 5325 } 5326 function continuationCdataInside(code) { 5327 if (code === 93) { 5328 effects.consume(code); 5329 return continuationDeclarationInside 5330 } 5331 return continuation(code) 5332 } 5333 function continuationDeclarationInside(code) { 5334 if (code === 62) { 5335 effects.consume(code); 5336 return continuationClose 5337 } 5338 if (code === 45 && marker === 2) { 5339 effects.consume(code); 5340 return continuationDeclarationInside 5341 } 5342 return continuation(code) 5343 } 5344 function continuationClose(code) { 5345 if (code === null || markdownLineEnding(code)) { 5346 effects.exit('htmlFlowData'); 5347 return continuationAfter(code) 5348 } 5349 effects.consume(code); 5350 return continuationClose 5351 } 5352 function continuationAfter(code) { 5353 effects.exit('htmlFlow'); 5354 return ok(code) 5355 } 5356} 5357function tokenizeNonLazyContinuationStart(effects, ok, nok) { 5358 const self = this; 5359 return start 5360 function start(code) { 5361 if (markdownLineEnding(code)) { 5362 effects.enter('lineEnding'); 5363 effects.consume(code); 5364 effects.exit('lineEnding'); 5365 return after 5366 } 5367 return nok(code) 5368 } 5369 function after(code) { 5370 return self.parser.lazy[self.now().line] ? nok(code) : ok(code) 5371 } 5372} 5373function tokenizeBlankLineBefore(effects, ok, nok) { 5374 return start 5375 function start(code) { 5376 effects.enter('lineEnding'); 5377 effects.consume(code); 5378 effects.exit('lineEnding'); 5379 return effects.attempt(blankLine, ok, nok) 5380 } 5381} 5382 5383const htmlText = { 5384 name: 'htmlText', 5385 tokenize: tokenizeHtmlText 5386}; 5387function tokenizeHtmlText(effects, ok, nok) { 5388 const self = this; 5389 let marker; 5390 let index; 5391 let returnState; 5392 return start 5393 function start(code) { 5394 effects.enter('htmlText'); 5395 effects.enter('htmlTextData'); 5396 effects.consume(code); 5397 return open 5398 } 5399 function open(code) { 5400 if (code === 33) { 5401 effects.consume(code); 5402 return declarationOpen 5403 } 5404 if (code === 47) { 5405 effects.consume(code); 5406 return tagCloseStart 5407 } 5408 if (code === 63) { 5409 effects.consume(code); 5410 return instruction 5411 } 5412 if (asciiAlpha(code)) { 5413 effects.consume(code); 5414 return tagOpen 5415 } 5416 return nok(code) 5417 } 5418 function declarationOpen(code) { 5419 if (code === 45) { 5420 effects.consume(code); 5421 return commentOpenInside 5422 } 5423 if (code === 91) { 5424 effects.consume(code); 5425 index = 0; 5426 return cdataOpenInside 5427 } 5428 if (asciiAlpha(code)) { 5429 effects.consume(code); 5430 return declaration 5431 } 5432 return nok(code) 5433 } 5434 function commentOpenInside(code) { 5435 if (code === 45) { 5436 effects.consume(code); 5437 return commentEnd 5438 } 5439 return nok(code) 5440 } 5441 function comment(code) { 5442 if (code === null) { 5443 return nok(code) 5444 } 5445 if (code === 45) { 5446 effects.consume(code); 5447 return commentClose 5448 } 5449 if (markdownLineEnding(code)) { 5450 returnState = comment; 5451 return lineEndingBefore(code) 5452 } 5453 effects.consume(code); 5454 return comment 5455 } 5456 function commentClose(code) { 5457 if (code === 45) { 5458 effects.consume(code); 5459 return commentEnd 5460 } 5461 return comment(code) 5462 } 5463 function commentEnd(code) { 5464 return code === 62 5465 ? end(code) 5466 : code === 45 5467 ? commentClose(code) 5468 : comment(code) 5469 } 5470 function cdataOpenInside(code) { 5471 const value = 'CDATA['; 5472 if (code === value.charCodeAt(index++)) { 5473 effects.consume(code); 5474 return index === value.length ? cdata : cdataOpenInside 5475 } 5476 return nok(code) 5477 } 5478 function cdata(code) { 5479 if (code === null) { 5480 return nok(code) 5481 } 5482 if (code === 93) { 5483 effects.consume(code); 5484 return cdataClose 5485 } 5486 if (markdownLineEnding(code)) { 5487 returnState = cdata; 5488 return lineEndingBefore(code) 5489 } 5490 effects.consume(code); 5491 return cdata 5492 } 5493 function cdataClose(code) { 5494 if (code === 93) { 5495 effects.consume(code); 5496 return cdataEnd 5497 } 5498 return cdata(code) 5499 } 5500 function cdataEnd(code) { 5501 if (code === 62) { 5502 return end(code) 5503 } 5504 if (code === 93) { 5505 effects.consume(code); 5506 return cdataEnd 5507 } 5508 return cdata(code) 5509 } 5510 function declaration(code) { 5511 if (code === null || code === 62) { 5512 return end(code) 5513 } 5514 if (markdownLineEnding(code)) { 5515 returnState = declaration; 5516 return lineEndingBefore(code) 5517 } 5518 effects.consume(code); 5519 return declaration 5520 } 5521 function instruction(code) { 5522 if (code === null) { 5523 return nok(code) 5524 } 5525 if (code === 63) { 5526 effects.consume(code); 5527 return instructionClose 5528 } 5529 if (markdownLineEnding(code)) { 5530 returnState = instruction; 5531 return lineEndingBefore(code) 5532 } 5533 effects.consume(code); 5534 return instruction 5535 } 5536 function instructionClose(code) { 5537 return code === 62 ? end(code) : instruction(code) 5538 } 5539 function tagCloseStart(code) { 5540 if (asciiAlpha(code)) { 5541 effects.consume(code); 5542 return tagClose 5543 } 5544 return nok(code) 5545 } 5546 function tagClose(code) { 5547 if (code === 45 || asciiAlphanumeric(code)) { 5548 effects.consume(code); 5549 return tagClose 5550 } 5551 return tagCloseBetween(code) 5552 } 5553 function tagCloseBetween(code) { 5554 if (markdownLineEnding(code)) { 5555 returnState = tagCloseBetween; 5556 return lineEndingBefore(code) 5557 } 5558 if (markdownSpace(code)) { 5559 effects.consume(code); 5560 return tagCloseBetween 5561 } 5562 return end(code) 5563 } 5564 function tagOpen(code) { 5565 if (code === 45 || asciiAlphanumeric(code)) { 5566 effects.consume(code); 5567 return tagOpen 5568 } 5569 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { 5570 return tagOpenBetween(code) 5571 } 5572 return nok(code) 5573 } 5574 function tagOpenBetween(code) { 5575 if (code === 47) { 5576 effects.consume(code); 5577 return end 5578 } 5579 if (code === 58 || code === 95 || asciiAlpha(code)) { 5580 effects.consume(code); 5581 return tagOpenAttributeName 5582 } 5583 if (markdownLineEnding(code)) { 5584 returnState = tagOpenBetween; 5585 return lineEndingBefore(code) 5586 } 5587 if (markdownSpace(code)) { 5588 effects.consume(code); 5589 return tagOpenBetween 5590 } 5591 return end(code) 5592 } 5593 function tagOpenAttributeName(code) { 5594 if ( 5595 code === 45 || 5596 code === 46 || 5597 code === 58 || 5598 code === 95 || 5599 asciiAlphanumeric(code) 5600 ) { 5601 effects.consume(code); 5602 return tagOpenAttributeName 5603 } 5604 return tagOpenAttributeNameAfter(code) 5605 } 5606 function tagOpenAttributeNameAfter(code) { 5607 if (code === 61) { 5608 effects.consume(code); 5609 return tagOpenAttributeValueBefore 5610 } 5611 if (markdownLineEnding(code)) { 5612 returnState = tagOpenAttributeNameAfter; 5613 return lineEndingBefore(code) 5614 } 5615 if (markdownSpace(code)) { 5616 effects.consume(code); 5617 return tagOpenAttributeNameAfter 5618 } 5619 return tagOpenBetween(code) 5620 } 5621 function tagOpenAttributeValueBefore(code) { 5622 if ( 5623 code === null || 5624 code === 60 || 5625 code === 61 || 5626 code === 62 || 5627 code === 96 5628 ) { 5629 return nok(code) 5630 } 5631 if (code === 34 || code === 39) { 5632 effects.consume(code); 5633 marker = code; 5634 return tagOpenAttributeValueQuoted 5635 } 5636 if (markdownLineEnding(code)) { 5637 returnState = tagOpenAttributeValueBefore; 5638 return lineEndingBefore(code) 5639 } 5640 if (markdownSpace(code)) { 5641 effects.consume(code); 5642 return tagOpenAttributeValueBefore 5643 } 5644 effects.consume(code); 5645 return tagOpenAttributeValueUnquoted 5646 } 5647 function tagOpenAttributeValueQuoted(code) { 5648 if (code === marker) { 5649 effects.consume(code); 5650 marker = undefined; 5651 return tagOpenAttributeValueQuotedAfter 5652 } 5653 if (code === null) { 5654 return nok(code) 5655 } 5656 if (markdownLineEnding(code)) { 5657 returnState = tagOpenAttributeValueQuoted; 5658 return lineEndingBefore(code) 5659 } 5660 effects.consume(code); 5661 return tagOpenAttributeValueQuoted 5662 } 5663 function tagOpenAttributeValueUnquoted(code) { 5664 if ( 5665 code === null || 5666 code === 34 || 5667 code === 39 || 5668 code === 60 || 5669 code === 61 || 5670 code === 96 5671 ) { 5672 return nok(code) 5673 } 5674 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { 5675 return tagOpenBetween(code) 5676 } 5677 effects.consume(code); 5678 return tagOpenAttributeValueUnquoted 5679 } 5680 function tagOpenAttributeValueQuotedAfter(code) { 5681 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { 5682 return tagOpenBetween(code) 5683 } 5684 return nok(code) 5685 } 5686 function end(code) { 5687 if (code === 62) { 5688 effects.consume(code); 5689 effects.exit('htmlTextData'); 5690 effects.exit('htmlText'); 5691 return ok 5692 } 5693 return nok(code) 5694 } 5695 function lineEndingBefore(code) { 5696 effects.exit('htmlTextData'); 5697 effects.enter('lineEnding'); 5698 effects.consume(code); 5699 effects.exit('lineEnding'); 5700 return lineEndingAfter 5701 } 5702 function lineEndingAfter(code) { 5703 return markdownSpace(code) 5704 ? factorySpace( 5705 effects, 5706 lineEndingAfterPrefix, 5707 'linePrefix', 5708 self.parser.constructs.disable.null.includes('codeIndented') 5709 ? undefined 5710 : 4 5711 )(code) 5712 : lineEndingAfterPrefix(code) 5713 } 5714 function lineEndingAfterPrefix(code) { 5715 effects.enter('htmlTextData'); 5716 return returnState(code) 5717 } 5718} 5719 5720const labelEnd = { 5721 name: 'labelEnd', 5722 tokenize: tokenizeLabelEnd, 5723 resolveTo: resolveToLabelEnd, 5724 resolveAll: resolveAllLabelEnd 5725}; 5726const resourceConstruct = { 5727 tokenize: tokenizeResource 5728}; 5729const referenceFullConstruct = { 5730 tokenize: tokenizeReferenceFull 5731}; 5732const referenceCollapsedConstruct = { 5733 tokenize: tokenizeReferenceCollapsed 5734}; 5735function resolveAllLabelEnd(events) { 5736 let index = -1; 5737 while (++index < events.length) { 5738 const token = events[index][1]; 5739 if ( 5740 token.type === 'labelImage' || 5741 token.type === 'labelLink' || 5742 token.type === 'labelEnd' 5743 ) { 5744 events.splice(index + 1, token.type === 'labelImage' ? 4 : 2); 5745 token.type = 'data'; 5746 index++; 5747 } 5748 } 5749 return events 5750} 5751function resolveToLabelEnd(events, context) { 5752 let index = events.length; 5753 let offset = 0; 5754 let token; 5755 let open; 5756 let close; 5757 let media; 5758 while (index--) { 5759 token = events[index][1]; 5760 if (open) { 5761 if ( 5762 token.type === 'link' || 5763 (token.type === 'labelLink' && token._inactive) 5764 ) { 5765 break 5766 } 5767 if (events[index][0] === 'enter' && token.type === 'labelLink') { 5768 token._inactive = true; 5769 } 5770 } else if (close) { 5771 if ( 5772 events[index][0] === 'enter' && 5773 (token.type === 'labelImage' || token.type === 'labelLink') && 5774 !token._balanced 5775 ) { 5776 open = index; 5777 if (token.type !== 'labelLink') { 5778 offset = 2; 5779 break 5780 } 5781 } 5782 } else if (token.type === 'labelEnd') { 5783 close = index; 5784 } 5785 } 5786 const group = { 5787 type: events[open][1].type === 'labelLink' ? 'link' : 'image', 5788 start: Object.assign({}, events[open][1].start), 5789 end: Object.assign({}, events[events.length - 1][1].end) 5790 }; 5791 const label = { 5792 type: 'label', 5793 start: Object.assign({}, events[open][1].start), 5794 end: Object.assign({}, events[close][1].end) 5795 }; 5796 const text = { 5797 type: 'labelText', 5798 start: Object.assign({}, events[open + offset + 2][1].end), 5799 end: Object.assign({}, events[close - 2][1].start) 5800 }; 5801 media = [ 5802 ['enter', group, context], 5803 ['enter', label, context] 5804 ]; 5805 media = push(media, events.slice(open + 1, open + offset + 3)); 5806 media = push(media, [['enter', text, context]]); 5807 media = push( 5808 media, 5809 resolveAll( 5810 context.parser.constructs.insideSpan.null, 5811 events.slice(open + offset + 4, close - 3), 5812 context 5813 ) 5814 ); 5815 media = push(media, [ 5816 ['exit', text, context], 5817 events[close - 2], 5818 events[close - 1], 5819 ['exit', label, context] 5820 ]); 5821 media = push(media, events.slice(close + 1)); 5822 media = push(media, [['exit', group, context]]); 5823 splice(events, open, events.length, media); 5824 return events 5825} 5826function tokenizeLabelEnd(effects, ok, nok) { 5827 const self = this; 5828 let index = self.events.length; 5829 let labelStart; 5830 let defined; 5831 while (index--) { 5832 if ( 5833 (self.events[index][1].type === 'labelImage' || 5834 self.events[index][1].type === 'labelLink') && 5835 !self.events[index][1]._balanced 5836 ) { 5837 labelStart = self.events[index][1]; 5838 break 5839 } 5840 } 5841 return start 5842 function start(code) { 5843 if (!labelStart) { 5844 return nok(code) 5845 } 5846 if (labelStart._inactive) { 5847 return labelEndNok(code) 5848 } 5849 defined = self.parser.defined.includes( 5850 normalizeIdentifier( 5851 self.sliceSerialize({ 5852 start: labelStart.end, 5853 end: self.now() 5854 }) 5855 ) 5856 ); 5857 effects.enter('labelEnd'); 5858 effects.enter('labelMarker'); 5859 effects.consume(code); 5860 effects.exit('labelMarker'); 5861 effects.exit('labelEnd'); 5862 return after 5863 } 5864 function after(code) { 5865 if (code === 40) { 5866 return effects.attempt( 5867 resourceConstruct, 5868 labelEndOk, 5869 defined ? labelEndOk : labelEndNok 5870 )(code) 5871 } 5872 if (code === 91) { 5873 return effects.attempt( 5874 referenceFullConstruct, 5875 labelEndOk, 5876 defined ? referenceNotFull : labelEndNok 5877 )(code) 5878 } 5879 return defined ? labelEndOk(code) : labelEndNok(code) 5880 } 5881 function referenceNotFull(code) { 5882 return effects.attempt( 5883 referenceCollapsedConstruct, 5884 labelEndOk, 5885 labelEndNok 5886 )(code) 5887 } 5888 function labelEndOk(code) { 5889 return ok(code) 5890 } 5891 function labelEndNok(code) { 5892 labelStart._balanced = true; 5893 return nok(code) 5894 } 5895} 5896function tokenizeResource(effects, ok, nok) { 5897 return resourceStart 5898 function resourceStart(code) { 5899 effects.enter('resource'); 5900 effects.enter('resourceMarker'); 5901 effects.consume(code); 5902 effects.exit('resourceMarker'); 5903 return resourceBefore 5904 } 5905 function resourceBefore(code) { 5906 return markdownLineEndingOrSpace(code) 5907 ? factoryWhitespace(effects, resourceOpen)(code) 5908 : resourceOpen(code) 5909 } 5910 function resourceOpen(code) { 5911 if (code === 41) { 5912 return resourceEnd(code) 5913 } 5914 return factoryDestination( 5915 effects, 5916 resourceDestinationAfter, 5917 resourceDestinationMissing, 5918 'resourceDestination', 5919 'resourceDestinationLiteral', 5920 'resourceDestinationLiteralMarker', 5921 'resourceDestinationRaw', 5922 'resourceDestinationString', 5923 32 5924 )(code) 5925 } 5926 function resourceDestinationAfter(code) { 5927 return markdownLineEndingOrSpace(code) 5928 ? factoryWhitespace(effects, resourceBetween)(code) 5929 : resourceEnd(code) 5930 } 5931 function resourceDestinationMissing(code) { 5932 return nok(code) 5933 } 5934 function resourceBetween(code) { 5935 if (code === 34 || code === 39 || code === 40) { 5936 return factoryTitle( 5937 effects, 5938 resourceTitleAfter, 5939 nok, 5940 'resourceTitle', 5941 'resourceTitleMarker', 5942 'resourceTitleString' 5943 )(code) 5944 } 5945 return resourceEnd(code) 5946 } 5947 function resourceTitleAfter(code) { 5948 return markdownLineEndingOrSpace(code) 5949 ? factoryWhitespace(effects, resourceEnd)(code) 5950 : resourceEnd(code) 5951 } 5952 function resourceEnd(code) { 5953 if (code === 41) { 5954 effects.enter('resourceMarker'); 5955 effects.consume(code); 5956 effects.exit('resourceMarker'); 5957 effects.exit('resource'); 5958 return ok 5959 } 5960 return nok(code) 5961 } 5962} 5963function tokenizeReferenceFull(effects, ok, nok) { 5964 const self = this; 5965 return referenceFull 5966 function referenceFull(code) { 5967 return factoryLabel.call( 5968 self, 5969 effects, 5970 referenceFullAfter, 5971 referenceFullMissing, 5972 'reference', 5973 'referenceMarker', 5974 'referenceString' 5975 )(code) 5976 } 5977 function referenceFullAfter(code) { 5978 return self.parser.defined.includes( 5979 normalizeIdentifier( 5980 self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) 5981 ) 5982 ) 5983 ? ok(code) 5984 : nok(code) 5985 } 5986 function referenceFullMissing(code) { 5987 return nok(code) 5988 } 5989} 5990function tokenizeReferenceCollapsed(effects, ok, nok) { 5991 return referenceCollapsedStart 5992 function referenceCollapsedStart(code) { 5993 effects.enter('reference'); 5994 effects.enter('referenceMarker'); 5995 effects.consume(code); 5996 effects.exit('referenceMarker'); 5997 return referenceCollapsedOpen 5998 } 5999 function referenceCollapsedOpen(code) { 6000 if (code === 93) { 6001 effects.enter('referenceMarker'); 6002 effects.consume(code); 6003 effects.exit('referenceMarker'); 6004 effects.exit('reference'); 6005 return ok 6006 } 6007 return nok(code) 6008 } 6009} 6010 6011const labelStartImage = { 6012 name: 'labelStartImage', 6013 tokenize: tokenizeLabelStartImage, 6014 resolveAll: labelEnd.resolveAll 6015}; 6016function tokenizeLabelStartImage(effects, ok, nok) { 6017 const self = this; 6018 return start 6019 function start(code) { 6020 effects.enter('labelImage'); 6021 effects.enter('labelImageMarker'); 6022 effects.consume(code); 6023 effects.exit('labelImageMarker'); 6024 return open 6025 } 6026 function open(code) { 6027 if (code === 91) { 6028 effects.enter('labelMarker'); 6029 effects.consume(code); 6030 effects.exit('labelMarker'); 6031 effects.exit('labelImage'); 6032 return after 6033 } 6034 return nok(code) 6035 } 6036 function after(code) { 6037 return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs 6038 ? nok(code) 6039 : ok(code) 6040 } 6041} 6042 6043const labelStartLink = { 6044 name: 'labelStartLink', 6045 tokenize: tokenizeLabelStartLink, 6046 resolveAll: labelEnd.resolveAll 6047}; 6048function tokenizeLabelStartLink(effects, ok, nok) { 6049 const self = this; 6050 return start 6051 function start(code) { 6052 effects.enter('labelLink'); 6053 effects.enter('labelMarker'); 6054 effects.consume(code); 6055 effects.exit('labelMarker'); 6056 effects.exit('labelLink'); 6057 return after 6058 } 6059 function after(code) { 6060 return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs 6061 ? nok(code) 6062 : ok(code) 6063 } 6064} 6065 6066const lineEnding = { 6067 name: 'lineEnding', 6068 tokenize: tokenizeLineEnding 6069}; 6070function tokenizeLineEnding(effects, ok) { 6071 return start 6072 function start(code) { 6073 effects.enter('lineEnding'); 6074 effects.consume(code); 6075 effects.exit('lineEnding'); 6076 return factorySpace(effects, ok, 'linePrefix') 6077 } 6078} 6079 6080const thematicBreak$1 = { 6081 name: 'thematicBreak', 6082 tokenize: tokenizeThematicBreak 6083}; 6084function tokenizeThematicBreak(effects, ok, nok) { 6085 let size = 0; 6086 let marker; 6087 return start 6088 function start(code) { 6089 effects.enter('thematicBreak'); 6090 return before(code) 6091 } 6092 function before(code) { 6093 marker = code; 6094 return atBreak(code) 6095 } 6096 function atBreak(code) { 6097 if (code === marker) { 6098 effects.enter('thematicBreakSequence'); 6099 return sequence(code) 6100 } 6101 if (size >= 3 && (code === null || markdownLineEnding(code))) { 6102 effects.exit('thematicBreak'); 6103 return ok(code) 6104 } 6105 return nok(code) 6106 } 6107 function sequence(code) { 6108 if (code === marker) { 6109 effects.consume(code); 6110 size++; 6111 return sequence 6112 } 6113 effects.exit('thematicBreakSequence'); 6114 return markdownSpace(code) 6115 ? factorySpace(effects, atBreak, 'whitespace')(code) 6116 : atBreak(code) 6117 } 6118} 6119 6120const list$1 = { 6121 name: 'list', 6122 tokenize: tokenizeListStart, 6123 continuation: { 6124 tokenize: tokenizeListContinuation 6125 }, 6126 exit: tokenizeListEnd 6127}; 6128const listItemPrefixWhitespaceConstruct = { 6129 tokenize: tokenizeListItemPrefixWhitespace, 6130 partial: true 6131}; 6132const indentConstruct = { 6133 tokenize: tokenizeIndent$1, 6134 partial: true 6135}; 6136function tokenizeListStart(effects, ok, nok) { 6137 const self = this; 6138 const tail = self.events[self.events.length - 1]; 6139 let initialSize = 6140 tail && tail[1].type === 'linePrefix' 6141 ? tail[2].sliceSerialize(tail[1], true).length 6142 : 0; 6143 let size = 0; 6144 return start 6145 function start(code) { 6146 const kind = 6147 self.containerState.type || 6148 (code === 42 || code === 43 || code === 45 6149 ? 'listUnordered' 6150 : 'listOrdered'); 6151 if ( 6152 kind === 'listUnordered' 6153 ? !self.containerState.marker || code === self.containerState.marker 6154 : asciiDigit(code) 6155 ) { 6156 if (!self.containerState.type) { 6157 self.containerState.type = kind; 6158 effects.enter(kind, { 6159 _container: true 6160 }); 6161 } 6162 if (kind === 'listUnordered') { 6163 effects.enter('listItemPrefix'); 6164 return code === 42 || code === 45 6165 ? effects.check(thematicBreak$1, nok, atMarker)(code) 6166 : atMarker(code) 6167 } 6168 if (!self.interrupt || code === 49) { 6169 effects.enter('listItemPrefix'); 6170 effects.enter('listItemValue'); 6171 return inside(code) 6172 } 6173 } 6174 return nok(code) 6175 } 6176 function inside(code) { 6177 if (asciiDigit(code) && ++size < 10) { 6178 effects.consume(code); 6179 return inside 6180 } 6181 if ( 6182 (!self.interrupt || size < 2) && 6183 (self.containerState.marker 6184 ? code === self.containerState.marker 6185 : code === 41 || code === 46) 6186 ) { 6187 effects.exit('listItemValue'); 6188 return atMarker(code) 6189 } 6190 return nok(code) 6191 } 6192 function atMarker(code) { 6193 effects.enter('listItemMarker'); 6194 effects.consume(code); 6195 effects.exit('listItemMarker'); 6196 self.containerState.marker = self.containerState.marker || code; 6197 return effects.check( 6198 blankLine, 6199 self.interrupt ? nok : onBlank, 6200 effects.attempt( 6201 listItemPrefixWhitespaceConstruct, 6202 endOfPrefix, 6203 otherPrefix 6204 ) 6205 ) 6206 } 6207 function onBlank(code) { 6208 self.containerState.initialBlankLine = true; 6209 initialSize++; 6210 return endOfPrefix(code) 6211 } 6212 function otherPrefix(code) { 6213 if (markdownSpace(code)) { 6214 effects.enter('listItemPrefixWhitespace'); 6215 effects.consume(code); 6216 effects.exit('listItemPrefixWhitespace'); 6217 return endOfPrefix 6218 } 6219 return nok(code) 6220 } 6221 function endOfPrefix(code) { 6222 self.containerState.size = 6223 initialSize + 6224 self.sliceSerialize(effects.exit('listItemPrefix'), true).length; 6225 return ok(code) 6226 } 6227} 6228function tokenizeListContinuation(effects, ok, nok) { 6229 const self = this; 6230 self.containerState._closeFlow = undefined; 6231 return effects.check(blankLine, onBlank, notBlank) 6232 function onBlank(code) { 6233 self.containerState.furtherBlankLines = 6234 self.containerState.furtherBlankLines || 6235 self.containerState.initialBlankLine; 6236 return factorySpace( 6237 effects, 6238 ok, 6239 'listItemIndent', 6240 self.containerState.size + 1 6241 )(code) 6242 } 6243 function notBlank(code) { 6244 if (self.containerState.furtherBlankLines || !markdownSpace(code)) { 6245 self.containerState.furtherBlankLines = undefined; 6246 self.containerState.initialBlankLine = undefined; 6247 return notInCurrentItem(code) 6248 } 6249 self.containerState.furtherBlankLines = undefined; 6250 self.containerState.initialBlankLine = undefined; 6251 return effects.attempt(indentConstruct, ok, notInCurrentItem)(code) 6252 } 6253 function notInCurrentItem(code) { 6254 self.containerState._closeFlow = true; 6255 self.interrupt = undefined; 6256 return factorySpace( 6257 effects, 6258 effects.attempt(list$1, ok, nok), 6259 'linePrefix', 6260 self.parser.constructs.disable.null.includes('codeIndented') 6261 ? undefined 6262 : 4 6263 )(code) 6264 } 6265} 6266function tokenizeIndent$1(effects, ok, nok) { 6267 const self = this; 6268 return factorySpace( 6269 effects, 6270 afterPrefix, 6271 'listItemIndent', 6272 self.containerState.size + 1 6273 ) 6274 function afterPrefix(code) { 6275 const tail = self.events[self.events.length - 1]; 6276 return tail && 6277 tail[1].type === 'listItemIndent' && 6278 tail[2].sliceSerialize(tail[1], true).length === self.containerState.size 6279 ? ok(code) 6280 : nok(code) 6281 } 6282} 6283function tokenizeListEnd(effects) { 6284 effects.exit(this.containerState.type); 6285} 6286function tokenizeListItemPrefixWhitespace(effects, ok, nok) { 6287 const self = this; 6288 return factorySpace( 6289 effects, 6290 afterPrefix, 6291 'listItemPrefixWhitespace', 6292 self.parser.constructs.disable.null.includes('codeIndented') 6293 ? undefined 6294 : 4 + 1 6295 ) 6296 function afterPrefix(code) { 6297 const tail = self.events[self.events.length - 1]; 6298 return !markdownSpace(code) && 6299 tail && 6300 tail[1].type === 'listItemPrefixWhitespace' 6301 ? ok(code) 6302 : nok(code) 6303 } 6304} 6305 6306const setextUnderline = { 6307 name: 'setextUnderline', 6308 tokenize: tokenizeSetextUnderline, 6309 resolveTo: resolveToSetextUnderline 6310}; 6311function resolveToSetextUnderline(events, context) { 6312 let index = events.length; 6313 let content; 6314 let text; 6315 let definition; 6316 while (index--) { 6317 if (events[index][0] === 'enter') { 6318 if (events[index][1].type === 'content') { 6319 content = index; 6320 break 6321 } 6322 if (events[index][1].type === 'paragraph') { 6323 text = index; 6324 } 6325 } 6326 else { 6327 if (events[index][1].type === 'content') { 6328 events.splice(index, 1); 6329 } 6330 if (!definition && events[index][1].type === 'definition') { 6331 definition = index; 6332 } 6333 } 6334 } 6335 const heading = { 6336 type: 'setextHeading', 6337 start: Object.assign({}, events[text][1].start), 6338 end: Object.assign({}, events[events.length - 1][1].end) 6339 }; 6340 events[text][1].type = 'setextHeadingText'; 6341 if (definition) { 6342 events.splice(text, 0, ['enter', heading, context]); 6343 events.splice(definition + 1, 0, ['exit', events[content][1], context]); 6344 events[content][1].end = Object.assign({}, events[definition][1].end); 6345 } else { 6346 events[content][1] = heading; 6347 } 6348 events.push(['exit', heading, context]); 6349 return events 6350} 6351function tokenizeSetextUnderline(effects, ok, nok) { 6352 const self = this; 6353 let marker; 6354 return start 6355 function start(code) { 6356 let index = self.events.length; 6357 let paragraph; 6358 while (index--) { 6359 if ( 6360 self.events[index][1].type !== 'lineEnding' && 6361 self.events[index][1].type !== 'linePrefix' && 6362 self.events[index][1].type !== 'content' 6363 ) { 6364 paragraph = self.events[index][1].type === 'paragraph'; 6365 break 6366 } 6367 } 6368 if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) { 6369 effects.enter('setextHeadingLine'); 6370 marker = code; 6371 return before(code) 6372 } 6373 return nok(code) 6374 } 6375 function before(code) { 6376 effects.enter('setextHeadingLineSequence'); 6377 return inside(code) 6378 } 6379 function inside(code) { 6380 if (code === marker) { 6381 effects.consume(code); 6382 return inside 6383 } 6384 effects.exit('setextHeadingLineSequence'); 6385 return markdownSpace(code) 6386 ? factorySpace(effects, after, 'lineSuffix')(code) 6387 : after(code) 6388 } 6389 function after(code) { 6390 if (code === null || markdownLineEnding(code)) { 6391 effects.exit('setextHeadingLine'); 6392 return ok(code) 6393 } 6394 return nok(code) 6395 } 6396} 6397 6398const flow$1 = { 6399 tokenize: initializeFlow 6400}; 6401function initializeFlow(effects) { 6402 const self = this; 6403 const initial = effects.attempt( 6404 blankLine, 6405 atBlankEnding, 6406 effects.attempt( 6407 this.parser.constructs.flowInitial, 6408 afterConstruct, 6409 factorySpace( 6410 effects, 6411 effects.attempt( 6412 this.parser.constructs.flow, 6413 afterConstruct, 6414 effects.attempt(content, afterConstruct) 6415 ), 6416 'linePrefix' 6417 ) 6418 ) 6419 ); 6420 return initial 6421 function atBlankEnding(code) { 6422 if (code === null) { 6423 effects.consume(code); 6424 return 6425 } 6426 effects.enter('lineEndingBlank'); 6427 effects.consume(code); 6428 effects.exit('lineEndingBlank'); 6429 self.currentConstruct = undefined; 6430 return initial 6431 } 6432 function afterConstruct(code) { 6433 if (code === null) { 6434 effects.consume(code); 6435 return 6436 } 6437 effects.enter('lineEnding'); 6438 effects.consume(code); 6439 effects.exit('lineEnding'); 6440 self.currentConstruct = undefined; 6441 return initial 6442 } 6443} 6444 6445const resolver = { 6446 resolveAll: createResolver() 6447}; 6448const string$1 = initializeFactory('string'); 6449const text$3 = initializeFactory('text'); 6450function initializeFactory(field) { 6451 return { 6452 tokenize: initializeText, 6453 resolveAll: createResolver( 6454 field === 'text' ? resolveAllLineSuffixes : undefined 6455 ) 6456 } 6457 function initializeText(effects) { 6458 const self = this; 6459 const constructs = this.parser.constructs[field]; 6460 const text = effects.attempt(constructs, start, notText); 6461 return start 6462 function start(code) { 6463 return atBreak(code) ? text(code) : notText(code) 6464 } 6465 function notText(code) { 6466 if (code === null) { 6467 effects.consume(code); 6468 return 6469 } 6470 effects.enter('data'); 6471 effects.consume(code); 6472 return data 6473 } 6474 function data(code) { 6475 if (atBreak(code)) { 6476 effects.exit('data'); 6477 return text(code) 6478 } 6479 effects.consume(code); 6480 return data 6481 } 6482 function atBreak(code) { 6483 if (code === null) { 6484 return true 6485 } 6486 const list = constructs[code]; 6487 let index = -1; 6488 if (list) { 6489 while (++index < list.length) { 6490 const item = list[index]; 6491 if (!item.previous || item.previous.call(self, self.previous)) { 6492 return true 6493 } 6494 } 6495 } 6496 return false 6497 } 6498 } 6499} 6500function createResolver(extraResolver) { 6501 return resolveAllText 6502 function resolveAllText(events, context) { 6503 let index = -1; 6504 let enter; 6505 while (++index <= events.length) { 6506 if (enter === undefined) { 6507 if (events[index] && events[index][1].type === 'data') { 6508 enter = index; 6509 index++; 6510 } 6511 } else if (!events[index] || events[index][1].type !== 'data') { 6512 if (index !== enter + 2) { 6513 events[enter][1].end = events[index - 1][1].end; 6514 events.splice(enter + 2, index - enter - 2); 6515 index = enter + 2; 6516 } 6517 enter = undefined; 6518 } 6519 } 6520 return extraResolver ? extraResolver(events, context) : events 6521 } 6522} 6523function resolveAllLineSuffixes(events, context) { 6524 let eventIndex = 0; 6525 while (++eventIndex <= events.length) { 6526 if ( 6527 (eventIndex === events.length || 6528 events[eventIndex][1].type === 'lineEnding') && 6529 events[eventIndex - 1][1].type === 'data' 6530 ) { 6531 const data = events[eventIndex - 1][1]; 6532 const chunks = context.sliceStream(data); 6533 let index = chunks.length; 6534 let bufferIndex = -1; 6535 let size = 0; 6536 let tabs; 6537 while (index--) { 6538 const chunk = chunks[index]; 6539 if (typeof chunk === 'string') { 6540 bufferIndex = chunk.length; 6541 while (chunk.charCodeAt(bufferIndex - 1) === 32) { 6542 size++; 6543 bufferIndex--; 6544 } 6545 if (bufferIndex) break 6546 bufferIndex = -1; 6547 } 6548 else if (chunk === -2) { 6549 tabs = true; 6550 size++; 6551 } else if (chunk === -1) ; else { 6552 index++; 6553 break 6554 } 6555 } 6556 if (size) { 6557 const token = { 6558 type: 6559 eventIndex === events.length || tabs || size < 2 6560 ? 'lineSuffix' 6561 : 'hardBreakTrailing', 6562 start: { 6563 line: data.end.line, 6564 column: data.end.column - size, 6565 offset: data.end.offset - size, 6566 _index: data.start._index + index, 6567 _bufferIndex: index 6568 ? bufferIndex 6569 : data.start._bufferIndex + bufferIndex 6570 }, 6571 end: Object.assign({}, data.end) 6572 }; 6573 data.end = Object.assign({}, token.start); 6574 if (data.start.offset === data.end.offset) { 6575 Object.assign(data, token); 6576 } else { 6577 events.splice( 6578 eventIndex, 6579 0, 6580 ['enter', token, context], 6581 ['exit', token, context] 6582 ); 6583 eventIndex += 2; 6584 } 6585 } 6586 eventIndex++; 6587 } 6588 } 6589 return events 6590} 6591 6592function createTokenizer(parser, initialize, from) { 6593 let point = Object.assign( 6594 from 6595 ? Object.assign({}, from) 6596 : { 6597 line: 1, 6598 column: 1, 6599 offset: 0 6600 }, 6601 { 6602 _index: 0, 6603 _bufferIndex: -1 6604 } 6605 ); 6606 const columnStart = {}; 6607 const resolveAllConstructs = []; 6608 let chunks = []; 6609 let stack = []; 6610 const effects = { 6611 consume, 6612 enter, 6613 exit, 6614 attempt: constructFactory(onsuccessfulconstruct), 6615 check: constructFactory(onsuccessfulcheck), 6616 interrupt: constructFactory(onsuccessfulcheck, { 6617 interrupt: true 6618 }) 6619 }; 6620 const context = { 6621 previous: null, 6622 code: null, 6623 containerState: {}, 6624 events: [], 6625 parser, 6626 sliceStream, 6627 sliceSerialize, 6628 now, 6629 defineSkip, 6630 write 6631 }; 6632 let state = initialize.tokenize.call(context, effects); 6633 if (initialize.resolveAll) { 6634 resolveAllConstructs.push(initialize); 6635 } 6636 return context 6637 function write(slice) { 6638 chunks = push(chunks, slice); 6639 main(); 6640 if (chunks[chunks.length - 1] !== null) { 6641 return [] 6642 } 6643 addResult(initialize, 0); 6644 context.events = resolveAll(resolveAllConstructs, context.events, context); 6645 return context.events 6646 } 6647 function sliceSerialize(token, expandTabs) { 6648 return serializeChunks(sliceStream(token), expandTabs) 6649 } 6650 function sliceStream(token) { 6651 return sliceChunks(chunks, token) 6652 } 6653 function now() { 6654 const {line, column, offset, _index, _bufferIndex} = point; 6655 return { 6656 line, 6657 column, 6658 offset, 6659 _index, 6660 _bufferIndex 6661 } 6662 } 6663 function defineSkip(value) { 6664 columnStart[value.line] = value.column; 6665 accountForPotentialSkip(); 6666 } 6667 function main() { 6668 let chunkIndex; 6669 while (point._index < chunks.length) { 6670 const chunk = chunks[point._index]; 6671 if (typeof chunk === 'string') { 6672 chunkIndex = point._index; 6673 if (point._bufferIndex < 0) { 6674 point._bufferIndex = 0; 6675 } 6676 while ( 6677 point._index === chunkIndex && 6678 point._bufferIndex < chunk.length 6679 ) { 6680 go(chunk.charCodeAt(point._bufferIndex)); 6681 } 6682 } else { 6683 go(chunk); 6684 } 6685 } 6686 } 6687 function go(code) { 6688 state = state(code); 6689 } 6690 function consume(code) { 6691 if (markdownLineEnding(code)) { 6692 point.line++; 6693 point.column = 1; 6694 point.offset += code === -3 ? 2 : 1; 6695 accountForPotentialSkip(); 6696 } else if (code !== -1) { 6697 point.column++; 6698 point.offset++; 6699 } 6700 if (point._bufferIndex < 0) { 6701 point._index++; 6702 } else { 6703 point._bufferIndex++; 6704 if (point._bufferIndex === chunks[point._index].length) { 6705 point._bufferIndex = -1; 6706 point._index++; 6707 } 6708 } 6709 context.previous = code; 6710 } 6711 function enter(type, fields) { 6712 const token = fields || {}; 6713 token.type = type; 6714 token.start = now(); 6715 context.events.push(['enter', token, context]); 6716 stack.push(token); 6717 return token 6718 } 6719 function exit(type) { 6720 const token = stack.pop(); 6721 token.end = now(); 6722 context.events.push(['exit', token, context]); 6723 return token 6724 } 6725 function onsuccessfulconstruct(construct, info) { 6726 addResult(construct, info.from); 6727 } 6728 function onsuccessfulcheck(_, info) { 6729 info.restore(); 6730 } 6731 function constructFactory(onreturn, fields) { 6732 return hook 6733 function hook(constructs, returnState, bogusState) { 6734 let listOfConstructs; 6735 let constructIndex; 6736 let currentConstruct; 6737 let info; 6738 return Array.isArray(constructs) 6739 ? handleListOfConstructs(constructs) 6740 : 'tokenize' in constructs 6741 ? 6742 handleListOfConstructs([constructs]) 6743 : handleMapOfConstructs(constructs) 6744 function handleMapOfConstructs(map) { 6745 return start 6746 function start(code) { 6747 const def = code !== null && map[code]; 6748 const all = code !== null && map.null; 6749 const list = [ 6750 ...(Array.isArray(def) ? def : def ? [def] : []), 6751 ...(Array.isArray(all) ? all : all ? [all] : []) 6752 ]; 6753 return handleListOfConstructs(list)(code) 6754 } 6755 } 6756 function handleListOfConstructs(list) { 6757 listOfConstructs = list; 6758 constructIndex = 0; 6759 if (list.length === 0) { 6760 return bogusState 6761 } 6762 return handleConstruct(list[constructIndex]) 6763 } 6764 function handleConstruct(construct) { 6765 return start 6766 function start(code) { 6767 info = store(); 6768 currentConstruct = construct; 6769 if (!construct.partial) { 6770 context.currentConstruct = construct; 6771 } 6772 if ( 6773 construct.name && 6774 context.parser.constructs.disable.null.includes(construct.name) 6775 ) { 6776 return nok() 6777 } 6778 return construct.tokenize.call( 6779 fields ? Object.assign(Object.create(context), fields) : context, 6780 effects, 6781 ok, 6782 nok 6783 )(code) 6784 } 6785 } 6786 function ok(code) { 6787 onreturn(currentConstruct, info); 6788 return returnState 6789 } 6790 function nok(code) { 6791 info.restore(); 6792 if (++constructIndex < listOfConstructs.length) { 6793 return handleConstruct(listOfConstructs[constructIndex]) 6794 } 6795 return bogusState 6796 } 6797 } 6798 } 6799 function addResult(construct, from) { 6800 if (construct.resolveAll && !resolveAllConstructs.includes(construct)) { 6801 resolveAllConstructs.push(construct); 6802 } 6803 if (construct.resolve) { 6804 splice( 6805 context.events, 6806 from, 6807 context.events.length - from, 6808 construct.resolve(context.events.slice(from), context) 6809 ); 6810 } 6811 if (construct.resolveTo) { 6812 context.events = construct.resolveTo(context.events, context); 6813 } 6814 } 6815 function store() { 6816 const startPoint = now(); 6817 const startPrevious = context.previous; 6818 const startCurrentConstruct = context.currentConstruct; 6819 const startEventsIndex = context.events.length; 6820 const startStack = Array.from(stack); 6821 return { 6822 restore, 6823 from: startEventsIndex 6824 } 6825 function restore() { 6826 point = startPoint; 6827 context.previous = startPrevious; 6828 context.currentConstruct = startCurrentConstruct; 6829 context.events.length = startEventsIndex; 6830 stack = startStack; 6831 accountForPotentialSkip(); 6832 } 6833 } 6834 function accountForPotentialSkip() { 6835 if (point.line in columnStart && point.column < 2) { 6836 point.column = columnStart[point.line]; 6837 point.offset += columnStart[point.line] - 1; 6838 } 6839 } 6840} 6841function sliceChunks(chunks, token) { 6842 const startIndex = token.start._index; 6843 const startBufferIndex = token.start._bufferIndex; 6844 const endIndex = token.end._index; 6845 const endBufferIndex = token.end._bufferIndex; 6846 let view; 6847 if (startIndex === endIndex) { 6848 view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)]; 6849 } else { 6850 view = chunks.slice(startIndex, endIndex); 6851 if (startBufferIndex > -1) { 6852 const head = view[0]; 6853 if (typeof head === 'string') { 6854 view[0] = head.slice(startBufferIndex); 6855 } else { 6856 view.shift(); 6857 } 6858 } 6859 if (endBufferIndex > 0) { 6860 view.push(chunks[endIndex].slice(0, endBufferIndex)); 6861 } 6862 } 6863 return view 6864} 6865function serializeChunks(chunks, expandTabs) { 6866 let index = -1; 6867 const result = []; 6868 let atTab; 6869 while (++index < chunks.length) { 6870 const chunk = chunks[index]; 6871 let value; 6872 if (typeof chunk === 'string') { 6873 value = chunk; 6874 } else 6875 switch (chunk) { 6876 case -5: { 6877 value = '\r'; 6878 break 6879 } 6880 case -4: { 6881 value = '\n'; 6882 break 6883 } 6884 case -3: { 6885 value = '\r' + '\n'; 6886 break 6887 } 6888 case -2: { 6889 value = expandTabs ? ' ' : '\t'; 6890 break 6891 } 6892 case -1: { 6893 if (!expandTabs && atTab) continue 6894 value = ' '; 6895 break 6896 } 6897 default: { 6898 value = String.fromCharCode(chunk); 6899 } 6900 } 6901 atTab = chunk === -2; 6902 result.push(value); 6903 } 6904 return result.join('') 6905} 6906 6907const document = { 6908 [42]: list$1, 6909 [43]: list$1, 6910 [45]: list$1, 6911 [48]: list$1, 6912 [49]: list$1, 6913 [50]: list$1, 6914 [51]: list$1, 6915 [52]: list$1, 6916 [53]: list$1, 6917 [54]: list$1, 6918 [55]: list$1, 6919 [56]: list$1, 6920 [57]: list$1, 6921 [62]: blockQuote 6922}; 6923const contentInitial = { 6924 [91]: definition$1 6925}; 6926const flowInitial = { 6927 [-2]: codeIndented, 6928 [-1]: codeIndented, 6929 [32]: codeIndented 6930}; 6931const flow = { 6932 [35]: headingAtx, 6933 [42]: thematicBreak$1, 6934 [45]: [setextUnderline, thematicBreak$1], 6935 [60]: htmlFlow, 6936 [61]: setextUnderline, 6937 [95]: thematicBreak$1, 6938 [96]: codeFenced, 6939 [126]: codeFenced 6940}; 6941const string = { 6942 [38]: characterReference, 6943 [92]: characterEscape 6944}; 6945const text$2 = { 6946 [-5]: lineEnding, 6947 [-4]: lineEnding, 6948 [-3]: lineEnding, 6949 [33]: labelStartImage, 6950 [38]: characterReference, 6951 [42]: attention, 6952 [60]: [autolink, htmlText], 6953 [91]: labelStartLink, 6954 [92]: [hardBreakEscape, characterEscape], 6955 [93]: labelEnd, 6956 [95]: attention, 6957 [96]: codeText 6958}; 6959const insideSpan = { 6960 null: [attention, resolver] 6961}; 6962const attentionMarkers = { 6963 null: [42, 95] 6964}; 6965const disable = { 6966 null: [] 6967}; 6968 6969var defaultConstructs = /*#__PURE__*/Object.freeze({ 6970 __proto__: null, 6971 attentionMarkers: attentionMarkers, 6972 contentInitial: contentInitial, 6973 disable: disable, 6974 document: document, 6975 flow: flow, 6976 flowInitial: flowInitial, 6977 insideSpan: insideSpan, 6978 string: string, 6979 text: text$2 6980}); 6981 6982function parse$1(options) { 6983 const settings = options || {}; 6984 const constructs = 6985 combineExtensions([defaultConstructs, ...(settings.extensions || [])]); 6986 const parser = { 6987 defined: [], 6988 lazy: {}, 6989 constructs, 6990 content: create(content$1), 6991 document: create(document$1), 6992 flow: create(flow$1), 6993 string: create(string$1), 6994 text: create(text$3) 6995 }; 6996 return parser 6997 function create(initial) { 6998 return creator 6999 function creator(from) { 7000 return createTokenizer(parser, initial, from) 7001 } 7002 } 7003} 7004 7005const search = /[\0\t\n\r]/g; 7006function preprocess() { 7007 let column = 1; 7008 let buffer = ''; 7009 let start = true; 7010 let atCarriageReturn; 7011 return preprocessor 7012 function preprocessor(value, encoding, end) { 7013 const chunks = []; 7014 let match; 7015 let next; 7016 let startPosition; 7017 let endPosition; 7018 let code; 7019 value = buffer + value.toString(encoding); 7020 startPosition = 0; 7021 buffer = ''; 7022 if (start) { 7023 if (value.charCodeAt(0) === 65279) { 7024 startPosition++; 7025 } 7026 start = undefined; 7027 } 7028 while (startPosition < value.length) { 7029 search.lastIndex = startPosition; 7030 match = search.exec(value); 7031 endPosition = 7032 match && match.index !== undefined ? match.index : value.length; 7033 code = value.charCodeAt(endPosition); 7034 if (!match) { 7035 buffer = value.slice(startPosition); 7036 break 7037 } 7038 if (code === 10 && startPosition === endPosition && atCarriageReturn) { 7039 chunks.push(-3); 7040 atCarriageReturn = undefined; 7041 } else { 7042 if (atCarriageReturn) { 7043 chunks.push(-5); 7044 atCarriageReturn = undefined; 7045 } 7046 if (startPosition < endPosition) { 7047 chunks.push(value.slice(startPosition, endPosition)); 7048 column += endPosition - startPosition; 7049 } 7050 switch (code) { 7051 case 0: { 7052 chunks.push(65533); 7053 column++; 7054 break 7055 } 7056 case 9: { 7057 next = Math.ceil(column / 4) * 4; 7058 chunks.push(-2); 7059 while (column++ < next) chunks.push(-1); 7060 break 7061 } 7062 case 10: { 7063 chunks.push(-4); 7064 column = 1; 7065 break 7066 } 7067 default: { 7068 atCarriageReturn = true; 7069 column = 1; 7070 } 7071 } 7072 } 7073 startPosition = endPosition + 1; 7074 } 7075 if (end) { 7076 if (atCarriageReturn) chunks.push(-5); 7077 if (buffer) chunks.push(buffer); 7078 chunks.push(null); 7079 } 7080 return chunks 7081 } 7082} 7083 7084function postprocess(events) { 7085 while (!subtokenize(events)) { 7086 } 7087 return events 7088} 7089 7090function decodeNumericCharacterReference(value, base) { 7091 const code = Number.parseInt(value, base); 7092 if ( 7093 code < 9 || 7094 code === 11 || 7095 (code > 13 && code < 32) || 7096 (code > 126 && code < 160) || 7097 (code > 55295 && code < 57344) || 7098 (code > 64975 && code < 65008) || 7099 (code & 65535) === 65535 || 7100 (code & 65535) === 65534 || 7101 code > 1114111 7102 ) { 7103 return '\uFFFD' 7104 } 7105 return String.fromCharCode(code) 7106} 7107 7108const characterEscapeOrReference = 7109 /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi; 7110function decodeString(value) { 7111 return value.replace(characterEscapeOrReference, decode) 7112} 7113function decode($0, $1, $2) { 7114 if ($1) { 7115 return $1 7116 } 7117 const head = $2.charCodeAt(0); 7118 if (head === 35) { 7119 const head = $2.charCodeAt(1); 7120 const hex = head === 120 || head === 88; 7121 return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10) 7122 } 7123 return decodeNamedCharacterReference($2) || $0 7124} 7125 7126const own$4 = {}.hasOwnProperty; 7127const fromMarkdown = 7128 function (value, encoding, options) { 7129 if (typeof encoding !== 'string') { 7130 options = encoding; 7131 encoding = undefined; 7132 } 7133 return compiler(options)( 7134 postprocess( 7135 parse$1(options).document().write(preprocess()(value, encoding, true)) 7136 ) 7137 ) 7138 }; 7139function compiler(options) { 7140 const config = { 7141 transforms: [], 7142 canContainEols: ['emphasis', 'fragment', 'heading', 'paragraph', 'strong'], 7143 enter: { 7144 autolink: opener(link), 7145 autolinkProtocol: onenterdata, 7146 autolinkEmail: onenterdata, 7147 atxHeading: opener(heading), 7148 blockQuote: opener(blockQuote), 7149 characterEscape: onenterdata, 7150 characterReference: onenterdata, 7151 codeFenced: opener(codeFlow), 7152 codeFencedFenceInfo: buffer, 7153 codeFencedFenceMeta: buffer, 7154 codeIndented: opener(codeFlow, buffer), 7155 codeText: opener(codeText, buffer), 7156 codeTextData: onenterdata, 7157 data: onenterdata, 7158 codeFlowValue: onenterdata, 7159 definition: opener(definition), 7160 definitionDestinationString: buffer, 7161 definitionLabelString: buffer, 7162 definitionTitleString: buffer, 7163 emphasis: opener(emphasis), 7164 hardBreakEscape: opener(hardBreak), 7165 hardBreakTrailing: opener(hardBreak), 7166 htmlFlow: opener(html, buffer), 7167 htmlFlowData: onenterdata, 7168 htmlText: opener(html, buffer), 7169 htmlTextData: onenterdata, 7170 image: opener(image), 7171 label: buffer, 7172 link: opener(link), 7173 listItem: opener(listItem), 7174 listItemValue: onenterlistitemvalue, 7175 listOrdered: opener(list, onenterlistordered), 7176 listUnordered: opener(list), 7177 paragraph: opener(paragraph), 7178 reference: onenterreference, 7179 referenceString: buffer, 7180 resourceDestinationString: buffer, 7181 resourceTitleString: buffer, 7182 setextHeading: opener(heading), 7183 strong: opener(strong), 7184 thematicBreak: opener(thematicBreak) 7185 }, 7186 exit: { 7187 atxHeading: closer(), 7188 atxHeadingSequence: onexitatxheadingsequence, 7189 autolink: closer(), 7190 autolinkEmail: onexitautolinkemail, 7191 autolinkProtocol: onexitautolinkprotocol, 7192 blockQuote: closer(), 7193 characterEscapeValue: onexitdata, 7194 characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker, 7195 characterReferenceMarkerNumeric: onexitcharacterreferencemarker, 7196 characterReferenceValue: onexitcharacterreferencevalue, 7197 codeFenced: closer(onexitcodefenced), 7198 codeFencedFence: onexitcodefencedfence, 7199 codeFencedFenceInfo: onexitcodefencedfenceinfo, 7200 codeFencedFenceMeta: onexitcodefencedfencemeta, 7201 codeFlowValue: onexitdata, 7202 codeIndented: closer(onexitcodeindented), 7203 codeText: closer(onexitcodetext), 7204 codeTextData: onexitdata, 7205 data: onexitdata, 7206 definition: closer(), 7207 definitionDestinationString: onexitdefinitiondestinationstring, 7208 definitionLabelString: onexitdefinitionlabelstring, 7209 definitionTitleString: onexitdefinitiontitlestring, 7210 emphasis: closer(), 7211 hardBreakEscape: closer(onexithardbreak), 7212 hardBreakTrailing: closer(onexithardbreak), 7213 htmlFlow: closer(onexithtmlflow), 7214 htmlFlowData: onexitdata, 7215 htmlText: closer(onexithtmltext), 7216 htmlTextData: onexitdata, 7217 image: closer(onexitimage), 7218 label: onexitlabel, 7219 labelText: onexitlabeltext, 7220 lineEnding: onexitlineending, 7221 link: closer(onexitlink), 7222 listItem: closer(), 7223 listOrdered: closer(), 7224 listUnordered: closer(), 7225 paragraph: closer(), 7226 referenceString: onexitreferencestring, 7227 resourceDestinationString: onexitresourcedestinationstring, 7228 resourceTitleString: onexitresourcetitlestring, 7229 resource: onexitresource, 7230 setextHeading: closer(onexitsetextheading), 7231 setextHeadingLineSequence: onexitsetextheadinglinesequence, 7232 setextHeadingText: onexitsetextheadingtext, 7233 strong: closer(), 7234 thematicBreak: closer() 7235 } 7236 }; 7237 configure$1(config, (options || {}).mdastExtensions || []); 7238 const data = {}; 7239 return compile 7240 function compile(events) { 7241 let tree = { 7242 type: 'root', 7243 children: [] 7244 }; 7245 const context = { 7246 stack: [tree], 7247 tokenStack: [], 7248 config, 7249 enter, 7250 exit, 7251 buffer, 7252 resume, 7253 setData, 7254 getData 7255 }; 7256 const listStack = []; 7257 let index = -1; 7258 while (++index < events.length) { 7259 if ( 7260 events[index][1].type === 'listOrdered' || 7261 events[index][1].type === 'listUnordered' 7262 ) { 7263 if (events[index][0] === 'enter') { 7264 listStack.push(index); 7265 } else { 7266 const tail = listStack.pop(); 7267 index = prepareList(events, tail, index); 7268 } 7269 } 7270 } 7271 index = -1; 7272 while (++index < events.length) { 7273 const handler = config[events[index][0]]; 7274 if (own$4.call(handler, events[index][1].type)) { 7275 handler[events[index][1].type].call( 7276 Object.assign( 7277 { 7278 sliceSerialize: events[index][2].sliceSerialize 7279 }, 7280 context 7281 ), 7282 events[index][1] 7283 ); 7284 } 7285 } 7286 if (context.tokenStack.length > 0) { 7287 const tail = context.tokenStack[context.tokenStack.length - 1]; 7288 const handler = tail[1] || defaultOnError; 7289 handler.call(context, undefined, tail[0]); 7290 } 7291 tree.position = { 7292 start: point$2( 7293 events.length > 0 7294 ? events[0][1].start 7295 : { 7296 line: 1, 7297 column: 1, 7298 offset: 0 7299 } 7300 ), 7301 end: point$2( 7302 events.length > 0 7303 ? events[events.length - 2][1].end 7304 : { 7305 line: 1, 7306 column: 1, 7307 offset: 0 7308 } 7309 ) 7310 }; 7311 index = -1; 7312 while (++index < config.transforms.length) { 7313 tree = config.transforms[index](tree) || tree; 7314 } 7315 return tree 7316 } 7317 function prepareList(events, start, length) { 7318 let index = start - 1; 7319 let containerBalance = -1; 7320 let listSpread = false; 7321 let listItem; 7322 let lineIndex; 7323 let firstBlankLineIndex; 7324 let atMarker; 7325 while (++index <= length) { 7326 const event = events[index]; 7327 if ( 7328 event[1].type === 'listUnordered' || 7329 event[1].type === 'listOrdered' || 7330 event[1].type === 'blockQuote' 7331 ) { 7332 if (event[0] === 'enter') { 7333 containerBalance++; 7334 } else { 7335 containerBalance--; 7336 } 7337 atMarker = undefined; 7338 } else if (event[1].type === 'lineEndingBlank') { 7339 if (event[0] === 'enter') { 7340 if ( 7341 listItem && 7342 !atMarker && 7343 !containerBalance && 7344 !firstBlankLineIndex 7345 ) { 7346 firstBlankLineIndex = index; 7347 } 7348 atMarker = undefined; 7349 } 7350 } else if ( 7351 event[1].type === 'linePrefix' || 7352 event[1].type === 'listItemValue' || 7353 event[1].type === 'listItemMarker' || 7354 event[1].type === 'listItemPrefix' || 7355 event[1].type === 'listItemPrefixWhitespace' 7356 ) ; else { 7357 atMarker = undefined; 7358 } 7359 if ( 7360 (!containerBalance && 7361 event[0] === 'enter' && 7362 event[1].type === 'listItemPrefix') || 7363 (containerBalance === -1 && 7364 event[0] === 'exit' && 7365 (event[1].type === 'listUnordered' || 7366 event[1].type === 'listOrdered')) 7367 ) { 7368 if (listItem) { 7369 let tailIndex = index; 7370 lineIndex = undefined; 7371 while (tailIndex--) { 7372 const tailEvent = events[tailIndex]; 7373 if ( 7374 tailEvent[1].type === 'lineEnding' || 7375 tailEvent[1].type === 'lineEndingBlank' 7376 ) { 7377 if (tailEvent[0] === 'exit') continue 7378 if (lineIndex) { 7379 events[lineIndex][1].type = 'lineEndingBlank'; 7380 listSpread = true; 7381 } 7382 tailEvent[1].type = 'lineEnding'; 7383 lineIndex = tailIndex; 7384 } else if ( 7385 tailEvent[1].type === 'linePrefix' || 7386 tailEvent[1].type === 'blockQuotePrefix' || 7387 tailEvent[1].type === 'blockQuotePrefixWhitespace' || 7388 tailEvent[1].type === 'blockQuoteMarker' || 7389 tailEvent[1].type === 'listItemIndent' 7390 ) ; else { 7391 break 7392 } 7393 } 7394 if ( 7395 firstBlankLineIndex && 7396 (!lineIndex || firstBlankLineIndex < lineIndex) 7397 ) { 7398 listItem._spread = true; 7399 } 7400 listItem.end = Object.assign( 7401 {}, 7402 lineIndex ? events[lineIndex][1].start : event[1].end 7403 ); 7404 events.splice(lineIndex || index, 0, ['exit', listItem, event[2]]); 7405 index++; 7406 length++; 7407 } 7408 if (event[1].type === 'listItemPrefix') { 7409 listItem = { 7410 type: 'listItem', 7411 _spread: false, 7412 start: Object.assign({}, event[1].start), 7413 end: undefined 7414 }; 7415 events.splice(index, 0, ['enter', listItem, event[2]]); 7416 index++; 7417 length++; 7418 firstBlankLineIndex = undefined; 7419 atMarker = true; 7420 } 7421 } 7422 } 7423 events[start][1]._spread = listSpread; 7424 return length 7425 } 7426 function setData(key, value) { 7427 data[key] = value; 7428 } 7429 function getData(key) { 7430 return data[key] 7431 } 7432 function opener(create, and) { 7433 return open 7434 function open(token) { 7435 enter.call(this, create(token), token); 7436 if (and) and.call(this, token); 7437 } 7438 } 7439 function buffer() { 7440 this.stack.push({ 7441 type: 'fragment', 7442 children: [] 7443 }); 7444 } 7445 function enter(node, token, errorHandler) { 7446 const parent = this.stack[this.stack.length - 1]; 7447 parent.children.push(node); 7448 this.stack.push(node); 7449 this.tokenStack.push([token, errorHandler]); 7450 node.position = { 7451 start: point$2(token.start) 7452 }; 7453 return node 7454 } 7455 function closer(and) { 7456 return close 7457 function close(token) { 7458 if (and) and.call(this, token); 7459 exit.call(this, token); 7460 } 7461 } 7462 function exit(token, onExitError) { 7463 const node = this.stack.pop(); 7464 const open = this.tokenStack.pop(); 7465 if (!open) { 7466 throw new Error( 7467 'Cannot close `' + 7468 token.type + 7469 '` (' + 7470 stringifyPosition$1({ 7471 start: token.start, 7472 end: token.end 7473 }) + 7474 '): it’s not open' 7475 ) 7476 } else if (open[0].type !== token.type) { 7477 if (onExitError) { 7478 onExitError.call(this, token, open[0]); 7479 } else { 7480 const handler = open[1] || defaultOnError; 7481 handler.call(this, token, open[0]); 7482 } 7483 } 7484 node.position.end = point$2(token.end); 7485 return node 7486 } 7487 function resume() { 7488 return toString(this.stack.pop()) 7489 } 7490 function onenterlistordered() { 7491 setData('expectingFirstListItemValue', true); 7492 } 7493 function onenterlistitemvalue(token) { 7494 if (getData('expectingFirstListItemValue')) { 7495 const ancestor = this.stack[this.stack.length - 2]; 7496 ancestor.start = Number.parseInt(this.sliceSerialize(token), 10); 7497 setData('expectingFirstListItemValue'); 7498 } 7499 } 7500 function onexitcodefencedfenceinfo() { 7501 const data = this.resume(); 7502 const node = this.stack[this.stack.length - 1]; 7503 node.lang = data; 7504 } 7505 function onexitcodefencedfencemeta() { 7506 const data = this.resume(); 7507 const node = this.stack[this.stack.length - 1]; 7508 node.meta = data; 7509 } 7510 function onexitcodefencedfence() { 7511 if (getData('flowCodeInside')) return 7512 this.buffer(); 7513 setData('flowCodeInside', true); 7514 } 7515 function onexitcodefenced() { 7516 const data = this.resume(); 7517 const node = this.stack[this.stack.length - 1]; 7518 node.value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, ''); 7519 setData('flowCodeInside'); 7520 } 7521 function onexitcodeindented() { 7522 const data = this.resume(); 7523 const node = this.stack[this.stack.length - 1]; 7524 node.value = data.replace(/(\r?\n|\r)$/g, ''); 7525 } 7526 function onexitdefinitionlabelstring(token) { 7527 const label = this.resume(); 7528 const node = this.stack[this.stack.length - 1]; 7529 node.label = label; 7530 node.identifier = normalizeIdentifier( 7531 this.sliceSerialize(token) 7532 ).toLowerCase(); 7533 } 7534 function onexitdefinitiontitlestring() { 7535 const data = this.resume(); 7536 const node = this.stack[this.stack.length - 1]; 7537 node.title = data; 7538 } 7539 function onexitdefinitiondestinationstring() { 7540 const data = this.resume(); 7541 const node = this.stack[this.stack.length - 1]; 7542 node.url = data; 7543 } 7544 function onexitatxheadingsequence(token) { 7545 const node = this.stack[this.stack.length - 1]; 7546 if (!node.depth) { 7547 const depth = this.sliceSerialize(token).length; 7548 node.depth = depth; 7549 } 7550 } 7551 function onexitsetextheadingtext() { 7552 setData('setextHeadingSlurpLineEnding', true); 7553 } 7554 function onexitsetextheadinglinesequence(token) { 7555 const node = this.stack[this.stack.length - 1]; 7556 node.depth = this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2; 7557 } 7558 function onexitsetextheading() { 7559 setData('setextHeadingSlurpLineEnding'); 7560 } 7561 function onenterdata(token) { 7562 const node = this.stack[this.stack.length - 1]; 7563 let tail = node.children[node.children.length - 1]; 7564 if (!tail || tail.type !== 'text') { 7565 tail = text(); 7566 tail.position = { 7567 start: point$2(token.start) 7568 }; 7569 node.children.push(tail); 7570 } 7571 this.stack.push(tail); 7572 } 7573 function onexitdata(token) { 7574 const tail = this.stack.pop(); 7575 tail.value += this.sliceSerialize(token); 7576 tail.position.end = point$2(token.end); 7577 } 7578 function onexitlineending(token) { 7579 const context = this.stack[this.stack.length - 1]; 7580 if (getData('atHardBreak')) { 7581 const tail = context.children[context.children.length - 1]; 7582 tail.position.end = point$2(token.end); 7583 setData('atHardBreak'); 7584 return 7585 } 7586 if ( 7587 !getData('setextHeadingSlurpLineEnding') && 7588 config.canContainEols.includes(context.type) 7589 ) { 7590 onenterdata.call(this, token); 7591 onexitdata.call(this, token); 7592 } 7593 } 7594 function onexithardbreak() { 7595 setData('atHardBreak', true); 7596 } 7597 function onexithtmlflow() { 7598 const data = this.resume(); 7599 const node = this.stack[this.stack.length - 1]; 7600 node.value = data; 7601 } 7602 function onexithtmltext() { 7603 const data = this.resume(); 7604 const node = this.stack[this.stack.length - 1]; 7605 node.value = data; 7606 } 7607 function onexitcodetext() { 7608 const data = this.resume(); 7609 const node = this.stack[this.stack.length - 1]; 7610 node.value = data; 7611 } 7612 function onexitlink() { 7613 const node = this.stack[this.stack.length - 1]; 7614 if (getData('inReference')) { 7615 const referenceType = getData('referenceType') || 'shortcut'; 7616 node.type += 'Reference'; 7617 node.referenceType = referenceType; 7618 delete node.url; 7619 delete node.title; 7620 } else { 7621 delete node.identifier; 7622 delete node.label; 7623 } 7624 setData('referenceType'); 7625 } 7626 function onexitimage() { 7627 const node = this.stack[this.stack.length - 1]; 7628 if (getData('inReference')) { 7629 const referenceType = getData('referenceType') || 'shortcut'; 7630 node.type += 'Reference'; 7631 node.referenceType = referenceType; 7632 delete node.url; 7633 delete node.title; 7634 } else { 7635 delete node.identifier; 7636 delete node.label; 7637 } 7638 setData('referenceType'); 7639 } 7640 function onexitlabeltext(token) { 7641 const string = this.sliceSerialize(token); 7642 const ancestor = this.stack[this.stack.length - 2]; 7643 ancestor.label = decodeString(string); 7644 ancestor.identifier = normalizeIdentifier(string).toLowerCase(); 7645 } 7646 function onexitlabel() { 7647 const fragment = this.stack[this.stack.length - 1]; 7648 const value = this.resume(); 7649 const node = this.stack[this.stack.length - 1]; 7650 setData('inReference', true); 7651 if (node.type === 'link') { 7652 const children = fragment.children; 7653 node.children = children; 7654 } else { 7655 node.alt = value; 7656 } 7657 } 7658 function onexitresourcedestinationstring() { 7659 const data = this.resume(); 7660 const node = this.stack[this.stack.length - 1]; 7661 node.url = data; 7662 } 7663 function onexitresourcetitlestring() { 7664 const data = this.resume(); 7665 const node = this.stack[this.stack.length - 1]; 7666 node.title = data; 7667 } 7668 function onexitresource() { 7669 setData('inReference'); 7670 } 7671 function onenterreference() { 7672 setData('referenceType', 'collapsed'); 7673 } 7674 function onexitreferencestring(token) { 7675 const label = this.resume(); 7676 const node = this.stack[this.stack.length - 1]; 7677 node.label = label; 7678 node.identifier = normalizeIdentifier( 7679 this.sliceSerialize(token) 7680 ).toLowerCase(); 7681 setData('referenceType', 'full'); 7682 } 7683 function onexitcharacterreferencemarker(token) { 7684 setData('characterReferenceType', token.type); 7685 } 7686 function onexitcharacterreferencevalue(token) { 7687 const data = this.sliceSerialize(token); 7688 const type = getData('characterReferenceType'); 7689 let value; 7690 if (type) { 7691 value = decodeNumericCharacterReference( 7692 data, 7693 type === 'characterReferenceMarkerNumeric' ? 10 : 16 7694 ); 7695 setData('characterReferenceType'); 7696 } else { 7697 const result = decodeNamedCharacterReference(data); 7698 value = result; 7699 } 7700 const tail = this.stack.pop(); 7701 tail.value += value; 7702 tail.position.end = point$2(token.end); 7703 } 7704 function onexitautolinkprotocol(token) { 7705 onexitdata.call(this, token); 7706 const node = this.stack[this.stack.length - 1]; 7707 node.url = this.sliceSerialize(token); 7708 } 7709 function onexitautolinkemail(token) { 7710 onexitdata.call(this, token); 7711 const node = this.stack[this.stack.length - 1]; 7712 node.url = 'mailto:' + this.sliceSerialize(token); 7713 } 7714 function blockQuote() { 7715 return { 7716 type: 'blockquote', 7717 children: [] 7718 } 7719 } 7720 function codeFlow() { 7721 return { 7722 type: 'code', 7723 lang: null, 7724 meta: null, 7725 value: '' 7726 } 7727 } 7728 function codeText() { 7729 return { 7730 type: 'inlineCode', 7731 value: '' 7732 } 7733 } 7734 function definition() { 7735 return { 7736 type: 'definition', 7737 identifier: '', 7738 label: null, 7739 title: null, 7740 url: '' 7741 } 7742 } 7743 function emphasis() { 7744 return { 7745 type: 'emphasis', 7746 children: [] 7747 } 7748 } 7749 function heading() { 7750 return { 7751 type: 'heading', 7752 depth: undefined, 7753 children: [] 7754 } 7755 } 7756 function hardBreak() { 7757 return { 7758 type: 'break' 7759 } 7760 } 7761 function html() { 7762 return { 7763 type: 'html', 7764 value: '' 7765 } 7766 } 7767 function image() { 7768 return { 7769 type: 'image', 7770 title: null, 7771 url: '', 7772 alt: null 7773 } 7774 } 7775 function link() { 7776 return { 7777 type: 'link', 7778 title: null, 7779 url: '', 7780 children: [] 7781 } 7782 } 7783 function list(token) { 7784 return { 7785 type: 'list', 7786 ordered: token.type === 'listOrdered', 7787 start: null, 7788 spread: token._spread, 7789 children: [] 7790 } 7791 } 7792 function listItem(token) { 7793 return { 7794 type: 'listItem', 7795 spread: token._spread, 7796 checked: null, 7797 children: [] 7798 } 7799 } 7800 function paragraph() { 7801 return { 7802 type: 'paragraph', 7803 children: [] 7804 } 7805 } 7806 function strong() { 7807 return { 7808 type: 'strong', 7809 children: [] 7810 } 7811 } 7812 function text() { 7813 return { 7814 type: 'text', 7815 value: '' 7816 } 7817 } 7818 function thematicBreak() { 7819 return { 7820 type: 'thematicBreak' 7821 } 7822 } 7823} 7824function point$2(d) { 7825 return { 7826 line: d.line, 7827 column: d.column, 7828 offset: d.offset 7829 } 7830} 7831function configure$1(combined, extensions) { 7832 let index = -1; 7833 while (++index < extensions.length) { 7834 const value = extensions[index]; 7835 if (Array.isArray(value)) { 7836 configure$1(combined, value); 7837 } else { 7838 extension(combined, value); 7839 } 7840 } 7841} 7842function extension(combined, extension) { 7843 let key; 7844 for (key in extension) { 7845 if (own$4.call(extension, key)) { 7846 if (key === 'canContainEols') { 7847 const right = extension[key]; 7848 if (right) { 7849 combined[key].push(...right); 7850 } 7851 } else if (key === 'transforms') { 7852 const right = extension[key]; 7853 if (right) { 7854 combined[key].push(...right); 7855 } 7856 } else if (key === 'enter' || key === 'exit') { 7857 const right = extension[key]; 7858 if (right) { 7859 Object.assign(combined[key], right); 7860 } 7861 } 7862 } 7863 } 7864} 7865function defaultOnError(left, right) { 7866 if (left) { 7867 throw new Error( 7868 'Cannot close `' + 7869 left.type + 7870 '` (' + 7871 stringifyPosition$1({ 7872 start: left.start, 7873 end: left.end 7874 }) + 7875 '): a different token (`' + 7876 right.type + 7877 '`, ' + 7878 stringifyPosition$1({ 7879 start: right.start, 7880 end: right.end 7881 }) + 7882 ') is open' 7883 ) 7884 } else { 7885 throw new Error( 7886 'Cannot close document, a token (`' + 7887 right.type + 7888 '`, ' + 7889 stringifyPosition$1({ 7890 start: right.start, 7891 end: right.end 7892 }) + 7893 ') is still open' 7894 ) 7895 } 7896} 7897 7898function remarkParse(options) { 7899 const parser = (doc) => { 7900 const settings = (this.data('settings')); 7901 return fromMarkdown( 7902 doc, 7903 Object.assign({}, settings, options, { 7904 extensions: this.data('micromarkExtensions') || [], 7905 mdastExtensions: this.data('fromMarkdownExtensions') || [] 7906 }) 7907 ) 7908 }; 7909 Object.assign(this, {Parser: parser}); 7910} 7911 7912const own$3 = {}.hasOwnProperty; 7913function zwitch(key, options) { 7914 const settings = options || {}; 7915 function one(value, ...parameters) { 7916 let fn = one.invalid; 7917 const handlers = one.handlers; 7918 if (value && own$3.call(value, key)) { 7919 const id = String(value[key]); 7920 fn = own$3.call(handlers, id) ? handlers[id] : one.unknown; 7921 } 7922 if (fn) { 7923 return fn.call(this, value, ...parameters) 7924 } 7925 } 7926 one.handlers = settings.handlers || {}; 7927 one.invalid = settings.invalid; 7928 one.unknown = settings.unknown; 7929 return one 7930} 7931 7932function configure(base, extension) { 7933 let index = -1; 7934 let key; 7935 if (extension.extensions) { 7936 while (++index < extension.extensions.length) { 7937 configure(base, extension.extensions[index]); 7938 } 7939 } 7940 for (key in extension) { 7941 if (key === 'extensions') ; else if (key === 'unsafe' || key === 'join') { 7942 base[key] = [...(base[key] || []), ...(extension[key] || [])]; 7943 } else if (key === 'handlers') { 7944 base[key] = Object.assign(base[key], extension[key] || {}); 7945 } else { 7946 base.options[key] = extension[key]; 7947 } 7948 } 7949 return base 7950} 7951 7952function blockquote(node, _, state, info) { 7953 const exit = state.enter('blockquote'); 7954 const tracker = state.createTracker(info); 7955 tracker.move('> '); 7956 tracker.shift(2); 7957 const value = state.indentLines( 7958 state.containerFlow(node, tracker.current()), 7959 map$3 7960 ); 7961 exit(); 7962 return value 7963} 7964function map$3(line, _, blank) { 7965 return '>' + (blank ? '' : ' ') + line 7966} 7967 7968function patternInScope(stack, pattern) { 7969 return ( 7970 listInScope(stack, pattern.inConstruct, true) && 7971 !listInScope(stack, pattern.notInConstruct, false) 7972 ) 7973} 7974function listInScope(stack, list, none) { 7975 if (typeof list === 'string') { 7976 list = [list]; 7977 } 7978 if (!list || list.length === 0) { 7979 return none 7980 } 7981 let index = -1; 7982 while (++index < list.length) { 7983 if (stack.includes(list[index])) { 7984 return true 7985 } 7986 } 7987 return false 7988} 7989 7990function hardBreak(_, _1, state, info) { 7991 let index = -1; 7992 while (++index < state.unsafe.length) { 7993 if ( 7994 state.unsafe[index].character === '\n' && 7995 patternInScope(state.stack, state.unsafe[index]) 7996 ) { 7997 return /[ \t]/.test(info.before) ? '' : ' ' 7998 } 7999 } 8000 return '\\\n' 8001} 8002 8003function longestStreak(value, substring) { 8004 const source = String(value); 8005 let index = source.indexOf(substring); 8006 let expected = index; 8007 let count = 0; 8008 let max = 0; 8009 if (typeof substring !== 'string') { 8010 throw new TypeError('Expected substring') 8011 } 8012 while (index !== -1) { 8013 if (index === expected) { 8014 if (++count > max) { 8015 max = count; 8016 } 8017 } else { 8018 count = 1; 8019 } 8020 expected = index + substring.length; 8021 index = source.indexOf(substring, expected); 8022 } 8023 return max 8024} 8025 8026function formatCodeAsIndented(node, state) { 8027 return Boolean( 8028 !state.options.fences && 8029 node.value && 8030 !node.lang && 8031 /[^ \r\n]/.test(node.value) && 8032 !/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(node.value) 8033 ) 8034} 8035 8036function checkFence(state) { 8037 const marker = state.options.fence || '`'; 8038 if (marker !== '`' && marker !== '~') { 8039 throw new Error( 8040 'Cannot serialize code with `' + 8041 marker + 8042 '` for `options.fence`, expected `` ` `` or `~`' 8043 ) 8044 } 8045 return marker 8046} 8047 8048function code$1(node, _, state, info) { 8049 const marker = checkFence(state); 8050 const raw = node.value || ''; 8051 const suffix = marker === '`' ? 'GraveAccent' : 'Tilde'; 8052 if (formatCodeAsIndented(node, state)) { 8053 const exit = state.enter('codeIndented'); 8054 const value = state.indentLines(raw, map$2); 8055 exit(); 8056 return value 8057 } 8058 const tracker = state.createTracker(info); 8059 const sequence = marker.repeat(Math.max(longestStreak(raw, marker) + 1, 3)); 8060 const exit = state.enter('codeFenced'); 8061 let value = tracker.move(sequence); 8062 if (node.lang) { 8063 const subexit = state.enter(`codeFencedLang${suffix}`); 8064 value += tracker.move( 8065 state.safe(node.lang, { 8066 before: value, 8067 after: ' ', 8068 encode: ['`'], 8069 ...tracker.current() 8070 }) 8071 ); 8072 subexit(); 8073 } 8074 if (node.lang && node.meta) { 8075 const subexit = state.enter(`codeFencedMeta${suffix}`); 8076 value += tracker.move(' '); 8077 value += tracker.move( 8078 state.safe(node.meta, { 8079 before: value, 8080 after: '\n', 8081 encode: ['`'], 8082 ...tracker.current() 8083 }) 8084 ); 8085 subexit(); 8086 } 8087 value += tracker.move('\n'); 8088 if (raw) { 8089 value += tracker.move(raw + '\n'); 8090 } 8091 value += tracker.move(sequence); 8092 exit(); 8093 return value 8094} 8095function map$2(line, _, blank) { 8096 return (blank ? '' : ' ') + line 8097} 8098 8099function checkQuote(state) { 8100 const marker = state.options.quote || '"'; 8101 if (marker !== '"' && marker !== "'") { 8102 throw new Error( 8103 'Cannot serialize title with `' + 8104 marker + 8105 '` for `options.quote`, expected `"`, or `\'`' 8106 ) 8107 } 8108 return marker 8109} 8110 8111function definition(node, _, state, info) { 8112 const quote = checkQuote(state); 8113 const suffix = quote === '"' ? 'Quote' : 'Apostrophe'; 8114 const exit = state.enter('definition'); 8115 let subexit = state.enter('label'); 8116 const tracker = state.createTracker(info); 8117 let value = tracker.move('['); 8118 value += tracker.move( 8119 state.safe(state.associationId(node), { 8120 before: value, 8121 after: ']', 8122 ...tracker.current() 8123 }) 8124 ); 8125 value += tracker.move(']: '); 8126 subexit(); 8127 if ( 8128 !node.url || 8129 /[\0- \u007F]/.test(node.url) 8130 ) { 8131 subexit = state.enter('destinationLiteral'); 8132 value += tracker.move('<'); 8133 value += tracker.move( 8134 state.safe(node.url, {before: value, after: '>', ...tracker.current()}) 8135 ); 8136 value += tracker.move('>'); 8137 } else { 8138 subexit = state.enter('destinationRaw'); 8139 value += tracker.move( 8140 state.safe(node.url, { 8141 before: value, 8142 after: node.title ? ' ' : '\n', 8143 ...tracker.current() 8144 }) 8145 ); 8146 } 8147 subexit(); 8148 if (node.title) { 8149 subexit = state.enter(`title${suffix}`); 8150 value += tracker.move(' ' + quote); 8151 value += tracker.move( 8152 state.safe(node.title, { 8153 before: value, 8154 after: quote, 8155 ...tracker.current() 8156 }) 8157 ); 8158 value += tracker.move(quote); 8159 subexit(); 8160 } 8161 exit(); 8162 return value 8163} 8164 8165function checkEmphasis(state) { 8166 const marker = state.options.emphasis || '*'; 8167 if (marker !== '*' && marker !== '_') { 8168 throw new Error( 8169 'Cannot serialize emphasis with `' + 8170 marker + 8171 '` for `options.emphasis`, expected `*`, or `_`' 8172 ) 8173 } 8174 return marker 8175} 8176 8177emphasis.peek = emphasisPeek; 8178function emphasis(node, _, state, info) { 8179 const marker = checkEmphasis(state); 8180 const exit = state.enter('emphasis'); 8181 const tracker = state.createTracker(info); 8182 let value = tracker.move(marker); 8183 value += tracker.move( 8184 state.containerPhrasing(node, { 8185 before: value, 8186 after: marker, 8187 ...tracker.current() 8188 }) 8189 ); 8190 value += tracker.move(marker); 8191 exit(); 8192 return value 8193} 8194function emphasisPeek(_, _1, state) { 8195 return state.options.emphasis || '*' 8196} 8197 8198const convert = 8199 ( 8200 function (test) { 8201 if (test === undefined || test === null) { 8202 return ok 8203 } 8204 if (typeof test === 'string') { 8205 return typeFactory(test) 8206 } 8207 if (typeof test === 'object') { 8208 return Array.isArray(test) ? anyFactory(test) : propsFactory(test) 8209 } 8210 if (typeof test === 'function') { 8211 return castFactory(test) 8212 } 8213 throw new Error('Expected function, string, or object as test') 8214 } 8215 ); 8216function anyFactory(tests) { 8217 const checks = []; 8218 let index = -1; 8219 while (++index < tests.length) { 8220 checks[index] = convert(tests[index]); 8221 } 8222 return castFactory(any) 8223 function any(...parameters) { 8224 let index = -1; 8225 while (++index < checks.length) { 8226 if (checks[index].call(this, ...parameters)) return true 8227 } 8228 return false 8229 } 8230} 8231function propsFactory(check) { 8232 return castFactory(all) 8233 function all(node) { 8234 let key; 8235 for (key in check) { 8236 if (node[key] !== check[key]) return false 8237 } 8238 return true 8239 } 8240} 8241function typeFactory(check) { 8242 return castFactory(type) 8243 function type(node) { 8244 return node && node.type === check 8245 } 8246} 8247function castFactory(check) { 8248 return assertion 8249 function assertion(node, ...parameters) { 8250 return Boolean( 8251 node && 8252 typeof node === 'object' && 8253 'type' in node && 8254 Boolean(check.call(this, node, ...parameters)) 8255 ) 8256 } 8257} 8258function ok() { 8259 return true 8260} 8261 8262function color$2(d) { 8263 return '\u001B[33m' + d + '\u001B[39m' 8264} 8265 8266const CONTINUE$1 = true; 8267const EXIT$1 = false; 8268const SKIP$1 = 'skip'; 8269const visitParents$1 = 8270 ( 8271 function (tree, test, visitor, reverse) { 8272 if (typeof test === 'function' && typeof visitor !== 'function') { 8273 reverse = visitor; 8274 visitor = test; 8275 test = null; 8276 } 8277 const is = convert(test); 8278 const step = reverse ? -1 : 1; 8279 factory(tree, undefined, [])(); 8280 function factory(node, index, parents) { 8281 const value = node && typeof node === 'object' ? node : {}; 8282 if (typeof value.type === 'string') { 8283 const name = 8284 typeof value.tagName === 'string' 8285 ? value.tagName 8286 : 8287 typeof value.name === 'string' 8288 ? value.name 8289 : undefined; 8290 Object.defineProperty(visit, 'name', { 8291 value: 8292 'node (' + color$2(node.type + (name ? '<' + name + '>' : '')) + ')' 8293 }); 8294 } 8295 return visit 8296 function visit() { 8297 let result = []; 8298 let subresult; 8299 let offset; 8300 let grandparents; 8301 if (!test || is(node, index, parents[parents.length - 1] || null)) { 8302 result = toResult$1(visitor(node, parents)); 8303 if (result[0] === EXIT$1) { 8304 return result 8305 } 8306 } 8307 if (node.children && result[0] !== SKIP$1) { 8308 offset = (reverse ? node.children.length : -1) + step; 8309 grandparents = parents.concat(node); 8310 while (offset > -1 && offset < node.children.length) { 8311 subresult = factory(node.children[offset], offset, grandparents)(); 8312 if (subresult[0] === EXIT$1) { 8313 return subresult 8314 } 8315 offset = 8316 typeof subresult[1] === 'number' ? subresult[1] : offset + step; 8317 } 8318 } 8319 return result 8320 } 8321 } 8322 } 8323 ); 8324function toResult$1(value) { 8325 if (Array.isArray(value)) { 8326 return value 8327 } 8328 if (typeof value === 'number') { 8329 return [CONTINUE$1, value] 8330 } 8331 return [value] 8332} 8333 8334const visit$1 = 8335 ( 8336 function (tree, test, visitor, reverse) { 8337 if (typeof test === 'function' && typeof visitor !== 'function') { 8338 reverse = visitor; 8339 visitor = test; 8340 test = null; 8341 } 8342 visitParents$1(tree, test, overload, reverse); 8343 function overload(node, parents) { 8344 const parent = parents[parents.length - 1]; 8345 return visitor( 8346 node, 8347 parent ? parent.children.indexOf(node) : null, 8348 parent 8349 ) 8350 } 8351 } 8352 ); 8353 8354function formatHeadingAsSetext(node, state) { 8355 let literalWithBreak = false; 8356 visit$1(node, (node) => { 8357 if ( 8358 ('value' in node && /\r?\n|\r/.test(node.value)) || 8359 node.type === 'break' 8360 ) { 8361 literalWithBreak = true; 8362 return EXIT$1 8363 } 8364 }); 8365 return Boolean( 8366 (!node.depth || node.depth < 3) && 8367 toString(node) && 8368 (state.options.setext || literalWithBreak) 8369 ) 8370} 8371 8372function heading(node, _, state, info) { 8373 const rank = Math.max(Math.min(6, node.depth || 1), 1); 8374 const tracker = state.createTracker(info); 8375 if (formatHeadingAsSetext(node, state)) { 8376 const exit = state.enter('headingSetext'); 8377 const subexit = state.enter('phrasing'); 8378 const value = state.containerPhrasing(node, { 8379 ...tracker.current(), 8380 before: '\n', 8381 after: '\n' 8382 }); 8383 subexit(); 8384 exit(); 8385 return ( 8386 value + 8387 '\n' + 8388 (rank === 1 ? '=' : '-').repeat( 8389 value.length - 8390 (Math.max(value.lastIndexOf('\r'), value.lastIndexOf('\n')) + 1) 8391 ) 8392 ) 8393 } 8394 const sequence = '#'.repeat(rank); 8395 const exit = state.enter('headingAtx'); 8396 const subexit = state.enter('phrasing'); 8397 tracker.move(sequence + ' '); 8398 let value = state.containerPhrasing(node, { 8399 before: '# ', 8400 after: '\n', 8401 ...tracker.current() 8402 }); 8403 if (/^[\t ]/.test(value)) { 8404 value = 8405 '&#x' + 8406 value.charCodeAt(0).toString(16).toUpperCase() + 8407 ';' + 8408 value.slice(1); 8409 } 8410 value = value ? sequence + ' ' + value : sequence; 8411 if (state.options.closeAtx) { 8412 value += ' ' + sequence; 8413 } 8414 subexit(); 8415 exit(); 8416 return value 8417} 8418 8419html.peek = htmlPeek; 8420function html(node) { 8421 return node.value || '' 8422} 8423function htmlPeek() { 8424 return '<' 8425} 8426 8427image.peek = imagePeek; 8428function image(node, _, state, info) { 8429 const quote = checkQuote(state); 8430 const suffix = quote === '"' ? 'Quote' : 'Apostrophe'; 8431 const exit = state.enter('image'); 8432 let subexit = state.enter('label'); 8433 const tracker = state.createTracker(info); 8434 let value = tracker.move('!['); 8435 value += tracker.move( 8436 state.safe(node.alt, {before: value, after: ']', ...tracker.current()}) 8437 ); 8438 value += tracker.move(']('); 8439 subexit(); 8440 if ( 8441 (!node.url && node.title) || 8442 /[\0- \u007F]/.test(node.url) 8443 ) { 8444 subexit = state.enter('destinationLiteral'); 8445 value += tracker.move('<'); 8446 value += tracker.move( 8447 state.safe(node.url, {before: value, after: '>', ...tracker.current()}) 8448 ); 8449 value += tracker.move('>'); 8450 } else { 8451 subexit = state.enter('destinationRaw'); 8452 value += tracker.move( 8453 state.safe(node.url, { 8454 before: value, 8455 after: node.title ? ' ' : ')', 8456 ...tracker.current() 8457 }) 8458 ); 8459 } 8460 subexit(); 8461 if (node.title) { 8462 subexit = state.enter(`title${suffix}`); 8463 value += tracker.move(' ' + quote); 8464 value += tracker.move( 8465 state.safe(node.title, { 8466 before: value, 8467 after: quote, 8468 ...tracker.current() 8469 }) 8470 ); 8471 value += tracker.move(quote); 8472 subexit(); 8473 } 8474 value += tracker.move(')'); 8475 exit(); 8476 return value 8477} 8478function imagePeek() { 8479 return '!' 8480} 8481 8482imageReference.peek = imageReferencePeek; 8483function imageReference(node, _, state, info) { 8484 const type = node.referenceType; 8485 const exit = state.enter('imageReference'); 8486 let subexit = state.enter('label'); 8487 const tracker = state.createTracker(info); 8488 let value = tracker.move('!['); 8489 const alt = state.safe(node.alt, { 8490 before: value, 8491 after: ']', 8492 ...tracker.current() 8493 }); 8494 value += tracker.move(alt + ']['); 8495 subexit(); 8496 const stack = state.stack; 8497 state.stack = []; 8498 subexit = state.enter('reference'); 8499 const reference = state.safe(state.associationId(node), { 8500 before: value, 8501 after: ']', 8502 ...tracker.current() 8503 }); 8504 subexit(); 8505 state.stack = stack; 8506 exit(); 8507 if (type === 'full' || !alt || alt !== reference) { 8508 value += tracker.move(reference + ']'); 8509 } else if (type === 'shortcut') { 8510 value = value.slice(0, -1); 8511 } else { 8512 value += tracker.move(']'); 8513 } 8514 return value 8515} 8516function imageReferencePeek() { 8517 return '!' 8518} 8519 8520function patternCompile(pattern) { 8521 if (!pattern._compiled) { 8522 const before = 8523 (pattern.atBreak ? '[\\r\\n][\\t ]*' : '') + 8524 (pattern.before ? '(?:' + pattern.before + ')' : ''); 8525 pattern._compiled = new RegExp( 8526 (before ? '(' + before + ')' : '') + 8527 (/[|\\{}()[\]^$+*?.-]/.test(pattern.character) ? '\\' : '') + 8528 pattern.character + 8529 (pattern.after ? '(?:' + pattern.after + ')' : ''), 8530 'g' 8531 ); 8532 } 8533 return pattern._compiled 8534} 8535 8536inlineCode.peek = inlineCodePeek; 8537function inlineCode(node, _, state) { 8538 let value = node.value || ''; 8539 let sequence = '`'; 8540 let index = -1; 8541 while (new RegExp('(^|[^`])' + sequence + '([^`]|$)').test(value)) { 8542 sequence += '`'; 8543 } 8544 if ( 8545 /[^ \r\n]/.test(value) && 8546 ((/^[ \r\n]/.test(value) && /[ \r\n]$/.test(value)) || /^`|`$/.test(value)) 8547 ) { 8548 value = ' ' + value + ' '; 8549 } 8550 while (++index < state.unsafe.length) { 8551 const pattern = state.unsafe[index]; 8552 const expression = patternCompile(pattern); 8553 let match; 8554 if (!pattern.atBreak) continue 8555 while ((match = expression.exec(value))) { 8556 let position = match.index; 8557 if ( 8558 value.charCodeAt(position) === 10 && 8559 value.charCodeAt(position - 1) === 13 8560 ) { 8561 position--; 8562 } 8563 value = value.slice(0, position) + ' ' + value.slice(match.index + 1); 8564 } 8565 } 8566 return sequence + value + sequence 8567} 8568function inlineCodePeek() { 8569 return '`' 8570} 8571 8572function formatLinkAsAutolink(node, state) { 8573 const raw = toString(node); 8574 return Boolean( 8575 !state.options.resourceLink && 8576 node.url && 8577 !node.title && 8578 node.children && 8579 node.children.length === 1 && 8580 node.children[0].type === 'text' && 8581 (raw === node.url || 'mailto:' + raw === node.url) && 8582 /^[a-z][a-z+.-]+:/i.test(node.url) && 8583 !/[\0- <>\u007F]/.test(node.url) 8584 ) 8585} 8586 8587link.peek = linkPeek; 8588function link(node, _, state, info) { 8589 const quote = checkQuote(state); 8590 const suffix = quote === '"' ? 'Quote' : 'Apostrophe'; 8591 const tracker = state.createTracker(info); 8592 let exit; 8593 let subexit; 8594 if (formatLinkAsAutolink(node, state)) { 8595 const stack = state.stack; 8596 state.stack = []; 8597 exit = state.enter('autolink'); 8598 let value = tracker.move('<'); 8599 value += tracker.move( 8600 state.containerPhrasing(node, { 8601 before: value, 8602 after: '>', 8603 ...tracker.current() 8604 }) 8605 ); 8606 value += tracker.move('>'); 8607 exit(); 8608 state.stack = stack; 8609 return value 8610 } 8611 exit = state.enter('link'); 8612 subexit = state.enter('label'); 8613 let value = tracker.move('['); 8614 value += tracker.move( 8615 state.containerPhrasing(node, { 8616 before: value, 8617 after: '](', 8618 ...tracker.current() 8619 }) 8620 ); 8621 value += tracker.move(']('); 8622 subexit(); 8623 if ( 8624 (!node.url && node.title) || 8625 /[\0- \u007F]/.test(node.url) 8626 ) { 8627 subexit = state.enter('destinationLiteral'); 8628 value += tracker.move('<'); 8629 value += tracker.move( 8630 state.safe(node.url, {before: value, after: '>', ...tracker.current()}) 8631 ); 8632 value += tracker.move('>'); 8633 } else { 8634 subexit = state.enter('destinationRaw'); 8635 value += tracker.move( 8636 state.safe(node.url, { 8637 before: value, 8638 after: node.title ? ' ' : ')', 8639 ...tracker.current() 8640 }) 8641 ); 8642 } 8643 subexit(); 8644 if (node.title) { 8645 subexit = state.enter(`title${suffix}`); 8646 value += tracker.move(' ' + quote); 8647 value += tracker.move( 8648 state.safe(node.title, { 8649 before: value, 8650 after: quote, 8651 ...tracker.current() 8652 }) 8653 ); 8654 value += tracker.move(quote); 8655 subexit(); 8656 } 8657 value += tracker.move(')'); 8658 exit(); 8659 return value 8660} 8661function linkPeek(node, _, state) { 8662 return formatLinkAsAutolink(node, state) ? '<' : '[' 8663} 8664 8665linkReference.peek = linkReferencePeek; 8666function linkReference(node, _, state, info) { 8667 const type = node.referenceType; 8668 const exit = state.enter('linkReference'); 8669 let subexit = state.enter('label'); 8670 const tracker = state.createTracker(info); 8671 let value = tracker.move('['); 8672 const text = state.containerPhrasing(node, { 8673 before: value, 8674 after: ']', 8675 ...tracker.current() 8676 }); 8677 value += tracker.move(text + ']['); 8678 subexit(); 8679 const stack = state.stack; 8680 state.stack = []; 8681 subexit = state.enter('reference'); 8682 const reference = state.safe(state.associationId(node), { 8683 before: value, 8684 after: ']', 8685 ...tracker.current() 8686 }); 8687 subexit(); 8688 state.stack = stack; 8689 exit(); 8690 if (type === 'full' || !text || text !== reference) { 8691 value += tracker.move(reference + ']'); 8692 } else if (type === 'shortcut') { 8693 value = value.slice(0, -1); 8694 } else { 8695 value += tracker.move(']'); 8696 } 8697 return value 8698} 8699function linkReferencePeek() { 8700 return '[' 8701} 8702 8703function checkBullet(state) { 8704 const marker = state.options.bullet || '*'; 8705 if (marker !== '*' && marker !== '+' && marker !== '-') { 8706 throw new Error( 8707 'Cannot serialize items with `' + 8708 marker + 8709 '` for `options.bullet`, expected `*`, `+`, or `-`' 8710 ) 8711 } 8712 return marker 8713} 8714 8715function checkBulletOther(state) { 8716 const bullet = checkBullet(state); 8717 const bulletOther = state.options.bulletOther; 8718 if (!bulletOther) { 8719 return bullet === '*' ? '-' : '*' 8720 } 8721 if (bulletOther !== '*' && bulletOther !== '+' && bulletOther !== '-') { 8722 throw new Error( 8723 'Cannot serialize items with `' + 8724 bulletOther + 8725 '` for `options.bulletOther`, expected `*`, `+`, or `-`' 8726 ) 8727 } 8728 if (bulletOther === bullet) { 8729 throw new Error( 8730 'Expected `bullet` (`' + 8731 bullet + 8732 '`) and `bulletOther` (`' + 8733 bulletOther + 8734 '`) to be different' 8735 ) 8736 } 8737 return bulletOther 8738} 8739 8740function checkBulletOrdered(state) { 8741 const marker = state.options.bulletOrdered || '.'; 8742 if (marker !== '.' && marker !== ')') { 8743 throw new Error( 8744 'Cannot serialize items with `' + 8745 marker + 8746 '` for `options.bulletOrdered`, expected `.` or `)`' 8747 ) 8748 } 8749 return marker 8750} 8751 8752function checkBulletOrderedOther(state) { 8753 const bulletOrdered = checkBulletOrdered(state); 8754 const bulletOrderedOther = state.options.bulletOrderedOther; 8755 if (!bulletOrderedOther) { 8756 return bulletOrdered === '.' ? ')' : '.' 8757 } 8758 if (bulletOrderedOther !== '.' && bulletOrderedOther !== ')') { 8759 throw new Error( 8760 'Cannot serialize items with `' + 8761 bulletOrderedOther + 8762 '` for `options.bulletOrderedOther`, expected `*`, `+`, or `-`' 8763 ) 8764 } 8765 if (bulletOrderedOther === bulletOrdered) { 8766 throw new Error( 8767 'Expected `bulletOrdered` (`' + 8768 bulletOrdered + 8769 '`) and `bulletOrderedOther` (`' + 8770 bulletOrderedOther + 8771 '`) to be different' 8772 ) 8773 } 8774 return bulletOrderedOther 8775} 8776 8777function checkRule(state) { 8778 const marker = state.options.rule || '*'; 8779 if (marker !== '*' && marker !== '-' && marker !== '_') { 8780 throw new Error( 8781 'Cannot serialize rules with `' + 8782 marker + 8783 '` for `options.rule`, expected `*`, `-`, or `_`' 8784 ) 8785 } 8786 return marker 8787} 8788 8789function list(node, parent, state, info) { 8790 const exit = state.enter('list'); 8791 const bulletCurrent = state.bulletCurrent; 8792 let bullet = node.ordered ? checkBulletOrdered(state) : checkBullet(state); 8793 const bulletOther = node.ordered 8794 ? checkBulletOrderedOther(state) 8795 : checkBulletOther(state); 8796 const bulletLastUsed = state.bulletLastUsed; 8797 let useDifferentMarker = false; 8798 if ( 8799 parent && 8800 (node.ordered 8801 ? state.options.bulletOrderedOther 8802 : state.options.bulletOther) && 8803 bulletLastUsed && 8804 bullet === bulletLastUsed 8805 ) { 8806 useDifferentMarker = true; 8807 } 8808 if (!node.ordered) { 8809 const firstListItem = node.children ? node.children[0] : undefined; 8810 if ( 8811 (bullet === '*' || bullet === '-') && 8812 firstListItem && 8813 (!firstListItem.children || !firstListItem.children[0]) && 8814 state.stack[state.stack.length - 1] === 'list' && 8815 state.stack[state.stack.length - 2] === 'listItem' && 8816 state.stack[state.stack.length - 3] === 'list' && 8817 state.stack[state.stack.length - 4] === 'listItem' && 8818 state.indexStack[state.indexStack.length - 1] === 0 && 8819 state.indexStack[state.indexStack.length - 2] === 0 && 8820 state.indexStack[state.indexStack.length - 3] === 0 8821 ) { 8822 useDifferentMarker = true; 8823 } 8824 if (checkRule(state) === bullet && firstListItem) { 8825 let index = -1; 8826 while (++index < node.children.length) { 8827 const item = node.children[index]; 8828 if ( 8829 item && 8830 item.type === 'listItem' && 8831 item.children && 8832 item.children[0] && 8833 item.children[0].type === 'thematicBreak' 8834 ) { 8835 useDifferentMarker = true; 8836 break 8837 } 8838 } 8839 } 8840 } 8841 if (useDifferentMarker) { 8842 bullet = bulletOther; 8843 } 8844 state.bulletCurrent = bullet; 8845 const value = state.containerFlow(node, info); 8846 state.bulletLastUsed = bullet; 8847 state.bulletCurrent = bulletCurrent; 8848 exit(); 8849 return value 8850} 8851 8852function checkListItemIndent(state) { 8853 const style = state.options.listItemIndent || 'tab'; 8854 if (style === 1 || style === '1') { 8855 return 'one' 8856 } 8857 if (style !== 'tab' && style !== 'one' && style !== 'mixed') { 8858 throw new Error( 8859 'Cannot serialize items with `' + 8860 style + 8861 '` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`' 8862 ) 8863 } 8864 return style 8865} 8866 8867function listItem(node, parent, state, info) { 8868 const listItemIndent = checkListItemIndent(state); 8869 let bullet = state.bulletCurrent || checkBullet(state); 8870 if (parent && parent.type === 'list' && parent.ordered) { 8871 bullet = 8872 (typeof parent.start === 'number' && parent.start > -1 8873 ? parent.start 8874 : 1) + 8875 (state.options.incrementListMarker === false 8876 ? 0 8877 : parent.children.indexOf(node)) + 8878 bullet; 8879 } 8880 let size = bullet.length + 1; 8881 if ( 8882 listItemIndent === 'tab' || 8883 (listItemIndent === 'mixed' && 8884 ((parent && parent.type === 'list' && parent.spread) || node.spread)) 8885 ) { 8886 size = Math.ceil(size / 4) * 4; 8887 } 8888 const tracker = state.createTracker(info); 8889 tracker.move(bullet + ' '.repeat(size - bullet.length)); 8890 tracker.shift(size); 8891 const exit = state.enter('listItem'); 8892 const value = state.indentLines( 8893 state.containerFlow(node, tracker.current()), 8894 map 8895 ); 8896 exit(); 8897 return value 8898 function map(line, index, blank) { 8899 if (index) { 8900 return (blank ? '' : ' '.repeat(size)) + line 8901 } 8902 return (blank ? bullet : bullet + ' '.repeat(size - bullet.length)) + line 8903 } 8904} 8905 8906function paragraph(node, _, state, info) { 8907 const exit = state.enter('paragraph'); 8908 const subexit = state.enter('phrasing'); 8909 const value = state.containerPhrasing(node, info); 8910 subexit(); 8911 exit(); 8912 return value 8913} 8914 8915const phrasing = ( 8916 convert([ 8917 'break', 8918 'delete', 8919 'emphasis', 8920 'footnote', 8921 'footnoteReference', 8922 'image', 8923 'imageReference', 8924 'inlineCode', 8925 'link', 8926 'linkReference', 8927 'strong', 8928 'text' 8929 ]) 8930); 8931 8932function root(node, _, state, info) { 8933 const hasPhrasing = node.children.some((d) => phrasing(d)); 8934 const fn = hasPhrasing ? state.containerPhrasing : state.containerFlow; 8935 return fn.call(state, node, info) 8936} 8937 8938function checkStrong(state) { 8939 const marker = state.options.strong || '*'; 8940 if (marker !== '*' && marker !== '_') { 8941 throw new Error( 8942 'Cannot serialize strong with `' + 8943 marker + 8944 '` for `options.strong`, expected `*`, or `_`' 8945 ) 8946 } 8947 return marker 8948} 8949 8950strong.peek = strongPeek; 8951function strong(node, _, state, info) { 8952 const marker = checkStrong(state); 8953 const exit = state.enter('strong'); 8954 const tracker = state.createTracker(info); 8955 let value = tracker.move(marker + marker); 8956 value += tracker.move( 8957 state.containerPhrasing(node, { 8958 before: value, 8959 after: marker, 8960 ...tracker.current() 8961 }) 8962 ); 8963 value += tracker.move(marker + marker); 8964 exit(); 8965 return value 8966} 8967function strongPeek(_, _1, state) { 8968 return state.options.strong || '*' 8969} 8970 8971function text$1(node, _, state, info) { 8972 return state.safe(node.value, info) 8973} 8974 8975function checkRuleRepetition(state) { 8976 const repetition = state.options.ruleRepetition || 3; 8977 if (repetition < 3) { 8978 throw new Error( 8979 'Cannot serialize rules with repetition `' + 8980 repetition + 8981 '` for `options.ruleRepetition`, expected `3` or more' 8982 ) 8983 } 8984 return repetition 8985} 8986 8987function thematicBreak(_, _1, state) { 8988 const value = ( 8989 checkRule(state) + (state.options.ruleSpaces ? ' ' : '') 8990 ).repeat(checkRuleRepetition(state)); 8991 return state.options.ruleSpaces ? value.slice(0, -1) : value 8992} 8993 8994const handle = { 8995 blockquote, 8996 break: hardBreak, 8997 code: code$1, 8998 definition, 8999 emphasis, 9000 hardBreak, 9001 heading, 9002 html, 9003 image, 9004 imageReference, 9005 inlineCode, 9006 link, 9007 linkReference, 9008 list, 9009 listItem, 9010 paragraph, 9011 root, 9012 strong, 9013 text: text$1, 9014 thematicBreak 9015}; 9016 9017const join = [joinDefaults]; 9018function joinDefaults(left, right, parent, state) { 9019 if ( 9020 right.type === 'code' && 9021 formatCodeAsIndented(right, state) && 9022 (left.type === 'list' || 9023 (left.type === right.type && formatCodeAsIndented(left, state))) 9024 ) { 9025 return false 9026 } 9027 if ( 9028 left.type === 'list' && 9029 left.type === right.type && 9030 Boolean(left.ordered) === Boolean(right.ordered) && 9031 !(left.ordered 9032 ? state.options.bulletOrderedOther 9033 : state.options.bulletOther) 9034 ) { 9035 return false 9036 } 9037 if ('spread' in parent && typeof parent.spread === 'boolean') { 9038 if ( 9039 left.type === 'paragraph' && 9040 (left.type === right.type || 9041 right.type === 'definition' || 9042 (right.type === 'heading' && formatHeadingAsSetext(right, state))) 9043 ) { 9044 return 9045 } 9046 return parent.spread ? 1 : 0 9047 } 9048} 9049 9050const fullPhrasingSpans = [ 9051 'autolink', 9052 'destinationLiteral', 9053 'destinationRaw', 9054 'reference', 9055 'titleQuote', 9056 'titleApostrophe' 9057]; 9058const unsafe = [ 9059 {character: '\t', after: '[\\r\\n]', inConstruct: 'phrasing'}, 9060 {character: '\t', before: '[\\r\\n]', inConstruct: 'phrasing'}, 9061 { 9062 character: '\t', 9063 inConstruct: ['codeFencedLangGraveAccent', 'codeFencedLangTilde'] 9064 }, 9065 { 9066 character: '\r', 9067 inConstruct: [ 9068 'codeFencedLangGraveAccent', 9069 'codeFencedLangTilde', 9070 'codeFencedMetaGraveAccent', 9071 'codeFencedMetaTilde', 9072 'destinationLiteral', 9073 'headingAtx' 9074 ] 9075 }, 9076 { 9077 character: '\n', 9078 inConstruct: [ 9079 'codeFencedLangGraveAccent', 9080 'codeFencedLangTilde', 9081 'codeFencedMetaGraveAccent', 9082 'codeFencedMetaTilde', 9083 'destinationLiteral', 9084 'headingAtx' 9085 ] 9086 }, 9087 {character: ' ', after: '[\\r\\n]', inConstruct: 'phrasing'}, 9088 {character: ' ', before: '[\\r\\n]', inConstruct: 'phrasing'}, 9089 { 9090 character: ' ', 9091 inConstruct: ['codeFencedLangGraveAccent', 'codeFencedLangTilde'] 9092 }, 9093 { 9094 character: '!', 9095 after: '\\[', 9096 inConstruct: 'phrasing', 9097 notInConstruct: fullPhrasingSpans 9098 }, 9099 {character: '"', inConstruct: 'titleQuote'}, 9100 {atBreak: true, character: '#'}, 9101 {character: '#', inConstruct: 'headingAtx', after: '(?:[\r\n]|$)'}, 9102 {character: '&', after: '[#A-Za-z]', inConstruct: 'phrasing'}, 9103 {character: "'", inConstruct: 'titleApostrophe'}, 9104 {character: '(', inConstruct: 'destinationRaw'}, 9105 { 9106 before: '\\]', 9107 character: '(', 9108 inConstruct: 'phrasing', 9109 notInConstruct: fullPhrasingSpans 9110 }, 9111 {atBreak: true, before: '\\d+', character: ')'}, 9112 {character: ')', inConstruct: 'destinationRaw'}, 9113 {atBreak: true, character: '*', after: '(?:[ \t\r\n*])'}, 9114 {character: '*', inConstruct: 'phrasing', notInConstruct: fullPhrasingSpans}, 9115 {atBreak: true, character: '+', after: '(?:[ \t\r\n])'}, 9116 {atBreak: true, character: '-', after: '(?:[ \t\r\n-])'}, 9117 {atBreak: true, before: '\\d+', character: '.', after: '(?:[ \t\r\n]|$)'}, 9118 {atBreak: true, character: '<', after: '[!/?A-Za-z]'}, 9119 { 9120 character: '<', 9121 after: '[!/?A-Za-z]', 9122 inConstruct: 'phrasing', 9123 notInConstruct: fullPhrasingSpans 9124 }, 9125 {character: '<', inConstruct: 'destinationLiteral'}, 9126 {atBreak: true, character: '='}, 9127 {atBreak: true, character: '>'}, 9128 {character: '>', inConstruct: 'destinationLiteral'}, 9129 {atBreak: true, character: '['}, 9130 {character: '[', inConstruct: 'phrasing', notInConstruct: fullPhrasingSpans}, 9131 {character: '[', inConstruct: ['label', 'reference']}, 9132 {character: '\\', after: '[\\r\\n]', inConstruct: 'phrasing'}, 9133 {character: ']', inConstruct: ['label', 'reference']}, 9134 {atBreak: true, character: '_'}, 9135 {character: '_', inConstruct: 'phrasing', notInConstruct: fullPhrasingSpans}, 9136 {atBreak: true, character: '`'}, 9137 { 9138 character: '`', 9139 inConstruct: ['codeFencedLangGraveAccent', 'codeFencedMetaGraveAccent'] 9140 }, 9141 {character: '`', inConstruct: 'phrasing', notInConstruct: fullPhrasingSpans}, 9142 {atBreak: true, character: '~'} 9143]; 9144 9145function association(node) { 9146 if (node.label || !node.identifier) { 9147 return node.label || '' 9148 } 9149 return decodeString(node.identifier) 9150} 9151 9152function containerPhrasing(parent, state, info) { 9153 const indexStack = state.indexStack; 9154 const children = parent.children || []; 9155 const results = []; 9156 let index = -1; 9157 let before = info.before; 9158 indexStack.push(-1); 9159 let tracker = state.createTracker(info); 9160 while (++index < children.length) { 9161 const child = children[index]; 9162 let after; 9163 indexStack[indexStack.length - 1] = index; 9164 if (index + 1 < children.length) { 9165 let handle = state.handle.handlers[children[index + 1].type]; 9166 if (handle && handle.peek) handle = handle.peek; 9167 after = handle 9168 ? handle(children[index + 1], parent, state, { 9169 before: '', 9170 after: '', 9171 ...tracker.current() 9172 }).charAt(0) 9173 : ''; 9174 } else { 9175 after = info.after; 9176 } 9177 if ( 9178 results.length > 0 && 9179 (before === '\r' || before === '\n') && 9180 child.type === 'html' 9181 ) { 9182 results[results.length - 1] = results[results.length - 1].replace( 9183 /(\r?\n|\r)$/, 9184 ' ' 9185 ); 9186 before = ' '; 9187 tracker = state.createTracker(info); 9188 tracker.move(results.join('')); 9189 } 9190 results.push( 9191 tracker.move( 9192 state.handle(child, parent, state, { 9193 ...tracker.current(), 9194 before, 9195 after 9196 }) 9197 ) 9198 ); 9199 before = results[results.length - 1].slice(-1); 9200 } 9201 indexStack.pop(); 9202 return results.join('') 9203} 9204 9205function containerFlow(parent, state, info) { 9206 const indexStack = state.indexStack; 9207 const children = parent.children || []; 9208 const tracker = state.createTracker(info); 9209 const results = []; 9210 let index = -1; 9211 indexStack.push(-1); 9212 while (++index < children.length) { 9213 const child = children[index]; 9214 indexStack[indexStack.length - 1] = index; 9215 results.push( 9216 tracker.move( 9217 state.handle(child, parent, state, { 9218 before: '\n', 9219 after: '\n', 9220 ...tracker.current() 9221 }) 9222 ) 9223 ); 9224 if (child.type !== 'list') { 9225 state.bulletLastUsed = undefined; 9226 } 9227 if (index < children.length - 1) { 9228 results.push( 9229 tracker.move(between(child, children[index + 1], parent, state)) 9230 ); 9231 } 9232 } 9233 indexStack.pop(); 9234 return results.join('') 9235} 9236function between(left, right, parent, state) { 9237 let index = state.join.length; 9238 while (index--) { 9239 const result = state.join[index](left, right, parent, state); 9240 if (result === true || result === 1) { 9241 break 9242 } 9243 if (typeof result === 'number') { 9244 return '\n'.repeat(1 + result) 9245 } 9246 if (result === false) { 9247 return '\n\n<!---->\n\n' 9248 } 9249 } 9250 return '\n\n' 9251} 9252 9253const eol$1 = /\r?\n|\r/g; 9254function indentLines(value, map) { 9255 const result = []; 9256 let start = 0; 9257 let line = 0; 9258 let match; 9259 while ((match = eol$1.exec(value))) { 9260 one(value.slice(start, match.index)); 9261 result.push(match[0]); 9262 start = match.index + match[0].length; 9263 line++; 9264 } 9265 one(value.slice(start)); 9266 return result.join('') 9267 function one(value) { 9268 result.push(map(value, line, !value)); 9269 } 9270} 9271 9272function safe(state, input, config) { 9273 const value = (config.before || '') + (input || '') + (config.after || ''); 9274 const positions = []; 9275 const result = []; 9276 const infos = {}; 9277 let index = -1; 9278 while (++index < state.unsafe.length) { 9279 const pattern = state.unsafe[index]; 9280 if (!patternInScope(state.stack, pattern)) { 9281 continue 9282 } 9283 const expression = patternCompile(pattern); 9284 let match; 9285 while ((match = expression.exec(value))) { 9286 const before = 'before' in pattern || Boolean(pattern.atBreak); 9287 const after = 'after' in pattern; 9288 const position = match.index + (before ? match[1].length : 0); 9289 if (positions.includes(position)) { 9290 if (infos[position].before && !before) { 9291 infos[position].before = false; 9292 } 9293 if (infos[position].after && !after) { 9294 infos[position].after = false; 9295 } 9296 } else { 9297 positions.push(position); 9298 infos[position] = {before, after}; 9299 } 9300 } 9301 } 9302 positions.sort(numerical); 9303 let start = config.before ? config.before.length : 0; 9304 const end = value.length - (config.after ? config.after.length : 0); 9305 index = -1; 9306 while (++index < positions.length) { 9307 const position = positions[index]; 9308 if (position < start || position >= end) { 9309 continue 9310 } 9311 if ( 9312 (position + 1 < end && 9313 positions[index + 1] === position + 1 && 9314 infos[position].after && 9315 !infos[position + 1].before && 9316 !infos[position + 1].after) || 9317 (positions[index - 1] === position - 1 && 9318 infos[position].before && 9319 !infos[position - 1].before && 9320 !infos[position - 1].after) 9321 ) { 9322 continue 9323 } 9324 if (start !== position) { 9325 result.push(escapeBackslashes(value.slice(start, position), '\\')); 9326 } 9327 start = position; 9328 if ( 9329 /[!-/:-@[-`{-~]/.test(value.charAt(position)) && 9330 (!config.encode || !config.encode.includes(value.charAt(position))) 9331 ) { 9332 result.push('\\'); 9333 } else { 9334 result.push( 9335 '&#x' + value.charCodeAt(position).toString(16).toUpperCase() + ';' 9336 ); 9337 start++; 9338 } 9339 } 9340 result.push(escapeBackslashes(value.slice(start, end), config.after)); 9341 return result.join('') 9342} 9343function numerical(a, b) { 9344 return a - b 9345} 9346function escapeBackslashes(value, after) { 9347 const expression = /\\(?=[!-/:-@[-`{-~])/g; 9348 const positions = []; 9349 const results = []; 9350 const whole = value + after; 9351 let index = -1; 9352 let start = 0; 9353 let match; 9354 while ((match = expression.exec(whole))) { 9355 positions.push(match.index); 9356 } 9357 while (++index < positions.length) { 9358 if (start !== positions[index]) { 9359 results.push(value.slice(start, positions[index])); 9360 } 9361 results.push('\\'); 9362 start = positions[index]; 9363 } 9364 results.push(value.slice(start)); 9365 return results.join('') 9366} 9367 9368function track(config) { 9369 const options = config || {}; 9370 const now = options.now || {}; 9371 let lineShift = options.lineShift || 0; 9372 let line = now.line || 1; 9373 let column = now.column || 1; 9374 return {move, current, shift} 9375 function current() { 9376 return {now: {line, column}, lineShift} 9377 } 9378 function shift(value) { 9379 lineShift += value; 9380 } 9381 function move(input) { 9382 const value = input || ''; 9383 const chunks = value.split(/\r?\n|\r/g); 9384 const tail = chunks[chunks.length - 1]; 9385 line += chunks.length - 1; 9386 column = 9387 chunks.length === 1 ? column + tail.length : 1 + tail.length + lineShift; 9388 return value 9389 } 9390} 9391 9392function toMarkdown(tree, options = {}) { 9393 const state = { 9394 enter, 9395 indentLines, 9396 associationId: association, 9397 containerPhrasing: containerPhrasingBound, 9398 containerFlow: containerFlowBound, 9399 createTracker: track, 9400 safe: safeBound, 9401 stack: [], 9402 unsafe: [], 9403 join: [], 9404 handlers: {}, 9405 options: {}, 9406 indexStack: [], 9407 handle: undefined 9408 }; 9409 configure(state, {unsafe, join, handlers: handle}); 9410 configure(state, options); 9411 if (state.options.tightDefinitions) { 9412 configure(state, {join: [joinDefinition]}); 9413 } 9414 state.handle = zwitch('type', { 9415 invalid, 9416 unknown, 9417 handlers: state.handlers 9418 }); 9419 let result = state.handle(tree, undefined, state, { 9420 before: '\n', 9421 after: '\n', 9422 now: {line: 1, column: 1}, 9423 lineShift: 0 9424 }); 9425 if ( 9426 result && 9427 result.charCodeAt(result.length - 1) !== 10 && 9428 result.charCodeAt(result.length - 1) !== 13 9429 ) { 9430 result += '\n'; 9431 } 9432 return result 9433 function enter(name) { 9434 state.stack.push(name); 9435 return exit 9436 function exit() { 9437 state.stack.pop(); 9438 } 9439 } 9440} 9441function invalid(value) { 9442 throw new Error('Cannot handle value `' + value + '`, expected node') 9443} 9444function unknown(node) { 9445 throw new Error('Cannot handle unknown node `' + node.type + '`') 9446} 9447function joinDefinition(left, right) { 9448 if (left.type === 'definition' && left.type === right.type) { 9449 return 0 9450 } 9451} 9452function containerPhrasingBound(parent, info) { 9453 return containerPhrasing(parent, this, info) 9454} 9455function containerFlowBound(parent, info) { 9456 return containerFlow(parent, this, info) 9457} 9458function safeBound(value, config) { 9459 return safe(this, value, config) 9460} 9461 9462function remarkStringify(options) { 9463 const compiler = (tree) => { 9464 const settings = (this.data('settings')); 9465 return toMarkdown( 9466 tree, 9467 Object.assign({}, settings, options, { 9468 extensions: 9469 ( 9470 this.data('toMarkdownExtensions') 9471 ) || [] 9472 }) 9473 ) 9474 }; 9475 Object.assign(this, {Compiler: compiler}); 9476} 9477 9478const wwwPrefix = { 9479 tokenize: tokenizeWwwPrefix, 9480 partial: true 9481}; 9482const domain = { 9483 tokenize: tokenizeDomain, 9484 partial: true 9485}; 9486const path = { 9487 tokenize: tokenizePath, 9488 partial: true 9489}; 9490const trail = { 9491 tokenize: tokenizeTrail, 9492 partial: true 9493}; 9494const emailDomainDotTrail = { 9495 tokenize: tokenizeEmailDomainDotTrail, 9496 partial: true 9497}; 9498const wwwAutolink = { 9499 tokenize: tokenizeWwwAutolink, 9500 previous: previousWww 9501}; 9502const protocolAutolink = { 9503 tokenize: tokenizeProtocolAutolink, 9504 previous: previousProtocol 9505}; 9506const emailAutolink = { 9507 tokenize: tokenizeEmailAutolink, 9508 previous: previousEmail 9509}; 9510const text = {}; 9511const gfmAutolinkLiteral = { 9512 text 9513}; 9514let code = 48; 9515while (code < 123) { 9516 text[code] = emailAutolink; 9517 code++; 9518 if (code === 58) code = 65; 9519 else if (code === 91) code = 97; 9520} 9521text[43] = emailAutolink; 9522text[45] = emailAutolink; 9523text[46] = emailAutolink; 9524text[95] = emailAutolink; 9525text[72] = [emailAutolink, protocolAutolink]; 9526text[104] = [emailAutolink, protocolAutolink]; 9527text[87] = [emailAutolink, wwwAutolink]; 9528text[119] = [emailAutolink, wwwAutolink]; 9529function tokenizeEmailAutolink(effects, ok, nok) { 9530 const self = this; 9531 let dot; 9532 let data; 9533 return start 9534 function start(code) { 9535 if ( 9536 !gfmAtext(code) || 9537 !previousEmail.call(self, self.previous) || 9538 previousUnbalanced(self.events) 9539 ) { 9540 return nok(code) 9541 } 9542 effects.enter('literalAutolink'); 9543 effects.enter('literalAutolinkEmail'); 9544 return atext(code) 9545 } 9546 function atext(code) { 9547 if (gfmAtext(code)) { 9548 effects.consume(code); 9549 return atext 9550 } 9551 if (code === 64) { 9552 effects.consume(code); 9553 return emailDomain 9554 } 9555 return nok(code) 9556 } 9557 function emailDomain(code) { 9558 if (code === 46) { 9559 return effects.check( 9560 emailDomainDotTrail, 9561 emailDomainAfter, 9562 emailDomainDot 9563 )(code) 9564 } 9565 if (code === 45 || code === 95 || asciiAlphanumeric(code)) { 9566 data = true; 9567 effects.consume(code); 9568 return emailDomain 9569 } 9570 return emailDomainAfter(code) 9571 } 9572 function emailDomainDot(code) { 9573 effects.consume(code); 9574 dot = true; 9575 return emailDomain 9576 } 9577 function emailDomainAfter(code) { 9578 if (data && dot && asciiAlpha(self.previous)) { 9579 effects.exit('literalAutolinkEmail'); 9580 effects.exit('literalAutolink'); 9581 return ok(code) 9582 } 9583 return nok(code) 9584 } 9585} 9586function tokenizeWwwAutolink(effects, ok, nok) { 9587 const self = this; 9588 return wwwStart 9589 function wwwStart(code) { 9590 if ( 9591 (code !== 87 && code !== 119) || 9592 !previousWww.call(self, self.previous) || 9593 previousUnbalanced(self.events) 9594 ) { 9595 return nok(code) 9596 } 9597 effects.enter('literalAutolink'); 9598 effects.enter('literalAutolinkWww'); 9599 return effects.check( 9600 wwwPrefix, 9601 effects.attempt(domain, effects.attempt(path, wwwAfter), nok), 9602 nok 9603 )(code) 9604 } 9605 function wwwAfter(code) { 9606 effects.exit('literalAutolinkWww'); 9607 effects.exit('literalAutolink'); 9608 return ok(code) 9609 } 9610} 9611function tokenizeProtocolAutolink(effects, ok, nok) { 9612 const self = this; 9613 let buffer = ''; 9614 let seen = false; 9615 return protocolStart 9616 function protocolStart(code) { 9617 if ( 9618 (code === 72 || code === 104) && 9619 previousProtocol.call(self, self.previous) && 9620 !previousUnbalanced(self.events) 9621 ) { 9622 effects.enter('literalAutolink'); 9623 effects.enter('literalAutolinkHttp'); 9624 buffer += String.fromCodePoint(code); 9625 effects.consume(code); 9626 return protocolPrefixInside 9627 } 9628 return nok(code) 9629 } 9630 function protocolPrefixInside(code) { 9631 if (asciiAlpha(code) && buffer.length < 5) { 9632 buffer += String.fromCodePoint(code); 9633 effects.consume(code); 9634 return protocolPrefixInside 9635 } 9636 if (code === 58) { 9637 const protocol = buffer.toLowerCase(); 9638 if (protocol === 'http' || protocol === 'https') { 9639 effects.consume(code); 9640 return protocolSlashesInside 9641 } 9642 } 9643 return nok(code) 9644 } 9645 function protocolSlashesInside(code) { 9646 if (code === 47) { 9647 effects.consume(code); 9648 if (seen) { 9649 return afterProtocol 9650 } 9651 seen = true; 9652 return protocolSlashesInside 9653 } 9654 return nok(code) 9655 } 9656 function afterProtocol(code) { 9657 return code === null || 9658 asciiControl(code) || 9659 markdownLineEndingOrSpace(code) || 9660 unicodeWhitespace(code) || 9661 unicodePunctuation(code) 9662 ? nok(code) 9663 : effects.attempt(domain, effects.attempt(path, protocolAfter), nok)(code) 9664 } 9665 function protocolAfter(code) { 9666 effects.exit('literalAutolinkHttp'); 9667 effects.exit('literalAutolink'); 9668 return ok(code) 9669 } 9670} 9671function tokenizeWwwPrefix(effects, ok, nok) { 9672 let size = 0; 9673 return wwwPrefixInside 9674 function wwwPrefixInside(code) { 9675 if ((code === 87 || code === 119) && size < 3) { 9676 size++; 9677 effects.consume(code); 9678 return wwwPrefixInside 9679 } 9680 if (code === 46 && size === 3) { 9681 effects.consume(code); 9682 return wwwPrefixAfter 9683 } 9684 return nok(code) 9685 } 9686 function wwwPrefixAfter(code) { 9687 return code === null ? nok(code) : ok(code) 9688 } 9689} 9690function tokenizeDomain(effects, ok, nok) { 9691 let underscoreInLastSegment; 9692 let underscoreInLastLastSegment; 9693 let seen; 9694 return domainInside 9695 function domainInside(code) { 9696 if (code === 46 || code === 95) { 9697 return effects.check(trail, domainAfter, domainAtPunctuation)(code) 9698 } 9699 if ( 9700 code === null || 9701 markdownLineEndingOrSpace(code) || 9702 unicodeWhitespace(code) || 9703 (code !== 45 && unicodePunctuation(code)) 9704 ) { 9705 return domainAfter(code) 9706 } 9707 seen = true; 9708 effects.consume(code); 9709 return domainInside 9710 } 9711 function domainAtPunctuation(code) { 9712 if (code === 95) { 9713 underscoreInLastSegment = true; 9714 } 9715 else { 9716 underscoreInLastLastSegment = underscoreInLastSegment; 9717 underscoreInLastSegment = undefined; 9718 } 9719 effects.consume(code); 9720 return domainInside 9721 } 9722 function domainAfter(code) { 9723 if (underscoreInLastLastSegment || underscoreInLastSegment || !seen) { 9724 return nok(code) 9725 } 9726 return ok(code) 9727 } 9728} 9729function tokenizePath(effects, ok) { 9730 let sizeOpen = 0; 9731 let sizeClose = 0; 9732 return pathInside 9733 function pathInside(code) { 9734 if (code === 40) { 9735 sizeOpen++; 9736 effects.consume(code); 9737 return pathInside 9738 } 9739 if (code === 41 && sizeClose < sizeOpen) { 9740 return pathAtPunctuation(code) 9741 } 9742 if ( 9743 code === 33 || 9744 code === 34 || 9745 code === 38 || 9746 code === 39 || 9747 code === 41 || 9748 code === 42 || 9749 code === 44 || 9750 code === 46 || 9751 code === 58 || 9752 code === 59 || 9753 code === 60 || 9754 code === 63 || 9755 code === 93 || 9756 code === 95 || 9757 code === 126 9758 ) { 9759 return effects.check(trail, ok, pathAtPunctuation)(code) 9760 } 9761 if ( 9762 code === null || 9763 markdownLineEndingOrSpace(code) || 9764 unicodeWhitespace(code) 9765 ) { 9766 return ok(code) 9767 } 9768 effects.consume(code); 9769 return pathInside 9770 } 9771 function pathAtPunctuation(code) { 9772 if (code === 41) { 9773 sizeClose++; 9774 } 9775 effects.consume(code); 9776 return pathInside 9777 } 9778} 9779function tokenizeTrail(effects, ok, nok) { 9780 return trail 9781 function trail(code) { 9782 if ( 9783 code === 33 || 9784 code === 34 || 9785 code === 39 || 9786 code === 41 || 9787 code === 42 || 9788 code === 44 || 9789 code === 46 || 9790 code === 58 || 9791 code === 59 || 9792 code === 63 || 9793 code === 95 || 9794 code === 126 9795 ) { 9796 effects.consume(code); 9797 return trail 9798 } 9799 if (code === 38) { 9800 effects.consume(code); 9801 return trailCharRefStart 9802 } 9803 if (code === 93) { 9804 effects.consume(code); 9805 return trailBracketAfter 9806 } 9807 if ( 9808 code === 60 || 9809 code === null || 9810 markdownLineEndingOrSpace(code) || 9811 unicodeWhitespace(code) 9812 ) { 9813 return ok(code) 9814 } 9815 return nok(code) 9816 } 9817 function trailBracketAfter(code) { 9818 if ( 9819 code === null || 9820 code === 40 || 9821 code === 91 || 9822 markdownLineEndingOrSpace(code) || 9823 unicodeWhitespace(code) 9824 ) { 9825 return ok(code) 9826 } 9827 return trail(code) 9828 } 9829 function trailCharRefStart(code) { 9830 return asciiAlpha(code) ? trailCharRefInside(code) : nok(code) 9831 } 9832 function trailCharRefInside(code) { 9833 if (code === 59) { 9834 effects.consume(code); 9835 return trail 9836 } 9837 if (asciiAlpha(code)) { 9838 effects.consume(code); 9839 return trailCharRefInside 9840 } 9841 return nok(code) 9842 } 9843} 9844function tokenizeEmailDomainDotTrail(effects, ok, nok) { 9845 return start 9846 function start(code) { 9847 effects.consume(code); 9848 return after 9849 } 9850 function after(code) { 9851 return asciiAlphanumeric(code) ? nok(code) : ok(code) 9852 } 9853} 9854function previousWww(code) { 9855 return ( 9856 code === null || 9857 code === 40 || 9858 code === 42 || 9859 code === 95 || 9860 code === 91 || 9861 code === 93 || 9862 code === 126 || 9863 markdownLineEndingOrSpace(code) 9864 ) 9865} 9866function previousProtocol(code) { 9867 return !asciiAlpha(code) 9868} 9869function previousEmail(code) { 9870 return !(code === 47 || gfmAtext(code)) 9871} 9872function gfmAtext(code) { 9873 return ( 9874 code === 43 || 9875 code === 45 || 9876 code === 46 || 9877 code === 95 || 9878 asciiAlphanumeric(code) 9879 ) 9880} 9881function previousUnbalanced(events) { 9882 let index = events.length; 9883 let result = false; 9884 while (index--) { 9885 const token = events[index][1]; 9886 if ( 9887 (token.type === 'labelLink' || token.type === 'labelImage') && 9888 !token._balanced 9889 ) { 9890 result = true; 9891 break 9892 } 9893 if (token._gfmAutolinkLiteralWalkedInto) { 9894 result = false; 9895 break 9896 } 9897 } 9898 if (events.length > 0 && !result) { 9899 events[events.length - 1][1]._gfmAutolinkLiteralWalkedInto = true; 9900 } 9901 return result 9902} 9903 9904const indent = { 9905 tokenize: tokenizeIndent, 9906 partial: true 9907}; 9908function gfmFootnote() { 9909 return { 9910 document: { 9911 [91]: { 9912 tokenize: tokenizeDefinitionStart, 9913 continuation: { 9914 tokenize: tokenizeDefinitionContinuation 9915 }, 9916 exit: gfmFootnoteDefinitionEnd 9917 } 9918 }, 9919 text: { 9920 [91]: { 9921 tokenize: tokenizeGfmFootnoteCall 9922 }, 9923 [93]: { 9924 add: 'after', 9925 tokenize: tokenizePotentialGfmFootnoteCall, 9926 resolveTo: resolveToPotentialGfmFootnoteCall 9927 } 9928 } 9929 } 9930} 9931function tokenizePotentialGfmFootnoteCall(effects, ok, nok) { 9932 const self = this; 9933 let index = self.events.length; 9934 const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []); 9935 let labelStart; 9936 while (index--) { 9937 const token = self.events[index][1]; 9938 if (token.type === 'labelImage') { 9939 labelStart = token; 9940 break 9941 } 9942 if ( 9943 token.type === 'gfmFootnoteCall' || 9944 token.type === 'labelLink' || 9945 token.type === 'label' || 9946 token.type === 'image' || 9947 token.type === 'link' 9948 ) { 9949 break 9950 } 9951 } 9952 return start 9953 function start(code) { 9954 if (!labelStart || !labelStart._balanced) { 9955 return nok(code) 9956 } 9957 const id = normalizeIdentifier( 9958 self.sliceSerialize({ 9959 start: labelStart.end, 9960 end: self.now() 9961 }) 9962 ); 9963 if (id.codePointAt(0) !== 94 || !defined.includes(id.slice(1))) { 9964 return nok(code) 9965 } 9966 effects.enter('gfmFootnoteCallLabelMarker'); 9967 effects.consume(code); 9968 effects.exit('gfmFootnoteCallLabelMarker'); 9969 return ok(code) 9970 } 9971} 9972function resolveToPotentialGfmFootnoteCall(events, context) { 9973 let index = events.length; 9974 while (index--) { 9975 if ( 9976 events[index][1].type === 'labelImage' && 9977 events[index][0] === 'enter' 9978 ) { 9979 events[index][1]; 9980 break 9981 } 9982 } 9983 events[index + 1][1].type = 'data'; 9984 events[index + 3][1].type = 'gfmFootnoteCallLabelMarker'; 9985 const call = { 9986 type: 'gfmFootnoteCall', 9987 start: Object.assign({}, events[index + 3][1].start), 9988 end: Object.assign({}, events[events.length - 1][1].end) 9989 }; 9990 const marker = { 9991 type: 'gfmFootnoteCallMarker', 9992 start: Object.assign({}, events[index + 3][1].end), 9993 end: Object.assign({}, events[index + 3][1].end) 9994 }; 9995 marker.end.column++; 9996 marker.end.offset++; 9997 marker.end._bufferIndex++; 9998 const string = { 9999 type: 'gfmFootnoteCallString', 10000 start: Object.assign({}, marker.end), 10001 end: Object.assign({}, events[events.length - 1][1].start) 10002 }; 10003 const chunk = { 10004 type: 'chunkString', 10005 contentType: 'string', 10006 start: Object.assign({}, string.start), 10007 end: Object.assign({}, string.end) 10008 }; 10009 const replacement = [ 10010 events[index + 1], 10011 events[index + 2], 10012 ['enter', call, context], 10013 events[index + 3], 10014 events[index + 4], 10015 ['enter', marker, context], 10016 ['exit', marker, context], 10017 ['enter', string, context], 10018 ['enter', chunk, context], 10019 ['exit', chunk, context], 10020 ['exit', string, context], 10021 events[events.length - 2], 10022 events[events.length - 1], 10023 ['exit', call, context] 10024 ]; 10025 events.splice(index, events.length - index + 1, ...replacement); 10026 return events 10027} 10028function tokenizeGfmFootnoteCall(effects, ok, nok) { 10029 const self = this; 10030 const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []); 10031 let size = 0; 10032 let data; 10033 return start 10034 function start(code) { 10035 effects.enter('gfmFootnoteCall'); 10036 effects.enter('gfmFootnoteCallLabelMarker'); 10037 effects.consume(code); 10038 effects.exit('gfmFootnoteCallLabelMarker'); 10039 return callStart 10040 } 10041 function callStart(code) { 10042 if (code !== 94) return nok(code) 10043 effects.enter('gfmFootnoteCallMarker'); 10044 effects.consume(code); 10045 effects.exit('gfmFootnoteCallMarker'); 10046 effects.enter('gfmFootnoteCallString'); 10047 effects.enter('chunkString').contentType = 'string'; 10048 return callData 10049 } 10050 function callData(code) { 10051 if ( 10052 size > 999 || 10053 (code === 93 && !data) || 10054 code === null || 10055 code === 91 || 10056 markdownLineEndingOrSpace(code) 10057 ) { 10058 return nok(code) 10059 } 10060 if (code === 93) { 10061 effects.exit('chunkString'); 10062 const token = effects.exit('gfmFootnoteCallString'); 10063 if (!defined.includes(normalizeIdentifier(self.sliceSerialize(token)))) { 10064 return nok(code) 10065 } 10066 effects.enter('gfmFootnoteCallLabelMarker'); 10067 effects.consume(code); 10068 effects.exit('gfmFootnoteCallLabelMarker'); 10069 effects.exit('gfmFootnoteCall'); 10070 return ok 10071 } 10072 if (!markdownLineEndingOrSpace(code)) { 10073 data = true; 10074 } 10075 size++; 10076 effects.consume(code); 10077 return code === 92 ? callEscape : callData 10078 } 10079 function callEscape(code) { 10080 if (code === 91 || code === 92 || code === 93) { 10081 effects.consume(code); 10082 size++; 10083 return callData 10084 } 10085 return callData(code) 10086 } 10087} 10088function tokenizeDefinitionStart(effects, ok, nok) { 10089 const self = this; 10090 const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = []); 10091 let identifier; 10092 let size = 0; 10093 let data; 10094 return start 10095 function start(code) { 10096 effects.enter('gfmFootnoteDefinition')._container = true; 10097 effects.enter('gfmFootnoteDefinitionLabel'); 10098 effects.enter('gfmFootnoteDefinitionLabelMarker'); 10099 effects.consume(code); 10100 effects.exit('gfmFootnoteDefinitionLabelMarker'); 10101 return labelAtMarker 10102 } 10103 function labelAtMarker(code) { 10104 if (code === 94) { 10105 effects.enter('gfmFootnoteDefinitionMarker'); 10106 effects.consume(code); 10107 effects.exit('gfmFootnoteDefinitionMarker'); 10108 effects.enter('gfmFootnoteDefinitionLabelString'); 10109 effects.enter('chunkString').contentType = 'string'; 10110 return labelInside 10111 } 10112 return nok(code) 10113 } 10114 function labelInside(code) { 10115 if ( 10116 size > 999 || 10117 (code === 93 && !data) || 10118 code === null || 10119 code === 91 || 10120 markdownLineEndingOrSpace(code) 10121 ) { 10122 return nok(code) 10123 } 10124 if (code === 93) { 10125 effects.exit('chunkString'); 10126 const token = effects.exit('gfmFootnoteDefinitionLabelString'); 10127 identifier = normalizeIdentifier(self.sliceSerialize(token)); 10128 effects.enter('gfmFootnoteDefinitionLabelMarker'); 10129 effects.consume(code); 10130 effects.exit('gfmFootnoteDefinitionLabelMarker'); 10131 effects.exit('gfmFootnoteDefinitionLabel'); 10132 return labelAfter 10133 } 10134 if (!markdownLineEndingOrSpace(code)) { 10135 data = true; 10136 } 10137 size++; 10138 effects.consume(code); 10139 return code === 92 ? labelEscape : labelInside 10140 } 10141 function labelEscape(code) { 10142 if (code === 91 || code === 92 || code === 93) { 10143 effects.consume(code); 10144 size++; 10145 return labelInside 10146 } 10147 return labelInside(code) 10148 } 10149 function labelAfter(code) { 10150 if (code === 58) { 10151 effects.enter('definitionMarker'); 10152 effects.consume(code); 10153 effects.exit('definitionMarker'); 10154 if (!defined.includes(identifier)) { 10155 defined.push(identifier); 10156 } 10157 return factorySpace( 10158 effects, 10159 whitespaceAfter, 10160 'gfmFootnoteDefinitionWhitespace' 10161 ) 10162 } 10163 return nok(code) 10164 } 10165 function whitespaceAfter(code) { 10166 return ok(code) 10167 } 10168} 10169function tokenizeDefinitionContinuation(effects, ok, nok) { 10170 return effects.check(blankLine, ok, effects.attempt(indent, ok, nok)) 10171} 10172function gfmFootnoteDefinitionEnd(effects) { 10173 effects.exit('gfmFootnoteDefinition'); 10174} 10175function tokenizeIndent(effects, ok, nok) { 10176 const self = this; 10177 return factorySpace( 10178 effects, 10179 afterPrefix, 10180 'gfmFootnoteDefinitionIndent', 10181 4 + 1 10182 ) 10183 function afterPrefix(code) { 10184 const tail = self.events[self.events.length - 1]; 10185 return tail && 10186 tail[1].type === 'gfmFootnoteDefinitionIndent' && 10187 tail[2].sliceSerialize(tail[1], true).length === 4 10188 ? ok(code) 10189 : nok(code) 10190 } 10191} 10192 10193function gfmStrikethrough(options) { 10194 const options_ = options || {}; 10195 let single = options_.singleTilde; 10196 const tokenizer = { 10197 tokenize: tokenizeStrikethrough, 10198 resolveAll: resolveAllStrikethrough 10199 }; 10200 if (single === null || single === undefined) { 10201 single = true; 10202 } 10203 return { 10204 text: { 10205 [126]: tokenizer 10206 }, 10207 insideSpan: { 10208 null: [tokenizer] 10209 }, 10210 attentionMarkers: { 10211 null: [126] 10212 } 10213 } 10214 function resolveAllStrikethrough(events, context) { 10215 let index = -1; 10216 while (++index < events.length) { 10217 if ( 10218 events[index][0] === 'enter' && 10219 events[index][1].type === 'strikethroughSequenceTemporary' && 10220 events[index][1]._close 10221 ) { 10222 let open = index; 10223 while (open--) { 10224 if ( 10225 events[open][0] === 'exit' && 10226 events[open][1].type === 'strikethroughSequenceTemporary' && 10227 events[open][1]._open && 10228 events[index][1].end.offset - events[index][1].start.offset === 10229 events[open][1].end.offset - events[open][1].start.offset 10230 ) { 10231 events[index][1].type = 'strikethroughSequence'; 10232 events[open][1].type = 'strikethroughSequence'; 10233 const strikethrough = { 10234 type: 'strikethrough', 10235 start: Object.assign({}, events[open][1].start), 10236 end: Object.assign({}, events[index][1].end) 10237 }; 10238 const text = { 10239 type: 'strikethroughText', 10240 start: Object.assign({}, events[open][1].end), 10241 end: Object.assign({}, events[index][1].start) 10242 }; 10243 const nextEvents = [ 10244 ['enter', strikethrough, context], 10245 ['enter', events[open][1], context], 10246 ['exit', events[open][1], context], 10247 ['enter', text, context] 10248 ]; 10249 const insideSpan = context.parser.constructs.insideSpan.null; 10250 if (insideSpan) { 10251 splice( 10252 nextEvents, 10253 nextEvents.length, 10254 0, 10255 resolveAll(insideSpan, events.slice(open + 1, index), context) 10256 ); 10257 } 10258 splice(nextEvents, nextEvents.length, 0, [ 10259 ['exit', text, context], 10260 ['enter', events[index][1], context], 10261 ['exit', events[index][1], context], 10262 ['exit', strikethrough, context] 10263 ]); 10264 splice(events, open - 1, index - open + 3, nextEvents); 10265 index = open + nextEvents.length - 2; 10266 break 10267 } 10268 } 10269 } 10270 } 10271 index = -1; 10272 while (++index < events.length) { 10273 if (events[index][1].type === 'strikethroughSequenceTemporary') { 10274 events[index][1].type = 'data'; 10275 } 10276 } 10277 return events 10278 } 10279 function tokenizeStrikethrough(effects, ok, nok) { 10280 const previous = this.previous; 10281 const events = this.events; 10282 let size = 0; 10283 return start 10284 function start(code) { 10285 if ( 10286 previous === 126 && 10287 events[events.length - 1][1].type !== 'characterEscape' 10288 ) { 10289 return nok(code) 10290 } 10291 effects.enter('strikethroughSequenceTemporary'); 10292 return more(code) 10293 } 10294 function more(code) { 10295 const before = classifyCharacter(previous); 10296 if (code === 126) { 10297 if (size > 1) return nok(code) 10298 effects.consume(code); 10299 size++; 10300 return more 10301 } 10302 if (size < 2 && !single) return nok(code) 10303 const token = effects.exit('strikethroughSequenceTemporary'); 10304 const after = classifyCharacter(code); 10305 token._open = !after || (after === 2 && Boolean(before)); 10306 token._close = !before || (before === 2 && Boolean(after)); 10307 return ok(code) 10308 } 10309 } 10310} 10311 10312class EditMap { 10313 constructor() { 10314 this.map = []; 10315 } 10316 add(index, remove, add) { 10317 addImpl(this, index, remove, add); 10318 } 10319 consume(events) { 10320 this.map.sort((a, b) => a[0] - b[0]); 10321 if (this.map.length === 0) { 10322 return 10323 } 10324 let index = this.map.length; 10325 const vecs = []; 10326 while (index > 0) { 10327 index -= 1; 10328 vecs.push(events.slice(this.map[index][0] + this.map[index][1])); 10329 vecs.push(this.map[index][2]); 10330 events.length = this.map[index][0]; 10331 } 10332 vecs.push([...events]); 10333 events.length = 0; 10334 let slice = vecs.pop(); 10335 while (slice) { 10336 events.push(...slice); 10337 slice = vecs.pop(); 10338 } 10339 this.map.length = 0; 10340 } 10341} 10342function addImpl(editMap, at, remove, add) { 10343 let index = 0; 10344 if (remove === 0 && add.length === 0) { 10345 return 10346 } 10347 while (index < editMap.map.length) { 10348 if (editMap.map[index][0] === at) { 10349 editMap.map[index][1] += remove; 10350 editMap.map[index][2].push(...add); 10351 return 10352 } 10353 index += 1; 10354 } 10355 editMap.map.push([at, remove, add]); 10356} 10357 10358function gfmTableAlign(events, index) { 10359 let inDelimiterRow = false; 10360 const align = []; 10361 while (index < events.length) { 10362 const event = events[index]; 10363 if (inDelimiterRow) { 10364 if (event[0] === 'enter') { 10365 if (event[1].type === 'tableContent') { 10366 align.push( 10367 events[index + 1][1].type === 'tableDelimiterMarker' 10368 ? 'left' 10369 : 'none' 10370 ); 10371 } 10372 } 10373 else if (event[1].type === 'tableContent') { 10374 if (events[index - 1][1].type === 'tableDelimiterMarker') { 10375 const alignIndex = align.length - 1; 10376 align[alignIndex] = align[alignIndex] === 'left' ? 'center' : 'right'; 10377 } 10378 } 10379 else if (event[1].type === 'tableDelimiterRow') { 10380 break 10381 } 10382 } else if (event[0] === 'enter' && event[1].type === 'tableDelimiterRow') { 10383 inDelimiterRow = true; 10384 } 10385 index += 1; 10386 } 10387 return align 10388} 10389 10390const gfmTable = { 10391 flow: { 10392 null: { 10393 tokenize: tokenizeTable, 10394 resolveAll: resolveTable 10395 } 10396 } 10397}; 10398function tokenizeTable(effects, ok, nok) { 10399 const self = this; 10400 let size = 0; 10401 let sizeB = 0; 10402 let seen; 10403 return start 10404 function start(code) { 10405 let index = self.events.length - 1; 10406 while (index > -1) { 10407 const type = self.events[index][1].type; 10408 if ( 10409 type === 'lineEnding' || 10410 type === 'linePrefix' 10411 ) 10412 index--; 10413 else break 10414 } 10415 const tail = index > -1 ? self.events[index][1].type : null; 10416 const next = 10417 tail === 'tableHead' || tail === 'tableRow' ? bodyRowStart : headRowBefore; 10418 if (next === bodyRowStart && self.parser.lazy[self.now().line]) { 10419 return nok(code) 10420 } 10421 return next(code) 10422 } 10423 function headRowBefore(code) { 10424 effects.enter('tableHead'); 10425 effects.enter('tableRow'); 10426 return headRowStart(code) 10427 } 10428 function headRowStart(code) { 10429 if (code === 124) { 10430 return headRowBreak(code) 10431 } 10432 seen = true; 10433 sizeB += 1; 10434 return headRowBreak(code) 10435 } 10436 function headRowBreak(code) { 10437 if (code === null) { 10438 return nok(code) 10439 } 10440 if (markdownLineEnding(code)) { 10441 if (sizeB > 1) { 10442 sizeB = 0; 10443 self.interrupt = true; 10444 effects.exit('tableRow'); 10445 effects.enter('lineEnding'); 10446 effects.consume(code); 10447 effects.exit('lineEnding'); 10448 return headDelimiterStart 10449 } 10450 return nok(code) 10451 } 10452 if (markdownSpace(code)) { 10453 return factorySpace(effects, headRowBreak, 'whitespace')(code) 10454 } 10455 sizeB += 1; 10456 if (seen) { 10457 seen = false; 10458 size += 1; 10459 } 10460 if (code === 124) { 10461 effects.enter('tableCellDivider'); 10462 effects.consume(code); 10463 effects.exit('tableCellDivider'); 10464 seen = true; 10465 return headRowBreak 10466 } 10467 effects.enter('data'); 10468 return headRowData(code) 10469 } 10470 function headRowData(code) { 10471 if (code === null || code === 124 || markdownLineEndingOrSpace(code)) { 10472 effects.exit('data'); 10473 return headRowBreak(code) 10474 } 10475 effects.consume(code); 10476 return code === 92 ? headRowEscape : headRowData 10477 } 10478 function headRowEscape(code) { 10479 if (code === 92 || code === 124) { 10480 effects.consume(code); 10481 return headRowData 10482 } 10483 return headRowData(code) 10484 } 10485 function headDelimiterStart(code) { 10486 self.interrupt = false; 10487 if (self.parser.lazy[self.now().line]) { 10488 return nok(code) 10489 } 10490 effects.enter('tableDelimiterRow'); 10491 seen = false; 10492 if (markdownSpace(code)) { 10493 return factorySpace( 10494 effects, 10495 headDelimiterBefore, 10496 'linePrefix', 10497 self.parser.constructs.disable.null.includes('codeIndented') 10498 ? undefined 10499 : 4 10500 )(code) 10501 } 10502 return headDelimiterBefore(code) 10503 } 10504 function headDelimiterBefore(code) { 10505 if (code === 45 || code === 58) { 10506 return headDelimiterValueBefore(code) 10507 } 10508 if (code === 124) { 10509 seen = true; 10510 effects.enter('tableCellDivider'); 10511 effects.consume(code); 10512 effects.exit('tableCellDivider'); 10513 return headDelimiterCellBefore 10514 } 10515 return headDelimiterNok(code) 10516 } 10517 function headDelimiterCellBefore(code) { 10518 if (markdownSpace(code)) { 10519 return factorySpace(effects, headDelimiterValueBefore, 'whitespace')(code) 10520 } 10521 return headDelimiterValueBefore(code) 10522 } 10523 function headDelimiterValueBefore(code) { 10524 if (code === 58) { 10525 sizeB += 1; 10526 seen = true; 10527 effects.enter('tableDelimiterMarker'); 10528 effects.consume(code); 10529 effects.exit('tableDelimiterMarker'); 10530 return headDelimiterLeftAlignmentAfter 10531 } 10532 if (code === 45) { 10533 sizeB += 1; 10534 return headDelimiterLeftAlignmentAfter(code) 10535 } 10536 if (code === null || markdownLineEnding(code)) { 10537 return headDelimiterCellAfter(code) 10538 } 10539 return headDelimiterNok(code) 10540 } 10541 function headDelimiterLeftAlignmentAfter(code) { 10542 if (code === 45) { 10543 effects.enter('tableDelimiterFiller'); 10544 return headDelimiterFiller(code) 10545 } 10546 return headDelimiterNok(code) 10547 } 10548 function headDelimiterFiller(code) { 10549 if (code === 45) { 10550 effects.consume(code); 10551 return headDelimiterFiller 10552 } 10553 if (code === 58) { 10554 seen = true; 10555 effects.exit('tableDelimiterFiller'); 10556 effects.enter('tableDelimiterMarker'); 10557 effects.consume(code); 10558 effects.exit('tableDelimiterMarker'); 10559 return headDelimiterRightAlignmentAfter 10560 } 10561 effects.exit('tableDelimiterFiller'); 10562 return headDelimiterRightAlignmentAfter(code) 10563 } 10564 function headDelimiterRightAlignmentAfter(code) { 10565 if (markdownSpace(code)) { 10566 return factorySpace(effects, headDelimiterCellAfter, 'whitespace')(code) 10567 } 10568 return headDelimiterCellAfter(code) 10569 } 10570 function headDelimiterCellAfter(code) { 10571 if (code === 124) { 10572 return headDelimiterBefore(code) 10573 } 10574 if (code === null || markdownLineEnding(code)) { 10575 if (!seen || size !== sizeB) { 10576 return headDelimiterNok(code) 10577 } 10578 effects.exit('tableDelimiterRow'); 10579 effects.exit('tableHead'); 10580 return ok(code) 10581 } 10582 return headDelimiterNok(code) 10583 } 10584 function headDelimiterNok(code) { 10585 return nok(code) 10586 } 10587 function bodyRowStart(code) { 10588 effects.enter('tableRow'); 10589 return bodyRowBreak(code) 10590 } 10591 function bodyRowBreak(code) { 10592 if (code === 124) { 10593 effects.enter('tableCellDivider'); 10594 effects.consume(code); 10595 effects.exit('tableCellDivider'); 10596 return bodyRowBreak 10597 } 10598 if (code === null || markdownLineEnding(code)) { 10599 effects.exit('tableRow'); 10600 return ok(code) 10601 } 10602 if (markdownSpace(code)) { 10603 return factorySpace(effects, bodyRowBreak, 'whitespace')(code) 10604 } 10605 effects.enter('data'); 10606 return bodyRowData(code) 10607 } 10608 function bodyRowData(code) { 10609 if (code === null || code === 124 || markdownLineEndingOrSpace(code)) { 10610 effects.exit('data'); 10611 return bodyRowBreak(code) 10612 } 10613 effects.consume(code); 10614 return code === 92 ? bodyRowEscape : bodyRowData 10615 } 10616 function bodyRowEscape(code) { 10617 if (code === 92 || code === 124) { 10618 effects.consume(code); 10619 return bodyRowData 10620 } 10621 return bodyRowData(code) 10622 } 10623} 10624function resolveTable(events, context) { 10625 let index = -1; 10626 let inFirstCellAwaitingPipe = true; 10627 let rowKind = 0; 10628 let lastCell = [0, 0, 0, 0]; 10629 let cell = [0, 0, 0, 0]; 10630 let afterHeadAwaitingFirstBodyRow = false; 10631 let lastTableEnd = 0; 10632 let currentTable; 10633 let currentBody; 10634 let currentCell; 10635 const map = new EditMap(); 10636 while (++index < events.length) { 10637 const event = events[index]; 10638 const token = event[1]; 10639 if (event[0] === 'enter') { 10640 if (token.type === 'tableHead') { 10641 afterHeadAwaitingFirstBodyRow = false; 10642 if (lastTableEnd !== 0) { 10643 flushTableEnd(map, context, lastTableEnd, currentTable, currentBody); 10644 currentBody = undefined; 10645 lastTableEnd = 0; 10646 } 10647 currentTable = { 10648 type: 'table', 10649 start: Object.assign({}, token.start), 10650 end: Object.assign({}, token.end) 10651 }; 10652 map.add(index, 0, [['enter', currentTable, context]]); 10653 } else if ( 10654 token.type === 'tableRow' || 10655 token.type === 'tableDelimiterRow' 10656 ) { 10657 inFirstCellAwaitingPipe = true; 10658 currentCell = undefined; 10659 lastCell = [0, 0, 0, 0]; 10660 cell = [0, index + 1, 0, 0]; 10661 if (afterHeadAwaitingFirstBodyRow) { 10662 afterHeadAwaitingFirstBodyRow = false; 10663 currentBody = { 10664 type: 'tableBody', 10665 start: Object.assign({}, token.start), 10666 end: Object.assign({}, token.end) 10667 }; 10668 map.add(index, 0, [['enter', currentBody, context]]); 10669 } 10670 rowKind = token.type === 'tableDelimiterRow' ? 2 : currentBody ? 3 : 1; 10671 } 10672 else if ( 10673 rowKind && 10674 (token.type === 'data' || 10675 token.type === 'tableDelimiterMarker' || 10676 token.type === 'tableDelimiterFiller') 10677 ) { 10678 inFirstCellAwaitingPipe = false; 10679 if (cell[2] === 0) { 10680 if (lastCell[1] !== 0) { 10681 cell[0] = cell[1]; 10682 currentCell = flushCell( 10683 map, 10684 context, 10685 lastCell, 10686 rowKind, 10687 undefined, 10688 currentCell 10689 ); 10690 lastCell = [0, 0, 0, 0]; 10691 } 10692 cell[2] = index; 10693 } 10694 } else if (token.type === 'tableCellDivider') { 10695 if (inFirstCellAwaitingPipe) { 10696 inFirstCellAwaitingPipe = false; 10697 } else { 10698 if (lastCell[1] !== 0) { 10699 cell[0] = cell[1]; 10700 currentCell = flushCell( 10701 map, 10702 context, 10703 lastCell, 10704 rowKind, 10705 undefined, 10706 currentCell 10707 ); 10708 } 10709 lastCell = cell; 10710 cell = [lastCell[1], index, 0, 0]; 10711 } 10712 } 10713 } 10714 else if (token.type === 'tableHead') { 10715 afterHeadAwaitingFirstBodyRow = true; 10716 lastTableEnd = index; 10717 } else if ( 10718 token.type === 'tableRow' || 10719 token.type === 'tableDelimiterRow' 10720 ) { 10721 lastTableEnd = index; 10722 if (lastCell[1] !== 0) { 10723 cell[0] = cell[1]; 10724 currentCell = flushCell( 10725 map, 10726 context, 10727 lastCell, 10728 rowKind, 10729 index, 10730 currentCell 10731 ); 10732 } else if (cell[1] !== 0) { 10733 currentCell = flushCell(map, context, cell, rowKind, index, currentCell); 10734 } 10735 rowKind = 0; 10736 } else if ( 10737 rowKind && 10738 (token.type === 'data' || 10739 token.type === 'tableDelimiterMarker' || 10740 token.type === 'tableDelimiterFiller') 10741 ) { 10742 cell[3] = index; 10743 } 10744 } 10745 if (lastTableEnd !== 0) { 10746 flushTableEnd(map, context, lastTableEnd, currentTable, currentBody); 10747 } 10748 map.consume(context.events); 10749 index = -1; 10750 while (++index < context.events.length) { 10751 const event = context.events[index]; 10752 if (event[0] === 'enter' && event[1].type === 'table') { 10753 event[1]._align = gfmTableAlign(context.events, index); 10754 } 10755 } 10756 return events 10757} 10758function flushCell(map, context, range, rowKind, rowEnd, previousCell) { 10759 const groupName = 10760 rowKind === 1 10761 ? 'tableHeader' 10762 : rowKind === 2 10763 ? 'tableDelimiter' 10764 : 'tableData'; 10765 const valueName = 'tableContent'; 10766 if (range[0] !== 0) { 10767 previousCell.end = Object.assign({}, getPoint(context.events, range[0])); 10768 map.add(range[0], 0, [['exit', previousCell, context]]); 10769 } 10770 const now = getPoint(context.events, range[1]); 10771 previousCell = { 10772 type: groupName, 10773 start: Object.assign({}, now), 10774 end: Object.assign({}, now) 10775 }; 10776 map.add(range[1], 0, [['enter', previousCell, context]]); 10777 if (range[2] !== 0) { 10778 const relatedStart = getPoint(context.events, range[2]); 10779 const relatedEnd = getPoint(context.events, range[3]); 10780 const valueToken = { 10781 type: valueName, 10782 start: Object.assign({}, relatedStart), 10783 end: Object.assign({}, relatedEnd) 10784 }; 10785 map.add(range[2], 0, [['enter', valueToken, context]]); 10786 if (rowKind !== 2) { 10787 const start = context.events[range[2]]; 10788 const end = context.events[range[3]]; 10789 start[1].end = Object.assign({}, end[1].end); 10790 start[1].type = 'chunkText'; 10791 start[1].contentType = 'text'; 10792 if (range[3] > range[2] + 1) { 10793 const a = range[2] + 1; 10794 const b = range[3] - range[2] - 1; 10795 map.add(a, b, []); 10796 } 10797 } 10798 map.add(range[3] + 1, 0, [['exit', valueToken, context]]); 10799 } 10800 if (rowEnd !== undefined) { 10801 previousCell.end = Object.assign({}, getPoint(context.events, rowEnd)); 10802 map.add(rowEnd, 0, [['exit', previousCell, context]]); 10803 previousCell = undefined; 10804 } 10805 return previousCell 10806} 10807function flushTableEnd(map, context, index, table, tableBody) { 10808 const exits = []; 10809 const related = getPoint(context.events, index); 10810 if (tableBody) { 10811 tableBody.end = Object.assign({}, related); 10812 exits.push(['exit', tableBody, context]); 10813 } 10814 table.end = Object.assign({}, related); 10815 exits.push(['exit', table, context]); 10816 map.add(index + 1, 0, exits); 10817} 10818function getPoint(events, index) { 10819 const event = events[index]; 10820 const side = event[0] === 'enter' ? 'start' : 'end'; 10821 return event[1][side] 10822} 10823 10824const tasklistCheck = { 10825 tokenize: tokenizeTasklistCheck 10826}; 10827const gfmTaskListItem = { 10828 text: { 10829 [91]: tasklistCheck 10830 } 10831}; 10832function tokenizeTasklistCheck(effects, ok, nok) { 10833 const self = this; 10834 return open 10835 function open(code) { 10836 if ( 10837 self.previous !== null || 10838 !self._gfmTasklistFirstContentOfListItem 10839 ) { 10840 return nok(code) 10841 } 10842 effects.enter('taskListCheck'); 10843 effects.enter('taskListCheckMarker'); 10844 effects.consume(code); 10845 effects.exit('taskListCheckMarker'); 10846 return inside 10847 } 10848 function inside(code) { 10849 if (markdownLineEndingOrSpace(code)) { 10850 effects.enter('taskListCheckValueUnchecked'); 10851 effects.consume(code); 10852 effects.exit('taskListCheckValueUnchecked'); 10853 return close 10854 } 10855 if (code === 88 || code === 120) { 10856 effects.enter('taskListCheckValueChecked'); 10857 effects.consume(code); 10858 effects.exit('taskListCheckValueChecked'); 10859 return close 10860 } 10861 return nok(code) 10862 } 10863 function close(code) { 10864 if (code === 93) { 10865 effects.enter('taskListCheckMarker'); 10866 effects.consume(code); 10867 effects.exit('taskListCheckMarker'); 10868 effects.exit('taskListCheck'); 10869 return after 10870 } 10871 return nok(code) 10872 } 10873 function after(code) { 10874 if (markdownLineEnding(code)) { 10875 return ok(code) 10876 } 10877 if (markdownSpace(code)) { 10878 return effects.check( 10879 { 10880 tokenize: spaceThenNonSpace 10881 }, 10882 ok, 10883 nok 10884 )(code) 10885 } 10886 return nok(code) 10887 } 10888} 10889function spaceThenNonSpace(effects, ok, nok) { 10890 return factorySpace(effects, after, 'whitespace') 10891 function after(code) { 10892 return code === null ? nok(code) : ok(code) 10893 } 10894} 10895 10896function gfm(options) { 10897 return combineExtensions([ 10898 gfmAutolinkLiteral, 10899 gfmFootnote(), 10900 gfmStrikethrough(options), 10901 gfmTable, 10902 gfmTaskListItem 10903 ]) 10904} 10905 10906function ccount(value, character) { 10907 const source = String(value); 10908 if (typeof character !== 'string') { 10909 throw new TypeError('Expected character') 10910 } 10911 let count = 0; 10912 let index = source.indexOf(character); 10913 while (index !== -1) { 10914 count++; 10915 index = source.indexOf(character, index + character.length); 10916 } 10917 return count 10918} 10919 10920function escapeStringRegexp(string) { 10921 if (typeof string !== 'string') { 10922 throw new TypeError('Expected a string'); 10923 } 10924 return string 10925 .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') 10926 .replace(/-/g, '\\x2d'); 10927} 10928 10929const own$2 = {}.hasOwnProperty; 10930const findAndReplace = 10931 ( 10932 function (tree, find, replace, options) { 10933 let settings; 10934 let schema; 10935 if (typeof find === 'string' || find instanceof RegExp) { 10936 schema = [[find, replace]]; 10937 settings = options; 10938 } else { 10939 schema = find; 10940 settings = replace; 10941 } 10942 if (!settings) { 10943 settings = {}; 10944 } 10945 const ignored = convert(settings.ignore || []); 10946 const pairs = toPairs(schema); 10947 let pairIndex = -1; 10948 while (++pairIndex < pairs.length) { 10949 visitParents$1(tree, 'text', visitor); 10950 } 10951 return tree 10952 function visitor(node, parents) { 10953 let index = -1; 10954 let grandparent; 10955 while (++index < parents.length) { 10956 const parent = parents[index]; 10957 if ( 10958 ignored( 10959 parent, 10960 grandparent ? grandparent.children.indexOf(parent) : undefined, 10961 grandparent 10962 ) 10963 ) { 10964 return 10965 } 10966 grandparent = parent; 10967 } 10968 if (grandparent) { 10969 return handler(node, parents) 10970 } 10971 } 10972 function handler(node, parents) { 10973 const parent = parents[parents.length - 1]; 10974 const find = pairs[pairIndex][0]; 10975 const replace = pairs[pairIndex][1]; 10976 let start = 0; 10977 const index = parent.children.indexOf(node); 10978 let change = false; 10979 let nodes = []; 10980 find.lastIndex = 0; 10981 let match = find.exec(node.value); 10982 while (match) { 10983 const position = match.index; 10984 const matchObject = { 10985 index: match.index, 10986 input: match.input, 10987 stack: [...parents, node] 10988 }; 10989 let value = replace(...match, matchObject); 10990 if (typeof value === 'string') { 10991 value = value.length > 0 ? {type: 'text', value} : undefined; 10992 } 10993 if (value !== false) { 10994 if (start !== position) { 10995 nodes.push({ 10996 type: 'text', 10997 value: node.value.slice(start, position) 10998 }); 10999 } 11000 if (Array.isArray(value)) { 11001 nodes.push(...value); 11002 } else if (value) { 11003 nodes.push(value); 11004 } 11005 start = position + match[0].length; 11006 change = true; 11007 } 11008 if (!find.global) { 11009 break 11010 } 11011 match = find.exec(node.value); 11012 } 11013 if (change) { 11014 if (start < node.value.length) { 11015 nodes.push({type: 'text', value: node.value.slice(start)}); 11016 } 11017 parent.children.splice(index, 1, ...nodes); 11018 } else { 11019 nodes = [node]; 11020 } 11021 return index + nodes.length 11022 } 11023 } 11024 ); 11025function toPairs(schema) { 11026 const result = []; 11027 if (typeof schema !== 'object') { 11028 throw new TypeError('Expected array or object as schema') 11029 } 11030 if (Array.isArray(schema)) { 11031 let index = -1; 11032 while (++index < schema.length) { 11033 result.push([ 11034 toExpression(schema[index][0]), 11035 toFunction(schema[index][1]) 11036 ]); 11037 } 11038 } else { 11039 let key; 11040 for (key in schema) { 11041 if (own$2.call(schema, key)) { 11042 result.push([toExpression(key), toFunction(schema[key])]); 11043 } 11044 } 11045 } 11046 return result 11047} 11048function toExpression(find) { 11049 return typeof find === 'string' ? new RegExp(escapeStringRegexp(find), 'g') : find 11050} 11051function toFunction(replace) { 11052 return typeof replace === 'function' ? replace : () => replace 11053} 11054 11055const inConstruct = 'phrasing'; 11056const notInConstruct = ['autolink', 'link', 'image', 'label']; 11057const gfmAutolinkLiteralFromMarkdown = { 11058 transforms: [transformGfmAutolinkLiterals], 11059 enter: { 11060 literalAutolink: enterLiteralAutolink, 11061 literalAutolinkEmail: enterLiteralAutolinkValue, 11062 literalAutolinkHttp: enterLiteralAutolinkValue, 11063 literalAutolinkWww: enterLiteralAutolinkValue 11064 }, 11065 exit: { 11066 literalAutolink: exitLiteralAutolink, 11067 literalAutolinkEmail: exitLiteralAutolinkEmail, 11068 literalAutolinkHttp: exitLiteralAutolinkHttp, 11069 literalAutolinkWww: exitLiteralAutolinkWww 11070 } 11071}; 11072const gfmAutolinkLiteralToMarkdown = { 11073 unsafe: [ 11074 { 11075 character: '@', 11076 before: '[+\\-.\\w]', 11077 after: '[\\-.\\w]', 11078 inConstruct, 11079 notInConstruct 11080 }, 11081 { 11082 character: '.', 11083 before: '[Ww]', 11084 after: '[\\-.\\w]', 11085 inConstruct, 11086 notInConstruct 11087 }, 11088 {character: ':', before: '[ps]', after: '\\/', inConstruct, notInConstruct} 11089 ] 11090}; 11091function enterLiteralAutolink(token) { 11092 this.enter({type: 'link', title: null, url: '', children: []}, token); 11093} 11094function enterLiteralAutolinkValue(token) { 11095 this.config.enter.autolinkProtocol.call(this, token); 11096} 11097function exitLiteralAutolinkHttp(token) { 11098 this.config.exit.autolinkProtocol.call(this, token); 11099} 11100function exitLiteralAutolinkWww(token) { 11101 this.config.exit.data.call(this, token); 11102 const node = (this.stack[this.stack.length - 1]); 11103 node.url = 'http://' + this.sliceSerialize(token); 11104} 11105function exitLiteralAutolinkEmail(token) { 11106 this.config.exit.autolinkEmail.call(this, token); 11107} 11108function exitLiteralAutolink(token) { 11109 this.exit(token); 11110} 11111function transformGfmAutolinkLiterals(tree) { 11112 findAndReplace( 11113 tree, 11114 [ 11115 [/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, findUrl], 11116 [/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/g, findEmail] 11117 ], 11118 {ignore: ['link', 'linkReference']} 11119 ); 11120} 11121function findUrl(_, protocol, domain, path, match) { 11122 let prefix = ''; 11123 if (!previous(match)) { 11124 return false 11125 } 11126 if (/^w/i.test(protocol)) { 11127 domain = protocol + domain; 11128 protocol = ''; 11129 prefix = 'http://'; 11130 } 11131 if (!isCorrectDomain(domain)) { 11132 return false 11133 } 11134 const parts = splitUrl(domain + path); 11135 if (!parts[0]) return false 11136 const result = { 11137 type: 'link', 11138 title: null, 11139 url: prefix + protocol + parts[0], 11140 children: [{type: 'text', value: protocol + parts[0]}] 11141 }; 11142 if (parts[1]) { 11143 return [result, {type: 'text', value: parts[1]}] 11144 } 11145 return result 11146} 11147function findEmail(_, atext, label, match) { 11148 if ( 11149 !previous(match, true) || 11150 /[-\d_]$/.test(label) 11151 ) { 11152 return false 11153 } 11154 return { 11155 type: 'link', 11156 title: null, 11157 url: 'mailto:' + atext + '@' + label, 11158 children: [{type: 'text', value: atext + '@' + label}] 11159 } 11160} 11161function isCorrectDomain(domain) { 11162 const parts = domain.split('.'); 11163 if ( 11164 parts.length < 2 || 11165 (parts[parts.length - 1] && 11166 (/_/.test(parts[parts.length - 1]) || 11167 !/[a-zA-Z\d]/.test(parts[parts.length - 1]))) || 11168 (parts[parts.length - 2] && 11169 (/_/.test(parts[parts.length - 2]) || 11170 !/[a-zA-Z\d]/.test(parts[parts.length - 2]))) 11171 ) { 11172 return false 11173 } 11174 return true 11175} 11176function splitUrl(url) { 11177 const trailExec = /[!"&'),.:;<>?\]}]+$/.exec(url); 11178 if (!trailExec) { 11179 return [url, undefined] 11180 } 11181 url = url.slice(0, trailExec.index); 11182 let trail = trailExec[0]; 11183 let closingParenIndex = trail.indexOf(')'); 11184 const openingParens = ccount(url, '('); 11185 let closingParens = ccount(url, ')'); 11186 while (closingParenIndex !== -1 && openingParens > closingParens) { 11187 url += trail.slice(0, closingParenIndex + 1); 11188 trail = trail.slice(closingParenIndex + 1); 11189 closingParenIndex = trail.indexOf(')'); 11190 closingParens++; 11191 } 11192 return [url, trail] 11193} 11194function previous(match, email) { 11195 const code = match.input.charCodeAt(match.index - 1); 11196 return ( 11197 (match.index === 0 || 11198 unicodeWhitespace(code) || 11199 unicodePunctuation(code)) && 11200 (!email || code !== 47) 11201 ) 11202} 11203 11204footnoteReference.peek = footnoteReferencePeek; 11205function gfmFootnoteFromMarkdown() { 11206 return { 11207 enter: { 11208 gfmFootnoteDefinition: enterFootnoteDefinition, 11209 gfmFootnoteDefinitionLabelString: enterFootnoteDefinitionLabelString, 11210 gfmFootnoteCall: enterFootnoteCall, 11211 gfmFootnoteCallString: enterFootnoteCallString 11212 }, 11213 exit: { 11214 gfmFootnoteDefinition: exitFootnoteDefinition, 11215 gfmFootnoteDefinitionLabelString: exitFootnoteDefinitionLabelString, 11216 gfmFootnoteCall: exitFootnoteCall, 11217 gfmFootnoteCallString: exitFootnoteCallString 11218 } 11219 } 11220} 11221function gfmFootnoteToMarkdown() { 11222 return { 11223 unsafe: [{character: '[', inConstruct: ['phrasing', 'label', 'reference']}], 11224 handlers: {footnoteDefinition, footnoteReference} 11225 } 11226} 11227function enterFootnoteDefinition(token) { 11228 this.enter( 11229 {type: 'footnoteDefinition', identifier: '', label: '', children: []}, 11230 token 11231 ); 11232} 11233function enterFootnoteDefinitionLabelString() { 11234 this.buffer(); 11235} 11236function exitFootnoteDefinitionLabelString(token) { 11237 const label = this.resume(); 11238 const node = ( 11239 this.stack[this.stack.length - 1] 11240 ); 11241 node.label = label; 11242 node.identifier = normalizeIdentifier( 11243 this.sliceSerialize(token) 11244 ).toLowerCase(); 11245} 11246function exitFootnoteDefinition(token) { 11247 this.exit(token); 11248} 11249function enterFootnoteCall(token) { 11250 this.enter({type: 'footnoteReference', identifier: '', label: ''}, token); 11251} 11252function enterFootnoteCallString() { 11253 this.buffer(); 11254} 11255function exitFootnoteCallString(token) { 11256 const label = this.resume(); 11257 const node = ( 11258 this.stack[this.stack.length - 1] 11259 ); 11260 node.label = label; 11261 node.identifier = normalizeIdentifier( 11262 this.sliceSerialize(token) 11263 ).toLowerCase(); 11264} 11265function exitFootnoteCall(token) { 11266 this.exit(token); 11267} 11268function footnoteReference(node, _, context, safeOptions) { 11269 const tracker = track(safeOptions); 11270 let value = tracker.move('[^'); 11271 const exit = context.enter('footnoteReference'); 11272 const subexit = context.enter('reference'); 11273 value += tracker.move( 11274 safe(context, association(node), { 11275 ...tracker.current(), 11276 before: value, 11277 after: ']' 11278 }) 11279 ); 11280 subexit(); 11281 exit(); 11282 value += tracker.move(']'); 11283 return value 11284} 11285function footnoteReferencePeek() { 11286 return '[' 11287} 11288function footnoteDefinition(node, _, context, safeOptions) { 11289 const tracker = track(safeOptions); 11290 let value = tracker.move('[^'); 11291 const exit = context.enter('footnoteDefinition'); 11292 const subexit = context.enter('label'); 11293 value += tracker.move( 11294 safe(context, association(node), { 11295 ...tracker.current(), 11296 before: value, 11297 after: ']' 11298 }) 11299 ); 11300 subexit(); 11301 value += tracker.move( 11302 ']:' + (node.children && node.children.length > 0 ? ' ' : '') 11303 ); 11304 tracker.shift(4); 11305 value += tracker.move( 11306 indentLines(containerFlow(node, context, tracker.current()), map$1) 11307 ); 11308 exit(); 11309 return value 11310} 11311function map$1(line, index, blank) { 11312 if (index === 0) { 11313 return line 11314 } 11315 return (blank ? '' : ' ') + line 11316} 11317 11318const constructsWithoutStrikethrough = [ 11319 'autolink', 11320 'destinationLiteral', 11321 'destinationRaw', 11322 'reference', 11323 'titleQuote', 11324 'titleApostrophe' 11325]; 11326handleDelete.peek = peekDelete; 11327const gfmStrikethroughFromMarkdown = { 11328 canContainEols: ['delete'], 11329 enter: {strikethrough: enterStrikethrough}, 11330 exit: {strikethrough: exitStrikethrough} 11331}; 11332const gfmStrikethroughToMarkdown = { 11333 unsafe: [ 11334 { 11335 character: '~', 11336 inConstruct: 'phrasing', 11337 notInConstruct: constructsWithoutStrikethrough 11338 } 11339 ], 11340 handlers: {delete: handleDelete} 11341}; 11342function enterStrikethrough(token) { 11343 this.enter({type: 'delete', children: []}, token); 11344} 11345function exitStrikethrough(token) { 11346 this.exit(token); 11347} 11348function handleDelete(node, _, context, safeOptions) { 11349 const tracker = track(safeOptions); 11350 const exit = context.enter('strikethrough'); 11351 let value = tracker.move('~~'); 11352 value += containerPhrasing(node, context, { 11353 ...tracker.current(), 11354 before: value, 11355 after: '~' 11356 }); 11357 value += tracker.move('~~'); 11358 exit(); 11359 return value 11360} 11361function peekDelete() { 11362 return '~' 11363} 11364 11365function markdownTable(table, options = {}) { 11366 const align = (options.align || []).concat(); 11367 const stringLength = options.stringLength || defaultStringLength; 11368 const alignments = []; 11369 const cellMatrix = []; 11370 const sizeMatrix = []; 11371 const longestCellByColumn = []; 11372 let mostCellsPerRow = 0; 11373 let rowIndex = -1; 11374 while (++rowIndex < table.length) { 11375 const row = []; 11376 const sizes = []; 11377 let columnIndex = -1; 11378 if (table[rowIndex].length > mostCellsPerRow) { 11379 mostCellsPerRow = table[rowIndex].length; 11380 } 11381 while (++columnIndex < table[rowIndex].length) { 11382 const cell = serialize(table[rowIndex][columnIndex]); 11383 if (options.alignDelimiters !== false) { 11384 const size = stringLength(cell); 11385 sizes[columnIndex] = size; 11386 if ( 11387 longestCellByColumn[columnIndex] === undefined || 11388 size > longestCellByColumn[columnIndex] 11389 ) { 11390 longestCellByColumn[columnIndex] = size; 11391 } 11392 } 11393 row.push(cell); 11394 } 11395 cellMatrix[rowIndex] = row; 11396 sizeMatrix[rowIndex] = sizes; 11397 } 11398 let columnIndex = -1; 11399 if (typeof align === 'object' && 'length' in align) { 11400 while (++columnIndex < mostCellsPerRow) { 11401 alignments[columnIndex] = toAlignment(align[columnIndex]); 11402 } 11403 } else { 11404 const code = toAlignment(align); 11405 while (++columnIndex < mostCellsPerRow) { 11406 alignments[columnIndex] = code; 11407 } 11408 } 11409 columnIndex = -1; 11410 const row = []; 11411 const sizes = []; 11412 while (++columnIndex < mostCellsPerRow) { 11413 const code = alignments[columnIndex]; 11414 let before = ''; 11415 let after = ''; 11416 if (code === 99 ) { 11417 before = ':'; 11418 after = ':'; 11419 } else if (code === 108 ) { 11420 before = ':'; 11421 } else if (code === 114 ) { 11422 after = ':'; 11423 } 11424 let size = 11425 options.alignDelimiters === false 11426 ? 1 11427 : Math.max( 11428 1, 11429 longestCellByColumn[columnIndex] - before.length - after.length 11430 ); 11431 const cell = before + '-'.repeat(size) + after; 11432 if (options.alignDelimiters !== false) { 11433 size = before.length + size + after.length; 11434 if (size > longestCellByColumn[columnIndex]) { 11435 longestCellByColumn[columnIndex] = size; 11436 } 11437 sizes[columnIndex] = size; 11438 } 11439 row[columnIndex] = cell; 11440 } 11441 cellMatrix.splice(1, 0, row); 11442 sizeMatrix.splice(1, 0, sizes); 11443 rowIndex = -1; 11444 const lines = []; 11445 while (++rowIndex < cellMatrix.length) { 11446 const row = cellMatrix[rowIndex]; 11447 const sizes = sizeMatrix[rowIndex]; 11448 columnIndex = -1; 11449 const line = []; 11450 while (++columnIndex < mostCellsPerRow) { 11451 const cell = row[columnIndex] || ''; 11452 let before = ''; 11453 let after = ''; 11454 if (options.alignDelimiters !== false) { 11455 const size = 11456 longestCellByColumn[columnIndex] - (sizes[columnIndex] || 0); 11457 const code = alignments[columnIndex]; 11458 if (code === 114 ) { 11459 before = ' '.repeat(size); 11460 } else if (code === 99 ) { 11461 if (size % 2) { 11462 before = ' '.repeat(size / 2 + 0.5); 11463 after = ' '.repeat(size / 2 - 0.5); 11464 } else { 11465 before = ' '.repeat(size / 2); 11466 after = before; 11467 } 11468 } else { 11469 after = ' '.repeat(size); 11470 } 11471 } 11472 if (options.delimiterStart !== false && !columnIndex) { 11473 line.push('|'); 11474 } 11475 if ( 11476 options.padding !== false && 11477 !(options.alignDelimiters === false && cell === '') && 11478 (options.delimiterStart !== false || columnIndex) 11479 ) { 11480 line.push(' '); 11481 } 11482 if (options.alignDelimiters !== false) { 11483 line.push(before); 11484 } 11485 line.push(cell); 11486 if (options.alignDelimiters !== false) { 11487 line.push(after); 11488 } 11489 if (options.padding !== false) { 11490 line.push(' '); 11491 } 11492 if ( 11493 options.delimiterEnd !== false || 11494 columnIndex !== mostCellsPerRow - 1 11495 ) { 11496 line.push('|'); 11497 } 11498 } 11499 lines.push( 11500 options.delimiterEnd === false 11501 ? line.join('').replace(/ +$/, '') 11502 : line.join('') 11503 ); 11504 } 11505 return lines.join('\n') 11506} 11507function serialize(value) { 11508 return value === null || value === undefined ? '' : String(value) 11509} 11510function defaultStringLength(value) { 11511 return value.length 11512} 11513function toAlignment(value) { 11514 const code = typeof value === 'string' ? value.codePointAt(0) : 0; 11515 return code === 67 || code === 99 11516 ? 99 11517 : code === 76 || code === 108 11518 ? 108 11519 : code === 82 || code === 114 11520 ? 114 11521 : 0 11522} 11523 11524const gfmTableFromMarkdown = { 11525 enter: { 11526 table: enterTable, 11527 tableData: enterCell, 11528 tableHeader: enterCell, 11529 tableRow: enterRow 11530 }, 11531 exit: { 11532 codeText: exitCodeText, 11533 table: exitTable, 11534 tableData: exit, 11535 tableHeader: exit, 11536 tableRow: exit 11537 } 11538}; 11539function enterTable(token) { 11540 const align = token._align; 11541 this.enter( 11542 { 11543 type: 'table', 11544 align: align.map((d) => (d === 'none' ? null : d)), 11545 children: [] 11546 }, 11547 token 11548 ); 11549 this.setData('inTable', true); 11550} 11551function exitTable(token) { 11552 this.exit(token); 11553 this.setData('inTable'); 11554} 11555function enterRow(token) { 11556 this.enter({type: 'tableRow', children: []}, token); 11557} 11558function exit(token) { 11559 this.exit(token); 11560} 11561function enterCell(token) { 11562 this.enter({type: 'tableCell', children: []}, token); 11563} 11564function exitCodeText(token) { 11565 let value = this.resume(); 11566 if (this.getData('inTable')) { 11567 value = value.replace(/\\([\\|])/g, replace); 11568 } 11569 const node = (this.stack[this.stack.length - 1]); 11570 node.value = value; 11571 this.exit(token); 11572} 11573function replace($0, $1) { 11574 return $1 === '|' ? $1 : $0 11575} 11576function gfmTableToMarkdown(options) { 11577 const settings = options || {}; 11578 const padding = settings.tableCellPadding; 11579 const alignDelimiters = settings.tablePipeAlign; 11580 const stringLength = settings.stringLength; 11581 const around = padding ? ' ' : '|'; 11582 return { 11583 unsafe: [ 11584 {character: '\r', inConstruct: 'tableCell'}, 11585 {character: '\n', inConstruct: 'tableCell'}, 11586 {atBreak: true, character: '|', after: '[\t :-]'}, 11587 {character: '|', inConstruct: 'tableCell'}, 11588 {atBreak: true, character: ':', after: '-'}, 11589 {atBreak: true, character: '-', after: '[:|-]'} 11590 ], 11591 handlers: { 11592 table: handleTable, 11593 tableRow: handleTableRow, 11594 tableCell: handleTableCell, 11595 inlineCode: inlineCodeWithTable 11596 } 11597 } 11598 function handleTable(node, _, context, safeOptions) { 11599 return serializeData( 11600 handleTableAsData(node, context, safeOptions), 11601 node.align 11602 ) 11603 } 11604 function handleTableRow(node, _, context, safeOptions) { 11605 const row = handleTableRowAsData(node, context, safeOptions); 11606 const value = serializeData([row]); 11607 return value.slice(0, value.indexOf('\n')) 11608 } 11609 function handleTableCell(node, _, context, safeOptions) { 11610 const exit = context.enter('tableCell'); 11611 const subexit = context.enter('phrasing'); 11612 const value = containerPhrasing(node, context, { 11613 ...safeOptions, 11614 before: around, 11615 after: around 11616 }); 11617 subexit(); 11618 exit(); 11619 return value 11620 } 11621 function serializeData(matrix, align) { 11622 return markdownTable(matrix, { 11623 align, 11624 alignDelimiters, 11625 padding, 11626 stringLength 11627 }) 11628 } 11629 function handleTableAsData(node, context, safeOptions) { 11630 const children = node.children; 11631 let index = -1; 11632 const result = []; 11633 const subexit = context.enter('table'); 11634 while (++index < children.length) { 11635 result[index] = handleTableRowAsData( 11636 children[index], 11637 context, 11638 safeOptions 11639 ); 11640 } 11641 subexit(); 11642 return result 11643 } 11644 function handleTableRowAsData(node, context, safeOptions) { 11645 const children = node.children; 11646 let index = -1; 11647 const result = []; 11648 const subexit = context.enter('tableRow'); 11649 while (++index < children.length) { 11650 result[index] = handleTableCell( 11651 children[index], 11652 node, 11653 context, 11654 safeOptions 11655 ); 11656 } 11657 subexit(); 11658 return result 11659 } 11660 function inlineCodeWithTable(node, parent, context) { 11661 let value = inlineCode(node, parent, context); 11662 if (context.stack.includes('tableCell')) { 11663 value = value.replace(/\|/g, '\\$&'); 11664 } 11665 return value 11666 } 11667} 11668 11669const gfmTaskListItemFromMarkdown = { 11670 exit: { 11671 taskListCheckValueChecked: exitCheck, 11672 taskListCheckValueUnchecked: exitCheck, 11673 paragraph: exitParagraphWithTaskListItem 11674 } 11675}; 11676const gfmTaskListItemToMarkdown = { 11677 unsafe: [{atBreak: true, character: '-', after: '[:|-]'}], 11678 handlers: {listItem: listItemWithTaskListItem} 11679}; 11680function exitCheck(token) { 11681 const node = (this.stack[this.stack.length - 2]); 11682 node.checked = token.type === 'taskListCheckValueChecked'; 11683} 11684function exitParagraphWithTaskListItem(token) { 11685 const parent = (this.stack[this.stack.length - 2]); 11686 if ( 11687 parent && 11688 parent.type === 'listItem' && 11689 typeof parent.checked === 'boolean' 11690 ) { 11691 const node = (this.stack[this.stack.length - 1]); 11692 const head = node.children[0]; 11693 if (head && head.type === 'text') { 11694 const siblings = parent.children; 11695 let index = -1; 11696 let firstParaghraph; 11697 while (++index < siblings.length) { 11698 const sibling = siblings[index]; 11699 if (sibling.type === 'paragraph') { 11700 firstParaghraph = sibling; 11701 break 11702 } 11703 } 11704 if (firstParaghraph === node) { 11705 head.value = head.value.slice(1); 11706 if (head.value.length === 0) { 11707 node.children.shift(); 11708 } else if ( 11709 node.position && 11710 head.position && 11711 typeof head.position.start.offset === 'number' 11712 ) { 11713 head.position.start.column++; 11714 head.position.start.offset++; 11715 node.position.start = Object.assign({}, head.position.start); 11716 } 11717 } 11718 } 11719 } 11720 this.exit(token); 11721} 11722function listItemWithTaskListItem(node, parent, context, safeOptions) { 11723 const head = node.children[0]; 11724 const checkable = 11725 typeof node.checked === 'boolean' && head && head.type === 'paragraph'; 11726 const checkbox = '[' + (node.checked ? 'x' : ' ') + '] '; 11727 const tracker = track(safeOptions); 11728 if (checkable) { 11729 tracker.move(checkbox); 11730 } 11731 let value = listItem(node, parent, context, { 11732 ...safeOptions, 11733 ...tracker.current() 11734 }); 11735 if (checkable) { 11736 value = value.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/, check); 11737 } 11738 return value 11739 function check($0) { 11740 return $0 + checkbox 11741 } 11742} 11743 11744function gfmFromMarkdown() { 11745 return [ 11746 gfmAutolinkLiteralFromMarkdown, 11747 gfmFootnoteFromMarkdown(), 11748 gfmStrikethroughFromMarkdown, 11749 gfmTableFromMarkdown, 11750 gfmTaskListItemFromMarkdown 11751 ] 11752} 11753function gfmToMarkdown(options) { 11754 return { 11755 extensions: [ 11756 gfmAutolinkLiteralToMarkdown, 11757 gfmFootnoteToMarkdown(), 11758 gfmStrikethroughToMarkdown, 11759 gfmTableToMarkdown(options), 11760 gfmTaskListItemToMarkdown 11761 ] 11762 } 11763} 11764 11765function remarkGfm(options = {}) { 11766 const data = this.data(); 11767 add('micromarkExtensions', gfm(options)); 11768 add('fromMarkdownExtensions', gfmFromMarkdown()); 11769 add('toMarkdownExtensions', gfmToMarkdown(options)); 11770 function add(field, value) { 11771 const list = ( 11772 data[field] ? data[field] : (data[field] = []) 11773 ); 11774 list.push(value); 11775 } 11776} 11777 11778function location(file) { 11779 const value = String(file); 11780 const indices = []; 11781 const search = /\r?\n|\r/g; 11782 while (search.test(value)) { 11783 indices.push(search.lastIndex); 11784 } 11785 indices.push(value.length + 1); 11786 return {toPoint, toOffset} 11787 function toPoint(offset) { 11788 let index = -1; 11789 if ( 11790 typeof offset === 'number' && 11791 offset > -1 && 11792 offset < indices[indices.length - 1] 11793 ) { 11794 while (++index < indices.length) { 11795 if (indices[index] > offset) { 11796 return { 11797 line: index + 1, 11798 column: offset - (index > 0 ? indices[index - 1] : 0) + 1, 11799 offset 11800 } 11801 } 11802 } 11803 } 11804 return {line: undefined, column: undefined, offset: undefined} 11805 } 11806 function toOffset(point) { 11807 const line = point && point.line; 11808 const column = point && point.column; 11809 if ( 11810 typeof line === 'number' && 11811 typeof column === 'number' && 11812 !Number.isNaN(line) && 11813 !Number.isNaN(column) && 11814 line - 1 in indices 11815 ) { 11816 const offset = (indices[line - 2] || 0) + column - 1 || 0; 11817 if (offset > -1 && offset < indices[indices.length - 1]) { 11818 return offset 11819 } 11820 } 11821 return -1 11822 } 11823} 11824 11825function color$1(d) { 11826 return '\u001B[33m' + d + '\u001B[39m' 11827} 11828 11829const CONTINUE = true; 11830const SKIP = 'skip'; 11831const EXIT = false; 11832const visitParents = 11833 ( 11834 function (tree, test, visitor, reverse) { 11835 if (typeof test === 'function' && typeof visitor !== 'function') { 11836 reverse = visitor; 11837 visitor = test; 11838 test = null; 11839 } 11840 var is = convert(test); 11841 var step = reverse ? -1 : 1; 11842 factory(tree, null, [])(); 11843 function factory(node, index, parents) { 11844 var value = typeof node === 'object' && node !== null ? node : {}; 11845 var name; 11846 if (typeof value.type === 'string') { 11847 name = 11848 typeof value.tagName === 'string' 11849 ? value.tagName 11850 : typeof value.name === 'string' 11851 ? value.name 11852 : undefined; 11853 Object.defineProperty(visit, 'name', { 11854 value: 11855 'node (' + 11856 color$1(value.type + (name ? '<' + name + '>' : '')) + 11857 ')' 11858 }); 11859 } 11860 return visit 11861 function visit() { 11862 var result = []; 11863 var subresult; 11864 var offset; 11865 var grandparents; 11866 if (!test || is(node, index, parents[parents.length - 1] || null)) { 11867 result = toResult(visitor(node, parents)); 11868 if (result[0] === EXIT) { 11869 return result 11870 } 11871 } 11872 if (node.children && result[0] !== SKIP) { 11873 offset = (reverse ? node.children.length : -1) + step; 11874 grandparents = parents.concat(node); 11875 while (offset > -1 && offset < node.children.length) { 11876 subresult = factory(node.children[offset], offset, grandparents)(); 11877 if (subresult[0] === EXIT) { 11878 return subresult 11879 } 11880 offset = 11881 typeof subresult[1] === 'number' ? subresult[1] : offset + step; 11882 } 11883 } 11884 return result 11885 } 11886 } 11887 } 11888 ); 11889function toResult(value) { 11890 if (Array.isArray(value)) { 11891 return value 11892 } 11893 if (typeof value === 'number') { 11894 return [CONTINUE, value] 11895 } 11896 return [value] 11897} 11898 11899const visit = 11900 ( 11901 function (tree, test, visitor, reverse) { 11902 if (typeof test === 'function' && typeof visitor !== 'function') { 11903 reverse = visitor; 11904 visitor = test; 11905 test = null; 11906 } 11907 visitParents(tree, test, overload, reverse); 11908 function overload(node, parents) { 11909 var parent = parents[parents.length - 1]; 11910 return visitor( 11911 node, 11912 parent ? parent.children.indexOf(node) : null, 11913 parent 11914 ) 11915 } 11916 } 11917 ); 11918 11919const own$1 = {}.hasOwnProperty; 11920function messageControl(options) { 11921 if (!options || typeof options !== 'object' || !options.name) { 11922 throw new Error( 11923 'Expected `name` in `options`, got `' + (options || {}).name + '`' 11924 ) 11925 } 11926 if (!options.marker) { 11927 throw new Error( 11928 'Expected `marker` in `options`, got `' + options.marker + '`' 11929 ) 11930 } 11931 const enable = 'enable' in options && options.enable ? options.enable : []; 11932 const disable = 'disable' in options && options.disable ? options.disable : []; 11933 let reset = options.reset; 11934 const sources = 11935 typeof options.source === 'string' 11936 ? [options.source] 11937 : options.source || [options.name]; 11938 return transformer 11939 function transformer(tree, file) { 11940 const toOffset = location(file).toOffset; 11941 const initial = !reset; 11942 const gaps = detectGaps(tree, file); 11943 const scope = {}; 11944 const globals = []; 11945 visit(tree, options.test, visitor); 11946 file.messages = file.messages.filter((m) => filter(m)); 11947 function visitor(node, position, parent) { 11948 const mark = options.marker(node); 11949 if (!mark || mark.name !== options.name) { 11950 return 11951 } 11952 const ruleIds = mark.attributes.split(/\s/g); 11953 const point = mark.node.position && mark.node.position.start; 11954 const next = 11955 (parent && position !== null && parent.children[position + 1]) || 11956 undefined; 11957 const tail = (next && next.position && next.position.end) || undefined; 11958 let index = -1; 11959 const verb = ruleIds.shift(); 11960 if (verb !== 'enable' && verb !== 'disable' && verb !== 'ignore') { 11961 file.fail( 11962 'Unknown keyword `' + 11963 verb + 11964 '`: expected ' + 11965 "`'enable'`, `'disable'`, or `'ignore'`", 11966 mark.node 11967 ); 11968 } 11969 if (ruleIds.length > 0) { 11970 while (++index < ruleIds.length) { 11971 const ruleId = ruleIds[index]; 11972 if (isKnown(ruleId, verb, mark.node)) { 11973 toggle(point, verb === 'enable', ruleId); 11974 if (verb === 'ignore') { 11975 toggle(tail, true, ruleId); 11976 } 11977 } 11978 } 11979 } else if (verb === 'ignore') { 11980 toggle(point, false); 11981 toggle(tail, true); 11982 } else { 11983 toggle(point, verb === 'enable'); 11984 reset = verb !== 'enable'; 11985 } 11986 } 11987 function filter(message) { 11988 let gapIndex = gaps.length; 11989 if (!message.source || !sources.includes(message.source)) { 11990 return true 11991 } 11992 if (!message.line) { 11993 message.line = 1; 11994 } 11995 if (!message.column) { 11996 message.column = 1; 11997 } 11998 const offset = toOffset(message); 11999 while (gapIndex--) { 12000 if (gaps[gapIndex][0] <= offset && gaps[gapIndex][1] > offset) { 12001 return false 12002 } 12003 } 12004 return ( 12005 (!message.ruleId || 12006 check(message, scope[message.ruleId], message.ruleId)) && 12007 check(message, globals) 12008 ) 12009 } 12010 function isKnown(ruleId, verb, node) { 12011 const result = options.known ? options.known.includes(ruleId) : true; 12012 if (!result) { 12013 file.message( 12014 'Unknown rule: cannot ' + verb + " `'" + ruleId + "'`", 12015 node 12016 ); 12017 } 12018 return result 12019 } 12020 function getState(ruleId) { 12021 const ranges = ruleId ? scope[ruleId] : globals; 12022 if (ranges && ranges.length > 0) { 12023 return ranges[ranges.length - 1].state 12024 } 12025 if (!ruleId) { 12026 return !reset 12027 } 12028 return reset ? enable.includes(ruleId) : !disable.includes(ruleId) 12029 } 12030 function toggle(point, state, ruleId) { 12031 let markers = ruleId ? scope[ruleId] : globals; 12032 if (!markers) { 12033 markers = []; 12034 scope[String(ruleId)] = markers; 12035 } 12036 const previousState = getState(ruleId); 12037 if (state !== previousState) { 12038 markers.push({state, point}); 12039 } 12040 if (!ruleId) { 12041 for (ruleId in scope) { 12042 if (own$1.call(scope, ruleId)) { 12043 toggle(point, state, ruleId); 12044 } 12045 } 12046 } 12047 } 12048 function check(message, ranges, ruleId) { 12049 if (ranges && ranges.length > 0) { 12050 let index = ranges.length; 12051 while (index--) { 12052 const range = ranges[index]; 12053 if ( 12054 message.line && 12055 message.column && 12056 range.point && 12057 range.point.line && 12058 range.point.column && 12059 (range.point.line < message.line || 12060 (range.point.line === message.line && 12061 range.point.column <= message.column)) 12062 ) { 12063 return range.state === true 12064 } 12065 } 12066 } 12067 if (!ruleId) { 12068 return Boolean(initial || reset) 12069 } 12070 return reset ? enable.includes(ruleId) : !disable.includes(ruleId) 12071 } 12072 } 12073} 12074function detectGaps(tree, file) { 12075 const children = tree.children || []; 12076 const lastNode = children[children.length - 1]; 12077 const gaps = []; 12078 let offset = 0; 12079 let gap; 12080 visit(tree, one); 12081 if ( 12082 lastNode && 12083 lastNode.position && 12084 lastNode.position.end && 12085 offset === lastNode.position.end.offset && 12086 file.toString().slice(offset).trim() !== '' 12087 ) { 12088 update(); 12089 update( 12090 tree && 12091 tree.position && 12092 tree.position.end && 12093 tree.position.end.offset && 12094 tree.position.end.offset - 1 12095 ); 12096 } 12097 return gaps 12098 function one(node) { 12099 update(node.position && node.position.start && node.position.start.offset); 12100 if (!('children' in node)) { 12101 update(node.position && node.position.end && node.position.end.offset); 12102 } 12103 } 12104 function update(latest) { 12105 if (latest === null || latest === undefined) { 12106 gap = true; 12107 } else if (offset < latest) { 12108 if (gap) { 12109 gaps.push([offset, latest]); 12110 gap = undefined; 12111 } 12112 offset = latest; 12113 } 12114 } 12115} 12116 12117const commentExpression = /\s*([a-zA-Z\d-]+)(\s+([\s\S]*))?\s*/; 12118const esCommentExpression = new RegExp( 12119 '(\\s*\\/\\*' + commentExpression.source + '\\*\\/\\s*)' 12120); 12121const markerExpression = new RegExp( 12122 '(\\s*<!--' + commentExpression.source + '-->\\s*)' 12123); 12124function commentMarker(value) { 12125 if ( 12126 isNode(value) && 12127 (value.type === 'html' || 12128 value.type === 'comment' || 12129 value.type === 'mdxFlowExpression' || 12130 value.type === 'mdxTextExpression') 12131 ) { 12132 let offset = 2; 12133 let match; 12134 if (value.type === 'comment') { 12135 match = value.value.match(commentExpression); 12136 offset = 1; 12137 } else if (value.type === 'html') { 12138 match = value.value.match(markerExpression); 12139 } else if ( 12140 value.type === 'mdxFlowExpression' || 12141 value.type === 'mdxTextExpression' 12142 ) { 12143 match = value.value.match(esCommentExpression); 12144 } 12145 if (match && match[0].length === value.value.length) { 12146 const parameters = parseParameters(match[offset + 1] || ''); 12147 if (parameters) { 12148 return { 12149 name: match[offset], 12150 attributes: (match[offset + 2] || '').trim(), 12151 parameters, 12152 node: value 12153 } 12154 } 12155 } 12156 } 12157 return null 12158} 12159function parseParameters(value) { 12160 const parameters = {}; 12161 return value 12162 .replace( 12163 /\s+([-\w]+)(?:=(?:"((?:\\[\s\S]|[^"])*)"|'((?:\\[\s\S]|[^'])*)'|((?:\\[\s\S]|[^"'\s])+)))?/gi, 12164 replacer 12165 ) 12166 .replace(/\s+/g, '') 12167 ? null 12168 : parameters 12169 function replacer(_, $1, $2, $3, $4) { 12170 let value = $2 === undefined ? ($3 === undefined ? $4 : $3) : $2; 12171 const number = Number(value); 12172 if (value === 'true' || value === undefined) { 12173 value = true; 12174 } else if (value === 'false') { 12175 value = false; 12176 } else if (value.trim() && !Number.isNaN(number)) { 12177 value = number; 12178 } 12179 parameters[$1] = value; 12180 return '' 12181 } 12182} 12183function isNode(value) { 12184 return Boolean(value && typeof value === 'object' && 'type' in value) 12185} 12186 12187const test = [ 12188 'html', 12189 'comment', 12190 'mdxFlowExpression', 12191 'mdxTextExpression' 12192]; 12193function remarkMessageControl(options) { 12194 return messageControl( 12195 Object.assign({marker: commentMarker, test}, options) 12196 ) 12197} 12198 12199function remarkLint() { 12200 this.use(lintMessageControl); 12201} 12202function lintMessageControl() { 12203 return remarkMessageControl({name: 'lint', source: 'remark-lint'}) 12204} 12205 12206function lintRule(meta, rule) { 12207 const id = typeof meta === 'string' ? meta : meta.origin; 12208 const url = typeof meta === 'string' ? undefined : meta.url; 12209 const parts = id.split(':'); 12210 const source = parts[1] ? parts[0] : undefined; 12211 const ruleId = parts[1]; 12212 Object.defineProperty(plugin, 'name', {value: id}); 12213 return plugin 12214 function plugin(config) { 12215 const [severity, options] = coerce$1(ruleId, config); 12216 if (!severity) return 12217 const fatal = severity === 2; 12218 return (tree, file, next) => { 12219 let index = file.messages.length - 1; 12220 wrap(rule, (error) => { 12221 const messages = file.messages; 12222 if (error && !messages.includes(error)) { 12223 try { 12224 file.fail(error); 12225 } catch {} 12226 } 12227 while (++index < messages.length) { 12228 Object.assign(messages[index], {ruleId, source, fatal, url}); 12229 } 12230 next(); 12231 })(tree, file, options); 12232 } 12233 } 12234} 12235function coerce$1(name, config) { 12236 if (!Array.isArray(config)) return [1, config] 12237 const [severity, ...options] = config; 12238 switch (severity) { 12239 case false: 12240 case 'off': 12241 case 0: { 12242 return [0, ...options] 12243 } 12244 case true: 12245 case 'on': 12246 case 'warn': 12247 case 1: { 12248 return [1, ...options] 12249 } 12250 case 'error': 12251 case 2: { 12252 return [2, ...options] 12253 } 12254 default: { 12255 if (typeof severity !== 'number') return [1, config] 12256 throw new Error( 12257 'Incorrect severity `' + 12258 severity + 12259 '` for `' + 12260 name + 12261 '`, ' + 12262 'expected 0, 1, or 2' 12263 ) 12264 } 12265 } 12266} 12267 12268/** 12269 * ## When should I use this? 12270 * 12271 * You can use this package to check that fenced code markers are consistent. 12272 * 12273 * ## API 12274 * 12275 * There are no options. 12276 * 12277 * ## Recommendation 12278 * 12279 * Turn this rule on. 12280 * See [StackExchange](https://unix.stackexchange.com/questions/18743) for more 12281 * info. 12282 * 12283 * ## Fix 12284 * 12285 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 12286 * always adds final line endings. 12287 * 12288 * ## Example 12289 * 12290 * ##### `ok.md` 12291 * 12292 * ###### In 12293 * 12294 * > **Note**: `␊` represents a line feed (`\n`). 12295 * 12296 * ```markdown 12297 * Alpha␊ 12298 * ``` 12299 * 12300 * ###### Out 12301 * 12302 * No messages. 12303 * 12304 * ##### `not-ok.md` 12305 * 12306 * ###### In 12307 * 12308 * > **Note**: `␀` represents the end of the file. 12309 * 12310 * ```markdown 12311 * Bravo␀ 12312 * ``` 12313 * 12314 * ###### Out 12315 * 12316 * ```text 12317 * 1:1: Missing newline character at end of file 12318 * ``` 12319 * 12320 * @module final-newline 12321 * @summary 12322 * remark-lint rule to warn when files don’t end in a newline. 12323 * @author Titus Wormer 12324 * @copyright 2015 Titus Wormer 12325 * @license MIT 12326 */ 12327const remarkLintFinalNewline = lintRule( 12328 { 12329 origin: 'remark-lint:final-newline', 12330 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-final-newline#readme' 12331 }, 12332 (_, file) => { 12333 const value = String(file); 12334 const last = value.length - 1; 12335 if (last > -1 && value.charAt(last) !== '\n') { 12336 file.message('Missing newline character at end of file'); 12337 } 12338 } 12339); 12340var remarkLintFinalNewline$1 = remarkLintFinalNewline; 12341 12342function commonjsRequire(path) { 12343 throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); 12344} 12345 12346var pluralize = {exports: {}}; 12347 12348(function (module, exports) { 12349 (function (root, pluralize) { 12350 if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') { 12351 module.exports = pluralize(); 12352 } else { 12353 root.pluralize = pluralize(); 12354 } 12355 })(commonjsGlobal, function () { 12356 var pluralRules = []; 12357 var singularRules = []; 12358 var uncountables = {}; 12359 var irregularPlurals = {}; 12360 var irregularSingles = {}; 12361 function sanitizeRule (rule) { 12362 if (typeof rule === 'string') { 12363 return new RegExp('^' + rule + '$', 'i'); 12364 } 12365 return rule; 12366 } 12367 function restoreCase (word, token) { 12368 if (word === token) return token; 12369 if (word === word.toLowerCase()) return token.toLowerCase(); 12370 if (word === word.toUpperCase()) return token.toUpperCase(); 12371 if (word[0] === word[0].toUpperCase()) { 12372 return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase(); 12373 } 12374 return token.toLowerCase(); 12375 } 12376 function interpolate (str, args) { 12377 return str.replace(/\$(\d{1,2})/g, function (match, index) { 12378 return args[index] || ''; 12379 }); 12380 } 12381 function replace (word, rule) { 12382 return word.replace(rule[0], function (match, index) { 12383 var result = interpolate(rule[1], arguments); 12384 if (match === '') { 12385 return restoreCase(word[index - 1], result); 12386 } 12387 return restoreCase(match, result); 12388 }); 12389 } 12390 function sanitizeWord (token, word, rules) { 12391 if (!token.length || uncountables.hasOwnProperty(token)) { 12392 return word; 12393 } 12394 var len = rules.length; 12395 while (len--) { 12396 var rule = rules[len]; 12397 if (rule[0].test(word)) return replace(word, rule); 12398 } 12399 return word; 12400 } 12401 function replaceWord (replaceMap, keepMap, rules) { 12402 return function (word) { 12403 var token = word.toLowerCase(); 12404 if (keepMap.hasOwnProperty(token)) { 12405 return restoreCase(word, token); 12406 } 12407 if (replaceMap.hasOwnProperty(token)) { 12408 return restoreCase(word, replaceMap[token]); 12409 } 12410 return sanitizeWord(token, word, rules); 12411 }; 12412 } 12413 function checkWord (replaceMap, keepMap, rules, bool) { 12414 return function (word) { 12415 var token = word.toLowerCase(); 12416 if (keepMap.hasOwnProperty(token)) return true; 12417 if (replaceMap.hasOwnProperty(token)) return false; 12418 return sanitizeWord(token, token, rules) === token; 12419 }; 12420 } 12421 function pluralize (word, count, inclusive) { 12422 var pluralized = count === 1 12423 ? pluralize.singular(word) : pluralize.plural(word); 12424 return (inclusive ? count + ' ' : '') + pluralized; 12425 } 12426 pluralize.plural = replaceWord( 12427 irregularSingles, irregularPlurals, pluralRules 12428 ); 12429 pluralize.isPlural = checkWord( 12430 irregularSingles, irregularPlurals, pluralRules 12431 ); 12432 pluralize.singular = replaceWord( 12433 irregularPlurals, irregularSingles, singularRules 12434 ); 12435 pluralize.isSingular = checkWord( 12436 irregularPlurals, irregularSingles, singularRules 12437 ); 12438 pluralize.addPluralRule = function (rule, replacement) { 12439 pluralRules.push([sanitizeRule(rule), replacement]); 12440 }; 12441 pluralize.addSingularRule = function (rule, replacement) { 12442 singularRules.push([sanitizeRule(rule), replacement]); 12443 }; 12444 pluralize.addUncountableRule = function (word) { 12445 if (typeof word === 'string') { 12446 uncountables[word.toLowerCase()] = true; 12447 return; 12448 } 12449 pluralize.addPluralRule(word, '$0'); 12450 pluralize.addSingularRule(word, '$0'); 12451 }; 12452 pluralize.addIrregularRule = function (single, plural) { 12453 plural = plural.toLowerCase(); 12454 single = single.toLowerCase(); 12455 irregularSingles[single] = plural; 12456 irregularPlurals[plural] = single; 12457 }; 12458 [ 12459 ['I', 'we'], 12460 ['me', 'us'], 12461 ['he', 'they'], 12462 ['she', 'they'], 12463 ['them', 'them'], 12464 ['myself', 'ourselves'], 12465 ['yourself', 'yourselves'], 12466 ['itself', 'themselves'], 12467 ['herself', 'themselves'], 12468 ['himself', 'themselves'], 12469 ['themself', 'themselves'], 12470 ['is', 'are'], 12471 ['was', 'were'], 12472 ['has', 'have'], 12473 ['this', 'these'], 12474 ['that', 'those'], 12475 ['echo', 'echoes'], 12476 ['dingo', 'dingoes'], 12477 ['volcano', 'volcanoes'], 12478 ['tornado', 'tornadoes'], 12479 ['torpedo', 'torpedoes'], 12480 ['genus', 'genera'], 12481 ['viscus', 'viscera'], 12482 ['stigma', 'stigmata'], 12483 ['stoma', 'stomata'], 12484 ['dogma', 'dogmata'], 12485 ['lemma', 'lemmata'], 12486 ['schema', 'schemata'], 12487 ['anathema', 'anathemata'], 12488 ['ox', 'oxen'], 12489 ['axe', 'axes'], 12490 ['die', 'dice'], 12491 ['yes', 'yeses'], 12492 ['foot', 'feet'], 12493 ['eave', 'eaves'], 12494 ['goose', 'geese'], 12495 ['tooth', 'teeth'], 12496 ['quiz', 'quizzes'], 12497 ['human', 'humans'], 12498 ['proof', 'proofs'], 12499 ['carve', 'carves'], 12500 ['valve', 'valves'], 12501 ['looey', 'looies'], 12502 ['thief', 'thieves'], 12503 ['groove', 'grooves'], 12504 ['pickaxe', 'pickaxes'], 12505 ['passerby', 'passersby'] 12506 ].forEach(function (rule) { 12507 return pluralize.addIrregularRule(rule[0], rule[1]); 12508 }); 12509 [ 12510 [/s?$/i, 's'], 12511 [/[^\u0000-\u007F]$/i, '$0'], 12512 [/([^aeiou]ese)$/i, '$1'], 12513 [/(ax|test)is$/i, '$1es'], 12514 [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'], 12515 [/(e[mn]u)s?$/i, '$1s'], 12516 [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'], 12517 [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'], 12518 [/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'], 12519 [/(seraph|cherub)(?:im)?$/i, '$1im'], 12520 [/(her|at|gr)o$/i, '$1oes'], 12521 [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'], 12522 [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'], 12523 [/sis$/i, 'ses'], 12524 [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'], 12525 [/([^aeiouy]|qu)y$/i, '$1ies'], 12526 [/([^ch][ieo][ln])ey$/i, '$1ies'], 12527 [/(x|ch|ss|sh|zz)$/i, '$1es'], 12528 [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'], 12529 [/\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'], 12530 [/(pe)(?:rson|ople)$/i, '$1ople'], 12531 [/(child)(?:ren)?$/i, '$1ren'], 12532 [/eaux$/i, '$0'], 12533 [/m[ae]n$/i, 'men'], 12534 ['thou', 'you'] 12535 ].forEach(function (rule) { 12536 return pluralize.addPluralRule(rule[0], rule[1]); 12537 }); 12538 [ 12539 [/s$/i, ''], 12540 [/(ss)$/i, '$1'], 12541 [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, '$1fe'], 12542 [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'], 12543 [/ies$/i, 'y'], 12544 [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'], 12545 [/\b(mon|smil)ies$/i, '$1ey'], 12546 [/\b((?:tit)?m|l)ice$/i, '$1ouse'], 12547 [/(seraph|cherub)im$/i, '$1'], 12548 [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'], 12549 [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'], 12550 [/(movie|twelve|abuse|e[mn]u)s$/i, '$1'], 12551 [/(test)(?:is|es)$/i, '$1is'], 12552 [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'], 12553 [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'], 12554 [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'], 12555 [/(alumn|alg|vertebr)ae$/i, '$1a'], 12556 [/(cod|mur|sil|vert|ind)ices$/i, '$1ex'], 12557 [/(matr|append)ices$/i, '$1ix'], 12558 [/(pe)(rson|ople)$/i, '$1rson'], 12559 [/(child)ren$/i, '$1'], 12560 [/(eau)x?$/i, '$1'], 12561 [/men$/i, 'man'] 12562 ].forEach(function (rule) { 12563 return pluralize.addSingularRule(rule[0], rule[1]); 12564 }); 12565 [ 12566 'adulthood', 12567 'advice', 12568 'agenda', 12569 'aid', 12570 'aircraft', 12571 'alcohol', 12572 'ammo', 12573 'analytics', 12574 'anime', 12575 'athletics', 12576 'audio', 12577 'bison', 12578 'blood', 12579 'bream', 12580 'buffalo', 12581 'butter', 12582 'carp', 12583 'cash', 12584 'chassis', 12585 'chess', 12586 'clothing', 12587 'cod', 12588 'commerce', 12589 'cooperation', 12590 'corps', 12591 'debris', 12592 'diabetes', 12593 'digestion', 12594 'elk', 12595 'energy', 12596 'equipment', 12597 'excretion', 12598 'expertise', 12599 'firmware', 12600 'flounder', 12601 'fun', 12602 'gallows', 12603 'garbage', 12604 'graffiti', 12605 'hardware', 12606 'headquarters', 12607 'health', 12608 'herpes', 12609 'highjinks', 12610 'homework', 12611 'housework', 12612 'information', 12613 'jeans', 12614 'justice', 12615 'kudos', 12616 'labour', 12617 'literature', 12618 'machinery', 12619 'mackerel', 12620 'mail', 12621 'media', 12622 'mews', 12623 'moose', 12624 'music', 12625 'mud', 12626 'manga', 12627 'news', 12628 'only', 12629 'personnel', 12630 'pike', 12631 'plankton', 12632 'pliers', 12633 'police', 12634 'pollution', 12635 'premises', 12636 'rain', 12637 'research', 12638 'rice', 12639 'salmon', 12640 'scissors', 12641 'series', 12642 'sewage', 12643 'shambles', 12644 'shrimp', 12645 'software', 12646 'species', 12647 'staff', 12648 'swine', 12649 'tennis', 12650 'traffic', 12651 'transportation', 12652 'trout', 12653 'tuna', 12654 'wealth', 12655 'welfare', 12656 'whiting', 12657 'wildebeest', 12658 'wildlife', 12659 'you', 12660 /pok[eé]mon$/i, 12661 /[^aeiou]ese$/i, 12662 /deer$/i, 12663 /fish$/i, 12664 /measles$/i, 12665 /o[iu]s$/i, 12666 /pox$/i, 12667 /sheep$/i 12668 ].forEach(pluralize.addUncountableRule); 12669 return pluralize; 12670 }); 12671} (pluralize)); 12672var pluralizeExports = pluralize.exports; 12673var plural = getDefaultExportFromCjs(pluralizeExports); 12674 12675/** 12676 * ## When should I use this? 12677 * 12678 * You can use this package to check that list items are not indented. 12679 * 12680 * ## API 12681 * 12682 * There are no options. 12683 * 12684 * ## Recommendation 12685 * 12686 * There is no specific handling of indented list items (or anything else) in 12687 * markdown. 12688 * While it is possible to use an indent to align ordered lists on their marker: 12689 * 12690 * ```markdown 12691 * 1. One 12692 * 10. Ten 12693 * 100. Hundred 12694 * ``` 12695 * 12696 * …such a style is uncommon and a bit hard to maintain: adding a 10th item 12697 * means 9 other items have to change (more arduous, while unlikely, would be 12698 * the 100th item). 12699 * Hence, it’s recommended to not indent items and to turn this rule on. 12700 * 12701 * ## Fix 12702 * 12703 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 12704 * formats all items without indent. 12705 * 12706 * @module list-item-bullet-indent 12707 * @summary 12708 * remark-lint rule to warn when list items are indented. 12709 * @author Titus Wormer 12710 * @copyright 2015 Titus Wormer 12711 * @license MIT 12712 * @example 12713 * {"name": "ok.md"} 12714 * 12715 * Paragraph. 12716 * 12717 * * List item 12718 * * List item 12719 * 12720 * @example 12721 * {"name": "not-ok.md", "label": "input"} 12722 * 12723 * Paragraph. 12724 * 12725 * ·* List item 12726 * ·* List item 12727 * 12728 * @example 12729 * {"name": "not-ok.md", "label": "output"} 12730 * 12731 * 3:2: Incorrect indentation before bullet: remove 1 space 12732 * 4:2: Incorrect indentation before bullet: remove 1 space 12733 */ 12734const remarkLintListItemBulletIndent = lintRule( 12735 { 12736 origin: 'remark-lint:list-item-bullet-indent', 12737 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-bullet-indent#readme' 12738 }, 12739 (tree, file) => { 12740 visit$1(tree, 'list', (list, _, grandparent) => { 12741 let index = -1; 12742 while (++index < list.children.length) { 12743 const item = list.children[index]; 12744 if ( 12745 grandparent && 12746 grandparent.type === 'root' && 12747 grandparent.position && 12748 typeof grandparent.position.start.column === 'number' && 12749 item.position && 12750 typeof item.position.start.column === 'number' 12751 ) { 12752 const indent = 12753 item.position.start.column - grandparent.position.start.column; 12754 if (indent) { 12755 file.message( 12756 'Incorrect indentation before bullet: remove ' + 12757 indent + 12758 ' ' + 12759 plural('space', indent), 12760 item.position.start 12761 ); 12762 } 12763 } 12764 } 12765 }); 12766 } 12767); 12768var remarkLintListItemBulletIndent$1 = remarkLintListItemBulletIndent; 12769 12770const pointStart = point$1('start'); 12771const pointEnd = point$1('end'); 12772function point$1(type) { 12773 return point 12774 function point(node) { 12775 const point = (node && node.position && node.position[type]) || {}; 12776 return { 12777 line: point.line || null, 12778 column: point.column || null, 12779 offset: point.offset > -1 ? point.offset : null 12780 } 12781 } 12782} 12783 12784function generated(node) { 12785 return ( 12786 !node || 12787 !node.position || 12788 !node.position.start || 12789 !node.position.start.line || 12790 !node.position.start.column || 12791 !node.position.end || 12792 !node.position.end.line || 12793 !node.position.end.column 12794 ) 12795} 12796 12797/** 12798 * ## When should I use this? 12799 * 12800 * You can use this package to check that the spacing between list item markers 12801 * and content is inconsistent. 12802 * 12803 * ## API 12804 * 12805 * The following options (default: `'tab-size'`) are accepted: 12806 * 12807 * * `'space'` 12808 * — prefer a single space 12809 * * `'tab-size'` 12810 * — prefer spaces the size of the next tab stop 12811 * * `'mixed'` 12812 * — prefer `'space'` for tight lists and `'tab-size'` for loose lists 12813 * 12814 * ## Recommendation 12815 * 12816 * First, some background. 12817 * The number of spaces that occur after list markers (`*`, `-`, and `+` for 12818 * unordered lists, or `.` and `)` for unordered lists) and before the content 12819 * on the first line, defines how much indentation can be used for further 12820 * lines. 12821 * At least one space is required and up to 4 spaces are allowed (if there is no 12822 * further content after the marker then it’s a blank line which is handled as 12823 * if there was one space; if there are 5 or more spaces and then content, it’s 12824 * also seen as one space and the rest is seen as indented code). 12825 * 12826 * There are two types of lists in markdown (other than ordered and unordered): 12827 * tight and loose lists. 12828 * Lists are tight by default but if there is a blank line between two list 12829 * items or between two blocks inside an item, that turns the whole list into a 12830 * loose list. 12831 * When turning markdown into HTML, paragraphs in tight lists are not wrapped 12832 * in `<p>` tags. 12833 * 12834 * Historically, how indentation of lists works in markdown has been a mess, 12835 * especially with how they interact with indented code. 12836 * CommonMark made that a *lot* better, but there remain (documented but 12837 * complex) edge cases and some behavior intuitive. 12838 * Due to this, the default of this list is `'tab-size'`, which worked the best 12839 * in most markdown parsers. 12840 * Currently, the situation between markdown parsers is better, so choosing 12841 * `'space'` (which seems to be the most common style used by authors) should 12842 * be okay. 12843 * 12844 * ## Fix 12845 * 12846 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 12847 * uses `'tab-size'` (named `'tab'` there) by default. 12848 * [`listItemIndent: '1'` (for `'space'`) or `listItemIndent: 'mixed'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionslistitemindent) 12849 * is supported. 12850 * 12851 * @module list-item-indent 12852 * @summary 12853 * remark-lint rule to warn when spacing between list item markers and 12854 * content is inconsistent. 12855 * @author Titus Wormer 12856 * @copyright 2015 Titus Wormer 12857 * @license MIT 12858 * @example 12859 * {"name": "ok.md"} 12860 * 12861 * *···List 12862 * ····item. 12863 * 12864 * Paragraph. 12865 * 12866 * 11.·List 12867 * ····item. 12868 * 12869 * Paragraph. 12870 * 12871 * *···List 12872 * ····item. 12873 * 12874 * *···List 12875 * ····item. 12876 * 12877 * @example 12878 * {"name": "ok.md", "config": "mixed"} 12879 * 12880 * *·List item. 12881 * 12882 * Paragraph. 12883 * 12884 * 11.·List item 12885 * 12886 * Paragraph. 12887 * 12888 * *···List 12889 * ····item. 12890 * 12891 * *···List 12892 * ····item. 12893 * 12894 * @example 12895 * {"name": "ok.md", "config": "space"} 12896 * 12897 * *·List item. 12898 * 12899 * Paragraph. 12900 * 12901 * 11.·List item 12902 * 12903 * Paragraph. 12904 * 12905 * *·List 12906 * ··item. 12907 * 12908 * *·List 12909 * ··item. 12910 * 12911 * @example 12912 * {"name": "not-ok.md", "config": "space", "label": "input"} 12913 * 12914 * *···List 12915 * ····item. 12916 * 12917 * @example 12918 * {"name": "not-ok.md", "config": "space", "label": "output"} 12919 * 12920 * 1:5: Incorrect list-item indent: remove 2 spaces 12921 * 12922 * @example 12923 * {"name": "not-ok.md", "config": "tab-size", "label": "input"} 12924 * 12925 * *·List 12926 * ··item. 12927 * 12928 * @example 12929 * {"name": "not-ok.md", "config": "tab-size", "label": "output"} 12930 * 12931 * 1:3: Incorrect list-item indent: add 2 spaces 12932 * 12933 * @example 12934 * {"name": "not-ok.md", "config": "mixed", "label": "input"} 12935 * 12936 * *···List item. 12937 * 12938 * @example 12939 * {"name": "not-ok.md", "config": "mixed", "label": "output"} 12940 * 12941 * 1:5: Incorrect list-item indent: remove 2 spaces 12942 * 12943 * @example 12944 * {"name": "not-ok.md", "config": "", "label": "output", "positionless": true} 12945 * 12946 * 1:1: Incorrect list-item indent style ``: use either `'tab-size'`, `'space'`, or `'mixed'` 12947 */ 12948const remarkLintListItemIndent = lintRule( 12949 { 12950 origin: 'remark-lint:list-item-indent', 12951 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-indent#readme' 12952 }, 12953 (tree, file, option = 'tab-size') => { 12954 const value = String(file); 12955 if (option !== 'tab-size' && option !== 'space' && option !== 'mixed') { 12956 file.fail( 12957 'Incorrect list-item indent style `' + 12958 option + 12959 "`: use either `'tab-size'`, `'space'`, or `'mixed'`" 12960 ); 12961 } 12962 visit$1(tree, 'list', (node) => { 12963 if (generated(node)) return 12964 const spread = node.spread; 12965 let index = -1; 12966 while (++index < node.children.length) { 12967 const item = node.children[index]; 12968 const head = item.children[0]; 12969 const final = pointStart(head); 12970 const marker = value 12971 .slice(pointStart(item).offset, final.offset) 12972 .replace(/\[[x ]?]\s*$/i, ''); 12973 const bulletSize = marker.replace(/\s+$/, '').length; 12974 const style = 12975 option === 'tab-size' || (option === 'mixed' && spread) 12976 ? Math.ceil(bulletSize / 4) * 4 12977 : bulletSize + 1; 12978 if (marker.length !== style) { 12979 const diff = style - marker.length; 12980 const abs = Math.abs(diff); 12981 file.message( 12982 'Incorrect list-item indent: ' + 12983 (diff > 0 ? 'add' : 'remove') + 12984 ' ' + 12985 abs + 12986 ' ' + 12987 plural('space', abs), 12988 final 12989 ); 12990 } 12991 } 12992 }); 12993 } 12994); 12995var remarkLintListItemIndent$1 = remarkLintListItemIndent; 12996 12997/** 12998 * ## When should I use this? 12999 * 13000 * You can use this package to check that lines in block quotes start with `>`. 13001 * 13002 * ## API 13003 * 13004 * There are no options. 13005 * 13006 * ## Recommendation 13007 * 13008 * Rules around “lazy” lines are not straightforward and visually confusing, 13009 * so it’s recommended to start each line with a `>`. 13010 * 13011 * ## Fix 13012 * 13013 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 13014 * adds `>` markers to every line in a block quote. 13015 * 13016 * @module no-blockquote-without-marker 13017 * @summary 13018 * remark-lint rule to warn when lines in block quotes start without `>`. 13019 * @author Titus Wormer 13020 * @copyright 2015 Titus Wormer 13021 * @license MIT 13022 * @example 13023 * {"name": "ok.md"} 13024 * 13025 * > Foo… 13026 * > …bar… 13027 * > …baz. 13028 * 13029 * @example 13030 * {"name": "ok-tabs.md"} 13031 * 13032 * >»Foo… 13033 * >»…bar… 13034 * >»…baz. 13035 * 13036 * @example 13037 * {"name": "not-ok.md", "label": "input"} 13038 * 13039 * > Foo… 13040 * …bar… 13041 * > …baz. 13042 * 13043 * @example 13044 * {"name": "not-ok.md", "label": "output"} 13045 * 13046 * 2:1: Missing marker in block quote 13047 * 13048 * @example 13049 * {"name": "not-ok-tabs.md", "label": "input"} 13050 * 13051 * >»Foo… 13052 * »…bar… 13053 * …baz. 13054 * 13055 * @example 13056 * {"name": "not-ok-tabs.md", "label": "output"} 13057 * 13058 * 2:1: Missing marker in block quote 13059 * 3:1: Missing marker in block quote 13060 */ 13061const remarkLintNoBlockquoteWithoutMarker = lintRule( 13062 { 13063 origin: 'remark-lint:no-blockquote-without-marker', 13064 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-blockquote-without-marker#readme' 13065 }, 13066 (tree, file) => { 13067 const value = String(file); 13068 const loc = location(file); 13069 visit$1(tree, 'blockquote', (node) => { 13070 let index = -1; 13071 while (++index < node.children.length) { 13072 const child = node.children[index]; 13073 if (child.type === 'paragraph' && !generated(child)) { 13074 const end = pointEnd(child).line; 13075 const column = pointStart(child).column; 13076 let line = pointStart(child).line; 13077 while (++line <= end) { 13078 const offset = loc.toOffset({line, column}); 13079 if (/>[\t ]+$/.test(value.slice(offset - 5, offset))) { 13080 continue 13081 } 13082 file.message('Missing marker in block quote', { 13083 line, 13084 column: column - 2 13085 }); 13086 } 13087 } 13088 } 13089 }); 13090 } 13091); 13092var remarkLintNoBlockquoteWithoutMarker$1 = remarkLintNoBlockquoteWithoutMarker; 13093 13094/** 13095 * ## When should I use this? 13096 * 13097 * You can use this package to check that autolink literal URLs are not used. 13098 * 13099 * ## API 13100 * 13101 * There are no options. 13102 * 13103 * ## Recommendation 13104 * 13105 * Autolink literal URLs (just a URL) are a feature enabled by GFM. 13106 * They don’t work everywhere. 13107 * Due to this, it’s recommended to instead use normal autolinks 13108 * (`<https://url>`) or links (`[text](url)`). 13109 * 13110 * ## Fix 13111 * 13112 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 13113 * never creates autolink literals and always uses normal autolinks (`<url>`). 13114 * 13115 * @module no-literal-urls 13116 * @summary 13117 * remark-lint rule to warn for autolink literals. 13118 * @author Titus Wormer 13119 * @copyright 2015 Titus Wormer 13120 * @license MIT 13121 * @example 13122 * {"name": "ok.md"} 13123 * 13124 * <http://foo.bar/baz> 13125 * 13126 * @example 13127 * {"name": "not-ok.md", "label": "input", "gfm": true} 13128 * 13129 * http://foo.bar/baz 13130 * 13131 * @example 13132 * {"name": "not-ok.md", "label": "output", "gfm": true} 13133 * 13134 * 1:1-1:19: Don’t use literal URLs without angle brackets 13135 */ 13136const remarkLintNoLiteralUrls = lintRule( 13137 { 13138 origin: 'remark-lint:no-literal-urls', 13139 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-literal-urls#readme' 13140 }, 13141 (tree, file) => { 13142 visit$1(tree, 'link', (node) => { 13143 const value = toString(node); 13144 if ( 13145 !generated(node) && 13146 pointStart(node).column === pointStart(node.children[0]).column && 13147 pointEnd(node).column === 13148 pointEnd(node.children[node.children.length - 1]).column && 13149 (node.url === 'mailto:' + value || node.url === value) 13150 ) { 13151 file.message('Don’t use literal URLs without angle brackets', node); 13152 } 13153 }); 13154 } 13155); 13156var remarkLintNoLiteralUrls$1 = remarkLintNoLiteralUrls; 13157 13158/** 13159 * ## When should I use this? 13160 * 13161 * You can use this package to check that ordered list markers are consistent. 13162 * 13163 * ## API 13164 * 13165 * The following options (default: `'consistent'`) are accepted: 13166 * 13167 * * `'.'` 13168 * — prefer dots 13169 * * `')'` 13170 * — prefer parens 13171 * * `'consistent'` 13172 * — detect the first used style and warn when further markers differ 13173 * 13174 * ## Recommendation 13175 * 13176 * Parens for list markers were not supported in markdown before CommonMark. 13177 * While they should work in most places now, not all markdown parsers follow 13178 * CommonMark. 13179 * Due to this, it’s recommended to prefer dots. 13180 * 13181 * ## Fix 13182 * 13183 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 13184 * formats ordered lists with dots by default. 13185 * Pass 13186 * [`bulletOrdered: ')'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsbulletordered) 13187 * to always use parens. 13188 * 13189 * @module ordered-list-marker-style 13190 * @summary 13191 * remark-lint rule to warn when ordered list markers are inconsistent. 13192 * @author Titus Wormer 13193 * @copyright 2015 Titus Wormer 13194 * @license MIT 13195 * @example 13196 * {"name": "ok.md"} 13197 * 13198 * 1. Foo 13199 * 13200 * 13201 * 1. Bar 13202 * 13203 * Unordered lists are not affected by this rule. 13204 * 13205 * * Foo 13206 * 13207 * @example 13208 * {"name": "ok.md", "config": "."} 13209 * 13210 * 1. Foo 13211 * 13212 * 2. Bar 13213 * 13214 * @example 13215 * {"name": "ok.md", "config": ")"} 13216 * 13217 * 1) Foo 13218 * 13219 * 2) Bar 13220 * 13221 * @example 13222 * {"name": "not-ok.md", "label": "input"} 13223 * 13224 * 1. Foo 13225 * 13226 * 2) Bar 13227 * 13228 * @example 13229 * {"name": "not-ok.md", "label": "output"} 13230 * 13231 * 3:1-3:8: Marker style should be `.` 13232 * 13233 * @example 13234 * {"name": "not-ok.md", "label": "output", "config": "", "positionless": true} 13235 * 13236 * 1:1: Incorrect ordered list item marker style ``: use either `'.'` or `')'` 13237 */ 13238const remarkLintOrderedListMarkerStyle = lintRule( 13239 { 13240 origin: 'remark-lint:ordered-list-marker-style', 13241 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-ordered-list-marker-style#readme' 13242 }, 13243 (tree, file, option = 'consistent') => { 13244 const value = String(file); 13245 if (option !== 'consistent' && option !== '.' && option !== ')') { 13246 file.fail( 13247 'Incorrect ordered list item marker style `' + 13248 option + 13249 "`: use either `'.'` or `')'`" 13250 ); 13251 } 13252 visit$1(tree, 'list', (node) => { 13253 let index = -1; 13254 if (!node.ordered) return 13255 while (++index < node.children.length) { 13256 const child = node.children[index]; 13257 if (!generated(child)) { 13258 const marker = ( 13259 value 13260 .slice( 13261 pointStart(child).offset, 13262 pointStart(child.children[0]).offset 13263 ) 13264 .replace(/\s|\d/g, '') 13265 .replace(/\[[x ]?]\s*$/i, '') 13266 ); 13267 if (option === 'consistent') { 13268 option = marker; 13269 } else if (marker !== option) { 13270 file.message('Marker style should be `' + option + '`', child); 13271 } 13272 } 13273 } 13274 }); 13275 } 13276); 13277var remarkLintOrderedListMarkerStyle$1 = remarkLintOrderedListMarkerStyle; 13278 13279/** 13280 * ## When should I use this? 13281 * 13282 * You can use this package to check that hard breaks use two spaces and 13283 * not more. 13284 * 13285 * ## API 13286 * 13287 * There are no options. 13288 * 13289 * ## Recommendation 13290 * 13291 * Less than two spaces do not create a hard breaks and more than two spaces 13292 * have no effect. 13293 * Due to this, it’s recommended to turn this rule on. 13294 * 13295 * @module hard-break-spaces 13296 * @summary 13297 * remark-lint rule to warn when more spaces are used than needed 13298 * for hard breaks. 13299 * @author Titus Wormer 13300 * @copyright 2015 Titus Wormer 13301 * @license MIT 13302 * @example 13303 * {"name": "ok.md"} 13304 * 13305 * Lorem ipsum·· 13306 * dolor sit amet 13307 * 13308 * @example 13309 * {"name": "not-ok.md", "label": "input"} 13310 * 13311 * Lorem ipsum··· 13312 * dolor sit amet. 13313 * 13314 * @example 13315 * {"name": "not-ok.md", "label": "output"} 13316 * 13317 * 1:12-2:1: Use two spaces for hard line breaks 13318 */ 13319const remarkLintHardBreakSpaces = lintRule( 13320 { 13321 origin: 'remark-lint:hard-break-spaces', 13322 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-hard-break-spaces#readme' 13323 }, 13324 (tree, file) => { 13325 const value = String(file); 13326 visit$1(tree, 'break', (node) => { 13327 if (!generated(node)) { 13328 const slice = value 13329 .slice(pointStart(node).offset, pointEnd(node).offset) 13330 .split('\n', 1)[0] 13331 .replace(/\r$/, ''); 13332 if (slice.length > 2) { 13333 file.message('Use two spaces for hard line breaks', node); 13334 } 13335 } 13336 }); 13337 } 13338); 13339var remarkLintHardBreakSpaces$1 = remarkLintHardBreakSpaces; 13340 13341/** 13342 * ## When should I use this? 13343 * 13344 * You can use this package to check that identifiers are defined once. 13345 * 13346 * ## API 13347 * 13348 * There are no options. 13349 * 13350 * ## Recommendation 13351 * 13352 * It’s a mistake when the same identifier is defined multiple times. 13353 * 13354 * @module no-duplicate-definitions 13355 * @summary 13356 * remark-lint rule to warn when identifiers are defined multiple times. 13357 * @author Titus Wormer 13358 * @copyright 2015 Titus Wormer 13359 * @license MIT 13360 * @example 13361 * {"name": "ok.md"} 13362 * 13363 * [foo]: bar 13364 * [baz]: qux 13365 * 13366 * @example 13367 * {"name": "not-ok.md", "label": "input"} 13368 * 13369 * [foo]: bar 13370 * [foo]: qux 13371 * 13372 * @example 13373 * {"name": "not-ok.md", "label": "output"} 13374 * 13375 * 2:1-2:11: Do not use definitions with the same identifier (1:1) 13376 */ 13377const remarkLintNoDuplicateDefinitions = lintRule( 13378 { 13379 origin: 'remark-lint:no-duplicate-definitions', 13380 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-duplicate-definitions#readme' 13381 }, 13382 (tree, file) => { 13383 const map = Object.create(null); 13384 visit$1(tree, (node) => { 13385 if ( 13386 (node.type === 'definition' || node.type === 'footnoteDefinition') && 13387 !generated(node) 13388 ) { 13389 const identifier = node.identifier; 13390 const duplicate = map[identifier]; 13391 if (duplicate) { 13392 file.message( 13393 'Do not use definitions with the same identifier (' + 13394 duplicate + 13395 ')', 13396 node 13397 ); 13398 } 13399 map[identifier] = stringifyPosition$1(pointStart(node)); 13400 } 13401 }); 13402 } 13403); 13404var remarkLintNoDuplicateDefinitions$1 = remarkLintNoDuplicateDefinitions; 13405 13406function headingStyle(node, relative) { 13407 const last = node.children[node.children.length - 1]; 13408 const depth = node.depth; 13409 const pos = node.position && node.position.end; 13410 const final = last && last.position && last.position.end; 13411 if (!pos) { 13412 return null 13413 } 13414 if (!last) { 13415 if (pos.column - 1 <= depth * 2) { 13416 return consolidate(depth, relative) 13417 } 13418 return 'atx-closed' 13419 } 13420 if (final && final.line + 1 === pos.line) { 13421 return 'setext' 13422 } 13423 if (final && final.column + depth < pos.column) { 13424 return 'atx-closed' 13425 } 13426 return consolidate(depth, relative) 13427} 13428function consolidate(depth, relative) { 13429 return depth < 3 13430 ? 'atx' 13431 : relative === 'atx' || relative === 'setext' 13432 ? relative 13433 : null 13434} 13435 13436/** 13437 * ## When should I use this? 13438 * 13439 * You can use this package to check that there is on space between `#` 13440 * characters and the content in headings. 13441 * 13442 * ## API 13443 * 13444 * There are no options. 13445 * 13446 * ## Recommendation 13447 * 13448 * One space is required and more than one space has no effect. 13449 * Due to this, it’s recommended to turn this rule on. 13450 * 13451 * ## Fix 13452 * 13453 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 13454 * formats headings with exactly one space. 13455 * 13456 * @module no-heading-content-indent 13457 * @summary 13458 * remark-lint rule to warn when there are too many spaces between 13459 * hashes and content in headings. 13460 * @author Titus Wormer 13461 * @copyright 2015 Titus Wormer 13462 * @license MIT 13463 * @example 13464 * {"name": "ok.md"} 13465 * 13466 * #·Foo 13467 * 13468 * ## Bar·## 13469 * 13470 * ##·Baz 13471 * 13472 * Setext headings are not affected. 13473 * 13474 * Baz 13475 * === 13476 * 13477 * @example 13478 * {"name": "not-ok.md", "label": "input"} 13479 * 13480 * #··Foo 13481 * 13482 * ## Bar··## 13483 * 13484 * ##··Baz 13485 * 13486 * @example 13487 * {"name": "not-ok.md", "label": "output"} 13488 * 13489 * 1:4: Remove 1 space before this heading’s content 13490 * 3:7: Remove 1 space after this heading’s content 13491 * 5:7: Remove 1 space before this heading’s content 13492 * 13493 * @example 13494 * {"name": "empty-heading.md"} 13495 * 13496 * #·· 13497 */ 13498const remarkLintNoHeadingContentIndent = lintRule( 13499 { 13500 origin: 'remark-lint:no-heading-content-indent', 13501 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-heading-content-indent#readme' 13502 }, 13503 (tree, file) => { 13504 visit$1(tree, 'heading', (node) => { 13505 if (generated(node)) { 13506 return 13507 } 13508 const type = headingStyle(node, 'atx'); 13509 if (type === 'atx' || type === 'atx-closed') { 13510 const head = pointStart(node.children[0]).column; 13511 if (!head) { 13512 return 13513 } 13514 const diff = head - pointStart(node).column - 1 - node.depth; 13515 if (diff) { 13516 file.message( 13517 'Remove ' + 13518 Math.abs(diff) + 13519 ' ' + 13520 plural('space', Math.abs(diff)) + 13521 ' before this heading’s content', 13522 pointStart(node.children[0]) 13523 ); 13524 } 13525 } 13526 if (type === 'atx-closed') { 13527 const final = pointEnd(node.children[node.children.length - 1]); 13528 const diff = pointEnd(node).column - final.column - 1 - node.depth; 13529 if (diff) { 13530 file.message( 13531 'Remove ' + 13532 diff + 13533 ' ' + 13534 plural('space', diff) + 13535 ' after this heading’s content', 13536 final 13537 ); 13538 } 13539 } 13540 }); 13541 } 13542); 13543var remarkLintNoHeadingContentIndent$1 = remarkLintNoHeadingContentIndent; 13544 13545/** 13546 * ## When should I use this? 13547 * 13548 * You can use this package to check that inline constructs (links) are 13549 * not padded. 13550 * Historically, it was possible to pad emphasis, strong, and strikethrough 13551 * too, but this was removed in CommonMark, making this rule much less useful. 13552 * 13553 * ## API 13554 * 13555 * There are no options. 13556 * 13557 * @module no-inline-padding 13558 * @summary 13559 * remark-lint rule to warn when inline constructs are padded. 13560 * @author Titus Wormer 13561 * @copyright 2015 Titus Wormer 13562 * @license MIT 13563 * @example 13564 * {"name": "ok.md"} 13565 * 13566 * Alpha [bravo](http://echo.fox/trot) 13567 * 13568 * @example 13569 * {"name": "not-ok.md", "label": "input"} 13570 * 13571 * Alpha [ bravo ](http://echo.fox/trot) 13572 * 13573 * @example 13574 * {"name": "not-ok.md", "label": "output"} 13575 * 13576 * 1:7-1:38: Don’t pad `link` with inner spaces 13577 */ 13578const remarkLintNoInlinePadding = lintRule( 13579 { 13580 origin: 'remark-lint:no-inline-padding', 13581 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-inline-padding#readme' 13582 }, 13583 (tree, file) => { 13584 visit$1(tree, (node) => { 13585 if ( 13586 (node.type === 'link' || node.type === 'linkReference') && 13587 !generated(node) 13588 ) { 13589 const value = toString(node); 13590 if (value.charAt(0) === ' ' || value.charAt(value.length - 1) === ' ') { 13591 file.message('Don’t pad `' + node.type + '` with inner spaces', node); 13592 } 13593 } 13594 }); 13595 } 13596); 13597var remarkLintNoInlinePadding$1 = remarkLintNoInlinePadding; 13598 13599/** 13600 * ## When should I use this? 13601 * 13602 * You can use this package to check that collapsed or full reference images 13603 * are used. 13604 * 13605 * ## API 13606 * 13607 * There are no options. 13608 * 13609 * ## Recommendation 13610 * 13611 * Shortcut references use an implicit style that looks a lot like something 13612 * that could occur as plain text instead of syntax. 13613 * In some cases, plain text is intended instead of an image. 13614 * Due to this, it’s recommended to use collapsed (or full) references 13615 * instead. 13616 * 13617 * @module no-shortcut-reference-image 13618 * @summary 13619 * remark-lint rule to warn when shortcut reference images are used. 13620 * @author Titus Wormer 13621 * @copyright 2015 Titus Wormer 13622 * @license MIT 13623 * @example 13624 * {"name": "ok.md"} 13625 * 13626 * ![foo][] 13627 * 13628 * [foo]: http://foo.bar/baz.png 13629 * 13630 * @example 13631 * {"name": "not-ok.md", "label": "input"} 13632 * 13633 * ![foo] 13634 * 13635 * [foo]: http://foo.bar/baz.png 13636 * 13637 * @example 13638 * {"name": "not-ok.md", "label": "output"} 13639 * 13640 * 1:1-1:7: Use the trailing [] on reference images 13641 */ 13642const remarkLintNoShortcutReferenceImage = lintRule( 13643 { 13644 origin: 'remark-lint:no-shortcut-reference-image', 13645 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-shortcut-reference-image#readme' 13646 }, 13647 (tree, file) => { 13648 visit$1(tree, 'imageReference', (node) => { 13649 if (!generated(node) && node.referenceType === 'shortcut') { 13650 file.message('Use the trailing [] on reference images', node); 13651 } 13652 }); 13653 } 13654); 13655var remarkLintNoShortcutReferenceImage$1 = remarkLintNoShortcutReferenceImage; 13656 13657/** 13658 * ## When should I use this? 13659 * 13660 * You can use this package to check that collapsed or full reference links 13661 * are used. 13662 * 13663 * ## API 13664 * 13665 * There are no options. 13666 * 13667 * ## Recommendation 13668 * 13669 * Shortcut references use an implicit style that looks a lot like something 13670 * that could occur as plain text instead of syntax. 13671 * In some cases, plain text is intended instead of a link. 13672 * Due to this, it’s recommended to use collapsed (or full) references 13673 * instead. 13674 * 13675 * @module no-shortcut-reference-link 13676 * @summary 13677 * remark-lint rule to warn when shortcut reference links are used. 13678 * @author Titus Wormer 13679 * @copyright 2015 Titus Wormer 13680 * @license MIT 13681 * @example 13682 * {"name": "ok.md"} 13683 * 13684 * [foo][] 13685 * 13686 * [foo]: http://foo.bar/baz 13687 * 13688 * @example 13689 * {"name": "not-ok.md", "label": "input"} 13690 * 13691 * [foo] 13692 * 13693 * [foo]: http://foo.bar/baz 13694 * 13695 * @example 13696 * {"name": "not-ok.md", "label": "output"} 13697 * 13698 * 1:1-1:6: Use the trailing `[]` on reference links 13699 */ 13700const remarkLintNoShortcutReferenceLink = lintRule( 13701 { 13702 origin: 'remark-lint:no-shortcut-reference-link', 13703 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-shortcut-reference-link#readme' 13704 }, 13705 (tree, file) => { 13706 visit$1(tree, 'linkReference', (node) => { 13707 if (!generated(node) && node.referenceType === 'shortcut') { 13708 file.message('Use the trailing `[]` on reference links', node); 13709 } 13710 }); 13711 } 13712); 13713var remarkLintNoShortcutReferenceLink$1 = remarkLintNoShortcutReferenceLink; 13714 13715/** 13716 * ## When should I use this? 13717 * 13718 * You can use this package to check that referenced definitions are defined. 13719 * 13720 * ## API 13721 * 13722 * The following options (default: `undefined`) are accepted: 13723 * 13724 * * `Object` with the following fields: 13725 * * `allow` (`Array<string | RegExp | { source: string }>`, 13726 * default: `[]`) 13727 * — text or regex that you want to be allowed between `[` and `]` 13728 * even though it’s undefined; regex is provided via a `RegExp` object 13729 * or via a `{source: string}` object where `source` is the source 13730 * text of a case-insensitive regex 13731 * 13732 * ## Recommendation 13733 * 13734 * Shortcut references use an implicit syntax that could also occur as plain 13735 * text. 13736 * For example, it is reasonable to expect an author adding `[…]` to abbreviate 13737 * some text somewhere in a document: 13738 * 13739 * ```markdown 13740 * > Some […] quote. 13741 * ``` 13742 * 13743 * This isn’t a problem, but it might become one when an author later adds a 13744 * definition: 13745 * 13746 * ```markdown 13747 * Some text. […][] 13748 * 13749 * […] #read-more "Read more" 13750 * ``` 13751 * 13752 * The second author might expect only their newly added text to form a link, 13753 * but their changes also result in a link for the first author’s text. 13754 * 13755 * @module no-undefined-references 13756 * @summary 13757 * remark-lint rule to warn when undefined definitions are referenced. 13758 * @author Titus Wormer 13759 * @copyright 2016 Titus Wormer 13760 * @license MIT 13761 * @example 13762 * {"name": "ok.md"} 13763 * 13764 * [foo][] 13765 * 13766 * Just a [ bracket. 13767 * 13768 * Typically, you’d want to use escapes (with a backslash: \\) to escape what 13769 * could turn into a \[reference otherwise]. 13770 * 13771 * Just two braces can’t link: []. 13772 * 13773 * [foo]: https://example.com 13774 * 13775 * @example 13776 * {"name": "ok-allow.md", "config": {"allow": ["...", "…"]}} 13777 * 13778 * > Eliding a portion of a quoted passage […] is acceptable. 13779 * 13780 * @example 13781 * {"name": "ok-allow.md", "config": {"allow": ["a", {"source": "^b\\."}]}} 13782 * 13783 * [foo][b.c] 13784 * 13785 * [bar][a] 13786 * 13787 * Matching is case-insensitive: [bar][B.C] 13788 * 13789 * @example 13790 * {"name": "not-ok.md", "label": "input"} 13791 * 13792 * [bar] 13793 * 13794 * [baz][] 13795 * 13796 * [text][qux] 13797 * 13798 * Spread [over 13799 * lines][] 13800 * 13801 * > in [a 13802 * > block quote][] 13803 * 13804 * [asd][a 13805 * 13806 * Can include [*emphasis*]. 13807 * 13808 * Multiple pairs: [a][b][c]. 13809 * 13810 * @example 13811 * {"name": "not-ok.md", "label": "output"} 13812 * 13813 * 1:1-1:6: Found reference to undefined definition 13814 * 3:1-3:8: Found reference to undefined definition 13815 * 5:1-5:12: Found reference to undefined definition 13816 * 7:8-8:9: Found reference to undefined definition 13817 * 10:6-11:17: Found reference to undefined definition 13818 * 13:1-13:6: Found reference to undefined definition 13819 * 15:13-15:25: Found reference to undefined definition 13820 * 17:17-17:23: Found reference to undefined definition 13821 * 17:23-17:26: Found reference to undefined definition 13822 * 13823 * @example 13824 * {"name": "not-ok.md", "label": "input", "config": {"allow": ["a", {"source": "^b\\."}]}} 13825 * 13826 * [foo][a.c] 13827 * 13828 * [bar][b] 13829 * 13830 * @example 13831 * {"name": "not-ok.md", "label": "output", "config": {"allow": ["a", {"source": "^b\\."}]}} 13832 * 13833 * 1:1-1:11: Found reference to undefined definition 13834 * 3:1-3:9: Found reference to undefined definition 13835 */ 13836const remarkLintNoUndefinedReferences = lintRule( 13837 { 13838 origin: 'remark-lint:no-undefined-references', 13839 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-undefined-references#readme' 13840 }, 13841 (tree, file, option = {}) => { 13842 const contents = String(file); 13843 const loc = location(file); 13844 const lineEnding = /(\r?\n|\r)[\t ]*(>[\t ]*)*/g; 13845 const map = Object.create(null); 13846 const allow = option.allow || []; 13847 const regexes = []; 13848 const strings = new Set(); 13849 let index = -1; 13850 while (++index < allow.length) { 13851 const value = allow[index]; 13852 if (typeof value === 'string') { 13853 strings.add(normalizeIdentifier(value)); 13854 } else if (value instanceof RegExp) { 13855 regexes.push(value); 13856 } else { 13857 regexes.push(new RegExp(value.source, 'i')); 13858 } 13859 } 13860 visit$1(tree, (node) => { 13861 if ( 13862 (node.type === 'definition' || node.type === 'footnoteDefinition') && 13863 !generated(node) 13864 ) { 13865 map[normalizeIdentifier(node.identifier)] = true; 13866 } 13867 }); 13868 visit$1(tree, (node) => { 13869 if ( 13870 (node.type === 'imageReference' || 13871 node.type === 'linkReference' || 13872 node.type === 'footnoteReference') && 13873 !generated(node) && 13874 !(normalizeIdentifier(node.identifier) in map) && 13875 !isAllowed(node.identifier) 13876 ) { 13877 file.message('Found reference to undefined definition', node); 13878 } 13879 if (node.type === 'paragraph' || node.type === 'heading') { 13880 findInPhrasing(node); 13881 } 13882 }); 13883 function findInPhrasing(node) { 13884 let ranges = []; 13885 visit$1(node, (child) => { 13886 if (child === node) return 13887 if (child.type === 'link' || child.type === 'linkReference') { 13888 ranges = []; 13889 return SKIP$1 13890 } 13891 if (child.type !== 'text') return 13892 const start = pointStart(child).offset; 13893 const end = pointEnd(child).offset; 13894 if (typeof start !== 'number' || typeof end !== 'number') { 13895 return EXIT$1 13896 } 13897 const source = contents.slice(start, end); 13898 const lines = [[start, '']]; 13899 let last = 0; 13900 lineEnding.lastIndex = 0; 13901 let match = lineEnding.exec(source); 13902 while (match) { 13903 const index = match.index; 13904 lines[lines.length - 1][1] = source.slice(last, index); 13905 last = index + match[0].length; 13906 lines.push([start + last, '']); 13907 match = lineEnding.exec(source); 13908 } 13909 lines[lines.length - 1][1] = source.slice(last); 13910 let lineIndex = -1; 13911 while (++lineIndex < lines.length) { 13912 const line = lines[lineIndex][1]; 13913 let index = 0; 13914 while (index < line.length) { 13915 const code = line.charCodeAt(index); 13916 if (code === 92) { 13917 const next = line.charCodeAt(index + 1); 13918 index++; 13919 if (next === 91 || next === 93) { 13920 index++; 13921 } 13922 } 13923 else if (code === 91) { 13924 ranges.push([lines[lineIndex][0] + index]); 13925 index++; 13926 } 13927 else if (code === 93) { 13928 if (ranges.length === 0) { 13929 index++; 13930 } else if (line.charCodeAt(index + 1) === 91) { 13931 index++; 13932 let range = ranges.pop(); 13933 if (range) { 13934 range.push(lines[lineIndex][0] + index); 13935 if (range.length === 4) { 13936 handleRange(range); 13937 range = []; 13938 } 13939 range.push(lines[lineIndex][0] + index); 13940 ranges.push(range); 13941 index++; 13942 } 13943 } else { 13944 index++; 13945 const range = ranges.pop(); 13946 if (range) { 13947 range.push(lines[lineIndex][0] + index); 13948 handleRange(range); 13949 } 13950 } 13951 } 13952 else { 13953 index++; 13954 } 13955 } 13956 } 13957 }); 13958 let index = -1; 13959 while (++index < ranges.length) { 13960 handleRange(ranges[index]); 13961 } 13962 return SKIP$1 13963 function handleRange(range) { 13964 if (range.length === 1) return 13965 if (range.length === 3) range.length = 2; 13966 if (range.length === 2 && range[0] + 2 === range[1]) return 13967 const offset = range.length === 4 && range[2] + 2 !== range[3] ? 2 : 0; 13968 const id = contents 13969 .slice(range[0 + offset] + 1, range[1 + offset] - 1) 13970 .replace(lineEnding, ' '); 13971 const pos = { 13972 start: loc.toPoint(range[0]), 13973 end: loc.toPoint(range[range.length - 1]) 13974 }; 13975 if ( 13976 !generated({position: pos}) && 13977 !(normalizeIdentifier(id) in map) && 13978 !isAllowed(id) 13979 ) { 13980 file.message('Found reference to undefined definition', pos); 13981 } 13982 } 13983 } 13984 function isAllowed(id) { 13985 const normalized = normalizeIdentifier(id); 13986 return ( 13987 strings.has(normalized) || 13988 regexes.some((regex) => regex.test(normalized)) 13989 ) 13990 } 13991 } 13992); 13993var remarkLintNoUndefinedReferences$1 = remarkLintNoUndefinedReferences; 13994 13995/** 13996 * ## When should I use this? 13997 * 13998 * You can use this package to check definitions are referenced. 13999 * 14000 * ## API 14001 * 14002 * There are no options. 14003 * 14004 * ## Recommendation 14005 * 14006 * Unused definitions do not contribute anything, so they can be removed. 14007 * 14008 * @module no-unused-definitions 14009 * @summary 14010 * remark-lint rule to warn when unreferenced definitions are used. 14011 * @author Titus Wormer 14012 * @copyright 2016 Titus Wormer 14013 * @license MIT 14014 * @example 14015 * {"name": "ok.md"} 14016 * 14017 * [foo][] 14018 * 14019 * [foo]: https://example.com 14020 * 14021 * @example 14022 * {"name": "not-ok.md", "label": "input"} 14023 * 14024 * [bar]: https://example.com 14025 * 14026 * @example 14027 * {"name": "not-ok.md", "label": "output"} 14028 * 14029 * 1:1-1:27: Found unused definition 14030 */ 14031const own = {}.hasOwnProperty; 14032const remarkLintNoUnusedDefinitions = lintRule( 14033 { 14034 origin: 'remark-lint:no-unused-definitions', 14035 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-unused-definitions#readme' 14036 }, 14037 (tree, file) => { 14038 const map = Object.create(null); 14039 visit$1(tree, (node) => { 14040 if ( 14041 (node.type === 'definition' || node.type === 'footnoteDefinition') && 14042 !generated(node) 14043 ) { 14044 map[node.identifier.toUpperCase()] = {node, used: false}; 14045 } 14046 }); 14047 visit$1(tree, (node) => { 14048 if ( 14049 node.type === 'imageReference' || 14050 node.type === 'linkReference' || 14051 node.type === 'footnoteReference' 14052 ) { 14053 const info = map[node.identifier.toUpperCase()]; 14054 if (!generated(node) && info) { 14055 info.used = true; 14056 } 14057 } 14058 }); 14059 let identifier; 14060 for (identifier in map) { 14061 if (own.call(map, identifier)) { 14062 const entry = map[identifier]; 14063 if (!entry.used) { 14064 file.message('Found unused definition', entry.node); 14065 } 14066 } 14067 } 14068 } 14069); 14070var remarkLintNoUnusedDefinitions$1 = remarkLintNoUnusedDefinitions; 14071 14072const remarkPresetLintRecommended = { 14073 plugins: [ 14074 remarkLint, 14075 remarkLintFinalNewline$1, 14076 remarkLintListItemBulletIndent$1, 14077 [remarkLintListItemIndent$1, 'tab-size'], 14078 remarkLintNoBlockquoteWithoutMarker$1, 14079 remarkLintNoLiteralUrls$1, 14080 [remarkLintOrderedListMarkerStyle$1, '.'], 14081 remarkLintHardBreakSpaces$1, 14082 remarkLintNoDuplicateDefinitions$1, 14083 remarkLintNoHeadingContentIndent$1, 14084 remarkLintNoInlinePadding$1, 14085 remarkLintNoShortcutReferenceImage$1, 14086 remarkLintNoShortcutReferenceLink$1, 14087 remarkLintNoUndefinedReferences$1, 14088 remarkLintNoUnusedDefinitions$1 14089 ] 14090}; 14091var remarkPresetLintRecommended$1 = remarkPresetLintRecommended; 14092 14093/** 14094 * ## When should I use this? 14095 * 14096 * You can use this package to check that the “indent” of block quotes is 14097 * consistent. 14098 * Indent here is the `>` (greater than) marker and the spaces before content. 14099 * 14100 * ## API 14101 * 14102 * The following options (default: `'consistent'`) are accepted: 14103 * 14104 * * `number` (example: `2`) 14105 * — preferred indent of `>` and spaces before content 14106 * * `'consistent'` 14107 * — detect the first used style and warn when further block quotes differ 14108 * 14109 * ## Recommendation 14110 * 14111 * CommonMark specifies that when block quotes are used the `>` markers can be 14112 * followed by an optional space. 14113 * No space at all arguably looks rather ugly: 14114 * 14115 * ```markdown 14116 * >Mars and 14117 * >Venus. 14118 * ``` 14119 * 14120 * There is no specific handling of more that one space, so if 5 spaces were 14121 * used after `>`, then indented code kicks in: 14122 * 14123 * ```markdown 14124 * > neptune() 14125 * ``` 14126 * 14127 * Due to this, it’s recommended to configure this rule with `2`. 14128 * 14129 * @module blockquote-indentation 14130 * @summary 14131 * remark-lint rule to warn when block quotes are indented too much or 14132 * too little. 14133 * @author Titus Wormer 14134 * @copyright 2015 Titus Wormer 14135 * @license MIT 14136 * @example 14137 * {"name": "ok.md", "config": 4} 14138 * 14139 * > Hello 14140 * 14141 * Paragraph. 14142 * 14143 * > World 14144 * @example 14145 * {"name": "ok.md", "config": 2} 14146 * 14147 * > Hello 14148 * 14149 * Paragraph. 14150 * 14151 * > World 14152 * 14153 * @example 14154 * {"name": "not-ok.md", "label": "input"} 14155 * 14156 * > Hello 14157 * 14158 * Paragraph. 14159 * 14160 * > World 14161 * 14162 * Paragraph. 14163 * 14164 * > World 14165 * 14166 * @example 14167 * {"name": "not-ok.md", "label": "output"} 14168 * 14169 * 5:5: Remove 1 space between block quote and content 14170 * 9:3: Add 1 space between block quote and content 14171 */ 14172const remarkLintBlockquoteIndentation = lintRule( 14173 { 14174 origin: 'remark-lint:blockquote-indentation', 14175 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-blockquote-indentation#readme' 14176 }, 14177 (tree, file, option = 'consistent') => { 14178 visit$1(tree, 'blockquote', (node) => { 14179 if (generated(node) || node.children.length === 0) { 14180 return 14181 } 14182 if (option === 'consistent') { 14183 option = check(node); 14184 } else { 14185 const diff = option - check(node); 14186 if (diff !== 0) { 14187 const abs = Math.abs(diff); 14188 file.message( 14189 (diff > 0 ? 'Add' : 'Remove') + 14190 ' ' + 14191 abs + 14192 ' ' + 14193 plural('space', abs) + 14194 ' between block quote and content', 14195 pointStart(node.children[0]) 14196 ); 14197 } 14198 } 14199 }); 14200 } 14201); 14202var remarkLintBlockquoteIndentation$1 = remarkLintBlockquoteIndentation; 14203function check(node) { 14204 return pointStart(node.children[0]).column - pointStart(node).column 14205} 14206 14207/** 14208 * ## When should I use this? 14209 * 14210 * You can use this package to check that the style of GFM tasklists is 14211 * consistent. 14212 * 14213 * ## API 14214 * 14215 * The following options (default: `'consistent'`) are accepted: 14216 * 14217 * * `Object` with the following fields: 14218 * * `checked` (`'x'`, `'X'`, or `'consistent'`, default: `'consistent'`) 14219 * — preferred character to use for checked checkboxes 14220 * * `unchecked` (`'·'` (a space), `'»'` (a tab), or `'consistent'`, 14221 * default: `'consistent'`) 14222 * — preferred character to use for unchecked checkboxes 14223 * * `'consistent'` 14224 * — detect the first used styles and warn when further checkboxes differ 14225 * 14226 * ## Recommendation 14227 * 14228 * It’s recommended to set `options.checked` to `'x'` (a lowercase X) as it 14229 * prevents an extra keyboard press and `options.unchecked` to `'·'` (a space) 14230 * to make all checkboxes align. 14231 * 14232 * ## Fix 14233 * 14234 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 14235 * formats checked checkboxes using `'x'` (lowercase X) and unchecked checkboxes 14236 * using `'·'` (a space). 14237 * 14238 * @module checkbox-character-style 14239 * @summary 14240 * remark-lint rule to warn when list item checkboxes violate a given 14241 * style. 14242 * @author Titus Wormer 14243 * @copyright 2015 Titus Wormer 14244 * @license MIT 14245 * @example 14246 * {"name": "ok.md", "config": {"checked": "x"}, "gfm": true} 14247 * 14248 * - [x] List item 14249 * - [x] List item 14250 * 14251 * @example 14252 * {"name": "ok.md", "config": {"checked": "X"}, "gfm": true} 14253 * 14254 * - [X] List item 14255 * - [X] List item 14256 * 14257 * @example 14258 * {"name": "ok.md", "config": {"unchecked": " "}, "gfm": true} 14259 * 14260 * - [ ] List item 14261 * - [ ] List item 14262 * - [ ]·· 14263 * - [ ] 14264 * 14265 * @example 14266 * {"name": "ok.md", "config": {"unchecked": "\t"}, "gfm": true} 14267 * 14268 * - [»] List item 14269 * - [»] List item 14270 * 14271 * @example 14272 * {"name": "not-ok.md", "label": "input", "gfm": true} 14273 * 14274 * - [x] List item 14275 * - [X] List item 14276 * - [ ] List item 14277 * - [»] List item 14278 * 14279 * @example 14280 * {"name": "not-ok.md", "label": "output", "gfm": true} 14281 * 14282 * 2:5: Checked checkboxes should use `x` as a marker 14283 * 4:5: Unchecked checkboxes should use ` ` as a marker 14284 * 14285 * @example 14286 * {"config": {"unchecked": ""}, "name": "not-ok.md", "label": "output", "positionless": true, "gfm": true} 14287 * 14288 * 1:1: Incorrect unchecked checkbox marker ``: use either `'\t'`, or `' '` 14289 * 14290 * @example 14291 * {"config": {"checked": ""}, "name": "not-ok.md", "label": "output", "positionless": true, "gfm": true} 14292 * 14293 * 1:1: Incorrect checked checkbox marker ``: use either `'x'`, or `'X'` 14294 */ 14295const remarkLintCheckboxCharacterStyle = lintRule( 14296 { 14297 origin: 'remark-lint:checkbox-character-style', 14298 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-checkbox-character-style#readme' 14299 }, 14300 (tree, file, option = 'consistent') => { 14301 const value = String(file); 14302 let checked = 'consistent'; 14303 let unchecked = 'consistent'; 14304 if (typeof option === 'object') { 14305 checked = option.checked || 'consistent'; 14306 unchecked = option.unchecked || 'consistent'; 14307 } 14308 if (unchecked !== 'consistent' && unchecked !== ' ' && unchecked !== '\t') { 14309 file.fail( 14310 'Incorrect unchecked checkbox marker `' + 14311 unchecked + 14312 "`: use either `'\\t'`, or `' '`" 14313 ); 14314 } 14315 if (checked !== 'consistent' && checked !== 'x' && checked !== 'X') { 14316 file.fail( 14317 'Incorrect checked checkbox marker `' + 14318 checked + 14319 "`: use either `'x'`, or `'X'`" 14320 ); 14321 } 14322 visit$1(tree, 'listItem', (node) => { 14323 const head = node.children[0]; 14324 const point = pointStart(head); 14325 if ( 14326 typeof node.checked !== 'boolean' || 14327 !head || 14328 typeof point.offset !== 'number' 14329 ) { 14330 return 14331 } 14332 point.offset -= 2; 14333 point.column -= 2; 14334 const match = /\[([\t Xx])]/.exec( 14335 value.slice(point.offset - 2, point.offset + 1) 14336 ); 14337 if (!match) return 14338 const style = node.checked ? checked : unchecked; 14339 if (style === 'consistent') { 14340 if (node.checked) { 14341 checked = match[1]; 14342 } else { 14343 unchecked = match[1]; 14344 } 14345 } else if (match[1] !== style) { 14346 file.message( 14347 (node.checked ? 'Checked' : 'Unchecked') + 14348 ' checkboxes should use `' + 14349 style + 14350 '` as a marker', 14351 point 14352 ); 14353 } 14354 }); 14355 } 14356); 14357var remarkLintCheckboxCharacterStyle$1 = remarkLintCheckboxCharacterStyle; 14358 14359/** 14360 * ## When should I use this? 14361 * 14362 * You can use this package to check that the “indent” after a GFM tasklist 14363 * checkbox is a single space. 14364 * 14365 * ## API 14366 * 14367 * There are no accepted options. 14368 * 14369 * ## Recommendation 14370 * 14371 * GFM allows zero or more spaces and tabs after checkboxes. 14372 * No space at all arguably looks rather ugly: 14373 * 14374 * ```markdown 14375 * * [x]Pluto 14376 * ``` 14377 * 14378 * More that one space is superfluous: 14379 * 14380 * ```markdown 14381 * * [x] Jupiter 14382 * ``` 14383 * 14384 * Due to this, it’s recommended to turn this rule on. 14385 * 14386 * ## Fix 14387 * 14388 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 14389 * formats checkboxes and the content after them with a single space between. 14390 * 14391 * @module checkbox-content-indent 14392 * @summary 14393 * remark-lint rule to warn when GFM tasklist checkboxes are followed by 14394 * more than one space. 14395 * @author Titus Wormer 14396 * @copyright 2015 Titus Wormer 14397 * @license MIT 14398 * @example 14399 * {"name": "ok.md", "gfm": true} 14400 * 14401 * - [ ] List item 14402 * + [x] List Item 14403 * * [X] List item 14404 * - [ ] List item 14405 * 14406 * @example 14407 * {"name": "not-ok.md", "label": "input", "gfm": true} 14408 * 14409 * - [ ] List item 14410 * + [x] List item 14411 * * [X] List item 14412 * - [ ] List item 14413 * 14414 * @example 14415 * {"name": "not-ok.md", "label": "output", "gfm": true} 14416 * 14417 * 2:7-2:8: Checkboxes should be followed by a single character 14418 * 3:7-3:9: Checkboxes should be followed by a single character 14419 * 4:7-4:10: Checkboxes should be followed by a single character 14420 */ 14421const remarkLintCheckboxContentIndent = lintRule( 14422 { 14423 origin: 'remark-lint:checkbox-content-indent', 14424 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-checkbox-content-indent#readme' 14425 }, 14426 (tree, file) => { 14427 const value = String(file); 14428 const loc = location(file); 14429 visit$1(tree, 'listItem', (node) => { 14430 const head = node.children[0]; 14431 const point = pointStart(head); 14432 if ( 14433 typeof node.checked !== 'boolean' || 14434 !head || 14435 typeof point.offset !== 'number' 14436 ) { 14437 return 14438 } 14439 const match = /\[([\t xX])]/.exec( 14440 value.slice(point.offset - 4, point.offset + 1) 14441 ); 14442 if (!match) return 14443 const initial = point.offset; 14444 let final = initial; 14445 while (/[\t ]/.test(value.charAt(final))) final++; 14446 if (final - initial > 0) { 14447 file.message('Checkboxes should be followed by a single character', { 14448 start: loc.toPoint(initial), 14449 end: loc.toPoint(final) 14450 }); 14451 } 14452 }); 14453 } 14454); 14455var remarkLintCheckboxContentIndent$1 = remarkLintCheckboxContentIndent; 14456 14457/** 14458 * ## When should I use this? 14459 * 14460 * You can use this package to check that code blocks are consistent. 14461 * 14462 * ## API 14463 * 14464 * The following options (default: `'consistent'`) are accepted: 14465 * 14466 * * `'fenced'` 14467 * — prefer fenced code blocks: 14468 * ````markdown 14469 * ```js 14470 * code() 14471 * ``` 14472 * ```` 14473 * * `'indented'` 14474 * — prefer indented code blocks: 14475 * ```markdown 14476 * code() 14477 * ``` 14478 * * `'consistent'` 14479 * — detect the first used style and warn when further code blocks differ 14480 * 14481 * ## Recommendation 14482 * 14483 * Indentation in markdown is complex, especially because lists and indented 14484 * code can interfere in unexpected ways. 14485 * Fenced code has more features than indented code: importantly, specifying a 14486 * programming language. 14487 * Since CommonMark took the idea of fenced code from GFM, fenced code became 14488 * widely supported. 14489 * Due to this, it’s recommended to configure this rule with `'fenced'`. 14490 * 14491 * ## Fix 14492 * 14493 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 14494 * formats code blocks as fenced code when they have a language flag and as 14495 * indented code otherwise. 14496 * Pass 14497 * [`fences: true`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsfences) 14498 * to always use fenced code. 14499 * 14500 * @module code-block-style 14501 * @summary 14502 * remark-lint rule to warn when code blocks violate a given style. 14503 * @author Titus Wormer 14504 * @copyright 2015 Titus Wormer 14505 * @license MIT 14506 * 14507 * @example 14508 * {"config": "indented", "name": "ok.md"} 14509 * 14510 * alpha() 14511 * 14512 * Paragraph. 14513 * 14514 * bravo() 14515 * 14516 * @example 14517 * {"config": "indented", "name": "not-ok.md", "label": "input"} 14518 * 14519 * ``` 14520 * alpha() 14521 * ``` 14522 * 14523 * Paragraph. 14524 * 14525 * ``` 14526 * bravo() 14527 * ``` 14528 * 14529 * @example 14530 * {"config": "indented", "name": "not-ok.md", "label": "output"} 14531 * 14532 * 1:1-3:4: Code blocks should be indented 14533 * 7:1-9:4: Code blocks should be indented 14534 * 14535 * @example 14536 * {"config": "fenced", "name": "ok.md"} 14537 * 14538 * ``` 14539 * alpha() 14540 * ``` 14541 * 14542 * Paragraph. 14543 * 14544 * ``` 14545 * bravo() 14546 * ``` 14547 * 14548 * @example 14549 * {"config": "fenced", "name": "not-ok-fenced.md", "label": "input"} 14550 * 14551 * alpha() 14552 * 14553 * Paragraph. 14554 * 14555 * bravo() 14556 * 14557 * @example 14558 * {"config": "fenced", "name": "not-ok-fenced.md", "label": "output"} 14559 * 14560 * 1:1-1:12: Code blocks should be fenced 14561 * 5:1-5:12: Code blocks should be fenced 14562 * 14563 * @example 14564 * {"name": "not-ok-consistent.md", "label": "input"} 14565 * 14566 * alpha() 14567 * 14568 * Paragraph. 14569 * 14570 * ``` 14571 * bravo() 14572 * ``` 14573 * 14574 * @example 14575 * {"name": "not-ok-consistent.md", "label": "output"} 14576 * 14577 * 5:1-7:4: Code blocks should be indented 14578 * 14579 * @example 14580 * {"config": "", "name": "not-ok-incorrect.md", "label": "output", "positionless": true} 14581 * 14582 * 1:1: Incorrect code block style ``: use either `'consistent'`, `'fenced'`, or `'indented'` 14583 */ 14584const remarkLintCodeBlockStyle = lintRule( 14585 { 14586 origin: 'remark-lint:code-block-style', 14587 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-code-block-style#readme' 14588 }, 14589 (tree, file, option = 'consistent') => { 14590 const value = String(file); 14591 if ( 14592 option !== 'consistent' && 14593 option !== 'fenced' && 14594 option !== 'indented' 14595 ) { 14596 file.fail( 14597 'Incorrect code block style `' + 14598 option + 14599 "`: use either `'consistent'`, `'fenced'`, or `'indented'`" 14600 ); 14601 } 14602 visit$1(tree, 'code', (node) => { 14603 if (generated(node)) { 14604 return 14605 } 14606 const initial = pointStart(node).offset; 14607 const final = pointEnd(node).offset; 14608 const current = 14609 node.lang || /^\s*([~`])\1{2,}/.test(value.slice(initial, final)) 14610 ? 'fenced' 14611 : 'indented'; 14612 if (option === 'consistent') { 14613 option = current; 14614 } else if (option !== current) { 14615 file.message('Code blocks should be ' + option, node); 14616 } 14617 }); 14618 } 14619); 14620var remarkLintCodeBlockStyle$1 = remarkLintCodeBlockStyle; 14621 14622/** 14623 * ## When should I use this? 14624 * 14625 * You can use this package to check that the labels used in definitions 14626 * do not use meaningless white space. 14627 * 14628 * ## API 14629 * 14630 * There are no options. 14631 * 14632 * ## Recommendation 14633 * 14634 * Definitions and references are matched together by collapsing white space. 14635 * Using more white space in labels might incorrectly indicate that they are of 14636 * importance. 14637 * Due to this, it’s recommended to use one space (or a line ending if needed) 14638 * and turn this rule on. 14639 * 14640 * @module definition-spacing 14641 * @summary 14642 * remark-lint rule to warn when consecutive whitespace is used in 14643 * a definition label. 14644 * @author Titus Wormer 14645 * @copyright 2015 Titus Wormer 14646 * @license MIT 14647 * @example 14648 * {"name": "ok.md"} 14649 * 14650 * [example domain]: http://example.com "Example Domain" 14651 * 14652 * @example 14653 * {"name": "not-ok.md", "label": "input"} 14654 * 14655 * [example····domain]: http://example.com "Example Domain" 14656 * 14657 * @example 14658 * {"name": "not-ok.md", "label": "output"} 14659 * 14660 * 1:1-1:57: Do not use consecutive whitespace in definition labels 14661 */ 14662const label = /^\s*\[((?:\\[\s\S]|[^[\]])+)]/; 14663const remarkLintDefinitionSpacing = lintRule( 14664 { 14665 origin: 'remark-lint:definition-spacing', 14666 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-definition-spacing#readme' 14667 }, 14668 (tree, file) => { 14669 const value = String(file); 14670 visit$1(tree, (node) => { 14671 if (node.type === 'definition' || node.type === 'footnoteDefinition') { 14672 const start = pointStart(node).offset; 14673 const end = pointEnd(node).offset; 14674 if (typeof start === 'number' && typeof end === 'number') { 14675 const match = value.slice(start, end).match(label); 14676 if (match && /[ \t\n]{2,}/.test(match[1])) { 14677 file.message( 14678 'Do not use consecutive whitespace in definition labels', 14679 node 14680 ); 14681 } 14682 } 14683 } 14684 }); 14685 } 14686); 14687var remarkLintDefinitionSpacing$1 = remarkLintDefinitionSpacing; 14688 14689/** 14690 * ## When should I use this? 14691 * 14692 * You can use this package to check that language flags of fenced code 14693 * are used and consistent. 14694 * 14695 * ## API 14696 * 14697 * The following options (default: `undefined`) are accepted: 14698 * 14699 * * `Array<string>` 14700 * — as if passing `{flags: options}` 14701 * * `Object` with the following fields: 14702 * * `allowEmpty` (`boolean`, default: `false`) 14703 * — allow language flags to be omitted 14704 * * `flags` (`Array<string>` default: `[]`) 14705 * — specific flags to allow (other flags will result in a warning) 14706 * 14707 * ## Recommendation 14708 * 14709 * While omitting the language flag is perfectly fine to signal that the code is 14710 * plain text, it *could* point to a mistake. 14711 * It’s recommended to instead use a certain flag for plain text (such as `txt`) 14712 * and to turn this rule on. 14713 * 14714 * @module fenced-code-flag 14715 * @summary 14716 * remark-lint rule to check that language flags of fenced code are used. 14717 * @author Titus Wormer 14718 * @copyright 2015 Titus Wormer 14719 * @license MIT 14720 * 14721 * @example 14722 * {"name": "ok.md"} 14723 * 14724 * ```alpha 14725 * bravo() 14726 * ``` 14727 * 14728 * @example 14729 * {"name": "not-ok.md", "label": "input"} 14730 * 14731 * ``` 14732 * alpha() 14733 * ``` 14734 * 14735 * @example 14736 * {"name": "not-ok.md", "label": "output"} 14737 * 14738 * 1:1-3:4: Missing code language flag 14739 * 14740 * @example 14741 * {"name": "ok.md", "config": {"allowEmpty": true}} 14742 * 14743 * ``` 14744 * alpha() 14745 * ``` 14746 * 14747 * @example 14748 * {"name": "not-ok.md", "config": {"allowEmpty": false}, "label": "input"} 14749 * 14750 * ``` 14751 * alpha() 14752 * ``` 14753 * 14754 * @example 14755 * {"name": "not-ok.md", "config": {"allowEmpty": false}, "label": "output"} 14756 * 14757 * 1:1-3:4: Missing code language flag 14758 * 14759 * @example 14760 * {"name": "ok.md", "config": ["alpha"]} 14761 * 14762 * ```alpha 14763 * bravo() 14764 * ``` 14765 * 14766 * @example 14767 * {"name": "ok.md", "config": {"flags":["alpha"]}} 14768 * 14769 * ```alpha 14770 * bravo() 14771 * ``` 14772 * 14773 * @example 14774 * {"name": "not-ok.md", "config": ["charlie"], "label": "input"} 14775 * 14776 * ```alpha 14777 * bravo() 14778 * ``` 14779 * 14780 * @example 14781 * {"name": "not-ok.md", "config": ["charlie"], "label": "output"} 14782 * 14783 * 1:1-3:4: Incorrect code language flag 14784 */ 14785const fence = /^ {0,3}([~`])\1{2,}/; 14786const remarkLintFencedCodeFlag = lintRule( 14787 { 14788 origin: 'remark-lint:fenced-code-flag', 14789 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-fenced-code-flag#readme' 14790 }, 14791 (tree, file, option) => { 14792 const value = String(file); 14793 let allowEmpty = false; 14794 let allowed = []; 14795 if (typeof option === 'object') { 14796 if (Array.isArray(option)) { 14797 allowed = option; 14798 } else { 14799 allowEmpty = Boolean(option.allowEmpty); 14800 if (option.flags) { 14801 allowed = option.flags; 14802 } 14803 } 14804 } 14805 visit$1(tree, 'code', (node) => { 14806 if (!generated(node)) { 14807 if (node.lang) { 14808 if (allowed.length > 0 && !allowed.includes(node.lang)) { 14809 file.message('Incorrect code language flag', node); 14810 } 14811 } else { 14812 const slice = value.slice( 14813 pointStart(node).offset, 14814 pointEnd(node).offset 14815 ); 14816 if (!allowEmpty && fence.test(slice)) { 14817 file.message('Missing code language flag', node); 14818 } 14819 } 14820 } 14821 }); 14822 } 14823); 14824var remarkLintFencedCodeFlag$1 = remarkLintFencedCodeFlag; 14825 14826/** 14827 * ## When should I use this? 14828 * 14829 * You can use this package to check that fenced code markers are consistent. 14830 * 14831 * ## API 14832 * 14833 * The following options (default: `'consistent'`) are accepted: 14834 * 14835 * * ``'`'`` 14836 * — prefer grave accents 14837 * * `'~'` 14838 * — prefer tildes 14839 * * `'consistent'` 14840 * — detect the first used style and warn when further fenced code differs 14841 * 14842 * ## Recommendation 14843 * 14844 * Tildes are extremely uncommon. 14845 * Due to this, it’s recommended to configure this rule with ``'`'``. 14846 * 14847 * ## Fix 14848 * 14849 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 14850 * formats fenced code with grave accents by default. 14851 * Pass 14852 * [`fence: '~'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsfence) 14853 * to always use tildes. 14854 * 14855 * @module fenced-code-marker 14856 * @summary 14857 * remark-lint rule to warn when fenced code markers are inconsistent. 14858 * @author Titus Wormer 14859 * @copyright 2015 Titus Wormer 14860 * @license MIT 14861 * @example 14862 * {"name": "ok.md"} 14863 * 14864 * Indented code blocks are not affected by this rule: 14865 * 14866 * bravo() 14867 * 14868 * @example 14869 * {"name": "ok.md", "config": "`"} 14870 * 14871 * ```alpha 14872 * bravo() 14873 * ``` 14874 * 14875 * ``` 14876 * charlie() 14877 * ``` 14878 * 14879 * @example 14880 * {"name": "ok.md", "config": "~"} 14881 * 14882 * ~~~alpha 14883 * bravo() 14884 * ~~~ 14885 * 14886 * ~~~ 14887 * charlie() 14888 * ~~~ 14889 * 14890 * @example 14891 * {"name": "not-ok-consistent-tick.md", "label": "input"} 14892 * 14893 * ```alpha 14894 * bravo() 14895 * ``` 14896 * 14897 * ~~~ 14898 * charlie() 14899 * ~~~ 14900 * 14901 * @example 14902 * {"name": "not-ok-consistent-tick.md", "label": "output"} 14903 * 14904 * 5:1-7:4: Fenced code should use `` ` `` as a marker 14905 * 14906 * @example 14907 * {"name": "not-ok-consistent-tilde.md", "label": "input"} 14908 * 14909 * ~~~alpha 14910 * bravo() 14911 * ~~~ 14912 * 14913 * ``` 14914 * charlie() 14915 * ``` 14916 * 14917 * @example 14918 * {"name": "not-ok-consistent-tilde.md", "label": "output"} 14919 * 14920 * 5:1-7:4: Fenced code should use `~` as a marker 14921 * 14922 * @example 14923 * {"name": "not-ok-incorrect.md", "config": "", "label": "output", "positionless": true} 14924 * 14925 * 1:1: Incorrect fenced code marker ``: use either `'consistent'`, `` '`' ``, or `'~'` 14926 */ 14927const remarkLintFencedCodeMarker = lintRule( 14928 { 14929 origin: 'remark-lint:fenced-code-marker', 14930 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-fenced-code-marker#readme' 14931 }, 14932 (tree, file, option = 'consistent') => { 14933 const contents = String(file); 14934 if (option !== 'consistent' && option !== '~' && option !== '`') { 14935 file.fail( 14936 'Incorrect fenced code marker `' + 14937 option + 14938 "`: use either `'consistent'`, `` '`' ``, or `'~'`" 14939 ); 14940 } 14941 visit$1(tree, 'code', (node) => { 14942 const start = pointStart(node).offset; 14943 if (typeof start === 'number') { 14944 const marker = contents 14945 .slice(start, start + 4) 14946 .replace(/^\s+/, '') 14947 .charAt(0); 14948 if (marker === '~' || marker === '`') { 14949 if (option === 'consistent') { 14950 option = marker; 14951 } else if (marker !== option) { 14952 file.message( 14953 'Fenced code should use `' + 14954 (option === '~' ? option : '` ` `') + 14955 '` as a marker', 14956 node 14957 ); 14958 } 14959 } 14960 } 14961 }); 14962 } 14963); 14964var remarkLintFencedCodeMarker$1 = remarkLintFencedCodeMarker; 14965 14966/** 14967 * ## When should I use this? 14968 * 14969 * You can use this package to check that file extensions are `md`. 14970 * 14971 * ## API 14972 * 14973 * The following options (default: `'md'`) are accepted: 14974 * 14975 * * `string` (example `'markdown'`) 14976 * — preferred file extension (no dot) 14977 * 14978 * > **Note**: does not warn when files have no file extensions (such as 14979 * > `AUTHORS` or `LICENSE`). 14980 * 14981 * ## Recommendation 14982 * 14983 * Use `md` as it’s the most common. 14984 * Also use `md` when your markdown contains common syntax extensions (such as 14985 * GFM, frontmatter, or math). 14986 * Do not use `md` for MDX: use `mdx` instead. 14987 * 14988 * @module file-extension 14989 * @summary 14990 * remark-lint rule to check the file extension. 14991 * @author Titus Wormer 14992 * @copyright 2015 Titus Wormer 14993 * @license MIT 14994 * @example 14995 * {"name": "readme.md"} 14996 * 14997 * @example 14998 * {"name": "readme"} 14999 * 15000 * @example 15001 * {"name": "readme.mkd", "label": "output", "positionless": true} 15002 * 15003 * 1:1: Incorrect extension: use `md` 15004 * 15005 * @example 15006 * {"name": "readme.mkd", "config": "mkd"} 15007 */ 15008const remarkLintFileExtension = lintRule( 15009 { 15010 origin: 'remark-lint:file-extension', 15011 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-file-extension#readme' 15012 }, 15013 (_, file, option = 'md') => { 15014 const ext = file.extname; 15015 if (ext && ext.slice(1) !== option) { 15016 file.message('Incorrect extension: use `' + option + '`'); 15017 } 15018 } 15019); 15020var remarkLintFileExtension$1 = remarkLintFileExtension; 15021 15022/** 15023 * ## When should I use this? 15024 * 15025 * You can use this package to check that definitions are placed at the end of 15026 * the document. 15027 * 15028 * ## API 15029 * 15030 * There are no options. 15031 * 15032 * ## Recommendation 15033 * 15034 * There are different strategies for placing definitions. 15035 * The simplest is perhaps to place them all at the bottem of documents. 15036 * If you prefer that, turn on this rule. 15037 * 15038 * @module final-definition 15039 * @summary 15040 * remark-lint rule to warn when definitions are used *in* the document 15041 * instead of at the end. 15042 * @author Titus Wormer 15043 * @copyright 2015 Titus Wormer 15044 * @license MIT 15045 * @example 15046 * {"name": "ok.md"} 15047 * 15048 * Paragraph. 15049 * 15050 * [example]: http://example.com "Example Domain" 15051 * 15052 * @example 15053 * {"name": "not-ok.md", "label": "input"} 15054 * 15055 * Paragraph. 15056 * 15057 * [example]: http://example.com "Example Domain" 15058 * 15059 * Another paragraph. 15060 * 15061 * @example 15062 * {"name": "not-ok.md", "label": "output"} 15063 * 15064 * 3:1-3:47: Move definitions to the end of the file (after the node at line `5`) 15065 * 15066 * @example 15067 * {"name": "ok-comments.md"} 15068 * 15069 * Paragraph. 15070 * 15071 * [example-1]: http://example.com/one/ 15072 * 15073 * <!-- Comments are fine between and after definitions --> 15074 * 15075 * [example-2]: http://example.com/two/ 15076 */ 15077const remarkLintFinalDefinition = lintRule( 15078 { 15079 origin: 'remark-lint:final-definition', 15080 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-final-definition#readme' 15081 }, 15082 (tree, file) => { 15083 let last = 0; 15084 visit$1( 15085 tree, 15086 (node) => { 15087 if ( 15088 node.type === 'root' || 15089 generated(node) || 15090 (node.type === 'html' && /^\s*<!--/.test(node.value)) 15091 ) { 15092 return 15093 } 15094 const line = pointStart(node).line; 15095 if (node.type === 'definition') { 15096 if (last && last > line) { 15097 file.message( 15098 'Move definitions to the end of the file (after the node at line `' + 15099 last + 15100 '`)', 15101 node 15102 ); 15103 } 15104 } else if (last === 0) { 15105 last = line; 15106 } 15107 }, 15108 true 15109 ); 15110 } 15111); 15112var remarkLintFinalDefinition$1 = remarkLintFinalDefinition; 15113 15114/** 15115 * ## When should I use this? 15116 * 15117 * You can use this package to check the heading rank of the first heading. 15118 * 15119 * ## API 15120 * 15121 * The following options (default: `1`) are accepted: 15122 * 15123 * * `number` (example `1`) 15124 * — expected rank of first heading 15125 * 15126 * ## Recommendation 15127 * 15128 * In most cases you’d want to first heading in a markdown document to start at 15129 * rank 1. 15130 * In some cases a different rank makes more sense, such as when building a blog 15131 * and generating the primary heading from frontmatter metadata, in which case 15132 * a value of `2` can be defined here. 15133 * 15134 * @module first-heading-level 15135 * @summary 15136 * remark-lint rule to warn when the first heading has an unexpected rank. 15137 * @author Titus Wormer 15138 * @copyright 2015 Titus Wormer 15139 * @license MIT 15140 * @example 15141 * {"name": "ok.md"} 15142 * 15143 * # The default is to expect a level one heading 15144 * 15145 * @example 15146 * {"name": "ok-html.md"} 15147 * 15148 * <h1>An HTML heading is also seen by this rule.</h1> 15149 * 15150 * @example 15151 * {"name": "ok-delayed.md"} 15152 * 15153 * You can use markdown content before the heading. 15154 * 15155 * <div>Or non-heading HTML</div> 15156 * 15157 * <h1>So the first heading, be it HTML or markdown, is checked</h1> 15158 * 15159 * @example 15160 * {"name": "not-ok.md", "label": "input"} 15161 * 15162 * ## Bravo 15163 * 15164 * Paragraph. 15165 * 15166 * @example 15167 * {"name": "not-ok.md", "label": "output"} 15168 * 15169 * 1:1-1:9: First heading level should be `1` 15170 * 15171 * @example 15172 * {"name": "not-ok-html.md", "label": "input"} 15173 * 15174 * <h2>Charlie</h2> 15175 * 15176 * Paragraph. 15177 * 15178 * @example 15179 * {"name": "not-ok-html.md", "label": "output"} 15180 * 15181 * 1:1-1:17: First heading level should be `1` 15182 * 15183 * @example 15184 * {"name": "ok.md", "config": 2} 15185 * 15186 * ## Delta 15187 * 15188 * Paragraph. 15189 * 15190 * @example 15191 * {"name": "ok-html.md", "config": 2} 15192 * 15193 * <h2>Echo</h2> 15194 * 15195 * Paragraph. 15196 * 15197 * @example 15198 * {"name": "not-ok.md", "config": 2, "label": "input"} 15199 * 15200 * # Foxtrot 15201 * 15202 * Paragraph. 15203 * 15204 * @example 15205 * {"name": "not-ok.md", "config": 2, "label": "output"} 15206 * 15207 * 1:1-1:10: First heading level should be `2` 15208 * 15209 * @example 15210 * {"name": "not-ok-html.md", "config": 2, "label": "input"} 15211 * 15212 * <h1>Golf</h1> 15213 * 15214 * Paragraph. 15215 * 15216 * @example 15217 * {"name": "not-ok-html.md", "config": 2, "label": "output"} 15218 * 15219 * 1:1-1:14: First heading level should be `2` 15220 */ 15221const re$2 = /<h([1-6])/; 15222const remarkLintFirstHeadingLevel = lintRule( 15223 { 15224 origin: 'remark-lint:first-heading-level', 15225 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-first-heading-level#readme' 15226 }, 15227 (tree, file, option = 1) => { 15228 visit$1(tree, (node) => { 15229 if (!generated(node)) { 15230 let rank; 15231 if (node.type === 'heading') { 15232 rank = node.depth; 15233 } else if (node.type === 'html') { 15234 rank = infer(node); 15235 } 15236 if (rank !== undefined) { 15237 if (rank !== option) { 15238 file.message('First heading level should be `' + option + '`', node); 15239 } 15240 return EXIT$1 15241 } 15242 } 15243 }); 15244 } 15245); 15246var remarkLintFirstHeadingLevel$1 = remarkLintFirstHeadingLevel; 15247function infer(node) { 15248 const results = node.value.match(re$2); 15249 return results ? Number(results[1]) : undefined 15250} 15251 15252/** 15253 * ## When should I use this? 15254 * 15255 * You can use this package to check that headings are consistent. 15256 * 15257 * ## API 15258 * 15259 * The following options (default: `'consistent'`) are accepted: 15260 * 15261 * * `'atx'` 15262 * — prefer ATX headings: 15263 * ```markdown 15264 * ## Hello 15265 * ``` 15266 * * `'atx-closed'` 15267 * — prefer ATX headings with a closing sequence: 15268 * ```markdown 15269 * ## Hello ## 15270 * ``` 15271 * * `'setext'` 15272 * — prefer setext headings: 15273 * ```markdown 15274 * Hello 15275 * ----- 15276 * ``` 15277 * * `'consistent'` 15278 * — detect the first used style and warn when further headings differ 15279 * 15280 * ## Recommendation 15281 * 15282 * Setext headings are limited in that they can only construct headings with a 15283 * rank of one and two. 15284 * On the other hand, they do allow multiple lines of content whereas ATX only 15285 * allows one line. 15286 * The number of used markers in their underline does not matter, leading to 15287 * either: 15288 * 15289 * * 1 marker (`Hello\n-`), which is the bare minimum, and for rank 2 headings 15290 * looks suspiciously like an empty list item 15291 * * using as many markers as the content (`Hello\n-----`), which is hard to 15292 * maintain 15293 * * an arbitrary number (`Hello\n---`), which for rank 2 headings looks 15294 * suspiciously like a thematic break 15295 * 15296 * Setext headings are also rather uncommon. 15297 * Using a sequence of hashes at the end of ATX headings is even more uncommon. 15298 * Due to this, it’s recommended to prefer ATX headings. 15299 * 15300 * ## Fix 15301 * 15302 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 15303 * formats headings as ATX by default. 15304 * The other styles can be configured with 15305 * [`setext: true`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionssetext) 15306 * or 15307 * [`closeAtx: true`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionscloseatx). 15308 * 15309 * @module heading-style 15310 * @summary 15311 * remark-lint rule to warn when headings violate a given style. 15312 * @author Titus Wormer 15313 * @copyright 2015 Titus Wormer 15314 * @license MIT 15315 * @example 15316 * {"name": "ok.md", "config": "atx"} 15317 * 15318 * # Alpha 15319 * 15320 * ## Bravo 15321 * 15322 * ### Charlie 15323 * 15324 * @example 15325 * {"name": "ok.md", "config": "atx-closed"} 15326 * 15327 * # Delta ## 15328 * 15329 * ## Echo ## 15330 * 15331 * ### Foxtrot ### 15332 * 15333 * @example 15334 * {"name": "ok.md", "config": "setext"} 15335 * 15336 * Golf 15337 * ==== 15338 * 15339 * Hotel 15340 * ----- 15341 * 15342 * ### India 15343 * 15344 * @example 15345 * {"name": "not-ok.md", "label": "input"} 15346 * 15347 * Juliett 15348 * ======= 15349 * 15350 * ## Kilo 15351 * 15352 * ### Lima ### 15353 * 15354 * @example 15355 * {"name": "not-ok.md", "label": "output"} 15356 * 15357 * 4:1-4:8: Headings should use setext 15358 * 6:1-6:13: Headings should use setext 15359 * 15360 * @example 15361 * {"name": "not-ok.md", "config": "", "label": "output", "positionless": true} 15362 * 15363 * 1:1: Incorrect heading style type ``: use either `'consistent'`, `'atx'`, `'atx-closed'`, or `'setext'` 15364 */ 15365const remarkLintHeadingStyle = lintRule( 15366 { 15367 origin: 'remark-lint:heading-style', 15368 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-heading-style#readme' 15369 }, 15370 (tree, file, option = 'consistent') => { 15371 if ( 15372 option !== 'consistent' && 15373 option !== 'atx' && 15374 option !== 'atx-closed' && 15375 option !== 'setext' 15376 ) { 15377 file.fail( 15378 'Incorrect heading style type `' + 15379 option + 15380 "`: use either `'consistent'`, `'atx'`, `'atx-closed'`, or `'setext'`" 15381 ); 15382 } 15383 visit$1(tree, 'heading', (node) => { 15384 if (!generated(node)) { 15385 if (option === 'consistent') { 15386 option = headingStyle(node) || 'consistent'; 15387 } else if (headingStyle(node, option) !== option) { 15388 file.message('Headings should use ' + option, node); 15389 } 15390 } 15391 }); 15392 } 15393); 15394var remarkLintHeadingStyle$1 = remarkLintHeadingStyle; 15395 15396/** 15397 * ## When should I use this? 15398 * 15399 * You can use this package to check that lines do not exceed a certain size. 15400 * 15401 * ## API 15402 * 15403 * The following options (default: `80`) are accepted: 15404 * 15405 * * `number` (example: `72`) 15406 * — max number of characters to accept in heading text 15407 * 15408 * Ignores nodes that cannot be wrapped, such as headings, tables, code, 15409 * definitions, HTML, and JSX. 15410 * Ignores images, links, and code (inline) if they start before the wrap, end 15411 * after the wrap, and there’s no white space after them. 15412 * 15413 * ## Recommendation 15414 * 15415 * Whether to wrap prose or not is a stylistic choice. 15416 * 15417 * @module maximum-line-length 15418 * @summary 15419 * remark-lint rule to warn when lines are too long. 15420 * @author Titus Wormer 15421 * @copyright 2015 Titus Wormer 15422 * @license MIT 15423 * @example 15424 * {"name": "ok.md", "positionless": true, "gfm": true} 15425 * 15426 * This line is simply not toooooooooooooooooooooooooooooooooooooooooooo 15427 * long. 15428 * 15429 * This is also fine: <http://this-long-url-with-a-long-domain.co.uk/a-long-path?query=variables> 15430 * 15431 * <http://this-link-is-fine.com> 15432 * 15433 * `alphaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJuliettKiloLimaMikeNovemberOscarPapaQuebec.romeo()` 15434 * 15435 * [foo](http://this-long-url-with-a-long-domain-is-ok.co.uk/a-long-path?query=variables) 15436 * 15437 * <http://this-long-url-with-a-long-domain-is-ok.co.uk/a-long-path?query=variables> 15438 * 15439 * ![foo](http://this-long-url-with-a-long-domain-is-ok.co.uk/a-long-path?query=variables) 15440 * 15441 * | An | exception | is | line | length | in | long | tables | because | those | can’t | just | 15442 * | -- | --------- | -- | ---- | ------ | -- | ---- | ------ | ------- | ----- | ----- | ---- | 15443 * | be | helped | | | | | | | | | | . | 15444 * 15445 * <a><b><i><p><q><s><u>alpha bravo charlie delta echo foxtrot golf</u></s></q></p></i></b></a> 15446 * 15447 * The following is also fine (note the `.`), because there is no whitespace. 15448 * 15449 * <http://this-long-url-with-a-long-domain-is-ok.co.uk/a-long-path?query=variables>. 15450 * 15451 * In addition, definitions are also fine: 15452 * 15453 * [foo]: <http://this-long-url-with-a-long-domain-is-ok.co.uk/a-long-path?query=variables> 15454 * 15455 * @example 15456 * {"name": "not-ok.md", "config": 80, "label": "input", "positionless": true} 15457 * 15458 * This line is simply not tooooooooooooooooooooooooooooooooooooooooooooooooooooooo 15459 * long. 15460 * 15461 * Just like thiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis one. 15462 * 15463 * And this one is also very wrong: because the link starts aaaaaaafter the column: <http://line.com> 15464 * 15465 * <http://this-long-url-with-a-long-domain-is-not-ok.co.uk/a-long-path?query=variables> and such. 15466 * 15467 * And this one is also very wrong: because the code starts aaaaaaafter the column: `alpha.bravo()` 15468 * 15469 * `alphaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJuliettKiloLimaMikeNovemberOscar.papa()` and such. 15470 * 15471 * @example 15472 * {"name": "not-ok.md", "config": 80, "label": "output", "positionless": true} 15473 * 15474 * 4:86: Line must be at most 80 characters 15475 * 6:99: Line must be at most 80 characters 15476 * 8:96: Line must be at most 80 characters 15477 * 10:97: Line must be at most 80 characters 15478 * 12:99: Line must be at most 80 characters 15479 * 15480 * @example 15481 * {"name": "ok-mixed-line-endings.md", "config": 10, "positionless": true} 15482 * 15483 * 0123456789␍␊ 15484 * 0123456789␊ 15485 * 01234␍␊ 15486 * 01234␊ 15487 * 15488 * @example 15489 * {"name": "not-ok-mixed-line-endings.md", "config": 10, "label": "input", "positionless": true} 15490 * 15491 * 012345678901␍␊ 15492 * 012345678901␊ 15493 * 01234567890␍␊ 15494 * 01234567890␊ 15495 * 15496 * @example 15497 * {"name": "not-ok-mixed-line-endings.md", "config": 10, "label": "output", "positionless": true} 15498 * 15499 * 1:13: Line must be at most 10 characters 15500 * 2:13: Line must be at most 10 characters 15501 * 3:12: Line must be at most 10 characters 15502 * 4:12: Line must be at most 10 characters 15503 */ 15504const remarkLintMaximumLineLength = lintRule( 15505 { 15506 origin: 'remark-lint:maximum-line-length', 15507 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-maximum-line-length#readme' 15508 }, 15509 (tree, file, option = 80) => { 15510 const value = String(file); 15511 const lines = value.split(/\r?\n/); 15512 visit$1(tree, (node) => { 15513 if ( 15514 (node.type === 'heading' || 15515 node.type === 'table' || 15516 node.type === 'code' || 15517 node.type === 'definition' || 15518 node.type === 'html' || 15519 node.type === 'jsx' || 15520 node.type === 'mdxFlowExpression' || 15521 node.type === 'mdxJsxFlowElement' || 15522 node.type === 'mdxJsxTextElement' || 15523 node.type === 'mdxTextExpression' || 15524 node.type === 'mdxjsEsm' || 15525 node.type === 'yaml' || 15526 node.type === 'toml') && 15527 !generated(node) 15528 ) { 15529 allowList(pointStart(node).line - 1, pointEnd(node).line); 15530 } 15531 }); 15532 visit$1(tree, (node, pos, parent) => { 15533 if ( 15534 (node.type === 'link' || 15535 node.type === 'image' || 15536 node.type === 'inlineCode') && 15537 !generated(node) && 15538 parent && 15539 typeof pos === 'number' 15540 ) { 15541 const initial = pointStart(node); 15542 const final = pointEnd(node); 15543 if (initial.column > option || final.column < option) { 15544 return 15545 } 15546 const next = parent.children[pos + 1]; 15547 if ( 15548 next && 15549 pointStart(next).line === initial.line && 15550 (!('value' in next) || /^(.+?[ \t].+?)/.test(next.value)) 15551 ) { 15552 return 15553 } 15554 allowList(initial.line - 1, final.line); 15555 } 15556 }); 15557 let index = -1; 15558 while (++index < lines.length) { 15559 const lineLength = lines[index].length; 15560 if (lineLength > option) { 15561 file.message('Line must be at most ' + option + ' characters', { 15562 line: index + 1, 15563 column: lineLength + 1 15564 }); 15565 } 15566 } 15567 function allowList(initial, final) { 15568 while (initial < final) { 15569 lines[initial++] = ''; 15570 } 15571 } 15572 } 15573); 15574var remarkLintMaximumLineLength$1 = remarkLintMaximumLineLength; 15575 15576/** 15577 * ## When should I use this? 15578 * 15579 * You can use this package to check that no more blank lines than needed 15580 * are used between blocks. 15581 * 15582 * ## API 15583 * 15584 * There are no options. 15585 * 15586 * ## Recommendation 15587 * 15588 * More than one blank line has no effect between blocks. 15589 * 15590 * ## Fix 15591 * 15592 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 15593 * adds exactly one blank line between any block. 15594 * 15595 * @module no-consecutive-blank-lines 15596 * @summary 15597 * remark-lint rule to warn when more blank lines that needed are used 15598 * between blocks. 15599 * @author Titus Wormer 15600 * @copyright 2015 Titus Wormer 15601 * @license MIT 15602 * @example 15603 * {"name": "ok.md"} 15604 * 15605 * Foo… 15606 * ␊ 15607 * …Bar. 15608 * 15609 * @example 15610 * {"name": "empty-document.md"} 15611 * 15612 * @example 15613 * {"name": "not-ok.md", "label": "input"} 15614 * 15615 * Foo… 15616 * ␊ 15617 * ␊ 15618 * …Bar 15619 * ␊ 15620 * ␊ 15621 * 15622 * @example 15623 * {"name": "not-ok.md", "label": "output"} 15624 * 15625 * 4:1: Remove 1 line before node 15626 * 4:5: Remove 2 lines after node 15627 */ 15628const unknownContainerSize = new Set(['mdxJsxFlowElement', 'mdxJsxTextElement']); 15629const remarkLintNoConsecutiveBlankLines = lintRule( 15630 { 15631 origin: 'remark-lint:no-consecutive-blank-lines', 15632 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-consecutive-blank-lines#readme' 15633 }, 15634 (tree, file) => { 15635 visit$1(tree, (node) => { 15636 if (!generated(node) && 'children' in node) { 15637 const head = node.children[0]; 15638 if (head && !generated(head)) { 15639 if (!unknownContainerSize.has(node.type)) { 15640 compare(pointStart(node), pointStart(head), 0); 15641 } 15642 let index = -1; 15643 while (++index < node.children.length) { 15644 const previous = node.children[index - 1]; 15645 const child = node.children[index]; 15646 if (previous && !generated(previous) && !generated(child)) { 15647 compare(pointEnd(previous), pointStart(child), 2); 15648 } 15649 } 15650 const tail = node.children[node.children.length - 1]; 15651 if ( 15652 tail !== head && 15653 !generated(tail) && 15654 !unknownContainerSize.has(node.type) 15655 ) { 15656 compare(pointEnd(node), pointEnd(tail), 1); 15657 } 15658 } 15659 } 15660 }); 15661 function compare(start, end, max) { 15662 const diff = end.line - start.line; 15663 const lines = Math.abs(diff) - max; 15664 if (lines > 0) { 15665 file.message( 15666 'Remove ' + 15667 lines + 15668 ' ' + 15669 plural('line', Math.abs(lines)) + 15670 ' ' + 15671 (diff > 0 ? 'before' : 'after') + 15672 ' node', 15673 end 15674 ); 15675 } 15676 } 15677 } 15678); 15679var remarkLintNoConsecutiveBlankLines$1 = remarkLintNoConsecutiveBlankLines; 15680 15681/** 15682 * ## When should I use this? 15683 * 15684 * You can use this package to check that file names do not start with 15685 * articles (`a`, `the`, etc). 15686 * 15687 * ## API 15688 * 15689 * There are no options. 15690 * 15691 * @module no-file-name-articles 15692 * @summary 15693 * remark-lint rule to warn when file names start with articles. 15694 * @author Titus Wormer 15695 * @copyright 2015 Titus Wormer 15696 * @license MIT 15697 * @example 15698 * {"name": "title.md"} 15699 * 15700 * @example 15701 * {"name": "a-title.md", "label": "output", "positionless": true} 15702 * 15703 * 1:1: Do not start file names with `a` 15704 * 15705 * @example 15706 * {"name": "the-title.md", "label": "output", "positionless": true} 15707 * 15708 * 1:1: Do not start file names with `the` 15709 * 15710 * @example 15711 * {"name": "teh-title.md", "label": "output", "positionless": true} 15712 * 15713 * 1:1: Do not start file names with `teh` 15714 * 15715 * @example 15716 * {"name": "an-article.md", "label": "output", "positionless": true} 15717 * 15718 * 1:1: Do not start file names with `an` 15719 */ 15720const remarkLintNoFileNameArticles = lintRule( 15721 { 15722 origin: 'remark-lint:no-file-name-articles', 15723 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-file-name-articles#readme' 15724 }, 15725 (_, file) => { 15726 const match = file.stem && file.stem.match(/^(the|teh|an?)\b/i); 15727 if (match) { 15728 file.message('Do not start file names with `' + match[0] + '`'); 15729 } 15730 } 15731); 15732var remarkLintNoFileNameArticles$1 = remarkLintNoFileNameArticles; 15733 15734/** 15735 * ## When should I use this? 15736 * 15737 * You can use this package to check that no consecutive dashes appear in 15738 * file names. 15739 * 15740 * ## API 15741 * 15742 * There are no options. 15743 * 15744 * @module no-file-name-consecutive-dashes 15745 * @summary 15746 * remark-lint rule to warn when consecutive dashes appear in file names. 15747 * @author Titus Wormer 15748 * @copyright 2015 Titus Wormer 15749 * @license MIT 15750 * @example 15751 * {"name": "plug-ins.md"} 15752 * 15753 * @example 15754 * {"name": "plug--ins.md", "label": "output", "positionless": true} 15755 * 15756 * 1:1: Do not use consecutive dashes in a file name 15757 */ 15758const remarkLintNoFileNameConsecutiveDashes = lintRule( 15759 { 15760 origin: 'remark-lint:no-file-name-consecutive-dashes', 15761 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-file-name-consecutive-dashes#readme' 15762 }, 15763 (_, file) => { 15764 if (file.stem && /-{2,}/.test(file.stem)) { 15765 file.message('Do not use consecutive dashes in a file name'); 15766 } 15767 } 15768); 15769var remarkLintNoFileNameConsecutiveDashes$1 = remarkLintNoFileNameConsecutiveDashes; 15770 15771/** 15772 * ## When should I use this? 15773 * 15774 * You can use this package to check that no initial or final dashes appear in 15775 * file names. 15776 * 15777 * ## API 15778 * 15779 * There are no options. 15780 * 15781 * @module no-file-name-outer-dashes 15782 * @summary 15783 * remark-lint rule to warn when initial or final dashes appear in file names. 15784 * @author Titus Wormer 15785 * @copyright 2015 Titus Wormer 15786 * @license MIT 15787 * @example 15788 * {"name": "readme.md"} 15789 * 15790 * @example 15791 * {"name": "-readme.md", "label": "output", "positionless": true} 15792 * 15793 * 1:1: Do not use initial or final dashes in a file name 15794 * 15795 * @example 15796 * {"name": "readme-.md", "label": "output", "positionless": true} 15797 * 15798 * 1:1: Do not use initial or final dashes in a file name 15799 */ 15800const remarkLintNofileNameOuterDashes = lintRule( 15801 { 15802 origin: 'remark-lint:no-file-name-outer-dashes', 15803 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-file-name-outer-dashes#readme' 15804 }, 15805 (_, file) => { 15806 if (file.stem && /^-|-$/.test(file.stem)) { 15807 file.message('Do not use initial or final dashes in a file name'); 15808 } 15809 } 15810); 15811var remarkLintNofileNameOuterDashes$1 = remarkLintNofileNameOuterDashes; 15812 15813/** 15814 * ## When should I use this? 15815 * 15816 * You can use this package to check that headings are not indented. 15817 * 15818 * ## API 15819 * 15820 * There are no options. 15821 * 15822 * ## Recommendation 15823 * 15824 * There is no specific handling of indented headings (or anything else) in 15825 * markdown. 15826 * While it is possible to use an indent to headings on their text: 15827 * 15828 * ```markdown 15829 * # One 15830 * ## Two 15831 * ### Three 15832 * #### Four 15833 * ``` 15834 * 15835 * …such style is uncommon, a bit hard to maintain, and it’s impossible to add a 15836 * heading with a rank of 5 as it would form indented code instead. 15837 * Hence, it’s recommended to not indent headings and to turn this rule on. 15838 * 15839 * ## Fix 15840 * 15841 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 15842 * formats all headings without indent. 15843 * 15844 * @module no-heading-indent 15845 * @summary 15846 * remark-lint rule to warn when headings are indented. 15847 * @author Titus Wormer 15848 * @copyright 2015 Titus Wormer 15849 * @license MIT 15850 * @example 15851 * {"name": "ok.md"} 15852 * 15853 * #·Hello world 15854 * 15855 * Foo 15856 * ----- 15857 * 15858 * #·Hello world·# 15859 * 15860 * Bar 15861 * ===== 15862 * 15863 * @example 15864 * {"name": "not-ok.md", "label": "input"} 15865 * 15866 * ···# Hello world 15867 * 15868 * ·Foo 15869 * ----- 15870 * 15871 * ·# Hello world # 15872 * 15873 * ···Bar 15874 * ===== 15875 * 15876 * @example 15877 * {"name": "not-ok.md", "label": "output"} 15878 * 15879 * 1:4: Remove 3 spaces before this heading 15880 * 3:2: Remove 1 space before this heading 15881 * 6:2: Remove 1 space before this heading 15882 * 8:4: Remove 3 spaces before this heading 15883 */ 15884const remarkLintNoHeadingIndent = lintRule( 15885 { 15886 origin: 'remark-lint:no-heading-indent', 15887 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-heading-indent#readme' 15888 }, 15889 (tree, file) => { 15890 visit$1(tree, 'heading', (node, _, parent) => { 15891 if (generated(node) || (parent && parent.type !== 'root')) { 15892 return 15893 } 15894 const diff = pointStart(node).column - 1; 15895 if (diff) { 15896 file.message( 15897 'Remove ' + 15898 diff + 15899 ' ' + 15900 plural('space', diff) + 15901 ' before this heading', 15902 pointStart(node) 15903 ); 15904 } 15905 }); 15906 } 15907); 15908var remarkLintNoHeadingIndent$1 = remarkLintNoHeadingIndent; 15909 15910/** 15911 * ## When should I use this? 15912 * 15913 * You can use this package to check that no more than one top level heading 15914 * is used. 15915 * 15916 * ## API 15917 * 15918 * The following options (default: `1`) are accepted: 15919 * 15920 * * `number` (example: `1`) 15921 * — assumed top level heading rank 15922 * 15923 * ## Recommendation 15924 * 15925 * Documents should almost always have one main heading, which is typically a 15926 * heading with a rank of `1`. 15927 * 15928 * @module no-multiple-toplevel-headings 15929 * @summary 15930 * remark-lint rule to warn when more than one top level heading is used. 15931 * @author Titus Wormer 15932 * @copyright 2015 Titus Wormer 15933 * @license MIT 15934 * @example 15935 * {"name": "ok.md", "config": 1} 15936 * 15937 * # Foo 15938 * 15939 * ## Bar 15940 * 15941 * @example 15942 * {"name": "not-ok.md", "config": 1, "label": "input"} 15943 * 15944 * # Foo 15945 * 15946 * # Bar 15947 * 15948 * @example 15949 * {"name": "not-ok.md", "config": 1, "label": "output"} 15950 * 15951 * 3:1-3:6: Don’t use multiple top level headings (1:1) 15952 */ 15953const remarkLintNoMultipleToplevelHeadings = lintRule( 15954 { 15955 origin: 'remark-lint:no-multiple-toplevel-headings', 15956 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-multiple-toplevel-headings#readme' 15957 }, 15958 (tree, file, option = 1) => { 15959 let duplicate; 15960 visit$1(tree, 'heading', (node) => { 15961 if (!generated(node) && node.depth === option) { 15962 if (duplicate) { 15963 file.message( 15964 'Don’t use multiple top level headings (' + duplicate + ')', 15965 node 15966 ); 15967 } else { 15968 duplicate = stringifyPosition$1(pointStart(node)); 15969 } 15970 } 15971 }); 15972 } 15973); 15974var remarkLintNoMultipleToplevelHeadings$1 = remarkLintNoMultipleToplevelHeadings; 15975 15976/** 15977 * ## When should I use this? 15978 * 15979 * You can use this package to check that not all lines in shell code are 15980 * preceded by dollars (`$`). 15981 * 15982 * ## API 15983 * 15984 * There are no options. 15985 * 15986 * ## Recommendation 15987 * 15988 * Dollars make copy/pasting hard. 15989 * Either put both dollars in front of some lines (to indicate shell commands) 15990 * and don’t put them in front of other lines, or use fenced code to indicate 15991 * shell commands on their own, followed by another fenced code that contains 15992 * just the output. 15993 * 15994 * @module no-shell-dollars 15995 * @summary 15996 * remark-lint rule to warn every line in shell code is preceded by `$`s. 15997 * @author Titus Wormer 15998 * @copyright 2015 Titus Wormer 15999 * @license MIT 16000 * @example 16001 * {"name": "ok.md"} 16002 * 16003 * ```bash 16004 * echo a 16005 * ``` 16006 * 16007 * ```sh 16008 * echo a 16009 * echo a > file 16010 * ``` 16011 * 16012 * ```zsh 16013 * $ echo a 16014 * a 16015 * $ echo a > file 16016 * ``` 16017 * 16018 * Some empty code: 16019 * 16020 * ```command 16021 * ``` 16022 * 16023 * It’s fine to use dollars in non-shell code. 16024 * 16025 * ```js 16026 * $('div').remove() 16027 * ``` 16028 * 16029 * @example 16030 * {"name": "not-ok.md", "label": "input"} 16031 * 16032 * ```sh 16033 * $ echo a 16034 * ``` 16035 * 16036 * ```bash 16037 * $ echo a 16038 * $ echo a > file 16039 * ``` 16040 * 16041 * @example 16042 * {"name": "not-ok.md", "label": "output"} 16043 * 16044 * 1:1-3:4: Do not use dollar signs before shell commands 16045 * 5:1-8:4: Do not use dollar signs before shell commands 16046 */ 16047const flags = new Set([ 16048 'sh', 16049 'bash', 16050 'bats', 16051 'cgi', 16052 'command', 16053 'fcgi', 16054 'ksh', 16055 'tmux', 16056 'tool', 16057 'zsh' 16058]); 16059const remarkLintNoShellDollars = lintRule( 16060 { 16061 origin: 'remark-lint:no-shell-dollars', 16062 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-shell-dollars#readme' 16063 }, 16064 (tree, file) => { 16065 visit$1(tree, 'code', (node) => { 16066 if (!generated(node) && node.lang && flags.has(node.lang)) { 16067 const lines = node.value 16068 .split('\n') 16069 .filter((line) => line.trim().length > 0); 16070 let index = -1; 16071 if (lines.length === 0) { 16072 return 16073 } 16074 while (++index < lines.length) { 16075 const line = lines[index]; 16076 if (line.trim() && !/^\s*\$\s*/.test(line)) { 16077 return 16078 } 16079 } 16080 file.message('Do not use dollar signs before shell commands', node); 16081 } 16082 }); 16083 } 16084); 16085var remarkLintNoShellDollars$1 = remarkLintNoShellDollars; 16086 16087/** 16088 * ## When should I use this? 16089 * 16090 * You can use this package to check that tables are not indented. 16091 * Tables are a GFM feature enabled with 16092 * [`remark-gfm`](https://github.com/remarkjs/remark-gfm). 16093 * 16094 * ## API 16095 * 16096 * There are no options. 16097 * 16098 * ## Recommendation 16099 * 16100 * There is no specific handling of indented tables (or anything else) in 16101 * markdown. 16102 * Hence, it’s recommended to not indent tables and to turn this rule on. 16103 * 16104 * ## Fix 16105 * 16106 * [`remark-gfm`](https://github.com/remarkjs/remark-gfm) 16107 * formats all tables without indent. 16108 * 16109 * @module no-table-indentation 16110 * @summary 16111 * remark-lint rule to warn when tables are indented. 16112 * @author Titus Wormer 16113 * @copyright 2015 Titus Wormer 16114 * @license MIT 16115 * @example 16116 * {"name": "ok.md", "gfm": true} 16117 * 16118 * Paragraph. 16119 * 16120 * | A | B | 16121 * | ----- | ----- | 16122 * | Alpha | Bravo | 16123 * 16124 * @example 16125 * {"name": "not-ok.md", "label": "input", "gfm": true} 16126 * 16127 * Paragraph. 16128 * 16129 * ···| A | B | 16130 * ···| ----- | ----- | 16131 * ···| Alpha | Bravo | 16132 * 16133 * @example 16134 * {"name": "not-ok.md", "label": "output", "gfm": true} 16135 * 16136 * 3:4: Do not indent table rows 16137 * 4:4: Do not indent table rows 16138 * 5:4: Do not indent table rows 16139 * 16140 * @example 16141 * {"name": "not-ok-blockquote.md", "label": "input", "gfm": true} 16142 * 16143 * >··| A | 16144 * >·| - | 16145 * 16146 * @example 16147 * {"name": "not-ok-blockquote.md", "label": "output", "gfm": true} 16148 * 16149 * 1:4: Do not indent table rows 16150 * 16151 * @example 16152 * {"name": "not-ok-list.md", "label": "input", "gfm": true} 16153 * 16154 * -···paragraph 16155 * 16156 * ·····| A | 16157 * ····| - | 16158 * 16159 * @example 16160 * {"name": "not-ok-list.md", "label": "output", "gfm": true} 16161 * 16162 * 3:6: Do not indent table rows 16163 */ 16164const remarkLintNoTableIndentation = lintRule( 16165 { 16166 origin: 'remark-lint:no-table-indentation', 16167 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-table-indentation#readme' 16168 }, 16169 (tree, file) => { 16170 const value = String(file); 16171 const loc = location(value); 16172 visit$1(tree, 'table', (node, _, parent) => { 16173 const end = pointEnd(node).line; 16174 let line = pointStart(node).line; 16175 let column = 0; 16176 if (parent && parent.type === 'root') { 16177 column = 1; 16178 } else if (parent && parent.type === 'blockquote') { 16179 column = pointStart(parent).column + 2; 16180 } else if (parent && parent.type === 'listItem') { 16181 column = pointStart(parent.children[0]).column; 16182 if (parent.children[0] === node) { 16183 line++; 16184 } 16185 } 16186 if (!column || !line) { 16187 return 16188 } 16189 while (line <= end) { 16190 let offset = loc.toOffset({line, column}); 16191 const lineColumn = offset; 16192 while (/[ \t]/.test(value.charAt(offset - 1))) { 16193 offset--; 16194 } 16195 if (!offset || /[\r\n>]/.test(value.charAt(offset - 1))) { 16196 offset = lineColumn; 16197 while (/[ \t]/.test(value.charAt(offset))) { 16198 offset++; 16199 } 16200 if (lineColumn !== offset) { 16201 file.message('Do not indent table rows', loc.toPoint(offset)); 16202 } 16203 } 16204 line++; 16205 } 16206 return SKIP$1 16207 }); 16208 } 16209); 16210var remarkLintNoTableIndentation$1 = remarkLintNoTableIndentation; 16211 16212/** 16213 * ## When should I use this? 16214 * 16215 * You can use this package to check that tabs are not used. 16216 * 16217 * ## API 16218 * 16219 * There are no options. 16220 * 16221 * ## Recommendation 16222 * 16223 * Regardless of the debate in other languages of whether to use tabs vs. 16224 * spaces, when it comes to markdown, tabs do not work as expected. 16225 * Largely around contains such as block quotes and lists. 16226 * Take for example block quotes: `>\ta` gives a paragraph with the text `a` 16227 * in a blockquote, so one might expect that `>\t\ta` results in indented code 16228 * with the text `a` in a block quote. 16229 * 16230 * ```markdown 16231 * >\ta 16232 * 16233 * >\t\ta 16234 * ``` 16235 * 16236 * Yields: 16237 * 16238 * ```html 16239 * <blockquote> 16240 * <p>a</p> 16241 * </blockquote> 16242 * <blockquote> 16243 * <pre><code> a 16244 * </code></pre> 16245 * </blockquote> 16246 * ``` 16247 * 16248 * Because markdown uses a hardcoded tab size of 4, the first tab could be 16249 * represented as 3 spaces (because there’s a `>` before). 16250 * One of those “spaces” is taken because block quotes allow the `>` to be 16251 * followed by one space, leaving 2 spaces. 16252 * The next tab can be represented as 4 spaces, so together we have 6 spaces. 16253 * The indented code uses 4 spaces, so there are two spaces left, which are 16254 * shown in the indented code. 16255 * 16256 * ## Fix 16257 * 16258 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 16259 * uses spaces exclusively for indentation. 16260 * 16261 * @module no-tabs 16262 * @summary 16263 * remark-lint rule to warn when tabs are used. 16264 * @author Titus Wormer 16265 * @copyright 2015 Titus Wormer 16266 * @license MIT 16267 * @example 16268 * {"name": "ok.md"} 16269 * 16270 * Foo Bar 16271 * 16272 * ····Foo 16273 * 16274 * @example 16275 * {"name": "not-ok.md", "label": "input", "positionless": true} 16276 * 16277 * »Here's one before a code block. 16278 * 16279 * Here's a tab:», and here is another:». 16280 * 16281 * And this is in `inline»code`. 16282 * 16283 * >»This is in a block quote. 16284 * 16285 * *»And… 16286 * 16287 * »1.»in a list. 16288 * 16289 * And this is a tab as the last character.» 16290 * 16291 * @example 16292 * {"name": "not-ok.md", "label": "output"} 16293 * 16294 * 1:1: Use spaces instead of tabs 16295 * 3:14: Use spaces instead of tabs 16296 * 3:37: Use spaces instead of tabs 16297 * 5:23: Use spaces instead of tabs 16298 * 7:2: Use spaces instead of tabs 16299 * 9:2: Use spaces instead of tabs 16300 * 11:1: Use spaces instead of tabs 16301 * 11:4: Use spaces instead of tabs 16302 * 13:41: Use spaces instead of tabs 16303 */ 16304const remarkLintNoTabs = lintRule( 16305 { 16306 origin: 'remark-lint:no-tabs', 16307 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-tabs#readme' 16308 }, 16309 (_, file) => { 16310 const value = String(file); 16311 const toPoint = location(file).toPoint; 16312 let index = value.indexOf('\t'); 16313 while (index !== -1) { 16314 file.message('Use spaces instead of tabs', toPoint(index)); 16315 index = value.indexOf('\t', index + 1); 16316 } 16317 } 16318); 16319var remarkLintNoTabs$1 = remarkLintNoTabs; 16320 16321var sliced$1 = function (args, slice, sliceEnd) { 16322 var ret = []; 16323 var len = args.length; 16324 if (0 === len) return ret; 16325 var start = slice < 0 16326 ? Math.max(0, slice + len) 16327 : slice || 0; 16328 if (sliceEnd !== undefined) { 16329 len = sliceEnd < 0 16330 ? sliceEnd + len 16331 : sliceEnd; 16332 } 16333 while (len-- > start) { 16334 ret[len - start] = args[len]; 16335 } 16336 return ret; 16337}; 16338getDefaultExportFromCjs(sliced$1); 16339 16340var slice = Array.prototype.slice; 16341var co_1 = co$1; 16342function co$1(fn) { 16343 var isGenFun = isGeneratorFunction(fn); 16344 return function (done) { 16345 var ctx = this; 16346 var gen = fn; 16347 if (isGenFun) { 16348 var args = slice.call(arguments), len = args.length; 16349 var hasCallback = len && 'function' == typeof args[len - 1]; 16350 done = hasCallback ? args.pop() : error; 16351 gen = fn.apply(this, args); 16352 } else { 16353 done = done || error; 16354 } 16355 next(); 16356 function exit(err, res) { 16357 setImmediate(function(){ 16358 done.call(ctx, err, res); 16359 }); 16360 } 16361 function next(err, res) { 16362 var ret; 16363 if (arguments.length > 2) res = slice.call(arguments, 1); 16364 if (err) { 16365 try { 16366 ret = gen.throw(err); 16367 } catch (e) { 16368 return exit(e); 16369 } 16370 } 16371 if (!err) { 16372 try { 16373 ret = gen.next(res); 16374 } catch (e) { 16375 return exit(e); 16376 } 16377 } 16378 if (ret.done) return exit(null, ret.value); 16379 ret.value = toThunk(ret.value, ctx); 16380 if ('function' == typeof ret.value) { 16381 var called = false; 16382 try { 16383 ret.value.call(ctx, function(){ 16384 if (called) return; 16385 called = true; 16386 next.apply(ctx, arguments); 16387 }); 16388 } catch (e) { 16389 setImmediate(function(){ 16390 if (called) return; 16391 called = true; 16392 next(e); 16393 }); 16394 } 16395 return; 16396 } 16397 next(new TypeError('You may only yield a function, promise, generator, array, or object, ' 16398 + 'but the following was passed: "' + String(ret.value) + '"')); 16399 } 16400 } 16401} 16402function toThunk(obj, ctx) { 16403 if (isGeneratorFunction(obj)) { 16404 return co$1(obj.call(ctx)); 16405 } 16406 if (isGenerator(obj)) { 16407 return co$1(obj); 16408 } 16409 if (isPromise(obj)) { 16410 return promiseToThunk(obj); 16411 } 16412 if ('function' == typeof obj) { 16413 return obj; 16414 } 16415 if (isObject$1(obj) || Array.isArray(obj)) { 16416 return objectToThunk.call(ctx, obj); 16417 } 16418 return obj; 16419} 16420function objectToThunk(obj){ 16421 var ctx = this; 16422 var isArray = Array.isArray(obj); 16423 return function(done){ 16424 var keys = Object.keys(obj); 16425 var pending = keys.length; 16426 var results = isArray 16427 ? new Array(pending) 16428 : new obj.constructor(); 16429 var finished; 16430 if (!pending) { 16431 setImmediate(function(){ 16432 done(null, results); 16433 }); 16434 return; 16435 } 16436 if (!isArray) { 16437 for (var i = 0; i < pending; i++) { 16438 results[keys[i]] = undefined; 16439 } 16440 } 16441 for (var i = 0; i < keys.length; i++) { 16442 run(obj[keys[i]], keys[i]); 16443 } 16444 function run(fn, key) { 16445 if (finished) return; 16446 try { 16447 fn = toThunk(fn, ctx); 16448 if ('function' != typeof fn) { 16449 results[key] = fn; 16450 return --pending || done(null, results); 16451 } 16452 fn.call(ctx, function(err, res){ 16453 if (finished) return; 16454 if (err) { 16455 finished = true; 16456 return done(err); 16457 } 16458 results[key] = res; 16459 --pending || done(null, results); 16460 }); 16461 } catch (err) { 16462 finished = true; 16463 done(err); 16464 } 16465 } 16466 } 16467} 16468function promiseToThunk(promise) { 16469 return function(fn){ 16470 promise.then(function(res) { 16471 fn(null, res); 16472 }, fn); 16473 } 16474} 16475function isPromise(obj) { 16476 return obj && 'function' == typeof obj.then; 16477} 16478function isGenerator(obj) { 16479 return obj && 'function' == typeof obj.next && 'function' == typeof obj.throw; 16480} 16481function isGeneratorFunction(obj) { 16482 return obj && obj.constructor && 'GeneratorFunction' == obj.constructor.name; 16483} 16484function isObject$1(val) { 16485 return val && Object == val.constructor; 16486} 16487function error(err) { 16488 if (!err) return; 16489 setImmediate(function(){ 16490 throw err; 16491 }); 16492} 16493getDefaultExportFromCjs(co_1); 16494 16495var sliced = sliced$1; 16496var noop = function(){}; 16497var co = co_1; 16498var wrapped_1 = wrapped$1; 16499function wrapped$1(fn) { 16500 function wrap() { 16501 var args = sliced(arguments); 16502 var last = args[args.length - 1]; 16503 var ctx = this; 16504 var done = typeof last == 'function' ? args.pop() : noop; 16505 if (!fn) { 16506 return done.apply(ctx, [null].concat(args)); 16507 } 16508 if (generator(fn)) { 16509 return co(fn).apply(ctx, args.concat(done)); 16510 } 16511 if (fn.length > args.length) { 16512 try { 16513 return fn.apply(ctx, args.concat(done)); 16514 } catch (e) { 16515 return done(e); 16516 } 16517 } 16518 return sync(fn, done).apply(ctx, args); 16519 } 16520 return wrap; 16521} 16522function sync(fn, done) { 16523 return function () { 16524 var ret; 16525 try { 16526 ret = fn.apply(this, arguments); 16527 } catch (err) { 16528 return done(err); 16529 } 16530 if (promise(ret)) { 16531 ret.then(function (value) { done(null, value); }, done); 16532 } else { 16533 ret instanceof Error ? done(ret) : done(null, ret); 16534 } 16535 } 16536} 16537function generator(value) { 16538 return value 16539 && value.constructor 16540 && 'GeneratorFunction' == value.constructor.name; 16541} 16542function promise(value) { 16543 return value && 'function' == typeof value.then; 16544} 16545getDefaultExportFromCjs(wrapped_1); 16546 16547var wrapped = wrapped_1; 16548var unifiedLintRule = factory; 16549function factory(id, rule) { 16550 var parts = id.split(':'); 16551 var source = parts[0]; 16552 var ruleId = parts[1]; 16553 var fn = wrapped(rule); 16554 if (!ruleId) { 16555 ruleId = source; 16556 source = null; 16557 } 16558 attacher.displayName = id; 16559 return attacher 16560 function attacher(raw) { 16561 var config = coerce(ruleId, raw); 16562 var severity = config[0]; 16563 var options = config[1]; 16564 var fatal = severity === 2; 16565 return severity ? transformer : undefined 16566 function transformer(tree, file, next) { 16567 var index = file.messages.length; 16568 fn(tree, file, options, done); 16569 function done(err) { 16570 var messages = file.messages; 16571 var message; 16572 if (err && messages.indexOf(err) === -1) { 16573 try { 16574 file.fail(err); 16575 } catch (_) {} 16576 } 16577 while (index < messages.length) { 16578 message = messages[index]; 16579 message.ruleId = ruleId; 16580 message.source = source; 16581 message.fatal = fatal; 16582 index++; 16583 } 16584 next(); 16585 } 16586 } 16587 } 16588} 16589function coerce(name, value) { 16590 var def = 1; 16591 var result; 16592 var level; 16593 if (typeof value === 'boolean') { 16594 result = [value]; 16595 } else if (value == null) { 16596 result = [def]; 16597 } else if ( 16598 typeof value === 'object' && 16599 (typeof value[0] === 'number' || 16600 typeof value[0] === 'boolean' || 16601 typeof value[0] === 'string') 16602 ) { 16603 result = value.concat(); 16604 } else { 16605 result = [1, value]; 16606 } 16607 level = result[0]; 16608 if (typeof level === 'boolean') { 16609 level = level ? 1 : 0; 16610 } else if (typeof level === 'string') { 16611 if (level === 'off') { 16612 level = 0; 16613 } else if (level === 'on' || level === 'warn') { 16614 level = 1; 16615 } else if (level === 'error') { 16616 level = 2; 16617 } else { 16618 level = 1; 16619 result = [level, result]; 16620 } 16621 } 16622 if (level < 0 || level > 2) { 16623 throw new Error( 16624 'Incorrect severity `' + 16625 level + 16626 '` for `' + 16627 name + 16628 '`, ' + 16629 'expected 0, 1, or 2' 16630 ) 16631 } 16632 result[0] = level; 16633 return result 16634} 16635getDefaultExportFromCjs(unifiedLintRule); 16636 16637var rule = unifiedLintRule; 16638var remarkLintNoTrailingSpaces = rule('remark-lint:no-trailing-spaces', noTrailingSpaces); 16639function noTrailingSpaces(ast, file) { 16640 var lines = file.toString().split(/\r?\n/); 16641 for (var i = 0; i < lines.length; i++) { 16642 var currentLine = lines[i]; 16643 var lineIndex = i + 1; 16644 if (/\s$/.test(currentLine)) { 16645 file.message('Remove trailing whitespace', { 16646 position: { 16647 start: { line: lineIndex, column: currentLine.length + 1 }, 16648 end: { line: lineIndex } 16649 } 16650 }); 16651 } 16652 } 16653} 16654var remarkLintNoTrailingSpaces$1 = getDefaultExportFromCjs(remarkLintNoTrailingSpaces); 16655 16656function* getLinksRecursively(node) { 16657 if (node.url) { 16658 yield node; 16659 } 16660 for (const child of node.children || []) { 16661 yield* getLinksRecursively(child); 16662 } 16663} 16664function validateLinks(tree, vfile) { 16665 const currentFileURL = pathToFileURL(path$1.join(vfile.cwd, vfile.path)); 16666 let previousDefinitionLabel; 16667 for (const node of getLinksRecursively(tree)) { 16668 if (node.url[0] !== "#") { 16669 const targetURL = new URL(node.url, currentFileURL); 16670 if (targetURL.protocol === "file:" && !fs.existsSync(targetURL)) { 16671 vfile.message("Broken link", node); 16672 } else if (targetURL.pathname === currentFileURL.pathname) { 16673 const expected = node.url.includes("#") 16674 ? node.url.slice(node.url.indexOf("#")) 16675 : "#"; 16676 vfile.message( 16677 `Self-reference must start with hash (expected "${expected}", got "${node.url}")`, 16678 node 16679 ); 16680 } 16681 } 16682 if (node.type === "definition") { 16683 if (previousDefinitionLabel && previousDefinitionLabel > node.label) { 16684 vfile.message( 16685 `Unordered reference ("${node.label}" should be before "${previousDefinitionLabel}")`, 16686 node 16687 ); 16688 } 16689 previousDefinitionLabel = node.label; 16690 } 16691 } 16692} 16693const remarkLintNodejsLinks = lintRule( 16694 "remark-lint:nodejs-links", 16695 validateLinks 16696); 16697 16698/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */ 16699function isNothing(subject) { 16700 return (typeof subject === 'undefined') || (subject === null); 16701} 16702function isObject(subject) { 16703 return (typeof subject === 'object') && (subject !== null); 16704} 16705function toArray(sequence) { 16706 if (Array.isArray(sequence)) return sequence; 16707 else if (isNothing(sequence)) return []; 16708 return [ sequence ]; 16709} 16710function extend(target, source) { 16711 var index, length, key, sourceKeys; 16712 if (source) { 16713 sourceKeys = Object.keys(source); 16714 for (index = 0, length = sourceKeys.length; index < length; index += 1) { 16715 key = sourceKeys[index]; 16716 target[key] = source[key]; 16717 } 16718 } 16719 return target; 16720} 16721function repeat(string, count) { 16722 var result = '', cycle; 16723 for (cycle = 0; cycle < count; cycle += 1) { 16724 result += string; 16725 } 16726 return result; 16727} 16728function isNegativeZero(number) { 16729 return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); 16730} 16731var isNothing_1 = isNothing; 16732var isObject_1 = isObject; 16733var toArray_1 = toArray; 16734var repeat_1 = repeat; 16735var isNegativeZero_1 = isNegativeZero; 16736var extend_1 = extend; 16737var common = { 16738 isNothing: isNothing_1, 16739 isObject: isObject_1, 16740 toArray: toArray_1, 16741 repeat: repeat_1, 16742 isNegativeZero: isNegativeZero_1, 16743 extend: extend_1 16744}; 16745function formatError(exception, compact) { 16746 var where = '', message = exception.reason || '(unknown reason)'; 16747 if (!exception.mark) return message; 16748 if (exception.mark.name) { 16749 where += 'in "' + exception.mark.name + '" '; 16750 } 16751 where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')'; 16752 if (!compact && exception.mark.snippet) { 16753 where += '\n\n' + exception.mark.snippet; 16754 } 16755 return message + ' ' + where; 16756} 16757function YAMLException$1(reason, mark) { 16758 Error.call(this); 16759 this.name = 'YAMLException'; 16760 this.reason = reason; 16761 this.mark = mark; 16762 this.message = formatError(this, false); 16763 if (Error.captureStackTrace) { 16764 Error.captureStackTrace(this, this.constructor); 16765 } else { 16766 this.stack = (new Error()).stack || ''; 16767 } 16768} 16769YAMLException$1.prototype = Object.create(Error.prototype); 16770YAMLException$1.prototype.constructor = YAMLException$1; 16771YAMLException$1.prototype.toString = function toString(compact) { 16772 return this.name + ': ' + formatError(this, compact); 16773}; 16774var exception = YAMLException$1; 16775function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { 16776 var head = ''; 16777 var tail = ''; 16778 var maxHalfLength = Math.floor(maxLineLength / 2) - 1; 16779 if (position - lineStart > maxHalfLength) { 16780 head = ' ... '; 16781 lineStart = position - maxHalfLength + head.length; 16782 } 16783 if (lineEnd - position > maxHalfLength) { 16784 tail = ' ...'; 16785 lineEnd = position + maxHalfLength - tail.length; 16786 } 16787 return { 16788 str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail, 16789 pos: position - lineStart + head.length 16790 }; 16791} 16792function padStart(string, max) { 16793 return common.repeat(' ', max - string.length) + string; 16794} 16795function makeSnippet(mark, options) { 16796 options = Object.create(options || null); 16797 if (!mark.buffer) return null; 16798 if (!options.maxLength) options.maxLength = 79; 16799 if (typeof options.indent !== 'number') options.indent = 1; 16800 if (typeof options.linesBefore !== 'number') options.linesBefore = 3; 16801 if (typeof options.linesAfter !== 'number') options.linesAfter = 2; 16802 var re = /\r?\n|\r|\0/g; 16803 var lineStarts = [ 0 ]; 16804 var lineEnds = []; 16805 var match; 16806 var foundLineNo = -1; 16807 while ((match = re.exec(mark.buffer))) { 16808 lineEnds.push(match.index); 16809 lineStarts.push(match.index + match[0].length); 16810 if (mark.position <= match.index && foundLineNo < 0) { 16811 foundLineNo = lineStarts.length - 2; 16812 } 16813 } 16814 if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; 16815 var result = '', i, line; 16816 var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; 16817 var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); 16818 for (i = 1; i <= options.linesBefore; i++) { 16819 if (foundLineNo - i < 0) break; 16820 line = getLine( 16821 mark.buffer, 16822 lineStarts[foundLineNo - i], 16823 lineEnds[foundLineNo - i], 16824 mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), 16825 maxLineLength 16826 ); 16827 result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + 16828 ' | ' + line.str + '\n' + result; 16829 } 16830 line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); 16831 result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + 16832 ' | ' + line.str + '\n'; 16833 result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n'; 16834 for (i = 1; i <= options.linesAfter; i++) { 16835 if (foundLineNo + i >= lineEnds.length) break; 16836 line = getLine( 16837 mark.buffer, 16838 lineStarts[foundLineNo + i], 16839 lineEnds[foundLineNo + i], 16840 mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), 16841 maxLineLength 16842 ); 16843 result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + 16844 ' | ' + line.str + '\n'; 16845 } 16846 return result.replace(/\n$/, ''); 16847} 16848var snippet = makeSnippet; 16849var TYPE_CONSTRUCTOR_OPTIONS = [ 16850 'kind', 16851 'multi', 16852 'resolve', 16853 'construct', 16854 'instanceOf', 16855 'predicate', 16856 'represent', 16857 'representName', 16858 'defaultStyle', 16859 'styleAliases' 16860]; 16861var YAML_NODE_KINDS = [ 16862 'scalar', 16863 'sequence', 16864 'mapping' 16865]; 16866function compileStyleAliases(map) { 16867 var result = {}; 16868 if (map !== null) { 16869 Object.keys(map).forEach(function (style) { 16870 map[style].forEach(function (alias) { 16871 result[String(alias)] = style; 16872 }); 16873 }); 16874 } 16875 return result; 16876} 16877function Type$1(tag, options) { 16878 options = options || {}; 16879 Object.keys(options).forEach(function (name) { 16880 if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { 16881 throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); 16882 } 16883 }); 16884 this.options = options; 16885 this.tag = tag; 16886 this.kind = options['kind'] || null; 16887 this.resolve = options['resolve'] || function () { return true; }; 16888 this.construct = options['construct'] || function (data) { return data; }; 16889 this.instanceOf = options['instanceOf'] || null; 16890 this.predicate = options['predicate'] || null; 16891 this.represent = options['represent'] || null; 16892 this.representName = options['representName'] || null; 16893 this.defaultStyle = options['defaultStyle'] || null; 16894 this.multi = options['multi'] || false; 16895 this.styleAliases = compileStyleAliases(options['styleAliases'] || null); 16896 if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { 16897 throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); 16898 } 16899} 16900var type = Type$1; 16901function compileList(schema, name) { 16902 var result = []; 16903 schema[name].forEach(function (currentType) { 16904 var newIndex = result.length; 16905 result.forEach(function (previousType, previousIndex) { 16906 if (previousType.tag === currentType.tag && 16907 previousType.kind === currentType.kind && 16908 previousType.multi === currentType.multi) { 16909 newIndex = previousIndex; 16910 } 16911 }); 16912 result[newIndex] = currentType; 16913 }); 16914 return result; 16915} 16916function compileMap() { 16917 var result = { 16918 scalar: {}, 16919 sequence: {}, 16920 mapping: {}, 16921 fallback: {}, 16922 multi: { 16923 scalar: [], 16924 sequence: [], 16925 mapping: [], 16926 fallback: [] 16927 } 16928 }, index, length; 16929 function collectType(type) { 16930 if (type.multi) { 16931 result.multi[type.kind].push(type); 16932 result.multi['fallback'].push(type); 16933 } else { 16934 result[type.kind][type.tag] = result['fallback'][type.tag] = type; 16935 } 16936 } 16937 for (index = 0, length = arguments.length; index < length; index += 1) { 16938 arguments[index].forEach(collectType); 16939 } 16940 return result; 16941} 16942function Schema$1(definition) { 16943 return this.extend(definition); 16944} 16945Schema$1.prototype.extend = function extend(definition) { 16946 var implicit = []; 16947 var explicit = []; 16948 if (definition instanceof type) { 16949 explicit.push(definition); 16950 } else if (Array.isArray(definition)) { 16951 explicit = explicit.concat(definition); 16952 } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { 16953 if (definition.implicit) implicit = implicit.concat(definition.implicit); 16954 if (definition.explicit) explicit = explicit.concat(definition.explicit); 16955 } else { 16956 throw new exception('Schema.extend argument should be a Type, [ Type ], ' + 16957 'or a schema definition ({ implicit: [...], explicit: [...] })'); 16958 } 16959 implicit.forEach(function (type$1) { 16960 if (!(type$1 instanceof type)) { 16961 throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.'); 16962 } 16963 if (type$1.loadKind && type$1.loadKind !== 'scalar') { 16964 throw new exception('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); 16965 } 16966 if (type$1.multi) { 16967 throw new exception('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.'); 16968 } 16969 }); 16970 explicit.forEach(function (type$1) { 16971 if (!(type$1 instanceof type)) { 16972 throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.'); 16973 } 16974 }); 16975 var result = Object.create(Schema$1.prototype); 16976 result.implicit = (this.implicit || []).concat(implicit); 16977 result.explicit = (this.explicit || []).concat(explicit); 16978 result.compiledImplicit = compileList(result, 'implicit'); 16979 result.compiledExplicit = compileList(result, 'explicit'); 16980 result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); 16981 return result; 16982}; 16983var schema = Schema$1; 16984var str = new type('tag:yaml.org,2002:str', { 16985 kind: 'scalar', 16986 construct: function (data) { return data !== null ? data : ''; } 16987}); 16988var seq = new type('tag:yaml.org,2002:seq', { 16989 kind: 'sequence', 16990 construct: function (data) { return data !== null ? data : []; } 16991}); 16992var map = new type('tag:yaml.org,2002:map', { 16993 kind: 'mapping', 16994 construct: function (data) { return data !== null ? data : {}; } 16995}); 16996var failsafe = new schema({ 16997 explicit: [ 16998 str, 16999 seq, 17000 map 17001 ] 17002}); 17003function resolveYamlNull(data) { 17004 if (data === null) return true; 17005 var max = data.length; 17006 return (max === 1 && data === '~') || 17007 (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); 17008} 17009function constructYamlNull() { 17010 return null; 17011} 17012function isNull(object) { 17013 return object === null; 17014} 17015var _null = new type('tag:yaml.org,2002:null', { 17016 kind: 'scalar', 17017 resolve: resolveYamlNull, 17018 construct: constructYamlNull, 17019 predicate: isNull, 17020 represent: { 17021 canonical: function () { return '~'; }, 17022 lowercase: function () { return 'null'; }, 17023 uppercase: function () { return 'NULL'; }, 17024 camelcase: function () { return 'Null'; }, 17025 empty: function () { return ''; } 17026 }, 17027 defaultStyle: 'lowercase' 17028}); 17029function resolveYamlBoolean(data) { 17030 if (data === null) return false; 17031 var max = data.length; 17032 return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || 17033 (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); 17034} 17035function constructYamlBoolean(data) { 17036 return data === 'true' || 17037 data === 'True' || 17038 data === 'TRUE'; 17039} 17040function isBoolean(object) { 17041 return Object.prototype.toString.call(object) === '[object Boolean]'; 17042} 17043var bool = new type('tag:yaml.org,2002:bool', { 17044 kind: 'scalar', 17045 resolve: resolveYamlBoolean, 17046 construct: constructYamlBoolean, 17047 predicate: isBoolean, 17048 represent: { 17049 lowercase: function (object) { return object ? 'true' : 'false'; }, 17050 uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, 17051 camelcase: function (object) { return object ? 'True' : 'False'; } 17052 }, 17053 defaultStyle: 'lowercase' 17054}); 17055function isHexCode(c) { 17056 return ((0x30 <= c) && (c <= 0x39)) || 17057 ((0x41 <= c) && (c <= 0x46)) || 17058 ((0x61 <= c) && (c <= 0x66)); 17059} 17060function isOctCode(c) { 17061 return ((0x30 <= c) && (c <= 0x37)); 17062} 17063function isDecCode(c) { 17064 return ((0x30 <= c) && (c <= 0x39)); 17065} 17066function resolveYamlInteger(data) { 17067 if (data === null) return false; 17068 var max = data.length, 17069 index = 0, 17070 hasDigits = false, 17071 ch; 17072 if (!max) return false; 17073 ch = data[index]; 17074 if (ch === '-' || ch === '+') { 17075 ch = data[++index]; 17076 } 17077 if (ch === '0') { 17078 if (index + 1 === max) return true; 17079 ch = data[++index]; 17080 if (ch === 'b') { 17081 index++; 17082 for (; index < max; index++) { 17083 ch = data[index]; 17084 if (ch === '_') continue; 17085 if (ch !== '0' && ch !== '1') return false; 17086 hasDigits = true; 17087 } 17088 return hasDigits && ch !== '_'; 17089 } 17090 if (ch === 'x') { 17091 index++; 17092 for (; index < max; index++) { 17093 ch = data[index]; 17094 if (ch === '_') continue; 17095 if (!isHexCode(data.charCodeAt(index))) return false; 17096 hasDigits = true; 17097 } 17098 return hasDigits && ch !== '_'; 17099 } 17100 if (ch === 'o') { 17101 index++; 17102 for (; index < max; index++) { 17103 ch = data[index]; 17104 if (ch === '_') continue; 17105 if (!isOctCode(data.charCodeAt(index))) return false; 17106 hasDigits = true; 17107 } 17108 return hasDigits && ch !== '_'; 17109 } 17110 } 17111 if (ch === '_') return false; 17112 for (; index < max; index++) { 17113 ch = data[index]; 17114 if (ch === '_') continue; 17115 if (!isDecCode(data.charCodeAt(index))) { 17116 return false; 17117 } 17118 hasDigits = true; 17119 } 17120 if (!hasDigits || ch === '_') return false; 17121 return true; 17122} 17123function constructYamlInteger(data) { 17124 var value = data, sign = 1, ch; 17125 if (value.indexOf('_') !== -1) { 17126 value = value.replace(/_/g, ''); 17127 } 17128 ch = value[0]; 17129 if (ch === '-' || ch === '+') { 17130 if (ch === '-') sign = -1; 17131 value = value.slice(1); 17132 ch = value[0]; 17133 } 17134 if (value === '0') return 0; 17135 if (ch === '0') { 17136 if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); 17137 if (value[1] === 'x') return sign * parseInt(value.slice(2), 16); 17138 if (value[1] === 'o') return sign * parseInt(value.slice(2), 8); 17139 } 17140 return sign * parseInt(value, 10); 17141} 17142function isInteger(object) { 17143 return (Object.prototype.toString.call(object)) === '[object Number]' && 17144 (object % 1 === 0 && !common.isNegativeZero(object)); 17145} 17146var int = new type('tag:yaml.org,2002:int', { 17147 kind: 'scalar', 17148 resolve: resolveYamlInteger, 17149 construct: constructYamlInteger, 17150 predicate: isInteger, 17151 represent: { 17152 binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, 17153 octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1); }, 17154 decimal: function (obj) { return obj.toString(10); }, 17155 hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } 17156 }, 17157 defaultStyle: 'decimal', 17158 styleAliases: { 17159 binary: [ 2, 'bin' ], 17160 octal: [ 8, 'oct' ], 17161 decimal: [ 10, 'dec' ], 17162 hexadecimal: [ 16, 'hex' ] 17163 } 17164}); 17165var YAML_FLOAT_PATTERN = new RegExp( 17166 '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + 17167 '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + 17168 '|[-+]?\\.(?:inf|Inf|INF)' + 17169 '|\\.(?:nan|NaN|NAN))$'); 17170function resolveYamlFloat(data) { 17171 if (data === null) return false; 17172 if (!YAML_FLOAT_PATTERN.test(data) || 17173 data[data.length - 1] === '_') { 17174 return false; 17175 } 17176 return true; 17177} 17178function constructYamlFloat(data) { 17179 var value, sign; 17180 value = data.replace(/_/g, '').toLowerCase(); 17181 sign = value[0] === '-' ? -1 : 1; 17182 if ('+-'.indexOf(value[0]) >= 0) { 17183 value = value.slice(1); 17184 } 17185 if (value === '.inf') { 17186 return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; 17187 } else if (value === '.nan') { 17188 return NaN; 17189 } 17190 return sign * parseFloat(value, 10); 17191} 17192var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; 17193function representYamlFloat(object, style) { 17194 var res; 17195 if (isNaN(object)) { 17196 switch (style) { 17197 case 'lowercase': return '.nan'; 17198 case 'uppercase': return '.NAN'; 17199 case 'camelcase': return '.NaN'; 17200 } 17201 } else if (Number.POSITIVE_INFINITY === object) { 17202 switch (style) { 17203 case 'lowercase': return '.inf'; 17204 case 'uppercase': return '.INF'; 17205 case 'camelcase': return '.Inf'; 17206 } 17207 } else if (Number.NEGATIVE_INFINITY === object) { 17208 switch (style) { 17209 case 'lowercase': return '-.inf'; 17210 case 'uppercase': return '-.INF'; 17211 case 'camelcase': return '-.Inf'; 17212 } 17213 } else if (common.isNegativeZero(object)) { 17214 return '-0.0'; 17215 } 17216 res = object.toString(10); 17217 return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; 17218} 17219function isFloat(object) { 17220 return (Object.prototype.toString.call(object) === '[object Number]') && 17221 (object % 1 !== 0 || common.isNegativeZero(object)); 17222} 17223var float = new type('tag:yaml.org,2002:float', { 17224 kind: 'scalar', 17225 resolve: resolveYamlFloat, 17226 construct: constructYamlFloat, 17227 predicate: isFloat, 17228 represent: representYamlFloat, 17229 defaultStyle: 'lowercase' 17230}); 17231var json = failsafe.extend({ 17232 implicit: [ 17233 _null, 17234 bool, 17235 int, 17236 float 17237 ] 17238}); 17239var core = json; 17240var YAML_DATE_REGEXP = new RegExp( 17241 '^([0-9][0-9][0-9][0-9])' + 17242 '-([0-9][0-9])' + 17243 '-([0-9][0-9])$'); 17244var YAML_TIMESTAMP_REGEXP = new RegExp( 17245 '^([0-9][0-9][0-9][0-9])' + 17246 '-([0-9][0-9]?)' + 17247 '-([0-9][0-9]?)' + 17248 '(?:[Tt]|[ \\t]+)' + 17249 '([0-9][0-9]?)' + 17250 ':([0-9][0-9])' + 17251 ':([0-9][0-9])' + 17252 '(?:\\.([0-9]*))?' + 17253 '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + 17254 '(?::([0-9][0-9]))?))?$'); 17255function resolveYamlTimestamp(data) { 17256 if (data === null) return false; 17257 if (YAML_DATE_REGEXP.exec(data) !== null) return true; 17258 if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; 17259 return false; 17260} 17261function constructYamlTimestamp(data) { 17262 var match, year, month, day, hour, minute, second, fraction = 0, 17263 delta = null, tz_hour, tz_minute, date; 17264 match = YAML_DATE_REGEXP.exec(data); 17265 if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); 17266 if (match === null) throw new Error('Date resolve error'); 17267 year = +(match[1]); 17268 month = +(match[2]) - 1; 17269 day = +(match[3]); 17270 if (!match[4]) { 17271 return new Date(Date.UTC(year, month, day)); 17272 } 17273 hour = +(match[4]); 17274 minute = +(match[5]); 17275 second = +(match[6]); 17276 if (match[7]) { 17277 fraction = match[7].slice(0, 3); 17278 while (fraction.length < 3) { 17279 fraction += '0'; 17280 } 17281 fraction = +fraction; 17282 } 17283 if (match[9]) { 17284 tz_hour = +(match[10]); 17285 tz_minute = +(match[11] || 0); 17286 delta = (tz_hour * 60 + tz_minute) * 60000; 17287 if (match[9] === '-') delta = -delta; 17288 } 17289 date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); 17290 if (delta) date.setTime(date.getTime() - delta); 17291 return date; 17292} 17293function representYamlTimestamp(object ) { 17294 return object.toISOString(); 17295} 17296var timestamp = new type('tag:yaml.org,2002:timestamp', { 17297 kind: 'scalar', 17298 resolve: resolveYamlTimestamp, 17299 construct: constructYamlTimestamp, 17300 instanceOf: Date, 17301 represent: representYamlTimestamp 17302}); 17303function resolveYamlMerge(data) { 17304 return data === '<<' || data === null; 17305} 17306var merge = new type('tag:yaml.org,2002:merge', { 17307 kind: 'scalar', 17308 resolve: resolveYamlMerge 17309}); 17310var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; 17311function resolveYamlBinary(data) { 17312 if (data === null) return false; 17313 var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; 17314 for (idx = 0; idx < max; idx++) { 17315 code = map.indexOf(data.charAt(idx)); 17316 if (code > 64) continue; 17317 if (code < 0) return false; 17318 bitlen += 6; 17319 } 17320 return (bitlen % 8) === 0; 17321} 17322function constructYamlBinary(data) { 17323 var idx, tailbits, 17324 input = data.replace(/[\r\n=]/g, ''), 17325 max = input.length, 17326 map = BASE64_MAP, 17327 bits = 0, 17328 result = []; 17329 for (idx = 0; idx < max; idx++) { 17330 if ((idx % 4 === 0) && idx) { 17331 result.push((bits >> 16) & 0xFF); 17332 result.push((bits >> 8) & 0xFF); 17333 result.push(bits & 0xFF); 17334 } 17335 bits = (bits << 6) | map.indexOf(input.charAt(idx)); 17336 } 17337 tailbits = (max % 4) * 6; 17338 if (tailbits === 0) { 17339 result.push((bits >> 16) & 0xFF); 17340 result.push((bits >> 8) & 0xFF); 17341 result.push(bits & 0xFF); 17342 } else if (tailbits === 18) { 17343 result.push((bits >> 10) & 0xFF); 17344 result.push((bits >> 2) & 0xFF); 17345 } else if (tailbits === 12) { 17346 result.push((bits >> 4) & 0xFF); 17347 } 17348 return new Uint8Array(result); 17349} 17350function representYamlBinary(object ) { 17351 var result = '', bits = 0, idx, tail, 17352 max = object.length, 17353 map = BASE64_MAP; 17354 for (idx = 0; idx < max; idx++) { 17355 if ((idx % 3 === 0) && idx) { 17356 result += map[(bits >> 18) & 0x3F]; 17357 result += map[(bits >> 12) & 0x3F]; 17358 result += map[(bits >> 6) & 0x3F]; 17359 result += map[bits & 0x3F]; 17360 } 17361 bits = (bits << 8) + object[idx]; 17362 } 17363 tail = max % 3; 17364 if (tail === 0) { 17365 result += map[(bits >> 18) & 0x3F]; 17366 result += map[(bits >> 12) & 0x3F]; 17367 result += map[(bits >> 6) & 0x3F]; 17368 result += map[bits & 0x3F]; 17369 } else if (tail === 2) { 17370 result += map[(bits >> 10) & 0x3F]; 17371 result += map[(bits >> 4) & 0x3F]; 17372 result += map[(bits << 2) & 0x3F]; 17373 result += map[64]; 17374 } else if (tail === 1) { 17375 result += map[(bits >> 2) & 0x3F]; 17376 result += map[(bits << 4) & 0x3F]; 17377 result += map[64]; 17378 result += map[64]; 17379 } 17380 return result; 17381} 17382function isBinary(obj) { 17383 return Object.prototype.toString.call(obj) === '[object Uint8Array]'; 17384} 17385var binary = new type('tag:yaml.org,2002:binary', { 17386 kind: 'scalar', 17387 resolve: resolveYamlBinary, 17388 construct: constructYamlBinary, 17389 predicate: isBinary, 17390 represent: representYamlBinary 17391}); 17392var _hasOwnProperty$3 = Object.prototype.hasOwnProperty; 17393var _toString$2 = Object.prototype.toString; 17394function resolveYamlOmap(data) { 17395 if (data === null) return true; 17396 var objectKeys = [], index, length, pair, pairKey, pairHasKey, 17397 object = data; 17398 for (index = 0, length = object.length; index < length; index += 1) { 17399 pair = object[index]; 17400 pairHasKey = false; 17401 if (_toString$2.call(pair) !== '[object Object]') return false; 17402 for (pairKey in pair) { 17403 if (_hasOwnProperty$3.call(pair, pairKey)) { 17404 if (!pairHasKey) pairHasKey = true; 17405 else return false; 17406 } 17407 } 17408 if (!pairHasKey) return false; 17409 if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); 17410 else return false; 17411 } 17412 return true; 17413} 17414function constructYamlOmap(data) { 17415 return data !== null ? data : []; 17416} 17417var omap = new type('tag:yaml.org,2002:omap', { 17418 kind: 'sequence', 17419 resolve: resolveYamlOmap, 17420 construct: constructYamlOmap 17421}); 17422var _toString$1 = Object.prototype.toString; 17423function resolveYamlPairs(data) { 17424 if (data === null) return true; 17425 var index, length, pair, keys, result, 17426 object = data; 17427 result = new Array(object.length); 17428 for (index = 0, length = object.length; index < length; index += 1) { 17429 pair = object[index]; 17430 if (_toString$1.call(pair) !== '[object Object]') return false; 17431 keys = Object.keys(pair); 17432 if (keys.length !== 1) return false; 17433 result[index] = [ keys[0], pair[keys[0]] ]; 17434 } 17435 return true; 17436} 17437function constructYamlPairs(data) { 17438 if (data === null) return []; 17439 var index, length, pair, keys, result, 17440 object = data; 17441 result = new Array(object.length); 17442 for (index = 0, length = object.length; index < length; index += 1) { 17443 pair = object[index]; 17444 keys = Object.keys(pair); 17445 result[index] = [ keys[0], pair[keys[0]] ]; 17446 } 17447 return result; 17448} 17449var pairs = new type('tag:yaml.org,2002:pairs', { 17450 kind: 'sequence', 17451 resolve: resolveYamlPairs, 17452 construct: constructYamlPairs 17453}); 17454var _hasOwnProperty$2 = Object.prototype.hasOwnProperty; 17455function resolveYamlSet(data) { 17456 if (data === null) return true; 17457 var key, object = data; 17458 for (key in object) { 17459 if (_hasOwnProperty$2.call(object, key)) { 17460 if (object[key] !== null) return false; 17461 } 17462 } 17463 return true; 17464} 17465function constructYamlSet(data) { 17466 return data !== null ? data : {}; 17467} 17468var set = new type('tag:yaml.org,2002:set', { 17469 kind: 'mapping', 17470 resolve: resolveYamlSet, 17471 construct: constructYamlSet 17472}); 17473var _default = core.extend({ 17474 implicit: [ 17475 timestamp, 17476 merge 17477 ], 17478 explicit: [ 17479 binary, 17480 omap, 17481 pairs, 17482 set 17483 ] 17484}); 17485var _hasOwnProperty$1 = Object.prototype.hasOwnProperty; 17486var CONTEXT_FLOW_IN = 1; 17487var CONTEXT_FLOW_OUT = 2; 17488var CONTEXT_BLOCK_IN = 3; 17489var CONTEXT_BLOCK_OUT = 4; 17490var CHOMPING_CLIP = 1; 17491var CHOMPING_STRIP = 2; 17492var CHOMPING_KEEP = 3; 17493var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; 17494var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; 17495var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; 17496var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; 17497var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; 17498function _class(obj) { return Object.prototype.toString.call(obj); } 17499function is_EOL(c) { 17500 return (c === 0x0A) || (c === 0x0D); 17501} 17502function is_WHITE_SPACE(c) { 17503 return (c === 0x09) || (c === 0x20); 17504} 17505function is_WS_OR_EOL(c) { 17506 return (c === 0x09) || 17507 (c === 0x20) || 17508 (c === 0x0A) || 17509 (c === 0x0D); 17510} 17511function is_FLOW_INDICATOR(c) { 17512 return c === 0x2C || 17513 c === 0x5B || 17514 c === 0x5D || 17515 c === 0x7B || 17516 c === 0x7D; 17517} 17518function fromHexCode(c) { 17519 var lc; 17520 if ((0x30 <= c) && (c <= 0x39)) { 17521 return c - 0x30; 17522 } 17523 lc = c | 0x20; 17524 if ((0x61 <= lc) && (lc <= 0x66)) { 17525 return lc - 0x61 + 10; 17526 } 17527 return -1; 17528} 17529function escapedHexLen(c) { 17530 if (c === 0x78) { return 2; } 17531 if (c === 0x75) { return 4; } 17532 if (c === 0x55) { return 8; } 17533 return 0; 17534} 17535function fromDecimalCode(c) { 17536 if ((0x30 <= c) && (c <= 0x39)) { 17537 return c - 0x30; 17538 } 17539 return -1; 17540} 17541function simpleEscapeSequence(c) { 17542 return (c === 0x30) ? '\x00' : 17543 (c === 0x61) ? '\x07' : 17544 (c === 0x62) ? '\x08' : 17545 (c === 0x74) ? '\x09' : 17546 (c === 0x09) ? '\x09' : 17547 (c === 0x6E) ? '\x0A' : 17548 (c === 0x76) ? '\x0B' : 17549 (c === 0x66) ? '\x0C' : 17550 (c === 0x72) ? '\x0D' : 17551 (c === 0x65) ? '\x1B' : 17552 (c === 0x20) ? ' ' : 17553 (c === 0x22) ? '\x22' : 17554 (c === 0x2F) ? '/' : 17555 (c === 0x5C) ? '\x5C' : 17556 (c === 0x4E) ? '\x85' : 17557 (c === 0x5F) ? '\xA0' : 17558 (c === 0x4C) ? '\u2028' : 17559 (c === 0x50) ? '\u2029' : ''; 17560} 17561function charFromCodepoint(c) { 17562 if (c <= 0xFFFF) { 17563 return String.fromCharCode(c); 17564 } 17565 return String.fromCharCode( 17566 ((c - 0x010000) >> 10) + 0xD800, 17567 ((c - 0x010000) & 0x03FF) + 0xDC00 17568 ); 17569} 17570var simpleEscapeCheck = new Array(256); 17571var simpleEscapeMap = new Array(256); 17572for (var i = 0; i < 256; i++) { 17573 simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; 17574 simpleEscapeMap[i] = simpleEscapeSequence(i); 17575} 17576function State$1(input, options) { 17577 this.input = input; 17578 this.filename = options['filename'] || null; 17579 this.schema = options['schema'] || _default; 17580 this.onWarning = options['onWarning'] || null; 17581 this.legacy = options['legacy'] || false; 17582 this.json = options['json'] || false; 17583 this.listener = options['listener'] || null; 17584 this.implicitTypes = this.schema.compiledImplicit; 17585 this.typeMap = this.schema.compiledTypeMap; 17586 this.length = input.length; 17587 this.position = 0; 17588 this.line = 0; 17589 this.lineStart = 0; 17590 this.lineIndent = 0; 17591 this.firstTabInLine = -1; 17592 this.documents = []; 17593} 17594function generateError(state, message) { 17595 var mark = { 17596 name: state.filename, 17597 buffer: state.input.slice(0, -1), 17598 position: state.position, 17599 line: state.line, 17600 column: state.position - state.lineStart 17601 }; 17602 mark.snippet = snippet(mark); 17603 return new exception(message, mark); 17604} 17605function throwError(state, message) { 17606 throw generateError(state, message); 17607} 17608function throwWarning(state, message) { 17609 if (state.onWarning) { 17610 state.onWarning.call(null, generateError(state, message)); 17611 } 17612} 17613var directiveHandlers = { 17614 YAML: function handleYamlDirective(state, name, args) { 17615 var match, major, minor; 17616 if (state.version !== null) { 17617 throwError(state, 'duplication of %YAML directive'); 17618 } 17619 if (args.length !== 1) { 17620 throwError(state, 'YAML directive accepts exactly one argument'); 17621 } 17622 match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); 17623 if (match === null) { 17624 throwError(state, 'ill-formed argument of the YAML directive'); 17625 } 17626 major = parseInt(match[1], 10); 17627 minor = parseInt(match[2], 10); 17628 if (major !== 1) { 17629 throwError(state, 'unacceptable YAML version of the document'); 17630 } 17631 state.version = args[0]; 17632 state.checkLineBreaks = (minor < 2); 17633 if (minor !== 1 && minor !== 2) { 17634 throwWarning(state, 'unsupported YAML version of the document'); 17635 } 17636 }, 17637 TAG: function handleTagDirective(state, name, args) { 17638 var handle, prefix; 17639 if (args.length !== 2) { 17640 throwError(state, 'TAG directive accepts exactly two arguments'); 17641 } 17642 handle = args[0]; 17643 prefix = args[1]; 17644 if (!PATTERN_TAG_HANDLE.test(handle)) { 17645 throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); 17646 } 17647 if (_hasOwnProperty$1.call(state.tagMap, handle)) { 17648 throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); 17649 } 17650 if (!PATTERN_TAG_URI.test(prefix)) { 17651 throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); 17652 } 17653 try { 17654 prefix = decodeURIComponent(prefix); 17655 } catch (err) { 17656 throwError(state, 'tag prefix is malformed: ' + prefix); 17657 } 17658 state.tagMap[handle] = prefix; 17659 } 17660}; 17661function captureSegment(state, start, end, checkJson) { 17662 var _position, _length, _character, _result; 17663 if (start < end) { 17664 _result = state.input.slice(start, end); 17665 if (checkJson) { 17666 for (_position = 0, _length = _result.length; _position < _length; _position += 1) { 17667 _character = _result.charCodeAt(_position); 17668 if (!(_character === 0x09 || 17669 (0x20 <= _character && _character <= 0x10FFFF))) { 17670 throwError(state, 'expected valid JSON character'); 17671 } 17672 } 17673 } else if (PATTERN_NON_PRINTABLE.test(_result)) { 17674 throwError(state, 'the stream contains non-printable characters'); 17675 } 17676 state.result += _result; 17677 } 17678} 17679function mergeMappings(state, destination, source, overridableKeys) { 17680 var sourceKeys, key, index, quantity; 17681 if (!common.isObject(source)) { 17682 throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); 17683 } 17684 sourceKeys = Object.keys(source); 17685 for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { 17686 key = sourceKeys[index]; 17687 if (!_hasOwnProperty$1.call(destination, key)) { 17688 destination[key] = source[key]; 17689 overridableKeys[key] = true; 17690 } 17691 } 17692} 17693function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, 17694 startLine, startLineStart, startPos) { 17695 var index, quantity; 17696 if (Array.isArray(keyNode)) { 17697 keyNode = Array.prototype.slice.call(keyNode); 17698 for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { 17699 if (Array.isArray(keyNode[index])) { 17700 throwError(state, 'nested arrays are not supported inside keys'); 17701 } 17702 if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { 17703 keyNode[index] = '[object Object]'; 17704 } 17705 } 17706 } 17707 if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { 17708 keyNode = '[object Object]'; 17709 } 17710 keyNode = String(keyNode); 17711 if (_result === null) { 17712 _result = {}; 17713 } 17714 if (keyTag === 'tag:yaml.org,2002:merge') { 17715 if (Array.isArray(valueNode)) { 17716 for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { 17717 mergeMappings(state, _result, valueNode[index], overridableKeys); 17718 } 17719 } else { 17720 mergeMappings(state, _result, valueNode, overridableKeys); 17721 } 17722 } else { 17723 if (!state.json && 17724 !_hasOwnProperty$1.call(overridableKeys, keyNode) && 17725 _hasOwnProperty$1.call(_result, keyNode)) { 17726 state.line = startLine || state.line; 17727 state.lineStart = startLineStart || state.lineStart; 17728 state.position = startPos || state.position; 17729 throwError(state, 'duplicated mapping key'); 17730 } 17731 if (keyNode === '__proto__') { 17732 Object.defineProperty(_result, keyNode, { 17733 configurable: true, 17734 enumerable: true, 17735 writable: true, 17736 value: valueNode 17737 }); 17738 } else { 17739 _result[keyNode] = valueNode; 17740 } 17741 delete overridableKeys[keyNode]; 17742 } 17743 return _result; 17744} 17745function readLineBreak(state) { 17746 var ch; 17747 ch = state.input.charCodeAt(state.position); 17748 if (ch === 0x0A) { 17749 state.position++; 17750 } else if (ch === 0x0D) { 17751 state.position++; 17752 if (state.input.charCodeAt(state.position) === 0x0A) { 17753 state.position++; 17754 } 17755 } else { 17756 throwError(state, 'a line break is expected'); 17757 } 17758 state.line += 1; 17759 state.lineStart = state.position; 17760 state.firstTabInLine = -1; 17761} 17762function skipSeparationSpace(state, allowComments, checkIndent) { 17763 var lineBreaks = 0, 17764 ch = state.input.charCodeAt(state.position); 17765 while (ch !== 0) { 17766 while (is_WHITE_SPACE(ch)) { 17767 if (ch === 0x09 && state.firstTabInLine === -1) { 17768 state.firstTabInLine = state.position; 17769 } 17770 ch = state.input.charCodeAt(++state.position); 17771 } 17772 if (allowComments && ch === 0x23) { 17773 do { 17774 ch = state.input.charCodeAt(++state.position); 17775 } while (ch !== 0x0A && ch !== 0x0D && ch !== 0); 17776 } 17777 if (is_EOL(ch)) { 17778 readLineBreak(state); 17779 ch = state.input.charCodeAt(state.position); 17780 lineBreaks++; 17781 state.lineIndent = 0; 17782 while (ch === 0x20) { 17783 state.lineIndent++; 17784 ch = state.input.charCodeAt(++state.position); 17785 } 17786 } else { 17787 break; 17788 } 17789 } 17790 if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { 17791 throwWarning(state, 'deficient indentation'); 17792 } 17793 return lineBreaks; 17794} 17795function testDocumentSeparator(state) { 17796 var _position = state.position, 17797 ch; 17798 ch = state.input.charCodeAt(_position); 17799 if ((ch === 0x2D || ch === 0x2E) && 17800 ch === state.input.charCodeAt(_position + 1) && 17801 ch === state.input.charCodeAt(_position + 2)) { 17802 _position += 3; 17803 ch = state.input.charCodeAt(_position); 17804 if (ch === 0 || is_WS_OR_EOL(ch)) { 17805 return true; 17806 } 17807 } 17808 return false; 17809} 17810function writeFoldedLines(state, count) { 17811 if (count === 1) { 17812 state.result += ' '; 17813 } else if (count > 1) { 17814 state.result += common.repeat('\n', count - 1); 17815 } 17816} 17817function readPlainScalar(state, nodeIndent, withinFlowCollection) { 17818 var preceding, 17819 following, 17820 captureStart, 17821 captureEnd, 17822 hasPendingContent, 17823 _line, 17824 _lineStart, 17825 _lineIndent, 17826 _kind = state.kind, 17827 _result = state.result, 17828 ch; 17829 ch = state.input.charCodeAt(state.position); 17830 if (is_WS_OR_EOL(ch) || 17831 is_FLOW_INDICATOR(ch) || 17832 ch === 0x23 || 17833 ch === 0x26 || 17834 ch === 0x2A || 17835 ch === 0x21 || 17836 ch === 0x7C || 17837 ch === 0x3E || 17838 ch === 0x27 || 17839 ch === 0x22 || 17840 ch === 0x25 || 17841 ch === 0x40 || 17842 ch === 0x60) { 17843 return false; 17844 } 17845 if (ch === 0x3F || ch === 0x2D) { 17846 following = state.input.charCodeAt(state.position + 1); 17847 if (is_WS_OR_EOL(following) || 17848 withinFlowCollection && is_FLOW_INDICATOR(following)) { 17849 return false; 17850 } 17851 } 17852 state.kind = 'scalar'; 17853 state.result = ''; 17854 captureStart = captureEnd = state.position; 17855 hasPendingContent = false; 17856 while (ch !== 0) { 17857 if (ch === 0x3A) { 17858 following = state.input.charCodeAt(state.position + 1); 17859 if (is_WS_OR_EOL(following) || 17860 withinFlowCollection && is_FLOW_INDICATOR(following)) { 17861 break; 17862 } 17863 } else if (ch === 0x23) { 17864 preceding = state.input.charCodeAt(state.position - 1); 17865 if (is_WS_OR_EOL(preceding)) { 17866 break; 17867 } 17868 } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || 17869 withinFlowCollection && is_FLOW_INDICATOR(ch)) { 17870 break; 17871 } else if (is_EOL(ch)) { 17872 _line = state.line; 17873 _lineStart = state.lineStart; 17874 _lineIndent = state.lineIndent; 17875 skipSeparationSpace(state, false, -1); 17876 if (state.lineIndent >= nodeIndent) { 17877 hasPendingContent = true; 17878 ch = state.input.charCodeAt(state.position); 17879 continue; 17880 } else { 17881 state.position = captureEnd; 17882 state.line = _line; 17883 state.lineStart = _lineStart; 17884 state.lineIndent = _lineIndent; 17885 break; 17886 } 17887 } 17888 if (hasPendingContent) { 17889 captureSegment(state, captureStart, captureEnd, false); 17890 writeFoldedLines(state, state.line - _line); 17891 captureStart = captureEnd = state.position; 17892 hasPendingContent = false; 17893 } 17894 if (!is_WHITE_SPACE(ch)) { 17895 captureEnd = state.position + 1; 17896 } 17897 ch = state.input.charCodeAt(++state.position); 17898 } 17899 captureSegment(state, captureStart, captureEnd, false); 17900 if (state.result) { 17901 return true; 17902 } 17903 state.kind = _kind; 17904 state.result = _result; 17905 return false; 17906} 17907function readSingleQuotedScalar(state, nodeIndent) { 17908 var ch, 17909 captureStart, captureEnd; 17910 ch = state.input.charCodeAt(state.position); 17911 if (ch !== 0x27) { 17912 return false; 17913 } 17914 state.kind = 'scalar'; 17915 state.result = ''; 17916 state.position++; 17917 captureStart = captureEnd = state.position; 17918 while ((ch = state.input.charCodeAt(state.position)) !== 0) { 17919 if (ch === 0x27) { 17920 captureSegment(state, captureStart, state.position, true); 17921 ch = state.input.charCodeAt(++state.position); 17922 if (ch === 0x27) { 17923 captureStart = state.position; 17924 state.position++; 17925 captureEnd = state.position; 17926 } else { 17927 return true; 17928 } 17929 } else if (is_EOL(ch)) { 17930 captureSegment(state, captureStart, captureEnd, true); 17931 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); 17932 captureStart = captureEnd = state.position; 17933 } else if (state.position === state.lineStart && testDocumentSeparator(state)) { 17934 throwError(state, 'unexpected end of the document within a single quoted scalar'); 17935 } else { 17936 state.position++; 17937 captureEnd = state.position; 17938 } 17939 } 17940 throwError(state, 'unexpected end of the stream within a single quoted scalar'); 17941} 17942function readDoubleQuotedScalar(state, nodeIndent) { 17943 var captureStart, 17944 captureEnd, 17945 hexLength, 17946 hexResult, 17947 tmp, 17948 ch; 17949 ch = state.input.charCodeAt(state.position); 17950 if (ch !== 0x22) { 17951 return false; 17952 } 17953 state.kind = 'scalar'; 17954 state.result = ''; 17955 state.position++; 17956 captureStart = captureEnd = state.position; 17957 while ((ch = state.input.charCodeAt(state.position)) !== 0) { 17958 if (ch === 0x22) { 17959 captureSegment(state, captureStart, state.position, true); 17960 state.position++; 17961 return true; 17962 } else if (ch === 0x5C) { 17963 captureSegment(state, captureStart, state.position, true); 17964 ch = state.input.charCodeAt(++state.position); 17965 if (is_EOL(ch)) { 17966 skipSeparationSpace(state, false, nodeIndent); 17967 } else if (ch < 256 && simpleEscapeCheck[ch]) { 17968 state.result += simpleEscapeMap[ch]; 17969 state.position++; 17970 } else if ((tmp = escapedHexLen(ch)) > 0) { 17971 hexLength = tmp; 17972 hexResult = 0; 17973 for (; hexLength > 0; hexLength--) { 17974 ch = state.input.charCodeAt(++state.position); 17975 if ((tmp = fromHexCode(ch)) >= 0) { 17976 hexResult = (hexResult << 4) + tmp; 17977 } else { 17978 throwError(state, 'expected hexadecimal character'); 17979 } 17980 } 17981 state.result += charFromCodepoint(hexResult); 17982 state.position++; 17983 } else { 17984 throwError(state, 'unknown escape sequence'); 17985 } 17986 captureStart = captureEnd = state.position; 17987 } else if (is_EOL(ch)) { 17988 captureSegment(state, captureStart, captureEnd, true); 17989 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); 17990 captureStart = captureEnd = state.position; 17991 } else if (state.position === state.lineStart && testDocumentSeparator(state)) { 17992 throwError(state, 'unexpected end of the document within a double quoted scalar'); 17993 } else { 17994 state.position++; 17995 captureEnd = state.position; 17996 } 17997 } 17998 throwError(state, 'unexpected end of the stream within a double quoted scalar'); 17999} 18000function readFlowCollection(state, nodeIndent) { 18001 var readNext = true, 18002 _line, 18003 _lineStart, 18004 _pos, 18005 _tag = state.tag, 18006 _result, 18007 _anchor = state.anchor, 18008 following, 18009 terminator, 18010 isPair, 18011 isExplicitPair, 18012 isMapping, 18013 overridableKeys = Object.create(null), 18014 keyNode, 18015 keyTag, 18016 valueNode, 18017 ch; 18018 ch = state.input.charCodeAt(state.position); 18019 if (ch === 0x5B) { 18020 terminator = 0x5D; 18021 isMapping = false; 18022 _result = []; 18023 } else if (ch === 0x7B) { 18024 terminator = 0x7D; 18025 isMapping = true; 18026 _result = {}; 18027 } else { 18028 return false; 18029 } 18030 if (state.anchor !== null) { 18031 state.anchorMap[state.anchor] = _result; 18032 } 18033 ch = state.input.charCodeAt(++state.position); 18034 while (ch !== 0) { 18035 skipSeparationSpace(state, true, nodeIndent); 18036 ch = state.input.charCodeAt(state.position); 18037 if (ch === terminator) { 18038 state.position++; 18039 state.tag = _tag; 18040 state.anchor = _anchor; 18041 state.kind = isMapping ? 'mapping' : 'sequence'; 18042 state.result = _result; 18043 return true; 18044 } else if (!readNext) { 18045 throwError(state, 'missed comma between flow collection entries'); 18046 } else if (ch === 0x2C) { 18047 throwError(state, "expected the node content, but found ','"); 18048 } 18049 keyTag = keyNode = valueNode = null; 18050 isPair = isExplicitPair = false; 18051 if (ch === 0x3F) { 18052 following = state.input.charCodeAt(state.position + 1); 18053 if (is_WS_OR_EOL(following)) { 18054 isPair = isExplicitPair = true; 18055 state.position++; 18056 skipSeparationSpace(state, true, nodeIndent); 18057 } 18058 } 18059 _line = state.line; 18060 _lineStart = state.lineStart; 18061 _pos = state.position; 18062 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); 18063 keyTag = state.tag; 18064 keyNode = state.result; 18065 skipSeparationSpace(state, true, nodeIndent); 18066 ch = state.input.charCodeAt(state.position); 18067 if ((isExplicitPair || state.line === _line) && ch === 0x3A) { 18068 isPair = true; 18069 ch = state.input.charCodeAt(++state.position); 18070 skipSeparationSpace(state, true, nodeIndent); 18071 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); 18072 valueNode = state.result; 18073 } 18074 if (isMapping) { 18075 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); 18076 } else if (isPair) { 18077 _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); 18078 } else { 18079 _result.push(keyNode); 18080 } 18081 skipSeparationSpace(state, true, nodeIndent); 18082 ch = state.input.charCodeAt(state.position); 18083 if (ch === 0x2C) { 18084 readNext = true; 18085 ch = state.input.charCodeAt(++state.position); 18086 } else { 18087 readNext = false; 18088 } 18089 } 18090 throwError(state, 'unexpected end of the stream within a flow collection'); 18091} 18092function readBlockScalar(state, nodeIndent) { 18093 var captureStart, 18094 folding, 18095 chomping = CHOMPING_CLIP, 18096 didReadContent = false, 18097 detectedIndent = false, 18098 textIndent = nodeIndent, 18099 emptyLines = 0, 18100 atMoreIndented = false, 18101 tmp, 18102 ch; 18103 ch = state.input.charCodeAt(state.position); 18104 if (ch === 0x7C) { 18105 folding = false; 18106 } else if (ch === 0x3E) { 18107 folding = true; 18108 } else { 18109 return false; 18110 } 18111 state.kind = 'scalar'; 18112 state.result = ''; 18113 while (ch !== 0) { 18114 ch = state.input.charCodeAt(++state.position); 18115 if (ch === 0x2B || ch === 0x2D) { 18116 if (CHOMPING_CLIP === chomping) { 18117 chomping = (ch === 0x2B) ? CHOMPING_KEEP : CHOMPING_STRIP; 18118 } else { 18119 throwError(state, 'repeat of a chomping mode identifier'); 18120 } 18121 } else if ((tmp = fromDecimalCode(ch)) >= 0) { 18122 if (tmp === 0) { 18123 throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); 18124 } else if (!detectedIndent) { 18125 textIndent = nodeIndent + tmp - 1; 18126 detectedIndent = true; 18127 } else { 18128 throwError(state, 'repeat of an indentation width identifier'); 18129 } 18130 } else { 18131 break; 18132 } 18133 } 18134 if (is_WHITE_SPACE(ch)) { 18135 do { ch = state.input.charCodeAt(++state.position); } 18136 while (is_WHITE_SPACE(ch)); 18137 if (ch === 0x23) { 18138 do { ch = state.input.charCodeAt(++state.position); } 18139 while (!is_EOL(ch) && (ch !== 0)); 18140 } 18141 } 18142 while (ch !== 0) { 18143 readLineBreak(state); 18144 state.lineIndent = 0; 18145 ch = state.input.charCodeAt(state.position); 18146 while ((!detectedIndent || state.lineIndent < textIndent) && 18147 (ch === 0x20)) { 18148 state.lineIndent++; 18149 ch = state.input.charCodeAt(++state.position); 18150 } 18151 if (!detectedIndent && state.lineIndent > textIndent) { 18152 textIndent = state.lineIndent; 18153 } 18154 if (is_EOL(ch)) { 18155 emptyLines++; 18156 continue; 18157 } 18158 if (state.lineIndent < textIndent) { 18159 if (chomping === CHOMPING_KEEP) { 18160 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); 18161 } else if (chomping === CHOMPING_CLIP) { 18162 if (didReadContent) { 18163 state.result += '\n'; 18164 } 18165 } 18166 break; 18167 } 18168 if (folding) { 18169 if (is_WHITE_SPACE(ch)) { 18170 atMoreIndented = true; 18171 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); 18172 } else if (atMoreIndented) { 18173 atMoreIndented = false; 18174 state.result += common.repeat('\n', emptyLines + 1); 18175 } else if (emptyLines === 0) { 18176 if (didReadContent) { 18177 state.result += ' '; 18178 } 18179 } else { 18180 state.result += common.repeat('\n', emptyLines); 18181 } 18182 } else { 18183 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); 18184 } 18185 didReadContent = true; 18186 detectedIndent = true; 18187 emptyLines = 0; 18188 captureStart = state.position; 18189 while (!is_EOL(ch) && (ch !== 0)) { 18190 ch = state.input.charCodeAt(++state.position); 18191 } 18192 captureSegment(state, captureStart, state.position, false); 18193 } 18194 return true; 18195} 18196function readBlockSequence(state, nodeIndent) { 18197 var _line, 18198 _tag = state.tag, 18199 _anchor = state.anchor, 18200 _result = [], 18201 following, 18202 detected = false, 18203 ch; 18204 if (state.firstTabInLine !== -1) return false; 18205 if (state.anchor !== null) { 18206 state.anchorMap[state.anchor] = _result; 18207 } 18208 ch = state.input.charCodeAt(state.position); 18209 while (ch !== 0) { 18210 if (state.firstTabInLine !== -1) { 18211 state.position = state.firstTabInLine; 18212 throwError(state, 'tab characters must not be used in indentation'); 18213 } 18214 if (ch !== 0x2D) { 18215 break; 18216 } 18217 following = state.input.charCodeAt(state.position + 1); 18218 if (!is_WS_OR_EOL(following)) { 18219 break; 18220 } 18221 detected = true; 18222 state.position++; 18223 if (skipSeparationSpace(state, true, -1)) { 18224 if (state.lineIndent <= nodeIndent) { 18225 _result.push(null); 18226 ch = state.input.charCodeAt(state.position); 18227 continue; 18228 } 18229 } 18230 _line = state.line; 18231 composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); 18232 _result.push(state.result); 18233 skipSeparationSpace(state, true, -1); 18234 ch = state.input.charCodeAt(state.position); 18235 if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { 18236 throwError(state, 'bad indentation of a sequence entry'); 18237 } else if (state.lineIndent < nodeIndent) { 18238 break; 18239 } 18240 } 18241 if (detected) { 18242 state.tag = _tag; 18243 state.anchor = _anchor; 18244 state.kind = 'sequence'; 18245 state.result = _result; 18246 return true; 18247 } 18248 return false; 18249} 18250function readBlockMapping(state, nodeIndent, flowIndent) { 18251 var following, 18252 allowCompact, 18253 _line, 18254 _keyLine, 18255 _keyLineStart, 18256 _keyPos, 18257 _tag = state.tag, 18258 _anchor = state.anchor, 18259 _result = {}, 18260 overridableKeys = Object.create(null), 18261 keyTag = null, 18262 keyNode = null, 18263 valueNode = null, 18264 atExplicitKey = false, 18265 detected = false, 18266 ch; 18267 if (state.firstTabInLine !== -1) return false; 18268 if (state.anchor !== null) { 18269 state.anchorMap[state.anchor] = _result; 18270 } 18271 ch = state.input.charCodeAt(state.position); 18272 while (ch !== 0) { 18273 if (!atExplicitKey && state.firstTabInLine !== -1) { 18274 state.position = state.firstTabInLine; 18275 throwError(state, 'tab characters must not be used in indentation'); 18276 } 18277 following = state.input.charCodeAt(state.position + 1); 18278 _line = state.line; 18279 if ((ch === 0x3F || ch === 0x3A) && is_WS_OR_EOL(following)) { 18280 if (ch === 0x3F) { 18281 if (atExplicitKey) { 18282 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); 18283 keyTag = keyNode = valueNode = null; 18284 } 18285 detected = true; 18286 atExplicitKey = true; 18287 allowCompact = true; 18288 } else if (atExplicitKey) { 18289 atExplicitKey = false; 18290 allowCompact = true; 18291 } else { 18292 throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); 18293 } 18294 state.position += 1; 18295 ch = following; 18296 } else { 18297 _keyLine = state.line; 18298 _keyLineStart = state.lineStart; 18299 _keyPos = state.position; 18300 if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { 18301 break; 18302 } 18303 if (state.line === _line) { 18304 ch = state.input.charCodeAt(state.position); 18305 while (is_WHITE_SPACE(ch)) { 18306 ch = state.input.charCodeAt(++state.position); 18307 } 18308 if (ch === 0x3A) { 18309 ch = state.input.charCodeAt(++state.position); 18310 if (!is_WS_OR_EOL(ch)) { 18311 throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); 18312 } 18313 if (atExplicitKey) { 18314 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); 18315 keyTag = keyNode = valueNode = null; 18316 } 18317 detected = true; 18318 atExplicitKey = false; 18319 allowCompact = false; 18320 keyTag = state.tag; 18321 keyNode = state.result; 18322 } else if (detected) { 18323 throwError(state, 'can not read an implicit mapping pair; a colon is missed'); 18324 } else { 18325 state.tag = _tag; 18326 state.anchor = _anchor; 18327 return true; 18328 } 18329 } else if (detected) { 18330 throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); 18331 } else { 18332 state.tag = _tag; 18333 state.anchor = _anchor; 18334 return true; 18335 } 18336 } 18337 if (state.line === _line || state.lineIndent > nodeIndent) { 18338 if (atExplicitKey) { 18339 _keyLine = state.line; 18340 _keyLineStart = state.lineStart; 18341 _keyPos = state.position; 18342 } 18343 if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { 18344 if (atExplicitKey) { 18345 keyNode = state.result; 18346 } else { 18347 valueNode = state.result; 18348 } 18349 } 18350 if (!atExplicitKey) { 18351 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); 18352 keyTag = keyNode = valueNode = null; 18353 } 18354 skipSeparationSpace(state, true, -1); 18355 ch = state.input.charCodeAt(state.position); 18356 } 18357 if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { 18358 throwError(state, 'bad indentation of a mapping entry'); 18359 } else if (state.lineIndent < nodeIndent) { 18360 break; 18361 } 18362 } 18363 if (atExplicitKey) { 18364 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); 18365 } 18366 if (detected) { 18367 state.tag = _tag; 18368 state.anchor = _anchor; 18369 state.kind = 'mapping'; 18370 state.result = _result; 18371 } 18372 return detected; 18373} 18374function readTagProperty(state) { 18375 var _position, 18376 isVerbatim = false, 18377 isNamed = false, 18378 tagHandle, 18379 tagName, 18380 ch; 18381 ch = state.input.charCodeAt(state.position); 18382 if (ch !== 0x21) return false; 18383 if (state.tag !== null) { 18384 throwError(state, 'duplication of a tag property'); 18385 } 18386 ch = state.input.charCodeAt(++state.position); 18387 if (ch === 0x3C) { 18388 isVerbatim = true; 18389 ch = state.input.charCodeAt(++state.position); 18390 } else if (ch === 0x21) { 18391 isNamed = true; 18392 tagHandle = '!!'; 18393 ch = state.input.charCodeAt(++state.position); 18394 } else { 18395 tagHandle = '!'; 18396 } 18397 _position = state.position; 18398 if (isVerbatim) { 18399 do { ch = state.input.charCodeAt(++state.position); } 18400 while (ch !== 0 && ch !== 0x3E); 18401 if (state.position < state.length) { 18402 tagName = state.input.slice(_position, state.position); 18403 ch = state.input.charCodeAt(++state.position); 18404 } else { 18405 throwError(state, 'unexpected end of the stream within a verbatim tag'); 18406 } 18407 } else { 18408 while (ch !== 0 && !is_WS_OR_EOL(ch)) { 18409 if (ch === 0x21) { 18410 if (!isNamed) { 18411 tagHandle = state.input.slice(_position - 1, state.position + 1); 18412 if (!PATTERN_TAG_HANDLE.test(tagHandle)) { 18413 throwError(state, 'named tag handle cannot contain such characters'); 18414 } 18415 isNamed = true; 18416 _position = state.position + 1; 18417 } else { 18418 throwError(state, 'tag suffix cannot contain exclamation marks'); 18419 } 18420 } 18421 ch = state.input.charCodeAt(++state.position); 18422 } 18423 tagName = state.input.slice(_position, state.position); 18424 if (PATTERN_FLOW_INDICATORS.test(tagName)) { 18425 throwError(state, 'tag suffix cannot contain flow indicator characters'); 18426 } 18427 } 18428 if (tagName && !PATTERN_TAG_URI.test(tagName)) { 18429 throwError(state, 'tag name cannot contain such characters: ' + tagName); 18430 } 18431 try { 18432 tagName = decodeURIComponent(tagName); 18433 } catch (err) { 18434 throwError(state, 'tag name is malformed: ' + tagName); 18435 } 18436 if (isVerbatim) { 18437 state.tag = tagName; 18438 } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) { 18439 state.tag = state.tagMap[tagHandle] + tagName; 18440 } else if (tagHandle === '!') { 18441 state.tag = '!' + tagName; 18442 } else if (tagHandle === '!!') { 18443 state.tag = 'tag:yaml.org,2002:' + tagName; 18444 } else { 18445 throwError(state, 'undeclared tag handle "' + tagHandle + '"'); 18446 } 18447 return true; 18448} 18449function readAnchorProperty(state) { 18450 var _position, 18451 ch; 18452 ch = state.input.charCodeAt(state.position); 18453 if (ch !== 0x26) return false; 18454 if (state.anchor !== null) { 18455 throwError(state, 'duplication of an anchor property'); 18456 } 18457 ch = state.input.charCodeAt(++state.position); 18458 _position = state.position; 18459 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { 18460 ch = state.input.charCodeAt(++state.position); 18461 } 18462 if (state.position === _position) { 18463 throwError(state, 'name of an anchor node must contain at least one character'); 18464 } 18465 state.anchor = state.input.slice(_position, state.position); 18466 return true; 18467} 18468function readAlias(state) { 18469 var _position, alias, 18470 ch; 18471 ch = state.input.charCodeAt(state.position); 18472 if (ch !== 0x2A) return false; 18473 ch = state.input.charCodeAt(++state.position); 18474 _position = state.position; 18475 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { 18476 ch = state.input.charCodeAt(++state.position); 18477 } 18478 if (state.position === _position) { 18479 throwError(state, 'name of an alias node must contain at least one character'); 18480 } 18481 alias = state.input.slice(_position, state.position); 18482 if (!_hasOwnProperty$1.call(state.anchorMap, alias)) { 18483 throwError(state, 'unidentified alias "' + alias + '"'); 18484 } 18485 state.result = state.anchorMap[alias]; 18486 skipSeparationSpace(state, true, -1); 18487 return true; 18488} 18489function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { 18490 var allowBlockStyles, 18491 allowBlockScalars, 18492 allowBlockCollections, 18493 indentStatus = 1, 18494 atNewLine = false, 18495 hasContent = false, 18496 typeIndex, 18497 typeQuantity, 18498 typeList, 18499 type, 18500 flowIndent, 18501 blockIndent; 18502 if (state.listener !== null) { 18503 state.listener('open', state); 18504 } 18505 state.tag = null; 18506 state.anchor = null; 18507 state.kind = null; 18508 state.result = null; 18509 allowBlockStyles = allowBlockScalars = allowBlockCollections = 18510 CONTEXT_BLOCK_OUT === nodeContext || 18511 CONTEXT_BLOCK_IN === nodeContext; 18512 if (allowToSeek) { 18513 if (skipSeparationSpace(state, true, -1)) { 18514 atNewLine = true; 18515 if (state.lineIndent > parentIndent) { 18516 indentStatus = 1; 18517 } else if (state.lineIndent === parentIndent) { 18518 indentStatus = 0; 18519 } else if (state.lineIndent < parentIndent) { 18520 indentStatus = -1; 18521 } 18522 } 18523 } 18524 if (indentStatus === 1) { 18525 while (readTagProperty(state) || readAnchorProperty(state)) { 18526 if (skipSeparationSpace(state, true, -1)) { 18527 atNewLine = true; 18528 allowBlockCollections = allowBlockStyles; 18529 if (state.lineIndent > parentIndent) { 18530 indentStatus = 1; 18531 } else if (state.lineIndent === parentIndent) { 18532 indentStatus = 0; 18533 } else if (state.lineIndent < parentIndent) { 18534 indentStatus = -1; 18535 } 18536 } else { 18537 allowBlockCollections = false; 18538 } 18539 } 18540 } 18541 if (allowBlockCollections) { 18542 allowBlockCollections = atNewLine || allowCompact; 18543 } 18544 if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { 18545 if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { 18546 flowIndent = parentIndent; 18547 } else { 18548 flowIndent = parentIndent + 1; 18549 } 18550 blockIndent = state.position - state.lineStart; 18551 if (indentStatus === 1) { 18552 if (allowBlockCollections && 18553 (readBlockSequence(state, blockIndent) || 18554 readBlockMapping(state, blockIndent, flowIndent)) || 18555 readFlowCollection(state, flowIndent)) { 18556 hasContent = true; 18557 } else { 18558 if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || 18559 readSingleQuotedScalar(state, flowIndent) || 18560 readDoubleQuotedScalar(state, flowIndent)) { 18561 hasContent = true; 18562 } else if (readAlias(state)) { 18563 hasContent = true; 18564 if (state.tag !== null || state.anchor !== null) { 18565 throwError(state, 'alias node should not have any properties'); 18566 } 18567 } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { 18568 hasContent = true; 18569 if (state.tag === null) { 18570 state.tag = '?'; 18571 } 18572 } 18573 if (state.anchor !== null) { 18574 state.anchorMap[state.anchor] = state.result; 18575 } 18576 } 18577 } else if (indentStatus === 0) { 18578 hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); 18579 } 18580 } 18581 if (state.tag === null) { 18582 if (state.anchor !== null) { 18583 state.anchorMap[state.anchor] = state.result; 18584 } 18585 } else if (state.tag === '?') { 18586 if (state.result !== null && state.kind !== 'scalar') { 18587 throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"'); 18588 } 18589 for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { 18590 type = state.implicitTypes[typeIndex]; 18591 if (type.resolve(state.result)) { 18592 state.result = type.construct(state.result); 18593 state.tag = type.tag; 18594 if (state.anchor !== null) { 18595 state.anchorMap[state.anchor] = state.result; 18596 } 18597 break; 18598 } 18599 } 18600 } else if (state.tag !== '!') { 18601 if (_hasOwnProperty$1.call(state.typeMap[state.kind || 'fallback'], state.tag)) { 18602 type = state.typeMap[state.kind || 'fallback'][state.tag]; 18603 } else { 18604 type = null; 18605 typeList = state.typeMap.multi[state.kind || 'fallback']; 18606 for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { 18607 if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { 18608 type = typeList[typeIndex]; 18609 break; 18610 } 18611 } 18612 } 18613 if (!type) { 18614 throwError(state, 'unknown tag !<' + state.tag + '>'); 18615 } 18616 if (state.result !== null && type.kind !== state.kind) { 18617 throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); 18618 } 18619 if (!type.resolve(state.result, state.tag)) { 18620 throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); 18621 } else { 18622 state.result = type.construct(state.result, state.tag); 18623 if (state.anchor !== null) { 18624 state.anchorMap[state.anchor] = state.result; 18625 } 18626 } 18627 } 18628 if (state.listener !== null) { 18629 state.listener('close', state); 18630 } 18631 return state.tag !== null || state.anchor !== null || hasContent; 18632} 18633function readDocument(state) { 18634 var documentStart = state.position, 18635 _position, 18636 directiveName, 18637 directiveArgs, 18638 hasDirectives = false, 18639 ch; 18640 state.version = null; 18641 state.checkLineBreaks = state.legacy; 18642 state.tagMap = Object.create(null); 18643 state.anchorMap = Object.create(null); 18644 while ((ch = state.input.charCodeAt(state.position)) !== 0) { 18645 skipSeparationSpace(state, true, -1); 18646 ch = state.input.charCodeAt(state.position); 18647 if (state.lineIndent > 0 || ch !== 0x25) { 18648 break; 18649 } 18650 hasDirectives = true; 18651 ch = state.input.charCodeAt(++state.position); 18652 _position = state.position; 18653 while (ch !== 0 && !is_WS_OR_EOL(ch)) { 18654 ch = state.input.charCodeAt(++state.position); 18655 } 18656 directiveName = state.input.slice(_position, state.position); 18657 directiveArgs = []; 18658 if (directiveName.length < 1) { 18659 throwError(state, 'directive name must not be less than one character in length'); 18660 } 18661 while (ch !== 0) { 18662 while (is_WHITE_SPACE(ch)) { 18663 ch = state.input.charCodeAt(++state.position); 18664 } 18665 if (ch === 0x23) { 18666 do { ch = state.input.charCodeAt(++state.position); } 18667 while (ch !== 0 && !is_EOL(ch)); 18668 break; 18669 } 18670 if (is_EOL(ch)) break; 18671 _position = state.position; 18672 while (ch !== 0 && !is_WS_OR_EOL(ch)) { 18673 ch = state.input.charCodeAt(++state.position); 18674 } 18675 directiveArgs.push(state.input.slice(_position, state.position)); 18676 } 18677 if (ch !== 0) readLineBreak(state); 18678 if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) { 18679 directiveHandlers[directiveName](state, directiveName, directiveArgs); 18680 } else { 18681 throwWarning(state, 'unknown document directive "' + directiveName + '"'); 18682 } 18683 } 18684 skipSeparationSpace(state, true, -1); 18685 if (state.lineIndent === 0 && 18686 state.input.charCodeAt(state.position) === 0x2D && 18687 state.input.charCodeAt(state.position + 1) === 0x2D && 18688 state.input.charCodeAt(state.position + 2) === 0x2D) { 18689 state.position += 3; 18690 skipSeparationSpace(state, true, -1); 18691 } else if (hasDirectives) { 18692 throwError(state, 'directives end mark is expected'); 18693 } 18694 composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); 18695 skipSeparationSpace(state, true, -1); 18696 if (state.checkLineBreaks && 18697 PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { 18698 throwWarning(state, 'non-ASCII line breaks are interpreted as content'); 18699 } 18700 state.documents.push(state.result); 18701 if (state.position === state.lineStart && testDocumentSeparator(state)) { 18702 if (state.input.charCodeAt(state.position) === 0x2E) { 18703 state.position += 3; 18704 skipSeparationSpace(state, true, -1); 18705 } 18706 return; 18707 } 18708 if (state.position < (state.length - 1)) { 18709 throwError(state, 'end of the stream or a document separator is expected'); 18710 } else { 18711 return; 18712 } 18713} 18714function loadDocuments(input, options) { 18715 input = String(input); 18716 options = options || {}; 18717 if (input.length !== 0) { 18718 if (input.charCodeAt(input.length - 1) !== 0x0A && 18719 input.charCodeAt(input.length - 1) !== 0x0D) { 18720 input += '\n'; 18721 } 18722 if (input.charCodeAt(0) === 0xFEFF) { 18723 input = input.slice(1); 18724 } 18725 } 18726 var state = new State$1(input, options); 18727 var nullpos = input.indexOf('\0'); 18728 if (nullpos !== -1) { 18729 state.position = nullpos; 18730 throwError(state, 'null byte is not allowed in input'); 18731 } 18732 state.input += '\0'; 18733 while (state.input.charCodeAt(state.position) === 0x20) { 18734 state.lineIndent += 1; 18735 state.position += 1; 18736 } 18737 while (state.position < (state.length - 1)) { 18738 readDocument(state); 18739 } 18740 return state.documents; 18741} 18742function loadAll$1(input, iterator, options) { 18743 if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { 18744 options = iterator; 18745 iterator = null; 18746 } 18747 var documents = loadDocuments(input, options); 18748 if (typeof iterator !== 'function') { 18749 return documents; 18750 } 18751 for (var index = 0, length = documents.length; index < length; index += 1) { 18752 iterator(documents[index]); 18753 } 18754} 18755function load$1(input, options) { 18756 var documents = loadDocuments(input, options); 18757 if (documents.length === 0) { 18758 return undefined; 18759 } else if (documents.length === 1) { 18760 return documents[0]; 18761 } 18762 throw new exception('expected a single document in the stream, but found more'); 18763} 18764var loadAll_1 = loadAll$1; 18765var load_1 = load$1; 18766var loader = { 18767 loadAll: loadAll_1, 18768 load: load_1 18769}; 18770var _toString = Object.prototype.toString; 18771var _hasOwnProperty = Object.prototype.hasOwnProperty; 18772var CHAR_BOM = 0xFEFF; 18773var CHAR_TAB = 0x09; 18774var CHAR_LINE_FEED = 0x0A; 18775var CHAR_CARRIAGE_RETURN = 0x0D; 18776var CHAR_SPACE = 0x20; 18777var CHAR_EXCLAMATION = 0x21; 18778var CHAR_DOUBLE_QUOTE = 0x22; 18779var CHAR_SHARP = 0x23; 18780var CHAR_PERCENT = 0x25; 18781var CHAR_AMPERSAND = 0x26; 18782var CHAR_SINGLE_QUOTE = 0x27; 18783var CHAR_ASTERISK = 0x2A; 18784var CHAR_COMMA = 0x2C; 18785var CHAR_MINUS = 0x2D; 18786var CHAR_COLON = 0x3A; 18787var CHAR_EQUALS = 0x3D; 18788var CHAR_GREATER_THAN = 0x3E; 18789var CHAR_QUESTION = 0x3F; 18790var CHAR_COMMERCIAL_AT = 0x40; 18791var CHAR_LEFT_SQUARE_BRACKET = 0x5B; 18792var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; 18793var CHAR_GRAVE_ACCENT = 0x60; 18794var CHAR_LEFT_CURLY_BRACKET = 0x7B; 18795var CHAR_VERTICAL_LINE = 0x7C; 18796var CHAR_RIGHT_CURLY_BRACKET = 0x7D; 18797var ESCAPE_SEQUENCES = {}; 18798ESCAPE_SEQUENCES[0x00] = '\\0'; 18799ESCAPE_SEQUENCES[0x07] = '\\a'; 18800ESCAPE_SEQUENCES[0x08] = '\\b'; 18801ESCAPE_SEQUENCES[0x09] = '\\t'; 18802ESCAPE_SEQUENCES[0x0A] = '\\n'; 18803ESCAPE_SEQUENCES[0x0B] = '\\v'; 18804ESCAPE_SEQUENCES[0x0C] = '\\f'; 18805ESCAPE_SEQUENCES[0x0D] = '\\r'; 18806ESCAPE_SEQUENCES[0x1B] = '\\e'; 18807ESCAPE_SEQUENCES[0x22] = '\\"'; 18808ESCAPE_SEQUENCES[0x5C] = '\\\\'; 18809ESCAPE_SEQUENCES[0x85] = '\\N'; 18810ESCAPE_SEQUENCES[0xA0] = '\\_'; 18811ESCAPE_SEQUENCES[0x2028] = '\\L'; 18812ESCAPE_SEQUENCES[0x2029] = '\\P'; 18813var DEPRECATED_BOOLEANS_SYNTAX = [ 18814 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', 18815 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' 18816]; 18817var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; 18818function compileStyleMap(schema, map) { 18819 var result, keys, index, length, tag, style, type; 18820 if (map === null) return {}; 18821 result = {}; 18822 keys = Object.keys(map); 18823 for (index = 0, length = keys.length; index < length; index += 1) { 18824 tag = keys[index]; 18825 style = String(map[tag]); 18826 if (tag.slice(0, 2) === '!!') { 18827 tag = 'tag:yaml.org,2002:' + tag.slice(2); 18828 } 18829 type = schema.compiledTypeMap['fallback'][tag]; 18830 if (type && _hasOwnProperty.call(type.styleAliases, style)) { 18831 style = type.styleAliases[style]; 18832 } 18833 result[tag] = style; 18834 } 18835 return result; 18836} 18837function encodeHex(character) { 18838 var string, handle, length; 18839 string = character.toString(16).toUpperCase(); 18840 if (character <= 0xFF) { 18841 handle = 'x'; 18842 length = 2; 18843 } else if (character <= 0xFFFF) { 18844 handle = 'u'; 18845 length = 4; 18846 } else if (character <= 0xFFFFFFFF) { 18847 handle = 'U'; 18848 length = 8; 18849 } else { 18850 throw new exception('code point within a string may not be greater than 0xFFFFFFFF'); 18851 } 18852 return '\\' + handle + common.repeat('0', length - string.length) + string; 18853} 18854var QUOTING_TYPE_SINGLE = 1, 18855 QUOTING_TYPE_DOUBLE = 2; 18856function State(options) { 18857 this.schema = options['schema'] || _default; 18858 this.indent = Math.max(1, (options['indent'] || 2)); 18859 this.noArrayIndent = options['noArrayIndent'] || false; 18860 this.skipInvalid = options['skipInvalid'] || false; 18861 this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); 18862 this.styleMap = compileStyleMap(this.schema, options['styles'] || null); 18863 this.sortKeys = options['sortKeys'] || false; 18864 this.lineWidth = options['lineWidth'] || 80; 18865 this.noRefs = options['noRefs'] || false; 18866 this.noCompatMode = options['noCompatMode'] || false; 18867 this.condenseFlow = options['condenseFlow'] || false; 18868 this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE; 18869 this.forceQuotes = options['forceQuotes'] || false; 18870 this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null; 18871 this.implicitTypes = this.schema.compiledImplicit; 18872 this.explicitTypes = this.schema.compiledExplicit; 18873 this.tag = null; 18874 this.result = ''; 18875 this.duplicates = []; 18876 this.usedDuplicates = null; 18877} 18878function indentString(string, spaces) { 18879 var ind = common.repeat(' ', spaces), 18880 position = 0, 18881 next = -1, 18882 result = '', 18883 line, 18884 length = string.length; 18885 while (position < length) { 18886 next = string.indexOf('\n', position); 18887 if (next === -1) { 18888 line = string.slice(position); 18889 position = length; 18890 } else { 18891 line = string.slice(position, next + 1); 18892 position = next + 1; 18893 } 18894 if (line.length && line !== '\n') result += ind; 18895 result += line; 18896 } 18897 return result; 18898} 18899function generateNextLine(state, level) { 18900 return '\n' + common.repeat(' ', state.indent * level); 18901} 18902function testImplicitResolving(state, str) { 18903 var index, length, type; 18904 for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { 18905 type = state.implicitTypes[index]; 18906 if (type.resolve(str)) { 18907 return true; 18908 } 18909 } 18910 return false; 18911} 18912function isWhitespace(c) { 18913 return c === CHAR_SPACE || c === CHAR_TAB; 18914} 18915function isPrintable(c) { 18916 return (0x00020 <= c && c <= 0x00007E) 18917 || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) 18918 || ((0x0E000 <= c && c <= 0x00FFFD) && c !== CHAR_BOM) 18919 || (0x10000 <= c && c <= 0x10FFFF); 18920} 18921function isNsCharOrWhitespace(c) { 18922 return isPrintable(c) 18923 && c !== CHAR_BOM 18924 && c !== CHAR_CARRIAGE_RETURN 18925 && c !== CHAR_LINE_FEED; 18926} 18927function isPlainSafe(c, prev, inblock) { 18928 var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); 18929 var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); 18930 return ( 18931 inblock ? 18932 cIsNsCharOrWhitespace 18933 : cIsNsCharOrWhitespace 18934 && c !== CHAR_COMMA 18935 && c !== CHAR_LEFT_SQUARE_BRACKET 18936 && c !== CHAR_RIGHT_SQUARE_BRACKET 18937 && c !== CHAR_LEFT_CURLY_BRACKET 18938 && c !== CHAR_RIGHT_CURLY_BRACKET 18939 ) 18940 && c !== CHAR_SHARP 18941 && !(prev === CHAR_COLON && !cIsNsChar) 18942 || (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) 18943 || (prev === CHAR_COLON && cIsNsChar); 18944} 18945function isPlainSafeFirst(c) { 18946 return isPrintable(c) && c !== CHAR_BOM 18947 && !isWhitespace(c) 18948 && c !== CHAR_MINUS 18949 && c !== CHAR_QUESTION 18950 && c !== CHAR_COLON 18951 && c !== CHAR_COMMA 18952 && c !== CHAR_LEFT_SQUARE_BRACKET 18953 && c !== CHAR_RIGHT_SQUARE_BRACKET 18954 && c !== CHAR_LEFT_CURLY_BRACKET 18955 && c !== CHAR_RIGHT_CURLY_BRACKET 18956 && c !== CHAR_SHARP 18957 && c !== CHAR_AMPERSAND 18958 && c !== CHAR_ASTERISK 18959 && c !== CHAR_EXCLAMATION 18960 && c !== CHAR_VERTICAL_LINE 18961 && c !== CHAR_EQUALS 18962 && c !== CHAR_GREATER_THAN 18963 && c !== CHAR_SINGLE_QUOTE 18964 && c !== CHAR_DOUBLE_QUOTE 18965 && c !== CHAR_PERCENT 18966 && c !== CHAR_COMMERCIAL_AT 18967 && c !== CHAR_GRAVE_ACCENT; 18968} 18969function isPlainSafeLast(c) { 18970 return !isWhitespace(c) && c !== CHAR_COLON; 18971} 18972function codePointAt(string, pos) { 18973 var first = string.charCodeAt(pos), second; 18974 if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) { 18975 second = string.charCodeAt(pos + 1); 18976 if (second >= 0xDC00 && second <= 0xDFFF) { 18977 return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; 18978 } 18979 } 18980 return first; 18981} 18982function needIndentIndicator(string) { 18983 var leadingSpaceRe = /^\n* /; 18984 return leadingSpaceRe.test(string); 18985} 18986var STYLE_PLAIN = 1, 18987 STYLE_SINGLE = 2, 18988 STYLE_LITERAL = 3, 18989 STYLE_FOLDED = 4, 18990 STYLE_DOUBLE = 5; 18991function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, 18992 testAmbiguousType, quotingType, forceQuotes, inblock) { 18993 var i; 18994 var char = 0; 18995 var prevChar = null; 18996 var hasLineBreak = false; 18997 var hasFoldableLine = false; 18998 var shouldTrackWidth = lineWidth !== -1; 18999 var previousLineBreak = -1; 19000 var plain = isPlainSafeFirst(codePointAt(string, 0)) 19001 && isPlainSafeLast(codePointAt(string, string.length - 1)); 19002 if (singleLineOnly || forceQuotes) { 19003 for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { 19004 char = codePointAt(string, i); 19005 if (!isPrintable(char)) { 19006 return STYLE_DOUBLE; 19007 } 19008 plain = plain && isPlainSafe(char, prevChar, inblock); 19009 prevChar = char; 19010 } 19011 } else { 19012 for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { 19013 char = codePointAt(string, i); 19014 if (char === CHAR_LINE_FEED) { 19015 hasLineBreak = true; 19016 if (shouldTrackWidth) { 19017 hasFoldableLine = hasFoldableLine || 19018 (i - previousLineBreak - 1 > lineWidth && 19019 string[previousLineBreak + 1] !== ' '); 19020 previousLineBreak = i; 19021 } 19022 } else if (!isPrintable(char)) { 19023 return STYLE_DOUBLE; 19024 } 19025 plain = plain && isPlainSafe(char, prevChar, inblock); 19026 prevChar = char; 19027 } 19028 hasFoldableLine = hasFoldableLine || (shouldTrackWidth && 19029 (i - previousLineBreak - 1 > lineWidth && 19030 string[previousLineBreak + 1] !== ' ')); 19031 } 19032 if (!hasLineBreak && !hasFoldableLine) { 19033 if (plain && !forceQuotes && !testAmbiguousType(string)) { 19034 return STYLE_PLAIN; 19035 } 19036 return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; 19037 } 19038 if (indentPerLevel > 9 && needIndentIndicator(string)) { 19039 return STYLE_DOUBLE; 19040 } 19041 if (!forceQuotes) { 19042 return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; 19043 } 19044 return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; 19045} 19046function writeScalar(state, string, level, iskey, inblock) { 19047 state.dump = (function () { 19048 if (string.length === 0) { 19049 return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"; 19050 } 19051 if (!state.noCompatMode) { 19052 if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { 19053 return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'"); 19054 } 19055 } 19056 var indent = state.indent * Math.max(1, level); 19057 var lineWidth = state.lineWidth === -1 19058 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); 19059 var singleLineOnly = iskey 19060 || (state.flowLevel > -1 && level >= state.flowLevel); 19061 function testAmbiguity(string) { 19062 return testImplicitResolving(state, string); 19063 } 19064 switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, 19065 testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) { 19066 case STYLE_PLAIN: 19067 return string; 19068 case STYLE_SINGLE: 19069 return "'" + string.replace(/'/g, "''") + "'"; 19070 case STYLE_LITERAL: 19071 return '|' + blockHeader(string, state.indent) 19072 + dropEndingNewline(indentString(string, indent)); 19073 case STYLE_FOLDED: 19074 return '>' + blockHeader(string, state.indent) 19075 + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); 19076 case STYLE_DOUBLE: 19077 return '"' + escapeString(string) + '"'; 19078 default: 19079 throw new exception('impossible error: invalid scalar style'); 19080 } 19081 }()); 19082} 19083function blockHeader(string, indentPerLevel) { 19084 var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; 19085 var clip = string[string.length - 1] === '\n'; 19086 var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); 19087 var chomp = keep ? '+' : (clip ? '' : '-'); 19088 return indentIndicator + chomp + '\n'; 19089} 19090function dropEndingNewline(string) { 19091 return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; 19092} 19093function foldString(string, width) { 19094 var lineRe = /(\n+)([^\n]*)/g; 19095 var result = (function () { 19096 var nextLF = string.indexOf('\n'); 19097 nextLF = nextLF !== -1 ? nextLF : string.length; 19098 lineRe.lastIndex = nextLF; 19099 return foldLine(string.slice(0, nextLF), width); 19100 }()); 19101 var prevMoreIndented = string[0] === '\n' || string[0] === ' '; 19102 var moreIndented; 19103 var match; 19104 while ((match = lineRe.exec(string))) { 19105 var prefix = match[1], line = match[2]; 19106 moreIndented = (line[0] === ' '); 19107 result += prefix 19108 + (!prevMoreIndented && !moreIndented && line !== '' 19109 ? '\n' : '') 19110 + foldLine(line, width); 19111 prevMoreIndented = moreIndented; 19112 } 19113 return result; 19114} 19115function foldLine(line, width) { 19116 if (line === '' || line[0] === ' ') return line; 19117 var breakRe = / [^ ]/g; 19118 var match; 19119 var start = 0, end, curr = 0, next = 0; 19120 var result = ''; 19121 while ((match = breakRe.exec(line))) { 19122 next = match.index; 19123 if (next - start > width) { 19124 end = (curr > start) ? curr : next; 19125 result += '\n' + line.slice(start, end); 19126 start = end + 1; 19127 } 19128 curr = next; 19129 } 19130 result += '\n'; 19131 if (line.length - start > width && curr > start) { 19132 result += line.slice(start, curr) + '\n' + line.slice(curr + 1); 19133 } else { 19134 result += line.slice(start); 19135 } 19136 return result.slice(1); 19137} 19138function escapeString(string) { 19139 var result = ''; 19140 var char = 0; 19141 var escapeSeq; 19142 for (var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { 19143 char = codePointAt(string, i); 19144 escapeSeq = ESCAPE_SEQUENCES[char]; 19145 if (!escapeSeq && isPrintable(char)) { 19146 result += string[i]; 19147 if (char >= 0x10000) result += string[i + 1]; 19148 } else { 19149 result += escapeSeq || encodeHex(char); 19150 } 19151 } 19152 return result; 19153} 19154function writeFlowSequence(state, level, object) { 19155 var _result = '', 19156 _tag = state.tag, 19157 index, 19158 length, 19159 value; 19160 for (index = 0, length = object.length; index < length; index += 1) { 19161 value = object[index]; 19162 if (state.replacer) { 19163 value = state.replacer.call(object, String(index), value); 19164 } 19165 if (writeNode(state, level, value, false, false) || 19166 (typeof value === 'undefined' && 19167 writeNode(state, level, null, false, false))) { 19168 if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : ''); 19169 _result += state.dump; 19170 } 19171 } 19172 state.tag = _tag; 19173 state.dump = '[' + _result + ']'; 19174} 19175function writeBlockSequence(state, level, object, compact) { 19176 var _result = '', 19177 _tag = state.tag, 19178 index, 19179 length, 19180 value; 19181 for (index = 0, length = object.length; index < length; index += 1) { 19182 value = object[index]; 19183 if (state.replacer) { 19184 value = state.replacer.call(object, String(index), value); 19185 } 19186 if (writeNode(state, level + 1, value, true, true, false, true) || 19187 (typeof value === 'undefined' && 19188 writeNode(state, level + 1, null, true, true, false, true))) { 19189 if (!compact || _result !== '') { 19190 _result += generateNextLine(state, level); 19191 } 19192 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { 19193 _result += '-'; 19194 } else { 19195 _result += '- '; 19196 } 19197 _result += state.dump; 19198 } 19199 } 19200 state.tag = _tag; 19201 state.dump = _result || '[]'; 19202} 19203function writeFlowMapping(state, level, object) { 19204 var _result = '', 19205 _tag = state.tag, 19206 objectKeyList = Object.keys(object), 19207 index, 19208 length, 19209 objectKey, 19210 objectValue, 19211 pairBuffer; 19212 for (index = 0, length = objectKeyList.length; index < length; index += 1) { 19213 pairBuffer = ''; 19214 if (_result !== '') pairBuffer += ', '; 19215 if (state.condenseFlow) pairBuffer += '"'; 19216 objectKey = objectKeyList[index]; 19217 objectValue = object[objectKey]; 19218 if (state.replacer) { 19219 objectValue = state.replacer.call(object, objectKey, objectValue); 19220 } 19221 if (!writeNode(state, level, objectKey, false, false)) { 19222 continue; 19223 } 19224 if (state.dump.length > 1024) pairBuffer += '? '; 19225 pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); 19226 if (!writeNode(state, level, objectValue, false, false)) { 19227 continue; 19228 } 19229 pairBuffer += state.dump; 19230 _result += pairBuffer; 19231 } 19232 state.tag = _tag; 19233 state.dump = '{' + _result + '}'; 19234} 19235function writeBlockMapping(state, level, object, compact) { 19236 var _result = '', 19237 _tag = state.tag, 19238 objectKeyList = Object.keys(object), 19239 index, 19240 length, 19241 objectKey, 19242 objectValue, 19243 explicitPair, 19244 pairBuffer; 19245 if (state.sortKeys === true) { 19246 objectKeyList.sort(); 19247 } else if (typeof state.sortKeys === 'function') { 19248 objectKeyList.sort(state.sortKeys); 19249 } else if (state.sortKeys) { 19250 throw new exception('sortKeys must be a boolean or a function'); 19251 } 19252 for (index = 0, length = objectKeyList.length; index < length; index += 1) { 19253 pairBuffer = ''; 19254 if (!compact || _result !== '') { 19255 pairBuffer += generateNextLine(state, level); 19256 } 19257 objectKey = objectKeyList[index]; 19258 objectValue = object[objectKey]; 19259 if (state.replacer) { 19260 objectValue = state.replacer.call(object, objectKey, objectValue); 19261 } 19262 if (!writeNode(state, level + 1, objectKey, true, true, true)) { 19263 continue; 19264 } 19265 explicitPair = (state.tag !== null && state.tag !== '?') || 19266 (state.dump && state.dump.length > 1024); 19267 if (explicitPair) { 19268 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { 19269 pairBuffer += '?'; 19270 } else { 19271 pairBuffer += '? '; 19272 } 19273 } 19274 pairBuffer += state.dump; 19275 if (explicitPair) { 19276 pairBuffer += generateNextLine(state, level); 19277 } 19278 if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { 19279 continue; 19280 } 19281 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { 19282 pairBuffer += ':'; 19283 } else { 19284 pairBuffer += ': '; 19285 } 19286 pairBuffer += state.dump; 19287 _result += pairBuffer; 19288 } 19289 state.tag = _tag; 19290 state.dump = _result || '{}'; 19291} 19292function detectType(state, object, explicit) { 19293 var _result, typeList, index, length, type, style; 19294 typeList = explicit ? state.explicitTypes : state.implicitTypes; 19295 for (index = 0, length = typeList.length; index < length; index += 1) { 19296 type = typeList[index]; 19297 if ((type.instanceOf || type.predicate) && 19298 (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && 19299 (!type.predicate || type.predicate(object))) { 19300 if (explicit) { 19301 if (type.multi && type.representName) { 19302 state.tag = type.representName(object); 19303 } else { 19304 state.tag = type.tag; 19305 } 19306 } else { 19307 state.tag = '?'; 19308 } 19309 if (type.represent) { 19310 style = state.styleMap[type.tag] || type.defaultStyle; 19311 if (_toString.call(type.represent) === '[object Function]') { 19312 _result = type.represent(object, style); 19313 } else if (_hasOwnProperty.call(type.represent, style)) { 19314 _result = type.represent[style](object, style); 19315 } else { 19316 throw new exception('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); 19317 } 19318 state.dump = _result; 19319 } 19320 return true; 19321 } 19322 } 19323 return false; 19324} 19325function writeNode(state, level, object, block, compact, iskey, isblockseq) { 19326 state.tag = null; 19327 state.dump = object; 19328 if (!detectType(state, object, false)) { 19329 detectType(state, object, true); 19330 } 19331 var type = _toString.call(state.dump); 19332 var inblock = block; 19333 var tagStr; 19334 if (block) { 19335 block = (state.flowLevel < 0 || state.flowLevel > level); 19336 } 19337 var objectOrArray = type === '[object Object]' || type === '[object Array]', 19338 duplicateIndex, 19339 duplicate; 19340 if (objectOrArray) { 19341 duplicateIndex = state.duplicates.indexOf(object); 19342 duplicate = duplicateIndex !== -1; 19343 } 19344 if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { 19345 compact = false; 19346 } 19347 if (duplicate && state.usedDuplicates[duplicateIndex]) { 19348 state.dump = '*ref_' + duplicateIndex; 19349 } else { 19350 if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { 19351 state.usedDuplicates[duplicateIndex] = true; 19352 } 19353 if (type === '[object Object]') { 19354 if (block && (Object.keys(state.dump).length !== 0)) { 19355 writeBlockMapping(state, level, state.dump, compact); 19356 if (duplicate) { 19357 state.dump = '&ref_' + duplicateIndex + state.dump; 19358 } 19359 } else { 19360 writeFlowMapping(state, level, state.dump); 19361 if (duplicate) { 19362 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; 19363 } 19364 } 19365 } else if (type === '[object Array]') { 19366 if (block && (state.dump.length !== 0)) { 19367 if (state.noArrayIndent && !isblockseq && level > 0) { 19368 writeBlockSequence(state, level - 1, state.dump, compact); 19369 } else { 19370 writeBlockSequence(state, level, state.dump, compact); 19371 } 19372 if (duplicate) { 19373 state.dump = '&ref_' + duplicateIndex + state.dump; 19374 } 19375 } else { 19376 writeFlowSequence(state, level, state.dump); 19377 if (duplicate) { 19378 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; 19379 } 19380 } 19381 } else if (type === '[object String]') { 19382 if (state.tag !== '?') { 19383 writeScalar(state, state.dump, level, iskey, inblock); 19384 } 19385 } else if (type === '[object Undefined]') { 19386 return false; 19387 } else { 19388 if (state.skipInvalid) return false; 19389 throw new exception('unacceptable kind of an object to dump ' + type); 19390 } 19391 if (state.tag !== null && state.tag !== '?') { 19392 tagStr = encodeURI( 19393 state.tag[0] === '!' ? state.tag.slice(1) : state.tag 19394 ).replace(/!/g, '%21'); 19395 if (state.tag[0] === '!') { 19396 tagStr = '!' + tagStr; 19397 } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') { 19398 tagStr = '!!' + tagStr.slice(18); 19399 } else { 19400 tagStr = '!<' + tagStr + '>'; 19401 } 19402 state.dump = tagStr + ' ' + state.dump; 19403 } 19404 } 19405 return true; 19406} 19407function getDuplicateReferences(object, state) { 19408 var objects = [], 19409 duplicatesIndexes = [], 19410 index, 19411 length; 19412 inspectNode(object, objects, duplicatesIndexes); 19413 for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { 19414 state.duplicates.push(objects[duplicatesIndexes[index]]); 19415 } 19416 state.usedDuplicates = new Array(length); 19417} 19418function inspectNode(object, objects, duplicatesIndexes) { 19419 var objectKeyList, 19420 index, 19421 length; 19422 if (object !== null && typeof object === 'object') { 19423 index = objects.indexOf(object); 19424 if (index !== -1) { 19425 if (duplicatesIndexes.indexOf(index) === -1) { 19426 duplicatesIndexes.push(index); 19427 } 19428 } else { 19429 objects.push(object); 19430 if (Array.isArray(object)) { 19431 for (index = 0, length = object.length; index < length; index += 1) { 19432 inspectNode(object[index], objects, duplicatesIndexes); 19433 } 19434 } else { 19435 objectKeyList = Object.keys(object); 19436 for (index = 0, length = objectKeyList.length; index < length; index += 1) { 19437 inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); 19438 } 19439 } 19440 } 19441 } 19442} 19443function dump$1(input, options) { 19444 options = options || {}; 19445 var state = new State(options); 19446 if (!state.noRefs) getDuplicateReferences(input, state); 19447 var value = input; 19448 if (state.replacer) { 19449 value = state.replacer.call({ '': value }, '', value); 19450 } 19451 if (writeNode(state, 0, value, true, true)) return state.dump + '\n'; 19452 return ''; 19453} 19454var dump_1 = dump$1; 19455var dumper = { 19456 dump: dump_1 19457}; 19458function renamed(from, to) { 19459 return function () { 19460 throw new Error('Function yaml.' + from + ' is removed in js-yaml 4. ' + 19461 'Use yaml.' + to + ' instead, which is now safe by default.'); 19462 }; 19463} 19464var Type = type; 19465var Schema = schema; 19466var FAILSAFE_SCHEMA = failsafe; 19467var JSON_SCHEMA = json; 19468var CORE_SCHEMA = core; 19469var DEFAULT_SCHEMA = _default; 19470var load = loader.load; 19471var loadAll = loader.loadAll; 19472var dump = dumper.dump; 19473var YAMLException = exception; 19474var types = { 19475 binary: binary, 19476 float: float, 19477 map: map, 19478 null: _null, 19479 pairs: pairs, 19480 set: set, 19481 timestamp: timestamp, 19482 bool: bool, 19483 int: int, 19484 merge: merge, 19485 omap: omap, 19486 seq: seq, 19487 str: str 19488}; 19489var safeLoad = renamed('safeLoad', 'load'); 19490var safeLoadAll = renamed('safeLoadAll', 'loadAll'); 19491var safeDump = renamed('safeDump', 'dump'); 19492var jsYaml = { 19493 Type: Type, 19494 Schema: Schema, 19495 FAILSAFE_SCHEMA: FAILSAFE_SCHEMA, 19496 JSON_SCHEMA: JSON_SCHEMA, 19497 CORE_SCHEMA: CORE_SCHEMA, 19498 DEFAULT_SCHEMA: DEFAULT_SCHEMA, 19499 load: load, 19500 loadAll: loadAll, 19501 dump: dump, 19502 YAMLException: YAMLException, 19503 types: types, 19504 safeLoad: safeLoad, 19505 safeLoadAll: safeLoadAll, 19506 safeDump: safeDump 19507}; 19508 19509const debug$1 = ( 19510 typeof process === 'object' && 19511 process.env && 19512 process.env.NODE_DEBUG && 19513 /\bsemver\b/i.test(process.env.NODE_DEBUG) 19514) ? (...args) => console.error('SEMVER', ...args) 19515 : () => {}; 19516var debug_1 = debug$1; 19517getDefaultExportFromCjs(debug_1); 19518 19519const SEMVER_SPEC_VERSION = '2.0.0'; 19520const MAX_LENGTH$1 = 256; 19521const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER || 19522 9007199254740991; 19523const MAX_SAFE_COMPONENT_LENGTH = 16; 19524const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH$1 - 6; 19525const RELEASE_TYPES = [ 19526 'major', 19527 'premajor', 19528 'minor', 19529 'preminor', 19530 'patch', 19531 'prepatch', 19532 'prerelease', 19533]; 19534var constants = { 19535 MAX_LENGTH: MAX_LENGTH$1, 19536 MAX_SAFE_COMPONENT_LENGTH, 19537 MAX_SAFE_BUILD_LENGTH, 19538 MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1, 19539 RELEASE_TYPES, 19540 SEMVER_SPEC_VERSION, 19541 FLAG_INCLUDE_PRERELEASE: 0b001, 19542 FLAG_LOOSE: 0b010, 19543}; 19544getDefaultExportFromCjs(constants); 19545 19546var re$1 = {exports: {}}; 19547 19548(function (module, exports) { 19549 const { 19550 MAX_SAFE_COMPONENT_LENGTH, 19551 MAX_SAFE_BUILD_LENGTH, 19552 MAX_LENGTH, 19553 } = constants; 19554 const debug = debug_1; 19555 exports = module.exports = {}; 19556 const re = exports.re = []; 19557 const safeRe = exports.safeRe = []; 19558 const src = exports.src = []; 19559 const t = exports.t = {}; 19560 let R = 0; 19561 const LETTERDASHNUMBER = '[a-zA-Z0-9-]'; 19562 const safeRegexReplacements = [ 19563 ['\\s', 1], 19564 ['\\d', MAX_LENGTH], 19565 [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH], 19566 ]; 19567 const makeSafeRegex = (value) => { 19568 for (const [token, max] of safeRegexReplacements) { 19569 value = value 19570 .split(`${token}*`).join(`${token}{0,${max}}`) 19571 .split(`${token}+`).join(`${token}{1,${max}}`); 19572 } 19573 return value 19574 }; 19575 const createToken = (name, value, isGlobal) => { 19576 const safe = makeSafeRegex(value); 19577 const index = R++; 19578 debug(name, index, value); 19579 t[name] = index; 19580 src[index] = value; 19581 re[index] = new RegExp(value, isGlobal ? 'g' : undefined); 19582 safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined); 19583 }; 19584 createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*'); 19585 createToken('NUMERICIDENTIFIERLOOSE', '\\d+'); 19586 createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`); 19587 createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + 19588 `(${src[t.NUMERICIDENTIFIER]})\\.` + 19589 `(${src[t.NUMERICIDENTIFIER]})`); 19590 createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + 19591 `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + 19592 `(${src[t.NUMERICIDENTIFIERLOOSE]})`); 19593 createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER] 19594 }|${src[t.NONNUMERICIDENTIFIER]})`); 19595 createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE] 19596 }|${src[t.NONNUMERICIDENTIFIER]})`); 19597 createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER] 19598 }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`); 19599 createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE] 19600 }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); 19601 createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`); 19602 createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] 19603 }(?:\\.${src[t.BUILDIDENTIFIER]})*))`); 19604 createToken('FULLPLAIN', `v?${src[t.MAINVERSION] 19605 }${src[t.PRERELEASE]}?${ 19606 src[t.BUILD]}?`); 19607 createToken('FULL', `^${src[t.FULLPLAIN]}$`); 19608 createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE] 19609 }${src[t.PRERELEASELOOSE]}?${ 19610 src[t.BUILD]}?`); 19611 createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`); 19612 createToken('GTLT', '((?:<|>)?=?)'); 19613 createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`); 19614 createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`); 19615 createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + 19616 `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + 19617 `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + 19618 `(?:${src[t.PRERELEASE]})?${ 19619 src[t.BUILD]}?` + 19620 `)?)?`); 19621 createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + 19622 `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + 19623 `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + 19624 `(?:${src[t.PRERELEASELOOSE]})?${ 19625 src[t.BUILD]}?` + 19626 `)?)?`); 19627 createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`); 19628 createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); 19629 createToken('COERCE', `${'(^|[^\\d])' + 19630 '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + 19631 `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + 19632 `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + 19633 `(?:$|[^\\d])`); 19634 createToken('COERCERTL', src[t.COERCE], true); 19635 createToken('LONETILDE', '(?:~>?)'); 19636 createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true); 19637 exports.tildeTrimReplace = '$1~'; 19638 createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`); 19639 createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); 19640 createToken('LONECARET', '(?:\\^)'); 19641 createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true); 19642 exports.caretTrimReplace = '$1^'; 19643 createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`); 19644 createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); 19645 createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`); 19646 createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); 19647 createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT] 19648 }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true); 19649 exports.comparatorTrimReplace = '$1$2$3'; 19650 createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + 19651 `\\s+-\\s+` + 19652 `(${src[t.XRANGEPLAIN]})` + 19653 `\\s*$`); 19654 createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + 19655 `\\s+-\\s+` + 19656 `(${src[t.XRANGEPLAINLOOSE]})` + 19657 `\\s*$`); 19658 createToken('STAR', '(<|>)?=?\\s*\\*'); 19659 createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$'); 19660 createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$'); 19661} (re$1, re$1.exports)); 19662var reExports = re$1.exports; 19663getDefaultExportFromCjs(reExports); 19664 19665const looseOption = Object.freeze({ loose: true }); 19666const emptyOpts = Object.freeze({ }); 19667const parseOptions$1 = options => { 19668 if (!options) { 19669 return emptyOpts 19670 } 19671 if (typeof options !== 'object') { 19672 return looseOption 19673 } 19674 return options 19675}; 19676var parseOptions_1 = parseOptions$1; 19677getDefaultExportFromCjs(parseOptions_1); 19678 19679const numeric = /^[0-9]+$/; 19680const compareIdentifiers$1 = (a, b) => { 19681 const anum = numeric.test(a); 19682 const bnum = numeric.test(b); 19683 if (anum && bnum) { 19684 a = +a; 19685 b = +b; 19686 } 19687 return a === b ? 0 19688 : (anum && !bnum) ? -1 19689 : (bnum && !anum) ? 1 19690 : a < b ? -1 19691 : 1 19692}; 19693const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a); 19694var identifiers = { 19695 compareIdentifiers: compareIdentifiers$1, 19696 rcompareIdentifiers, 19697}; 19698getDefaultExportFromCjs(identifiers); 19699 19700const debug = debug_1; 19701const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants; 19702const { safeRe: re, t } = reExports; 19703const parseOptions = parseOptions_1; 19704const { compareIdentifiers } = identifiers; 19705let SemVer$2 = class SemVer { 19706 constructor (version, options) { 19707 options = parseOptions(options); 19708 if (version instanceof SemVer) { 19709 if (version.loose === !!options.loose && 19710 version.includePrerelease === !!options.includePrerelease) { 19711 return version 19712 } else { 19713 version = version.version; 19714 } 19715 } else if (typeof version !== 'string') { 19716 throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`) 19717 } 19718 if (version.length > MAX_LENGTH) { 19719 throw new TypeError( 19720 `version is longer than ${MAX_LENGTH} characters` 19721 ) 19722 } 19723 debug('SemVer', version, options); 19724 this.options = options; 19725 this.loose = !!options.loose; 19726 this.includePrerelease = !!options.includePrerelease; 19727 const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]); 19728 if (!m) { 19729 throw new TypeError(`Invalid Version: ${version}`) 19730 } 19731 this.raw = version; 19732 this.major = +m[1]; 19733 this.minor = +m[2]; 19734 this.patch = +m[3]; 19735 if (this.major > MAX_SAFE_INTEGER || this.major < 0) { 19736 throw new TypeError('Invalid major version') 19737 } 19738 if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { 19739 throw new TypeError('Invalid minor version') 19740 } 19741 if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { 19742 throw new TypeError('Invalid patch version') 19743 } 19744 if (!m[4]) { 19745 this.prerelease = []; 19746 } else { 19747 this.prerelease = m[4].split('.').map((id) => { 19748 if (/^[0-9]+$/.test(id)) { 19749 const num = +id; 19750 if (num >= 0 && num < MAX_SAFE_INTEGER) { 19751 return num 19752 } 19753 } 19754 return id 19755 }); 19756 } 19757 this.build = m[5] ? m[5].split('.') : []; 19758 this.format(); 19759 } 19760 format () { 19761 this.version = `${this.major}.${this.minor}.${this.patch}`; 19762 if (this.prerelease.length) { 19763 this.version += `-${this.prerelease.join('.')}`; 19764 } 19765 return this.version 19766 } 19767 toString () { 19768 return this.version 19769 } 19770 compare (other) { 19771 debug('SemVer.compare', this.version, this.options, other); 19772 if (!(other instanceof SemVer)) { 19773 if (typeof other === 'string' && other === this.version) { 19774 return 0 19775 } 19776 other = new SemVer(other, this.options); 19777 } 19778 if (other.version === this.version) { 19779 return 0 19780 } 19781 return this.compareMain(other) || this.comparePre(other) 19782 } 19783 compareMain (other) { 19784 if (!(other instanceof SemVer)) { 19785 other = new SemVer(other, this.options); 19786 } 19787 return ( 19788 compareIdentifiers(this.major, other.major) || 19789 compareIdentifiers(this.minor, other.minor) || 19790 compareIdentifiers(this.patch, other.patch) 19791 ) 19792 } 19793 comparePre (other) { 19794 if (!(other instanceof SemVer)) { 19795 other = new SemVer(other, this.options); 19796 } 19797 if (this.prerelease.length && !other.prerelease.length) { 19798 return -1 19799 } else if (!this.prerelease.length && other.prerelease.length) { 19800 return 1 19801 } else if (!this.prerelease.length && !other.prerelease.length) { 19802 return 0 19803 } 19804 let i = 0; 19805 do { 19806 const a = this.prerelease[i]; 19807 const b = other.prerelease[i]; 19808 debug('prerelease compare', i, a, b); 19809 if (a === undefined && b === undefined) { 19810 return 0 19811 } else if (b === undefined) { 19812 return 1 19813 } else if (a === undefined) { 19814 return -1 19815 } else if (a === b) { 19816 continue 19817 } else { 19818 return compareIdentifiers(a, b) 19819 } 19820 } while (++i) 19821 } 19822 compareBuild (other) { 19823 if (!(other instanceof SemVer)) { 19824 other = new SemVer(other, this.options); 19825 } 19826 let i = 0; 19827 do { 19828 const a = this.build[i]; 19829 const b = other.build[i]; 19830 debug('prerelease compare', i, a, b); 19831 if (a === undefined && b === undefined) { 19832 return 0 19833 } else if (b === undefined) { 19834 return 1 19835 } else if (a === undefined) { 19836 return -1 19837 } else if (a === b) { 19838 continue 19839 } else { 19840 return compareIdentifiers(a, b) 19841 } 19842 } while (++i) 19843 } 19844 inc (release, identifier, identifierBase) { 19845 switch (release) { 19846 case 'premajor': 19847 this.prerelease.length = 0; 19848 this.patch = 0; 19849 this.minor = 0; 19850 this.major++; 19851 this.inc('pre', identifier, identifierBase); 19852 break 19853 case 'preminor': 19854 this.prerelease.length = 0; 19855 this.patch = 0; 19856 this.minor++; 19857 this.inc('pre', identifier, identifierBase); 19858 break 19859 case 'prepatch': 19860 this.prerelease.length = 0; 19861 this.inc('patch', identifier, identifierBase); 19862 this.inc('pre', identifier, identifierBase); 19863 break 19864 case 'prerelease': 19865 if (this.prerelease.length === 0) { 19866 this.inc('patch', identifier, identifierBase); 19867 } 19868 this.inc('pre', identifier, identifierBase); 19869 break 19870 case 'major': 19871 if ( 19872 this.minor !== 0 || 19873 this.patch !== 0 || 19874 this.prerelease.length === 0 19875 ) { 19876 this.major++; 19877 } 19878 this.minor = 0; 19879 this.patch = 0; 19880 this.prerelease = []; 19881 break 19882 case 'minor': 19883 if (this.patch !== 0 || this.prerelease.length === 0) { 19884 this.minor++; 19885 } 19886 this.patch = 0; 19887 this.prerelease = []; 19888 break 19889 case 'patch': 19890 if (this.prerelease.length === 0) { 19891 this.patch++; 19892 } 19893 this.prerelease = []; 19894 break 19895 case 'pre': { 19896 const base = Number(identifierBase) ? 1 : 0; 19897 if (!identifier && identifierBase === false) { 19898 throw new Error('invalid increment argument: identifier is empty') 19899 } 19900 if (this.prerelease.length === 0) { 19901 this.prerelease = [base]; 19902 } else { 19903 let i = this.prerelease.length; 19904 while (--i >= 0) { 19905 if (typeof this.prerelease[i] === 'number') { 19906 this.prerelease[i]++; 19907 i = -2; 19908 } 19909 } 19910 if (i === -1) { 19911 if (identifier === this.prerelease.join('.') && identifierBase === false) { 19912 throw new Error('invalid increment argument: identifier already exists') 19913 } 19914 this.prerelease.push(base); 19915 } 19916 } 19917 if (identifier) { 19918 let prerelease = [identifier, base]; 19919 if (identifierBase === false) { 19920 prerelease = [identifier]; 19921 } 19922 if (compareIdentifiers(this.prerelease[0], identifier) === 0) { 19923 if (isNaN(this.prerelease[1])) { 19924 this.prerelease = prerelease; 19925 } 19926 } else { 19927 this.prerelease = prerelease; 19928 } 19929 } 19930 break 19931 } 19932 default: 19933 throw new Error(`invalid increment argument: ${release}`) 19934 } 19935 this.raw = this.format(); 19936 if (this.build.length) { 19937 this.raw += `+${this.build.join('.')}`; 19938 } 19939 return this 19940 } 19941}; 19942var semver = SemVer$2; 19943getDefaultExportFromCjs(semver); 19944 19945const SemVer$1 = semver; 19946const parse = (version, options, throwErrors = false) => { 19947 if (version instanceof SemVer$1) { 19948 return version 19949 } 19950 try { 19951 return new SemVer$1(version, options) 19952 } catch (er) { 19953 if (!throwErrors) { 19954 return null 19955 } 19956 throw er 19957 } 19958}; 19959var parse_1 = parse; 19960var semverParse = getDefaultExportFromCjs(parse_1); 19961 19962const SemVer = semver; 19963const compare$1 = (a, b, loose) => 19964 new SemVer(a, loose).compare(new SemVer(b, loose)); 19965var compare_1 = compare$1; 19966getDefaultExportFromCjs(compare_1); 19967 19968const compare = compare_1; 19969const lt = (a, b, loose) => compare(a, b, loose) < 0; 19970var lt_1 = lt; 19971var semverLt = getDefaultExportFromCjs(lt_1); 19972 19973const allowedKeys = [ 19974 "added", 19975 "napiVersion", 19976 "deprecated", 19977 "removed", 19978 "changes", 19979]; 19980const changesExpectedKeys = ["version", "pr-url", "description"]; 19981const VERSION_PLACEHOLDER = "REPLACEME"; 19982const MAX_SAFE_SEMVER_VERSION = semverParse( 19983 Array.from({ length: 3 }, () => Number.MAX_SAFE_INTEGER).join(".") 19984); 19985const validVersionNumberRegex = /^v\d+\.\d+\.\d+$/; 19986const prUrlRegex = new RegExp("^https://github.com/nodejs/node/pull/\\d+$"); 19987const privatePRUrl = "https://github.com/nodejs-private/node-private/pull/"; 19988let releasedVersions; 19989let invalidVersionMessage = "version(s) must respect the pattern `vx.x.x` or"; 19990if (process.env.NODE_RELEASED_VERSIONS) { 19991 console.log("Using release list from env..."); 19992 releasedVersions = process.env.NODE_RELEASED_VERSIONS.split(",").map( 19993 (v) => `v${v}` 19994 ); 19995 invalidVersionMessage = `version not listed in the changelogs, `; 19996} 19997invalidVersionMessage += `use the placeholder \`${VERSION_PLACEHOLDER}\``; 19998const kContainsIllegalKey = Symbol("illegal key"); 19999const kWrongKeyOrder = Symbol("Wrong key order"); 20000function unorderedKeys(meta) { 20001 const keys = Object.keys(meta); 20002 let previousKeyIndex = -1; 20003 for (const key of keys) { 20004 const keyIndex = allowedKeys.indexOf(key); 20005 if (keyIndex <= previousKeyIndex) { 20006 return keyIndex === -1 ? kContainsIllegalKey : kWrongKeyOrder; 20007 } 20008 previousKeyIndex = keyIndex; 20009 } 20010} 20011function containsInvalidVersionNumber(version) { 20012 if (Array.isArray(version)) { 20013 return version.some(containsInvalidVersionNumber); 20014 } 20015 if (version === undefined || version === VERSION_PLACEHOLDER) return false; 20016 if ( 20017 releasedVersions && 20018 (version[1] !== "0" || (version[3] !== "0" && version[3] !== "1")) 20019 ) 20020 return !releasedVersions.includes(version); 20021 return !validVersionNumberRegex.test(version); 20022} 20023const getValidSemver = (version) => 20024 version === VERSION_PLACEHOLDER ? MAX_SAFE_SEMVER_VERSION : version; 20025function areVersionsUnordered(versions) { 20026 if (!Array.isArray(versions)) return false; 20027 for (let index = 1; index < versions.length; index++) { 20028 if ( 20029 semverLt( 20030 getValidSemver(versions[index - 1]), 20031 getValidSemver(versions[index]) 20032 ) 20033 ) { 20034 return true; 20035 } 20036 } 20037} 20038function invalidChangesKeys(change) { 20039 const keys = Object.keys(change); 20040 const { length } = keys; 20041 if (length !== changesExpectedKeys.length) return true; 20042 for (let index = 0; index < length; index++) { 20043 if (keys[index] !== changesExpectedKeys[index]) return true; 20044 } 20045} 20046function validateSecurityChange(file, node, change, index) { 20047 if ("commit" in change) { 20048 if (typeof change.commit !== "string" || isNaN(`0x${change.commit}`)) { 20049 file.message( 20050 `changes[${index}]: Ill-formed security change commit ID`, 20051 node 20052 ); 20053 } 20054 if (Object.keys(change)[1] === "commit") { 20055 change = { ...change }; 20056 delete change.commit; 20057 } 20058 } 20059 if (invalidChangesKeys(change)) { 20060 const securityChangeExpectedKeys = [...changesExpectedKeys]; 20061 securityChangeExpectedKeys[0] += "[, commit]"; 20062 file.message( 20063 `changes[${index}]: Invalid keys. Expected keys are: ` + 20064 securityChangeExpectedKeys.join(", "), 20065 node 20066 ); 20067 } 20068} 20069function validateChanges(file, node, changes) { 20070 if (!Array.isArray(changes)) 20071 return file.message("`changes` must be a YAML list", node); 20072 const changesVersions = []; 20073 for (let index = 0; index < changes.length; index++) { 20074 const change = changes[index]; 20075 const isAncient = 20076 typeof change.version === "string" && change.version.startsWith("v0."); 20077 const isSecurityChange = 20078 !isAncient && 20079 typeof change["pr-url"] === "string" && 20080 change["pr-url"].startsWith(privatePRUrl); 20081 if (isSecurityChange) { 20082 validateSecurityChange(file, node, change, index); 20083 } else if (!isAncient && invalidChangesKeys(change)) { 20084 file.message( 20085 `changes[${index}]: Invalid keys. Expected keys are: ` + 20086 changesExpectedKeys.join(", "), 20087 node 20088 ); 20089 } 20090 if (containsInvalidVersionNumber(change.version)) { 20091 file.message(`changes[${index}]: ${invalidVersionMessage}`, node); 20092 } else if (areVersionsUnordered(change.version)) { 20093 file.message(`changes[${index}]: list of versions is not in order`, node); 20094 } 20095 if (!isAncient && !isSecurityChange && !prUrlRegex.test(change["pr-url"])) { 20096 file.message( 20097 `changes[${index}]: PR-URL does not match the expected pattern`, 20098 node 20099 ); 20100 } 20101 if (typeof change.description !== "string" || !change.description.length) { 20102 file.message( 20103 `changes[${index}]: must contain a non-empty description`, 20104 node 20105 ); 20106 } else if (!change.description.endsWith(".")) { 20107 file.message( 20108 `changes[${index}]: description must end with a period`, 20109 node 20110 ); 20111 } 20112 changesVersions.push( 20113 Array.isArray(change.version) ? change.version[0] : change.version 20114 ); 20115 } 20116 if (areVersionsUnordered(changesVersions)) { 20117 file.message("Items in `changes` list are not in order", node); 20118 } 20119} 20120function validateMeta(node, file, meta) { 20121 switch (unorderedKeys(meta)) { 20122 case kContainsIllegalKey: 20123 file.message( 20124 "YAML dictionary contains illegal keys. Accepted values are: " + 20125 allowedKeys.join(", "), 20126 node 20127 ); 20128 break; 20129 case kWrongKeyOrder: 20130 file.message( 20131 "YAML dictionary keys should be in this order: " + 20132 allowedKeys.join(", "), 20133 node 20134 ); 20135 break; 20136 } 20137 if (containsInvalidVersionNumber(meta.added)) { 20138 file.message(`Invalid \`added\` value: ${invalidVersionMessage}`, node); 20139 } else if (areVersionsUnordered(meta.added)) { 20140 file.message("Versions in `added` list are not in order", node); 20141 } 20142 if (containsInvalidVersionNumber(meta.deprecated)) { 20143 file.message( 20144 `Invalid \`deprecated\` value: ${invalidVersionMessage}`, 20145 node 20146 ); 20147 } else if (areVersionsUnordered(meta.deprecated)) { 20148 file.message("Versions in `deprecated` list are not in order", node); 20149 } 20150 if (containsInvalidVersionNumber(meta.removed)) { 20151 file.message(`Invalid \`removed\` value: ${invalidVersionMessage}`, node); 20152 } else if (areVersionsUnordered(meta.removed)) { 20153 file.message("Versions in `removed` list are not in order", node); 20154 } 20155 if ("changes" in meta) { 20156 validateChanges(file, node, meta.changes); 20157 } 20158} 20159function validateYAMLComments(tree, file) { 20160 visit$1(tree, "html", function visitor(node) { 20161 if (node.value.startsWith("<!--YAML\n")) 20162 file.message( 20163 "Expected `<!-- YAML`, found `<!--YAML`. Please add a space", 20164 node 20165 ); 20166 if (!node.value.startsWith("<!-- YAML\n")) return; 20167 try { 20168 const meta = jsYaml.load("#" + node.value.slice(0, -"-->".length)); 20169 validateMeta(node, file, meta); 20170 } catch (e) { 20171 file.message(e, node); 20172 } 20173 }); 20174} 20175const remarkLintNodejsYamlComments = lintRule( 20176 "remark-lint:nodejs-yaml-comments", 20177 validateYAMLComments 20178); 20179 20180const remarkLintProhibitedStrings = lintRule('remark-lint:prohibited-strings', prohibitedStrings); 20181function testProhibited (val, content) { 20182 let regexpFlags = 'g'; 20183 let no = val.no; 20184 if (!no) { 20185 no = escapeStringRegexp(val.yes); 20186 regexpFlags += 'i'; 20187 } 20188 let regexpString = '(?<!\\.|@[a-zA-Z0-9/-]*)'; 20189 let ignoreNextTo; 20190 if (val.ignoreNextTo) { 20191 if (Array.isArray(val.ignoreNextTo)) { 20192 const parts = val.ignoreNextTo.map(a => escapeStringRegexp(a)).join('|'); 20193 ignoreNextTo = `(?:${parts})`; 20194 } else { 20195 ignoreNextTo = escapeStringRegexp(val.ignoreNextTo); 20196 } 20197 } else { 20198 ignoreNextTo = ''; 20199 } 20200 const replaceCaptureGroups = !!val.replaceCaptureGroups; 20201 if (/^\b/.test(no)) { 20202 regexpString += '\\b'; 20203 } 20204 if (ignoreNextTo) { 20205 regexpString += `(?<!${ignoreNextTo})`; 20206 } 20207 regexpString += `(${no})`; 20208 if (ignoreNextTo) { 20209 regexpString += `(?!${ignoreNextTo})`; 20210 } 20211 if (/\b$/.test(no)) { 20212 regexpString += '\\b'; 20213 } 20214 regexpString += '(?!\\.\\w)'; 20215 const re = new RegExp(regexpString, regexpFlags); 20216 const results = []; 20217 let result = re.exec(content); 20218 while (result) { 20219 if (result[1] !== val.yes) { 20220 let yes = val.yes; 20221 if (replaceCaptureGroups) { 20222 yes = result[1].replace(new RegExp(no), yes); 20223 } 20224 results.push({ result: result[1], index: result.index, yes: yes }); 20225 } 20226 result = re.exec(content); 20227 } 20228 return results 20229} 20230function prohibitedStrings (ast, file, strings) { 20231 const myLocation = location(file); 20232 visit$1(ast, 'text', checkText); 20233 function checkText (node) { 20234 const content = node.value; 20235 const initial = pointStart(node).offset; 20236 strings.forEach((val) => { 20237 const results = testProhibited(val, content); 20238 if (results.length) { 20239 results.forEach(({ result, index, yes }) => { 20240 const message = val.yes ? `Use "${yes}" instead of "${result}"` : `Do not use "${result}"`; 20241 file.message(message, { 20242 start: myLocation.toPoint(initial + index), 20243 end: myLocation.toPoint(initial + index + [...result].length) 20244 }); 20245 }); 20246 } 20247 }); 20248 } 20249} 20250 20251/** 20252 * ## When should I use this? 20253 * 20254 * You can use this package to check that rules (thematic breaks, horizontal 20255 * rules) are consistent. 20256 * 20257 * ## API 20258 * 20259 * The following options (default: `'consistent'`) are accepted: 20260 * 20261 * * `string` (example: `'** * **'`, `'___'`) 20262 * — thematic break to prefer 20263 * * `'consistent'` 20264 * — detect the first used style and warn when further rules differ 20265 * 20266 * ## Recommendation 20267 * 20268 * Rules consist of a `*`, `-`, or `_` character, which occurs at least three 20269 * times with nothing else except for arbitrary spaces or tabs on a single line. 20270 * Using spaces, tabs, and more than three markers seems unnecessary work to 20271 * type out. 20272 * Because asterisks can be used as a marker for more markdown constructs, 20273 * it’s recommended to use that for rules (and lists, emphasis, strong) too. 20274 * Due to this, it’s recommended to pass `'***'`. 20275 * 20276 * ## Fix 20277 * 20278 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 20279 * formats rules with `***` by default. 20280 * There are three settings to control rules: 20281 * 20282 * * [`rule`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsrule) 20283 * (default: `'*'`) — marker 20284 * * [`ruleRepetition`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsrulerepetition) 20285 * (default: `3`) — repetitions 20286 * * [`ruleSpaces`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsrulespaces) 20287 * (default: `false`) — use spaces between markers 20288 * 20289 * @module rule-style 20290 * @summary 20291 * remark-lint rule to warn when rule markers are inconsistent. 20292 * @author Titus Wormer 20293 * @copyright 2015 Titus Wormer 20294 * @license MIT 20295 * @example 20296 * {"name": "ok.md", "config": "* * *"} 20297 * 20298 * * * * 20299 * 20300 * * * * 20301 * 20302 * @example 20303 * {"name": "ok.md", "config": "_______"} 20304 * 20305 * _______ 20306 * 20307 * _______ 20308 * 20309 * @example 20310 * {"name": "not-ok.md", "label": "input"} 20311 * 20312 * *** 20313 * 20314 * * * * 20315 * 20316 * @example 20317 * {"name": "not-ok.md", "label": "output"} 20318 * 20319 * 3:1-3:6: Rules should use `***` 20320 * 20321 * @example 20322 * {"name": "not-ok.md", "label": "output", "config": "", "positionless": true} 20323 * 20324 * 1:1: Incorrect preferred rule style: provide a correct markdown rule or `'consistent'` 20325 */ 20326const remarkLintRuleStyle = lintRule( 20327 { 20328 origin: 'remark-lint:rule-style', 20329 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-rule-style#readme' 20330 }, 20331 (tree, file, option = 'consistent') => { 20332 const value = String(file); 20333 if (option !== 'consistent' && /[^-_* ]/.test(option)) { 20334 file.fail( 20335 "Incorrect preferred rule style: provide a correct markdown rule or `'consistent'`" 20336 ); 20337 } 20338 visit$1(tree, 'thematicBreak', (node) => { 20339 const initial = pointStart(node).offset; 20340 const final = pointEnd(node).offset; 20341 if (typeof initial === 'number' && typeof final === 'number') { 20342 const rule = value.slice(initial, final); 20343 if (option === 'consistent') { 20344 option = rule; 20345 } else if (rule !== option) { 20346 file.message('Rules should use `' + option + '`', node); 20347 } 20348 } 20349 }); 20350 } 20351); 20352var remarkLintRuleStyle$1 = remarkLintRuleStyle; 20353 20354/** 20355 * ## When should I use this? 20356 * 20357 * You can use this package to check that strong markers are consistent. 20358 * 20359 * ## API 20360 * 20361 * The following options (default: `'consistent'`) are accepted: 20362 * 20363 * * `'*'` 20364 * — prefer asterisks 20365 * * `'_'` 20366 * — prefer underscores 20367 * * `'consistent'` 20368 * — detect the first used style and warn when further strong differs 20369 * 20370 * ## Recommendation 20371 * 20372 * Underscores and asterisks work slightly different: asterisks can form strong 20373 * in more cases than underscores. 20374 * Because underscores are sometimes used to represent normal underscores inside 20375 * words, there are extra rules supporting that. 20376 * Asterisks can also be used as the marker of more constructs than underscores: 20377 * lists. 20378 * Due to having simpler parsing rules, looking more like syntax, and that they 20379 * can be used for more constructs, it’s recommended to prefer asterisks. 20380 * 20381 * ## Fix 20382 * 20383 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 20384 * formats strong with asterisks by default. 20385 * Pass 20386 * [`strong: '_'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsstrong) 20387 * to always use underscores. 20388 * 20389 * @module strong-marker 20390 * @summary 20391 * remark-lint rule to warn when strong markers are inconsistent. 20392 * @author Titus Wormer 20393 * @copyright 2015 Titus Wormer 20394 * @license MIT 20395 * @example 20396 * {"name": "ok.md"} 20397 * 20398 * **foo** and **bar**. 20399 * 20400 * @example 20401 * {"name": "also-ok.md"} 20402 * 20403 * __foo__ and __bar__. 20404 * 20405 * @example 20406 * {"name": "ok.md", "config": "*"} 20407 * 20408 * **foo**. 20409 * 20410 * @example 20411 * {"name": "ok.md", "config": "_"} 20412 * 20413 * __foo__. 20414 * 20415 * @example 20416 * {"name": "not-ok.md", "label": "input"} 20417 * 20418 * **foo** and __bar__. 20419 * 20420 * @example 20421 * {"name": "not-ok.md", "label": "output"} 20422 * 20423 * 1:13-1:20: Strong should use `*` as a marker 20424 * 20425 * @example 20426 * {"name": "not-ok.md", "label": "output", "config": "", "positionless": true} 20427 * 20428 * 1:1: Incorrect strong marker ``: use either `'consistent'`, `'*'`, or `'_'` 20429 */ 20430const remarkLintStrongMarker = lintRule( 20431 { 20432 origin: 'remark-lint:strong-marker', 20433 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-strong-marker#readme' 20434 }, 20435 (tree, file, option = 'consistent') => { 20436 const value = String(file); 20437 if (option !== '*' && option !== '_' && option !== 'consistent') { 20438 file.fail( 20439 'Incorrect strong marker `' + 20440 option + 20441 "`: use either `'consistent'`, `'*'`, or `'_'`" 20442 ); 20443 } 20444 visit$1(tree, 'strong', (node) => { 20445 const start = pointStart(node).offset; 20446 if (typeof start === 'number') { 20447 const marker = (value.charAt(start)); 20448 if (option === 'consistent') { 20449 option = marker; 20450 } else if (marker !== option) { 20451 file.message('Strong should use `' + option + '` as a marker', node); 20452 } 20453 } 20454 }); 20455 } 20456); 20457var remarkLintStrongMarker$1 = remarkLintStrongMarker; 20458 20459/** 20460 * ## When should I use this? 20461 * 20462 * You can use this package to check that table cells are padded consistently. 20463 * Tables are a GFM feature enabled with 20464 * [`remark-gfm`](https://github.com/remarkjs/remark-gfm). 20465 * 20466 * ## API 20467 * 20468 * The following options (default: `'consistent'`) are accepted: 20469 * 20470 * * `'padded'` 20471 * — prefer at least one space between pipes and content 20472 * * `'compact'` 20473 * — prefer zero spaces between pipes and content 20474 * * `'consistent'` 20475 * — detect the first used style and warn when further tables differ 20476 * 20477 * ## Recommendation 20478 * 20479 * It’s recommended to use at least one space between pipes and content for 20480 * legibility of the markup (`'padded'`). 20481 * 20482 * ## Fix 20483 * 20484 * [`remark-gfm`](https://github.com/remarkjs/remark-gfm) 20485 * formats all table cells as padded by default. 20486 * Pass 20487 * [`tableCellPadding: false`](https://github.com/remarkjs/remark-gfm#optionstablecellpadding) 20488 * to use a more compact style. 20489 * 20490 * @module table-cell-padding 20491 * @summary 20492 * remark-lint rule to warn when table cells are inconsistently padded. 20493 * @author Titus Wormer 20494 * @copyright 2015 Titus Wormer 20495 * @license MIT 20496 * @example 20497 * {"name": "ok.md", "config": "padded", "gfm": true} 20498 * 20499 * | A | B | 20500 * | ----- | ----- | 20501 * | Alpha | Bravo | 20502 * 20503 * @example 20504 * {"name": "not-ok.md", "label": "input", "config": "padded", "gfm": true} 20505 * 20506 * | A | B | 20507 * | :----|----: | 20508 * | Alpha|Bravo | 20509 * 20510 * | C | D | 20511 * | :----- | ---: | 20512 * |Charlie | Delta| 20513 * 20514 * Too much padding isn’t good either: 20515 * 20516 * | E | F | G | H | 20517 * | :---- | -------- | :----: | -----: | 20518 * | Echo | Foxtrot | Golf | Hotel | 20519 * 20520 * @example 20521 * {"name": "not-ok.md", "label": "output", "config": "padded", "gfm": true} 20522 * 20523 * 3:8: Cell should be padded 20524 * 3:9: Cell should be padded 20525 * 7:2: Cell should be padded 20526 * 7:17: Cell should be padded 20527 * 13:7: Cell should be padded with 1 space, not 2 20528 * 13:18: Cell should be padded with 1 space, not 2 20529 * 13:23: Cell should be padded with 1 space, not 2 20530 * 13:27: Cell should be padded with 1 space, not 2 20531 * 13:32: Cell should be padded with 1 space, not 2 20532 * 20533 * @example 20534 * {"name": "ok.md", "config": "compact", "gfm": true} 20535 * 20536 * |A |B | 20537 * |-----|-----| 20538 * |Alpha|Bravo| 20539 * 20540 * @example 20541 * {"name": "not-ok.md", "label": "input", "config": "compact", "gfm": true} 20542 * 20543 * | A | B | 20544 * | -----| -----| 20545 * | Alpha| Bravo| 20546 * 20547 * |C | D| 20548 * |:------|-----:| 20549 * |Charlie|Delta | 20550 * 20551 * @example 20552 * {"name": "not-ok.md", "label": "output", "config": "compact", "gfm": true} 20553 * 20554 * 3:5: Cell should be compact 20555 * 3:12: Cell should be compact 20556 * 7:15: Cell should be compact 20557 * 20558 * @example 20559 * {"name": "ok-padded.md", "config": "consistent", "gfm": true} 20560 * 20561 * | A | B | 20562 * | ----- | ----- | 20563 * | Alpha | Bravo | 20564 * 20565 * | C | D | 20566 * | ------- | ----- | 20567 * | Charlie | Delta | 20568 * 20569 * @example 20570 * {"name": "not-ok-padded.md", "label": "input", "config": "consistent", "gfm": true} 20571 * 20572 * | A | B | 20573 * | ----- | ----- | 20574 * | Alpha | Bravo | 20575 * 20576 * | C | D | 20577 * | :----- | ----: | 20578 * |Charlie | Delta | 20579 * 20580 * @example 20581 * {"name": "not-ok-padded.md", "label": "output", "config": "consistent", "gfm": true} 20582 * 20583 * 7:2: Cell should be padded 20584 * 20585 * @example 20586 * {"name": "ok-compact.md", "config": "consistent", "gfm": true} 20587 * 20588 * |A |B | 20589 * |-----|-----| 20590 * |Alpha|Bravo| 20591 * 20592 * |C |D | 20593 * |-------|-----| 20594 * |Charlie|Delta| 20595 * 20596 * @example 20597 * {"name": "not-ok-compact.md", "label": "input", "config": "consistent", "gfm": true} 20598 * 20599 * |A |B | 20600 * |-----|-----| 20601 * |Alpha|Bravo| 20602 * 20603 * |C | D| 20604 * |:------|-----:| 20605 * |Charlie|Delta | 20606 * 20607 * @example 20608 * {"name": "not-ok-compact.md", "label": "output", "config": "consistent", "gfm": true} 20609 * 20610 * 7:15: Cell should be compact 20611 * 20612 * @example 20613 * {"name": "not-ok.md", "label": "output", "config": "", "positionless": true, "gfm": true} 20614 * 20615 * 1:1: Incorrect table cell padding style ``, expected `'padded'`, `'compact'`, or `'consistent'` 20616 * 20617 * @example 20618 * {"name": "empty.md", "label": "input", "config": "padded", "gfm": true} 20619 * 20620 * <!-- Empty cells are OK, but those surrounding them may not be. --> 20621 * 20622 * | | Alpha | Bravo| 20623 * | ------ | ----- | ---: | 20624 * | Charlie| | Echo| 20625 * 20626 * @example 20627 * {"name": "empty.md", "label": "output", "config": "padded", "gfm": true} 20628 * 20629 * 3:25: Cell should be padded 20630 * 5:10: Cell should be padded 20631 * 5:25: Cell should be padded 20632 * 20633 * @example 20634 * {"name": "missing-body.md", "config": "padded", "gfm": true} 20635 * 20636 * <!-- Missing cells are fine as well. --> 20637 * 20638 * | Alpha | Bravo | Charlie | 20639 * | ----- | ------- | ------- | 20640 * | Delta | 20641 * | Echo | Foxtrot | 20642 */ 20643const remarkLintTableCellPadding = lintRule( 20644 { 20645 origin: 'remark-lint:table-cell-padding', 20646 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-cell-padding#readme' 20647 }, 20648 (tree, file, option = 'consistent') => { 20649 if ( 20650 option !== 'padded' && 20651 option !== 'compact' && 20652 option !== 'consistent' 20653 ) { 20654 file.fail( 20655 'Incorrect table cell padding style `' + 20656 option + 20657 "`, expected `'padded'`, `'compact'`, or `'consistent'`" 20658 ); 20659 } 20660 visit$1(tree, 'table', (node) => { 20661 const rows = node.children; 20662 const align = node.align || []; 20663 const sizes = []; 20664 const entries = []; 20665 let index = -1; 20666 while (++index < align.length) { 20667 const alignment = align[index]; 20668 sizes[index] = alignment === 'center' ? 3 : alignment ? 2 : 1; 20669 } 20670 index = -1; 20671 while (++index < rows.length) { 20672 const row = rows[index]; 20673 let column = -1; 20674 while (++column < row.children.length) { 20675 const cell = row.children[column]; 20676 const cellStart = pointStart(cell).offset; 20677 const cellEnd = pointEnd(cell).offset; 20678 const contentStart = pointStart(cell.children[0]).offset; 20679 const contentEnd = pointEnd( 20680 cell.children[cell.children.length - 1] 20681 ).offset; 20682 if ( 20683 typeof cellStart !== 'number' || 20684 typeof cellEnd !== 'number' || 20685 typeof contentStart !== 'number' || 20686 typeof contentEnd !== 'number' 20687 ) { 20688 continue 20689 } 20690 entries.push({ 20691 node: cell, 20692 start: contentStart - cellStart - 1, 20693 end: 20694 cellEnd - 20695 contentEnd - 20696 (column === row.children.length - 1 ? 1 : 0), 20697 column 20698 }); 20699 sizes[column] = Math.max( 20700 sizes[column] || 0, 20701 contentEnd - contentStart 20702 ); 20703 } 20704 } 20705 const style = 20706 option === 'consistent' 20707 ? entries[0] && (!entries[0].start || !entries[0].end) 20708 ? 0 20709 : 1 20710 : option === 'padded' 20711 ? 1 20712 : 0; 20713 index = -1; 20714 while (++index < entries.length) { 20715 checkSide('start', entries[index], style, sizes); 20716 checkSide('end', entries[index], style, sizes); 20717 } 20718 return SKIP$1 20719 }); 20720 function checkSide(side, entry, style, sizes) { 20721 const cell = entry.node; 20722 const column = entry.column; 20723 const spacing = entry[side]; 20724 if (spacing === undefined || spacing === style) { 20725 return 20726 } 20727 let reason = 'Cell should be '; 20728 if (style === 0) { 20729 if (size(cell) < sizes[column]) { 20730 return 20731 } 20732 reason += 'compact'; 20733 } else { 20734 reason += 'padded'; 20735 if (spacing > style) { 20736 if (size(cell) < sizes[column]) { 20737 return 20738 } 20739 reason += ' with 1 space, not ' + spacing; 20740 } 20741 } 20742 file.message( 20743 reason, 20744 side === 'start' 20745 ? pointStart(cell.children[0]) 20746 : pointEnd(cell.children[cell.children.length - 1]) 20747 ); 20748 } 20749 } 20750); 20751var remarkLintTableCellPadding$1 = remarkLintTableCellPadding; 20752function size(node) { 20753 const head = pointStart(node.children[0]).offset; 20754 const tail = pointEnd(node.children[node.children.length - 1]).offset; 20755 return typeof head === 'number' && typeof tail === 'number' ? tail - head : 0 20756} 20757 20758/** 20759 * ## When should I use this? 20760 * 20761 * You can use this package to check that tables have initial and final 20762 * delimiters. 20763 * Tables are a GFM feature enabled with 20764 * [`remark-gfm`](https://github.com/remarkjs/remark-gfm). 20765 * 20766 * ## API 20767 * 20768 * There are no options. 20769 * 20770 * ## Recommendation 20771 * 20772 * While tables don’t require initial or final delimiters (pipes before the 20773 * first and after the last cells in a row), it arguably does look weird. 20774 * 20775 * ## Fix 20776 * 20777 * [`remark-gfm`](https://github.com/remarkjs/remark-gfm) 20778 * formats all tables with initial and final delimiters. 20779 * 20780 * @module table-pipes 20781 * @summary 20782 * remark-lint rule to warn when tables are missing initial and final 20783 * delimiters. 20784 * @author Titus Wormer 20785 * @copyright 2015 Titus Wormer 20786 * @license MIT 20787 * @example 20788 * {"name": "ok.md", "gfm": true} 20789 * 20790 * | A | B | 20791 * | ----- | ----- | 20792 * | Alpha | Bravo | 20793 * 20794 * @example 20795 * {"name": "not-ok.md", "label": "input", "gfm": true} 20796 * 20797 * A | B 20798 * ----- | ----- 20799 * Alpha | Bravo 20800 * 20801 * @example 20802 * {"name": "not-ok.md", "label": "output", "gfm": true} 20803 * 20804 * 1:1: Missing initial pipe in table fence 20805 * 1:10: Missing final pipe in table fence 20806 * 3:1: Missing initial pipe in table fence 20807 * 3:14: Missing final pipe in table fence 20808 */ 20809const reasonStart = 'Missing initial pipe in table fence'; 20810const reasonEnd = 'Missing final pipe in table fence'; 20811const remarkLintTablePipes = lintRule( 20812 { 20813 origin: 'remark-lint:table-pipes', 20814 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-pipes#readme' 20815 }, 20816 (tree, file) => { 20817 const value = String(file); 20818 visit$1(tree, 'table', (node) => { 20819 let index = -1; 20820 while (++index < node.children.length) { 20821 const row = node.children[index]; 20822 const start = pointStart(row); 20823 const end = pointEnd(row); 20824 if ( 20825 typeof start.offset === 'number' && 20826 value.charCodeAt(start.offset) !== 124 20827 ) { 20828 file.message(reasonStart, start); 20829 } 20830 if ( 20831 typeof end.offset === 'number' && 20832 value.charCodeAt(end.offset - 1) !== 124 20833 ) { 20834 file.message(reasonEnd, end); 20835 } 20836 } 20837 }); 20838 } 20839); 20840var remarkLintTablePipes$1 = remarkLintTablePipes; 20841 20842/** 20843 * ## When should I use this? 20844 * 20845 * You can use this package to check that unordered list markers (bullets) 20846 * are consistent. 20847 * 20848 * ## API 20849 * 20850 * The following options (default: `'consistent'`) are accepted: 20851 * 20852 * * `'*'` 20853 * — prefer asterisks 20854 * * `'+'` 20855 * — prefer plusses 20856 * * `'-'` 20857 * — prefer dashes 20858 * * `'consistent'` 20859 * — detect the first used style and warn when further markers differ 20860 * 20861 * ## Recommendation 20862 * 20863 * Because asterisks can be used as a marker for more markdown constructs, 20864 * it’s recommended to use that for lists (and thematic breaks, emphasis, 20865 * strong) too. 20866 * 20867 * ## Fix 20868 * 20869 * [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) 20870 * formats ordered lists with asterisks by default. 20871 * Pass 20872 * [`bullet: '+'` or `bullet: '-'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsbullet) 20873 * to always use plusses or dashes. 20874 * 20875 * @module unordered-list-marker-style 20876 * @summary 20877 * remark-lint rule to warn when unordered list markers are inconsistent. 20878 * @author Titus Wormer 20879 * @copyright 2015 Titus Wormer 20880 * @license MIT 20881 * @example 20882 * {"name": "ok.md"} 20883 * 20884 * By default (`'consistent'`), if the file uses only one marker, 20885 * that’s OK. 20886 * 20887 * * Foo 20888 * * Bar 20889 * * Baz 20890 * 20891 * Ordered lists are not affected. 20892 * 20893 * 1. Foo 20894 * 2. Bar 20895 * 3. Baz 20896 * 20897 * @example 20898 * {"name": "ok.md", "config": "*"} 20899 * 20900 * * Foo 20901 * 20902 * @example 20903 * {"name": "ok.md", "config": "-"} 20904 * 20905 * - Foo 20906 * 20907 * @example 20908 * {"name": "ok.md", "config": "+"} 20909 * 20910 * + Foo 20911 * 20912 * @example 20913 * {"name": "not-ok.md", "label": "input"} 20914 * 20915 * * Foo 20916 * - Bar 20917 * + Baz 20918 * 20919 * @example 20920 * {"name": "not-ok.md", "label": "output"} 20921 * 20922 * 2:1-2:6: Marker style should be `*` 20923 * 3:1-3:6: Marker style should be `*` 20924 * 20925 * @example 20926 * {"name": "not-ok.md", "label": "output", "config": "", "positionless": true} 20927 * 20928 * 1:1: Incorrect unordered list item marker style ``: use either `'-'`, `'*'`, or `'+'` 20929 */ 20930const markers = new Set(['-', '*', '+']); 20931const remarkLintUnorderedListMarkerStyle = lintRule( 20932 { 20933 origin: 'remark-lint:unordered-list-marker-style', 20934 url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-unordered-list-marker-style#readme' 20935 }, 20936 (tree, file, option = 'consistent') => { 20937 const value = String(file); 20938 if (option !== 'consistent' && !markers.has(option)) { 20939 file.fail( 20940 'Incorrect unordered list item marker style `' + 20941 option + 20942 "`: use either `'-'`, `'*'`, or `'+'`" 20943 ); 20944 } 20945 visit$1(tree, 'list', (node) => { 20946 if (node.ordered) return 20947 let index = -1; 20948 while (++index < node.children.length) { 20949 const child = node.children[index]; 20950 if (!generated(child)) { 20951 const marker = ( 20952 value 20953 .slice( 20954 pointStart(child).offset, 20955 pointStart(child.children[0]).offset 20956 ) 20957 .replace(/\[[x ]?]\s*$/i, '') 20958 .replace(/\s/g, '') 20959 ); 20960 if (option === 'consistent') { 20961 option = marker; 20962 } else if (marker !== option) { 20963 file.message('Marker style should be `' + option + '`', child); 20964 } 20965 } 20966 } 20967 }); 20968 } 20969); 20970var remarkLintUnorderedListMarkerStyle$1 = remarkLintUnorderedListMarkerStyle; 20971 20972const plugins = [ 20973 remarkGfm, 20974 remarkPresetLintRecommended$1, 20975 [remarkLintBlockquoteIndentation$1, 2], 20976 [remarkLintCheckboxCharacterStyle$1, { checked: "x", unchecked: " " }], 20977 remarkLintCheckboxContentIndent$1, 20978 [remarkLintCodeBlockStyle$1, "fenced"], 20979 remarkLintDefinitionSpacing$1, 20980 [ 20981 remarkLintFencedCodeFlag$1, 20982 { 20983 flags: [ 20984 "bash", 20985 "c", 20986 "cjs", 20987 "coffee", 20988 "console", 20989 "cpp", 20990 "diff", 20991 "http", 20992 "js", 20993 "json", 20994 "markdown", 20995 "mjs", 20996 "powershell", 20997 "r", 20998 "text", 20999 "ts", 21000 ], 21001 }, 21002 ], 21003 [remarkLintFencedCodeMarker$1, "`"], 21004 [remarkLintFileExtension$1, "md"], 21005 remarkLintFinalDefinition$1, 21006 [remarkLintFirstHeadingLevel$1, 1], 21007 [remarkLintHeadingStyle$1, "atx"], 21008 [remarkLintListItemIndent$1, "space"], 21009 remarkLintMaximumLineLength$1, 21010 remarkLintNoConsecutiveBlankLines$1, 21011 remarkLintNoFileNameArticles$1, 21012 remarkLintNoFileNameConsecutiveDashes$1, 21013 remarkLintNofileNameOuterDashes$1, 21014 remarkLintNoHeadingIndent$1, 21015 remarkLintNoMultipleToplevelHeadings$1, 21016 remarkLintNoShellDollars$1, 21017 remarkLintNoTableIndentation$1, 21018 remarkLintNoTabs$1, 21019 remarkLintNoTrailingSpaces$1, 21020 remarkLintNodejsLinks, 21021 remarkLintNodejsYamlComments, 21022 [ 21023 remarkLintProhibitedStrings, 21024 [ 21025 { yes: "End-of-Life" }, 21026 { no: "filesystem", yes: "file system" }, 21027 { yes: "GitHub" }, 21028 { no: "hostname", yes: "host name" }, 21029 { yes: "JavaScript" }, 21030 { no: "[Ll]ong[ -][Tt]erm [Ss]upport", yes: "Long Term Support" }, 21031 { no: "Node", yes: "Node.js", ignoreNextTo: "-API" }, 21032 { yes: "Node.js" }, 21033 { no: "Node[Jj][Ss]", yes: "Node.js" }, 21034 { no: "Node\\.js's?", yes: "the Node.js" }, 21035 { no: "[Nn]ote that", yes: "<nothing>" }, 21036 { yes: "RFC" }, 21037 { no: "[Rr][Ff][Cc]\\d+", yes: "RFC <number>" }, 21038 { yes: "Unix" }, 21039 { yes: "Valgrind" }, 21040 { yes: "V8" }, 21041 ], 21042 ], 21043 remarkLintRuleStyle$1, 21044 [remarkLintStrongMarker$1, "*"], 21045 [remarkLintTableCellPadding$1, "padded"], 21046 remarkLintTablePipes$1, 21047 [remarkLintUnorderedListMarkerStyle$1, "*"], 21048]; 21049const settings = { 21050 emphasis: "_", 21051 listItemIndent: 1, 21052 tightDefinitions: true, 21053}; 21054const remarkPresetLintNode = { plugins, settings }; 21055 21056function stringifyPosition(value) { 21057 if (!value || typeof value !== 'object') { 21058 return '' 21059 } 21060 if ('position' in value || 'type' in value) { 21061 return position(value.position) 21062 } 21063 if ('start' in value || 'end' in value) { 21064 return position(value) 21065 } 21066 if ('line' in value || 'column' in value) { 21067 return point(value) 21068 } 21069 return '' 21070} 21071function point(point) { 21072 return index(point && point.line) + ':' + index(point && point.column) 21073} 21074function position(pos) { 21075 return point(pos && pos.start) + '-' + point(pos && pos.end) 21076} 21077function index(value) { 21078 return value && typeof value === 'number' ? value : 1 21079} 21080 21081class VFileMessage extends Error { 21082 constructor(causeOrReason, optionsOrParentOrPlace, origin) { 21083 super(); 21084 if (typeof optionsOrParentOrPlace === 'string') { 21085 origin = optionsOrParentOrPlace; 21086 optionsOrParentOrPlace = undefined; 21087 } 21088 let reason = ''; 21089 let options = {}; 21090 let legacyCause = false; 21091 if (optionsOrParentOrPlace) { 21092 if ( 21093 'line' in optionsOrParentOrPlace && 21094 'column' in optionsOrParentOrPlace 21095 ) { 21096 options = {place: optionsOrParentOrPlace}; 21097 } 21098 else if ( 21099 'start' in optionsOrParentOrPlace && 21100 'end' in optionsOrParentOrPlace 21101 ) { 21102 options = {place: optionsOrParentOrPlace}; 21103 } 21104 else if ('type' in optionsOrParentOrPlace) { 21105 options = { 21106 ancestors: [optionsOrParentOrPlace], 21107 place: optionsOrParentOrPlace.position 21108 }; 21109 } 21110 else { 21111 options = {...optionsOrParentOrPlace}; 21112 } 21113 } 21114 if (typeof causeOrReason === 'string') { 21115 reason = causeOrReason; 21116 } 21117 else if (!options.cause && causeOrReason) { 21118 legacyCause = true; 21119 reason = causeOrReason.message; 21120 options.cause = causeOrReason; 21121 } 21122 if (!options.ruleId && !options.source && typeof origin === 'string') { 21123 const index = origin.indexOf(':'); 21124 if (index === -1) { 21125 options.ruleId = origin; 21126 } else { 21127 options.source = origin.slice(0, index); 21128 options.ruleId = origin.slice(index + 1); 21129 } 21130 } 21131 if (!options.place && options.ancestors && options.ancestors) { 21132 const parent = options.ancestors[options.ancestors.length - 1]; 21133 if (parent) { 21134 options.place = parent.position; 21135 } 21136 } 21137 const start = 21138 options.place && 'start' in options.place 21139 ? options.place.start 21140 : options.place; 21141 this.ancestors = options.ancestors || undefined; 21142 this.cause = options.cause || undefined; 21143 this.column = start ? start.column : undefined; 21144 this.fatal = undefined; 21145 this.file; 21146 this.message = reason; 21147 this.line = start ? start.line : undefined; 21148 this.name = stringifyPosition(options.place) || '1:1'; 21149 this.place = options.place || undefined; 21150 this.reason = this.message; 21151 this.ruleId = options.ruleId || undefined; 21152 this.source = options.source || undefined; 21153 this.stack = 21154 legacyCause && options.cause && typeof options.cause.stack === 'string' 21155 ? options.cause.stack 21156 : ''; 21157 this.actual; 21158 this.expected; 21159 this.note; 21160 this.url; 21161 } 21162} 21163VFileMessage.prototype.file = ''; 21164VFileMessage.prototype.name = ''; 21165VFileMessage.prototype.reason = ''; 21166VFileMessage.prototype.message = ''; 21167VFileMessage.prototype.stack = ''; 21168VFileMessage.prototype.column = undefined; 21169VFileMessage.prototype.line = undefined; 21170VFileMessage.prototype.ancestors = undefined; 21171VFileMessage.prototype.cause = undefined; 21172VFileMessage.prototype.fatal = undefined; 21173VFileMessage.prototype.place = undefined; 21174VFileMessage.prototype.ruleId = undefined; 21175VFileMessage.prototype.source = undefined; 21176 21177function isUrl(fileUrlOrPath) { 21178 return Boolean( 21179 fileUrlOrPath !== null && 21180 typeof fileUrlOrPath === 'object' && 21181 'href' in fileUrlOrPath && 21182 fileUrlOrPath.href && 21183 'protocol' in fileUrlOrPath && 21184 fileUrlOrPath.protocol && 21185 fileUrlOrPath.auth === undefined 21186 ) 21187} 21188 21189const order = ([ 21190 'history', 21191 'path', 21192 'basename', 21193 'stem', 21194 'extname', 21195 'dirname' 21196]); 21197class VFile { 21198 constructor(value) { 21199 let options; 21200 if (!value) { 21201 options = {}; 21202 } else if (isUrl(value)) { 21203 options = {path: value}; 21204 } else if (typeof value === 'string' || isUint8Array$1(value)) { 21205 options = {value}; 21206 } else { 21207 options = value; 21208 } 21209 this.cwd = process$1.cwd(); 21210 this.data = {}; 21211 this.history = []; 21212 this.messages = []; 21213 this.value; 21214 this.map; 21215 this.result; 21216 this.stored; 21217 let index = -1; 21218 while (++index < order.length) { 21219 const prop = order[index]; 21220 if ( 21221 prop in options && 21222 options[prop] !== undefined && 21223 options[prop] !== null 21224 ) { 21225 this[prop] = prop === 'history' ? [...options[prop]] : options[prop]; 21226 } 21227 } 21228 let prop; 21229 for (prop in options) { 21230 if (!order.includes(prop)) { 21231 this[prop] = options[prop]; 21232 } 21233 } 21234 } 21235 get basename() { 21236 return typeof this.path === 'string' ? path$2.basename(this.path) : undefined 21237 } 21238 set basename(basename) { 21239 assertNonEmpty(basename, 'basename'); 21240 assertPart(basename, 'basename'); 21241 this.path = path$2.join(this.dirname || '', basename); 21242 } 21243 get dirname() { 21244 return typeof this.path === 'string' ? path$2.dirname(this.path) : undefined 21245 } 21246 set dirname(dirname) { 21247 assertPath(this.basename, 'dirname'); 21248 this.path = path$2.join(dirname || '', this.basename); 21249 } 21250 get extname() { 21251 return typeof this.path === 'string' ? path$2.extname(this.path) : undefined 21252 } 21253 set extname(extname) { 21254 assertPart(extname, 'extname'); 21255 assertPath(this.dirname, 'extname'); 21256 if (extname) { 21257 if (extname.codePointAt(0) !== 46 ) { 21258 throw new Error('`extname` must start with `.`') 21259 } 21260 if (extname.includes('.', 1)) { 21261 throw new Error('`extname` cannot contain multiple dots') 21262 } 21263 } 21264 this.path = path$2.join(this.dirname, this.stem + (extname || '')); 21265 } 21266 get path() { 21267 return this.history[this.history.length - 1] 21268 } 21269 set path(path) { 21270 if (isUrl(path)) { 21271 path = fileURLToPath$1(path); 21272 } 21273 assertNonEmpty(path, 'path'); 21274 if (this.path !== path) { 21275 this.history.push(path); 21276 } 21277 } 21278 get stem() { 21279 return typeof this.path === 'string' 21280 ? path$2.basename(this.path, this.extname) 21281 : undefined 21282 } 21283 set stem(stem) { 21284 assertNonEmpty(stem, 'stem'); 21285 assertPart(stem, 'stem'); 21286 this.path = path$2.join(this.dirname || '', stem + (this.extname || '')); 21287 } 21288 fail(causeOrReason, optionsOrParentOrPlace, origin) { 21289 const message = this.message(causeOrReason, optionsOrParentOrPlace, origin); 21290 message.fatal = true; 21291 throw message 21292 } 21293 info(causeOrReason, optionsOrParentOrPlace, origin) { 21294 const message = this.message(causeOrReason, optionsOrParentOrPlace, origin); 21295 message.fatal = undefined; 21296 return message 21297 } 21298 message(causeOrReason, optionsOrParentOrPlace, origin) { 21299 const message = new VFileMessage( 21300 causeOrReason, 21301 optionsOrParentOrPlace, 21302 origin 21303 ); 21304 if (this.path) { 21305 message.name = this.path + ':' + message.name; 21306 message.file = this.path; 21307 } 21308 message.fatal = false; 21309 this.messages.push(message); 21310 return message 21311 } 21312 toString(encoding) { 21313 if (this.value === undefined) { 21314 return '' 21315 } 21316 if (typeof this.value === 'string') { 21317 return this.value 21318 } 21319 const decoder = new TextDecoder(encoding || undefined); 21320 return decoder.decode(this.value) 21321 } 21322} 21323function assertPart(part, name) { 21324 if (part && part.includes(path$2.sep)) { 21325 throw new Error( 21326 '`' + name + '` cannot be a path: did not expect `' + path$2.sep + '`' 21327 ) 21328 } 21329} 21330function assertNonEmpty(part, name) { 21331 if (!part) { 21332 throw new Error('`' + name + '` cannot be empty') 21333 } 21334} 21335function assertPath(path, name) { 21336 if (!path) { 21337 throw new Error('Setting `' + name + '` requires `path` to be set too') 21338 } 21339} 21340function isUint8Array$1(value) { 21341 return Boolean( 21342 value && 21343 typeof value === 'object' && 21344 'byteLength' in value && 21345 'byteOffset' in value 21346 ) 21347} 21348 21349function read(description, options, callback) { 21350 const file = toVFile(description); 21351 if (!callback && typeof options === 'function') { 21352 callback = options; 21353 options = undefined; 21354 } 21355 if (!callback) { 21356 return new Promise(executor) 21357 } 21358 executor(resolve, callback); 21359 function resolve(result) { 21360 callback(undefined, result); 21361 } 21362 function executor(resolve, reject) { 21363 let fp; 21364 try { 21365 fp = path$2.resolve(file.cwd, file.path); 21366 } catch (error) { 21367 const exception = (error); 21368 return reject(exception) 21369 } 21370 fs$1.readFile(fp, options, done); 21371 function done(error, result) { 21372 if (error) { 21373 reject(error); 21374 } else { 21375 file.value = result; 21376 resolve(file); 21377 } 21378 } 21379 } 21380} 21381function toVFile(description) { 21382 if (typeof description === 'string' || description instanceof URL) { 21383 description = {path: description}; 21384 } else if (isUint8Array(description)) { 21385 description = {path: new TextDecoder().decode(description)}; 21386 } 21387 return looksLikeAVFile(description) ? description : new VFile(description) 21388} 21389function looksLikeAVFile(value) { 21390 return Boolean( 21391 value && 21392 typeof value === 'object' && 21393 'message' in value && 21394 'messages' in value 21395 ) 21396} 21397function isUint8Array(value) { 21398 return Boolean( 21399 value && 21400 typeof value === 'object' && 21401 'byteLength' in value && 21402 'byteOffset' in value 21403 ) 21404} 21405 21406function ansiRegex({onlyFirst = false} = {}) { 21407 const pattern = [ 21408 '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', 21409 '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))' 21410 ].join('|'); 21411 return new RegExp(pattern, onlyFirst ? undefined : 'g'); 21412} 21413 21414const regex = ansiRegex(); 21415function stripAnsi(string) { 21416 if (typeof string !== 'string') { 21417 throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``); 21418 } 21419 return string.replace(regex, ''); 21420} 21421 21422var eastasianwidth = {exports: {}}; 21423 21424(function (module) { 21425 var eaw = {}; 21426 { 21427 module.exports = eaw; 21428 } 21429 eaw.eastAsianWidth = function(character) { 21430 var x = character.charCodeAt(0); 21431 var y = (character.length == 2) ? character.charCodeAt(1) : 0; 21432 var codePoint = x; 21433 if ((0xD800 <= x && x <= 0xDBFF) && (0xDC00 <= y && y <= 0xDFFF)) { 21434 x &= 0x3FF; 21435 y &= 0x3FF; 21436 codePoint = (x << 10) | y; 21437 codePoint += 0x10000; 21438 } 21439 if ((0x3000 == codePoint) || 21440 (0xFF01 <= codePoint && codePoint <= 0xFF60) || 21441 (0xFFE0 <= codePoint && codePoint <= 0xFFE6)) { 21442 return 'F'; 21443 } 21444 if ((0x20A9 == codePoint) || 21445 (0xFF61 <= codePoint && codePoint <= 0xFFBE) || 21446 (0xFFC2 <= codePoint && codePoint <= 0xFFC7) || 21447 (0xFFCA <= codePoint && codePoint <= 0xFFCF) || 21448 (0xFFD2 <= codePoint && codePoint <= 0xFFD7) || 21449 (0xFFDA <= codePoint && codePoint <= 0xFFDC) || 21450 (0xFFE8 <= codePoint && codePoint <= 0xFFEE)) { 21451 return 'H'; 21452 } 21453 if ((0x1100 <= codePoint && codePoint <= 0x115F) || 21454 (0x11A3 <= codePoint && codePoint <= 0x11A7) || 21455 (0x11FA <= codePoint && codePoint <= 0x11FF) || 21456 (0x2329 <= codePoint && codePoint <= 0x232A) || 21457 (0x2E80 <= codePoint && codePoint <= 0x2E99) || 21458 (0x2E9B <= codePoint && codePoint <= 0x2EF3) || 21459 (0x2F00 <= codePoint && codePoint <= 0x2FD5) || 21460 (0x2FF0 <= codePoint && codePoint <= 0x2FFB) || 21461 (0x3001 <= codePoint && codePoint <= 0x303E) || 21462 (0x3041 <= codePoint && codePoint <= 0x3096) || 21463 (0x3099 <= codePoint && codePoint <= 0x30FF) || 21464 (0x3105 <= codePoint && codePoint <= 0x312D) || 21465 (0x3131 <= codePoint && codePoint <= 0x318E) || 21466 (0x3190 <= codePoint && codePoint <= 0x31BA) || 21467 (0x31C0 <= codePoint && codePoint <= 0x31E3) || 21468 (0x31F0 <= codePoint && codePoint <= 0x321E) || 21469 (0x3220 <= codePoint && codePoint <= 0x3247) || 21470 (0x3250 <= codePoint && codePoint <= 0x32FE) || 21471 (0x3300 <= codePoint && codePoint <= 0x4DBF) || 21472 (0x4E00 <= codePoint && codePoint <= 0xA48C) || 21473 (0xA490 <= codePoint && codePoint <= 0xA4C6) || 21474 (0xA960 <= codePoint && codePoint <= 0xA97C) || 21475 (0xAC00 <= codePoint && codePoint <= 0xD7A3) || 21476 (0xD7B0 <= codePoint && codePoint <= 0xD7C6) || 21477 (0xD7CB <= codePoint && codePoint <= 0xD7FB) || 21478 (0xF900 <= codePoint && codePoint <= 0xFAFF) || 21479 (0xFE10 <= codePoint && codePoint <= 0xFE19) || 21480 (0xFE30 <= codePoint && codePoint <= 0xFE52) || 21481 (0xFE54 <= codePoint && codePoint <= 0xFE66) || 21482 (0xFE68 <= codePoint && codePoint <= 0xFE6B) || 21483 (0x1B000 <= codePoint && codePoint <= 0x1B001) || 21484 (0x1F200 <= codePoint && codePoint <= 0x1F202) || 21485 (0x1F210 <= codePoint && codePoint <= 0x1F23A) || 21486 (0x1F240 <= codePoint && codePoint <= 0x1F248) || 21487 (0x1F250 <= codePoint && codePoint <= 0x1F251) || 21488 (0x20000 <= codePoint && codePoint <= 0x2F73F) || 21489 (0x2B740 <= codePoint && codePoint <= 0x2FFFD) || 21490 (0x30000 <= codePoint && codePoint <= 0x3FFFD)) { 21491 return 'W'; 21492 } 21493 if ((0x0020 <= codePoint && codePoint <= 0x007E) || 21494 (0x00A2 <= codePoint && codePoint <= 0x00A3) || 21495 (0x00A5 <= codePoint && codePoint <= 0x00A6) || 21496 (0x00AC == codePoint) || 21497 (0x00AF == codePoint) || 21498 (0x27E6 <= codePoint && codePoint <= 0x27ED) || 21499 (0x2985 <= codePoint && codePoint <= 0x2986)) { 21500 return 'Na'; 21501 } 21502 if ((0x00A1 == codePoint) || 21503 (0x00A4 == codePoint) || 21504 (0x00A7 <= codePoint && codePoint <= 0x00A8) || 21505 (0x00AA == codePoint) || 21506 (0x00AD <= codePoint && codePoint <= 0x00AE) || 21507 (0x00B0 <= codePoint && codePoint <= 0x00B4) || 21508 (0x00B6 <= codePoint && codePoint <= 0x00BA) || 21509 (0x00BC <= codePoint && codePoint <= 0x00BF) || 21510 (0x00C6 == codePoint) || 21511 (0x00D0 == codePoint) || 21512 (0x00D7 <= codePoint && codePoint <= 0x00D8) || 21513 (0x00DE <= codePoint && codePoint <= 0x00E1) || 21514 (0x00E6 == codePoint) || 21515 (0x00E8 <= codePoint && codePoint <= 0x00EA) || 21516 (0x00EC <= codePoint && codePoint <= 0x00ED) || 21517 (0x00F0 == codePoint) || 21518 (0x00F2 <= codePoint && codePoint <= 0x00F3) || 21519 (0x00F7 <= codePoint && codePoint <= 0x00FA) || 21520 (0x00FC == codePoint) || 21521 (0x00FE == codePoint) || 21522 (0x0101 == codePoint) || 21523 (0x0111 == codePoint) || 21524 (0x0113 == codePoint) || 21525 (0x011B == codePoint) || 21526 (0x0126 <= codePoint && codePoint <= 0x0127) || 21527 (0x012B == codePoint) || 21528 (0x0131 <= codePoint && codePoint <= 0x0133) || 21529 (0x0138 == codePoint) || 21530 (0x013F <= codePoint && codePoint <= 0x0142) || 21531 (0x0144 == codePoint) || 21532 (0x0148 <= codePoint && codePoint <= 0x014B) || 21533 (0x014D == codePoint) || 21534 (0x0152 <= codePoint && codePoint <= 0x0153) || 21535 (0x0166 <= codePoint && codePoint <= 0x0167) || 21536 (0x016B == codePoint) || 21537 (0x01CE == codePoint) || 21538 (0x01D0 == codePoint) || 21539 (0x01D2 == codePoint) || 21540 (0x01D4 == codePoint) || 21541 (0x01D6 == codePoint) || 21542 (0x01D8 == codePoint) || 21543 (0x01DA == codePoint) || 21544 (0x01DC == codePoint) || 21545 (0x0251 == codePoint) || 21546 (0x0261 == codePoint) || 21547 (0x02C4 == codePoint) || 21548 (0x02C7 == codePoint) || 21549 (0x02C9 <= codePoint && codePoint <= 0x02CB) || 21550 (0x02CD == codePoint) || 21551 (0x02D0 == codePoint) || 21552 (0x02D8 <= codePoint && codePoint <= 0x02DB) || 21553 (0x02DD == codePoint) || 21554 (0x02DF == codePoint) || 21555 (0x0300 <= codePoint && codePoint <= 0x036F) || 21556 (0x0391 <= codePoint && codePoint <= 0x03A1) || 21557 (0x03A3 <= codePoint && codePoint <= 0x03A9) || 21558 (0x03B1 <= codePoint && codePoint <= 0x03C1) || 21559 (0x03C3 <= codePoint && codePoint <= 0x03C9) || 21560 (0x0401 == codePoint) || 21561 (0x0410 <= codePoint && codePoint <= 0x044F) || 21562 (0x0451 == codePoint) || 21563 (0x2010 == codePoint) || 21564 (0x2013 <= codePoint && codePoint <= 0x2016) || 21565 (0x2018 <= codePoint && codePoint <= 0x2019) || 21566 (0x201C <= codePoint && codePoint <= 0x201D) || 21567 (0x2020 <= codePoint && codePoint <= 0x2022) || 21568 (0x2024 <= codePoint && codePoint <= 0x2027) || 21569 (0x2030 == codePoint) || 21570 (0x2032 <= codePoint && codePoint <= 0x2033) || 21571 (0x2035 == codePoint) || 21572 (0x203B == codePoint) || 21573 (0x203E == codePoint) || 21574 (0x2074 == codePoint) || 21575 (0x207F == codePoint) || 21576 (0x2081 <= codePoint && codePoint <= 0x2084) || 21577 (0x20AC == codePoint) || 21578 (0x2103 == codePoint) || 21579 (0x2105 == codePoint) || 21580 (0x2109 == codePoint) || 21581 (0x2113 == codePoint) || 21582 (0x2116 == codePoint) || 21583 (0x2121 <= codePoint && codePoint <= 0x2122) || 21584 (0x2126 == codePoint) || 21585 (0x212B == codePoint) || 21586 (0x2153 <= codePoint && codePoint <= 0x2154) || 21587 (0x215B <= codePoint && codePoint <= 0x215E) || 21588 (0x2160 <= codePoint && codePoint <= 0x216B) || 21589 (0x2170 <= codePoint && codePoint <= 0x2179) || 21590 (0x2189 == codePoint) || 21591 (0x2190 <= codePoint && codePoint <= 0x2199) || 21592 (0x21B8 <= codePoint && codePoint <= 0x21B9) || 21593 (0x21D2 == codePoint) || 21594 (0x21D4 == codePoint) || 21595 (0x21E7 == codePoint) || 21596 (0x2200 == codePoint) || 21597 (0x2202 <= codePoint && codePoint <= 0x2203) || 21598 (0x2207 <= codePoint && codePoint <= 0x2208) || 21599 (0x220B == codePoint) || 21600 (0x220F == codePoint) || 21601 (0x2211 == codePoint) || 21602 (0x2215 == codePoint) || 21603 (0x221A == codePoint) || 21604 (0x221D <= codePoint && codePoint <= 0x2220) || 21605 (0x2223 == codePoint) || 21606 (0x2225 == codePoint) || 21607 (0x2227 <= codePoint && codePoint <= 0x222C) || 21608 (0x222E == codePoint) || 21609 (0x2234 <= codePoint && codePoint <= 0x2237) || 21610 (0x223C <= codePoint && codePoint <= 0x223D) || 21611 (0x2248 == codePoint) || 21612 (0x224C == codePoint) || 21613 (0x2252 == codePoint) || 21614 (0x2260 <= codePoint && codePoint <= 0x2261) || 21615 (0x2264 <= codePoint && codePoint <= 0x2267) || 21616 (0x226A <= codePoint && codePoint <= 0x226B) || 21617 (0x226E <= codePoint && codePoint <= 0x226F) || 21618 (0x2282 <= codePoint && codePoint <= 0x2283) || 21619 (0x2286 <= codePoint && codePoint <= 0x2287) || 21620 (0x2295 == codePoint) || 21621 (0x2299 == codePoint) || 21622 (0x22A5 == codePoint) || 21623 (0x22BF == codePoint) || 21624 (0x2312 == codePoint) || 21625 (0x2460 <= codePoint && codePoint <= 0x24E9) || 21626 (0x24EB <= codePoint && codePoint <= 0x254B) || 21627 (0x2550 <= codePoint && codePoint <= 0x2573) || 21628 (0x2580 <= codePoint && codePoint <= 0x258F) || 21629 (0x2592 <= codePoint && codePoint <= 0x2595) || 21630 (0x25A0 <= codePoint && codePoint <= 0x25A1) || 21631 (0x25A3 <= codePoint && codePoint <= 0x25A9) || 21632 (0x25B2 <= codePoint && codePoint <= 0x25B3) || 21633 (0x25B6 <= codePoint && codePoint <= 0x25B7) || 21634 (0x25BC <= codePoint && codePoint <= 0x25BD) || 21635 (0x25C0 <= codePoint && codePoint <= 0x25C1) || 21636 (0x25C6 <= codePoint && codePoint <= 0x25C8) || 21637 (0x25CB == codePoint) || 21638 (0x25CE <= codePoint && codePoint <= 0x25D1) || 21639 (0x25E2 <= codePoint && codePoint <= 0x25E5) || 21640 (0x25EF == codePoint) || 21641 (0x2605 <= codePoint && codePoint <= 0x2606) || 21642 (0x2609 == codePoint) || 21643 (0x260E <= codePoint && codePoint <= 0x260F) || 21644 (0x2614 <= codePoint && codePoint <= 0x2615) || 21645 (0x261C == codePoint) || 21646 (0x261E == codePoint) || 21647 (0x2640 == codePoint) || 21648 (0x2642 == codePoint) || 21649 (0x2660 <= codePoint && codePoint <= 0x2661) || 21650 (0x2663 <= codePoint && codePoint <= 0x2665) || 21651 (0x2667 <= codePoint && codePoint <= 0x266A) || 21652 (0x266C <= codePoint && codePoint <= 0x266D) || 21653 (0x266F == codePoint) || 21654 (0x269E <= codePoint && codePoint <= 0x269F) || 21655 (0x26BE <= codePoint && codePoint <= 0x26BF) || 21656 (0x26C4 <= codePoint && codePoint <= 0x26CD) || 21657 (0x26CF <= codePoint && codePoint <= 0x26E1) || 21658 (0x26E3 == codePoint) || 21659 (0x26E8 <= codePoint && codePoint <= 0x26FF) || 21660 (0x273D == codePoint) || 21661 (0x2757 == codePoint) || 21662 (0x2776 <= codePoint && codePoint <= 0x277F) || 21663 (0x2B55 <= codePoint && codePoint <= 0x2B59) || 21664 (0x3248 <= codePoint && codePoint <= 0x324F) || 21665 (0xE000 <= codePoint && codePoint <= 0xF8FF) || 21666 (0xFE00 <= codePoint && codePoint <= 0xFE0F) || 21667 (0xFFFD == codePoint) || 21668 (0x1F100 <= codePoint && codePoint <= 0x1F10A) || 21669 (0x1F110 <= codePoint && codePoint <= 0x1F12D) || 21670 (0x1F130 <= codePoint && codePoint <= 0x1F169) || 21671 (0x1F170 <= codePoint && codePoint <= 0x1F19A) || 21672 (0xE0100 <= codePoint && codePoint <= 0xE01EF) || 21673 (0xF0000 <= codePoint && codePoint <= 0xFFFFD) || 21674 (0x100000 <= codePoint && codePoint <= 0x10FFFD)) { 21675 return 'A'; 21676 } 21677 return 'N'; 21678 }; 21679 eaw.characterLength = function(character) { 21680 var code = this.eastAsianWidth(character); 21681 if (code == 'F' || code == 'W' || code == 'A') { 21682 return 2; 21683 } else { 21684 return 1; 21685 } 21686 }; 21687 function stringToArray(string) { 21688 return string.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || []; 21689 } 21690 eaw.length = function(string) { 21691 var characters = stringToArray(string); 21692 var len = 0; 21693 for (var i = 0; i < characters.length; i++) { 21694 len = len + this.characterLength(characters[i]); 21695 } 21696 return len; 21697 }; 21698 eaw.slice = function(text, start, end) { 21699 textLen = eaw.length(text); 21700 start = start ? start : 0; 21701 end = end ? end : 1; 21702 if (start < 0) { 21703 start = textLen + start; 21704 } 21705 if (end < 0) { 21706 end = textLen + end; 21707 } 21708 var result = ''; 21709 var eawLen = 0; 21710 var chars = stringToArray(text); 21711 for (var i = 0; i < chars.length; i++) { 21712 var char = chars[i]; 21713 var charLen = eaw.length(char); 21714 if (eawLen >= start - (charLen == 2 ? 1 : 0)) { 21715 if (eawLen + charLen <= end) { 21716 result += char; 21717 } else { 21718 break; 21719 } 21720 } 21721 eawLen += charLen; 21722 } 21723 return result; 21724 }; 21725} (eastasianwidth)); 21726var eastasianwidthExports = eastasianwidth.exports; 21727var eastAsianWidth = getDefaultExportFromCjs(eastasianwidthExports); 21728 21729var emojiRegex = () => { 21730 return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC3\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC08\uDC26](?:\u200D\u2B1B)?|[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g; 21731}; 21732 21733function stringWidth(string, options) { 21734 if (typeof string !== 'string' || string.length === 0) { 21735 return 0; 21736 } 21737 options = { 21738 ambiguousIsNarrow: true, 21739 countAnsiEscapeCodes: false, 21740 ...options, 21741 }; 21742 if (!options.countAnsiEscapeCodes) { 21743 string = stripAnsi(string); 21744 } 21745 if (string.length === 0) { 21746 return 0; 21747 } 21748 const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2; 21749 let width = 0; 21750 for (const {segment: character} of new Intl.Segmenter().segment(string)) { 21751 const codePoint = character.codePointAt(0); 21752 if (codePoint <= 0x1F || (codePoint >= 0x7F && codePoint <= 0x9F)) { 21753 continue; 21754 } 21755 if (codePoint >= 0x3_00 && codePoint <= 0x3_6F) { 21756 continue; 21757 } 21758 if (emojiRegex().test(character)) { 21759 width += 2; 21760 continue; 21761 } 21762 const code = eastAsianWidth.eastAsianWidth(character); 21763 switch (code) { 21764 case 'F': 21765 case 'W': { 21766 width += 2; 21767 break; 21768 } 21769 case 'A': { 21770 width += ambiguousCharacterWidth; 21771 break; 21772 } 21773 default: { 21774 width += 1; 21775 } 21776 } 21777 } 21778 return width; 21779} 21780 21781function compareFile(a, b) { 21782 return compareString(a, b, 'path') 21783} 21784function compareMessage(a, b) { 21785 return ( 21786 compareNumber(a, b, 'line') || 21787 compareNumber(a, b, 'column') || 21788 compareBoolean(a, b, 'fatal') || 21789 compareString(a, b, 'source') || 21790 compareString(a, b, 'ruleId') || 21791 compareString(a, b, 'reason') 21792 ) 21793} 21794function compareBoolean(a, b, field) { 21795 return scoreNullableBoolean(a[field]) - scoreNullableBoolean(b[field]) 21796} 21797function compareNumber(a, b, field) { 21798 return (a[field] || 0) - (b[field] || 0) 21799} 21800function compareString(a, b, field) { 21801 return String(a[field] || '').localeCompare(String(b[field] || '')) 21802} 21803function scoreNullableBoolean(value) { 21804 return value ? 0 : value === false ? 1 : 2 21805} 21806 21807function statistics(value) { 21808 const result = {fatal: 0, warn: 0, info: 0}; 21809 if (!value) { 21810 throw new TypeError( 21811 'Expected file or message for `value`, not `' + value + '`' 21812 ) 21813 } 21814 if (Array.isArray(value)) { 21815 list(value); 21816 } else { 21817 one(value); 21818 } 21819 return { 21820 fatal: result.fatal, 21821 nonfatal: result.warn + result.info, 21822 warn: result.warn, 21823 info: result.info, 21824 total: result.fatal + result.warn + result.info 21825 } 21826 function list(value) { 21827 let index = -1; 21828 while (++index < value.length) { 21829 one(value[index]); 21830 } 21831 } 21832 function one(value) { 21833 if ('messages' in value) return list(value.messages) 21834 result[value.fatal ? 'fatal' : value.fatal === false ? 'warn' : 'info']++; 21835 } 21836} 21837 21838function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) { 21839 const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); 21840 const position = argv.indexOf(prefix + flag); 21841 const terminatorPosition = argv.indexOf('--'); 21842 return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); 21843} 21844const {env} = process$1; 21845let flagForceColor; 21846if ( 21847 hasFlag('no-color') 21848 || hasFlag('no-colors') 21849 || hasFlag('color=false') 21850 || hasFlag('color=never') 21851) { 21852 flagForceColor = 0; 21853} else if ( 21854 hasFlag('color') 21855 || hasFlag('colors') 21856 || hasFlag('color=true') 21857 || hasFlag('color=always') 21858) { 21859 flagForceColor = 1; 21860} 21861function envForceColor() { 21862 if ('FORCE_COLOR' in env) { 21863 if (env.FORCE_COLOR === 'true') { 21864 return 1; 21865 } 21866 if (env.FORCE_COLOR === 'false') { 21867 return 0; 21868 } 21869 return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3); 21870 } 21871} 21872function translateLevel(level) { 21873 if (level === 0) { 21874 return false; 21875 } 21876 return { 21877 level, 21878 hasBasic: true, 21879 has256: level >= 2, 21880 has16m: level >= 3, 21881 }; 21882} 21883function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { 21884 const noFlagForceColor = envForceColor(); 21885 if (noFlagForceColor !== undefined) { 21886 flagForceColor = noFlagForceColor; 21887 } 21888 const forceColor = sniffFlags ? flagForceColor : noFlagForceColor; 21889 if (forceColor === 0) { 21890 return 0; 21891 } 21892 if (sniffFlags) { 21893 if (hasFlag('color=16m') 21894 || hasFlag('color=full') 21895 || hasFlag('color=truecolor')) { 21896 return 3; 21897 } 21898 if (hasFlag('color=256')) { 21899 return 2; 21900 } 21901 } 21902 if ('TF_BUILD' in env && 'AGENT_NAME' in env) { 21903 return 1; 21904 } 21905 if (haveStream && !streamIsTTY && forceColor === undefined) { 21906 return 0; 21907 } 21908 const min = forceColor || 0; 21909 if (env.TERM === 'dumb') { 21910 return min; 21911 } 21912 if (process$1.platform === 'win32') { 21913 const osRelease = os.release().split('.'); 21914 if ( 21915 Number(osRelease[0]) >= 10 21916 && Number(osRelease[2]) >= 10_586 21917 ) { 21918 return Number(osRelease[2]) >= 14_931 ? 3 : 2; 21919 } 21920 return 1; 21921 } 21922 if ('CI' in env) { 21923 if ('GITHUB_ACTIONS' in env || 'GITEA_ACTIONS' in env) { 21924 return 3; 21925 } 21926 if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') { 21927 return 1; 21928 } 21929 return min; 21930 } 21931 if ('TEAMCITY_VERSION' in env) { 21932 return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; 21933 } 21934 if (env.COLORTERM === 'truecolor') { 21935 return 3; 21936 } 21937 if (env.TERM === 'xterm-kitty') { 21938 return 3; 21939 } 21940 if ('TERM_PROGRAM' in env) { 21941 const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); 21942 switch (env.TERM_PROGRAM) { 21943 case 'iTerm.app': { 21944 return version >= 3 ? 3 : 2; 21945 } 21946 case 'Apple_Terminal': { 21947 return 2; 21948 } 21949 } 21950 } 21951 if (/-256(color)?$/i.test(env.TERM)) { 21952 return 2; 21953 } 21954 if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { 21955 return 1; 21956 } 21957 if ('COLORTERM' in env) { 21958 return 1; 21959 } 21960 return min; 21961} 21962function createSupportsColor(stream, options = {}) { 21963 const level = _supportsColor(stream, { 21964 streamIsTTY: stream && stream.isTTY, 21965 ...options, 21966 }); 21967 return translateLevel(level); 21968} 21969const supportsColor = { 21970 stdout: createSupportsColor({isTTY: tty.isatty(1)}), 21971 stderr: createSupportsColor({isTTY: tty.isatty(2)}), 21972}; 21973 21974const color = supportsColor.stderr.hasBasic; 21975 21976const eol = /\r?\n|\r/; 21977function reporter(files, options) { 21978 if ( 21979 !files || 21980 ('name' in files && 'message' in files) 21981 ) { 21982 throw new TypeError( 21983 'Unexpected value for `files`, expected one or more `VFile`s' 21984 ) 21985 } 21986 const settings = options || {}; 21987 const colorEnabled = 21988 typeof settings.color === 'boolean' ? settings.color : color; 21989 let oneFileMode = false; 21990 if (Array.isArray(files)) ; else { 21991 oneFileMode = true; 21992 files = [files]; 21993 } 21994 return serializeRows( 21995 createRows( 21996 { 21997 defaultName: settings.defaultName || undefined, 21998 oneFileMode, 21999 quiet: settings.quiet || false, 22000 silent: settings.silent || false, 22001 traceLimit: 22002 typeof settings.traceLimit === 'number' ? settings.traceLimit : 10, 22003 verbose: settings.verbose || false, 22004 bold: colorEnabled ? '\u001B[1m' : '', 22005 underline: colorEnabled ? '\u001B[4m' : '', 22006 normalIntensity: colorEnabled ? '\u001B[22m' : '', 22007 noUnderline: colorEnabled ? '\u001B[24m' : '', 22008 red: colorEnabled ? '\u001B[31m' : '', 22009 cyan: colorEnabled ? '\u001B[36m' : '', 22010 green: colorEnabled ? '\u001B[32m' : '', 22011 yellow: colorEnabled ? '\u001B[33m' : '', 22012 defaultColor: colorEnabled ? '\u001B[39m' : '' 22013 }, 22014 files 22015 ) 22016 ) 22017} 22018function createAncestorsLines(state, ancestors) { 22019 const min = 22020 ancestors.length > state.traceLimit 22021 ? ancestors.length - state.traceLimit 22022 : 0; 22023 let index = ancestors.length; 22024 const lines = []; 22025 if (index > min) { 22026 lines.unshift(' ' + state.bold + '[trace]' + state.normalIntensity + ':'); 22027 } 22028 while (index-- > min) { 22029 const node = ancestors[index]; 22030 const value = node; 22031 const name = 22032 typeof value.tagName === 'string' 22033 ? value.tagName 22034 : 22035 typeof value.name === 'string' 22036 ? value.name 22037 : undefined; 22038 const position = stringifyPosition$1(node.position); 22039 lines.push( 22040 ' at ' + 22041 state.yellow + 22042 node.type + 22043 (name ? '<' + name + '>' : '') + 22044 state.defaultColor + 22045 (position ? ' (' + position + ')' : '') 22046 ); 22047 } 22048 return lines 22049} 22050function createByline(state, stats) { 22051 let result = ''; 22052 if (stats.fatal) { 22053 result = 22054 state.red + 22055 '✖' + 22056 state.defaultColor + 22057 ' ' + 22058 stats.fatal + 22059 ' ' + 22060 (fatalToLabel(true) + (stats.fatal === 1 ? '' : 's')); 22061 } 22062 if (stats.warn) { 22063 result = 22064 (result ? result + ', ' : '') + 22065 (state.yellow + '⚠' + state.defaultColor) + 22066 ' ' + 22067 stats.warn + 22068 ' ' + 22069 (fatalToLabel(false) + (stats.warn === 1 ? '' : 's')); 22070 } 22071 if (stats.total !== stats.fatal && stats.total !== stats.warn) { 22072 result = stats.total + ' messages (' + result + ')'; 22073 } 22074 return result 22075} 22076function createCauseLines(state, cause) { 22077 const lines = [' ' + state.bold + '[cause]' + state.normalIntensity + ':']; 22078 const stackLines = (cause.stack || cause.message).split(eol); 22079 stackLines[0] = ' ' + stackLines[0]; 22080 lines.push(...stackLines); 22081 return lines 22082} 22083function createFileLine(state, file) { 22084 const stats = statistics(file.messages); 22085 const fromPath = file.history[0]; 22086 const toPath = file.path; 22087 let left = ''; 22088 let right = ''; 22089 if (!state.oneFileMode || state.defaultName || fromPath) { 22090 const name = fromPath || state.defaultName || '<stdin>'; 22091 left = 22092 state.underline + 22093 (stats.fatal ? state.red : stats.total ? state.yellow : state.green) + 22094 name + 22095 state.defaultColor + 22096 state.noUnderline + 22097 (file.stored && name !== toPath ? ' > ' + toPath : ''); 22098 } 22099 if (file.stored) { 22100 right = state.yellow + 'written' + state.defaultColor; 22101 } else if (!stats.total) { 22102 right = 'no issues found'; 22103 } 22104 return left && right ? left + ': ' + right : left + right 22105} 22106function createNoteLines(state, note) { 22107 const noteLines = note.split(eol); 22108 let index = -1; 22109 while (++index < noteLines.length) { 22110 noteLines[index] = ' ' + noteLines[index]; 22111 } 22112 return [ 22113 ' ' + state.bold + '[note]' + state.normalIntensity + ':', 22114 ...noteLines 22115 ] 22116} 22117function createMessageLine(state, message) { 22118 const label = fatalToLabel(message.fatal); 22119 let reason = message.stack || message.message; 22120 const match = eol.exec(reason); 22121 let rest = []; 22122 if (match) { 22123 rest = reason.slice(match.index + 1).split(eol); 22124 reason = reason.slice(0, match.index); 22125 } 22126 const place = message.place || message.position; 22127 const row = [ 22128 stringifyPosition$1(place), 22129 (label === 'error' ? state.red : state.yellow) + label + state.defaultColor, 22130 formatReason(state, reason), 22131 message.ruleId || '', 22132 message.source || '' 22133 ]; 22134 if (message.cause) { 22135 rest.push(...createCauseLines(state, message.cause)); 22136 } 22137 if (state.verbose && message.url) { 22138 rest.push(...createUrlLines(state, message.url)); 22139 } 22140 if (state.verbose && message.note) { 22141 rest.push(...createNoteLines(state, message.note)); 22142 } 22143 if (state.verbose && message.ancestors) { 22144 rest.push(...createAncestorsLines(state, message.ancestors)); 22145 } 22146 return [row, ...rest] 22147} 22148function createRows(state, files) { 22149 const sortedFiles = [...files].sort(compareFile); 22150 const all = []; 22151 let index = -1; 22152 const rows = []; 22153 let lastWasMessage = false; 22154 while (++index < sortedFiles.length) { 22155 const file = sortedFiles[index]; 22156 const messages = [...file.messages].sort(compareMessage); 22157 const messageRows = []; 22158 let offset = -1; 22159 while (++offset < messages.length) { 22160 const message = messages[offset]; 22161 if (!state.silent || message.fatal) { 22162 all.push(message); 22163 messageRows.push(...createMessageLine(state, message)); 22164 } 22165 } 22166 if ((!state.quiet && !state.silent) || messageRows.length > 0) { 22167 const line = createFileLine(state, file); 22168 if (lastWasMessage && line) rows.push(''); 22169 if (line) rows.push(line); 22170 if (messageRows.length > 0) rows.push(...messageRows); 22171 lastWasMessage = messageRows.length > 0; 22172 } 22173 } 22174 const stats = statistics(all); 22175 if (stats.fatal || stats.warn) { 22176 rows.push('', createByline(state, stats)); 22177 } 22178 return rows 22179} 22180function createUrlLines(state, url) { 22181 return [ 22182 ' ' + state.bold + '[url]' + state.normalIntensity + ':', 22183 ' ' + url 22184 ] 22185} 22186function formatReason(state, reason) { 22187 const result = []; 22188 const splits = []; 22189 let index = reason.indexOf('`'); 22190 while (index !== -1) { 22191 const split = {index, size: 1}; 22192 splits.push(split); 22193 while (reason.codePointAt(index + 1) === 96) { 22194 split.size++; 22195 index++; 22196 } 22197 index = reason.indexOf('`', index + 1); 22198 } 22199 index = -1; 22200 let textStart = 0; 22201 while (++index < splits.length) { 22202 let closeIndex = index; 22203 let close; 22204 while (++closeIndex < splits.length) { 22205 if (splits[index].size === splits[closeIndex].size) { 22206 close = splits[closeIndex]; 22207 break 22208 } 22209 } 22210 if (close) { 22211 const codeStart = splits[index].index; 22212 const codeEnd = close.index + close.size; 22213 result.push( 22214 reason.slice(textStart, codeStart) + 22215 state.cyan + 22216 reason.slice(codeStart, codeEnd) + 22217 state.defaultColor 22218 ); 22219 textStart = codeEnd; 22220 index = closeIndex; 22221 } 22222 } 22223 result.push(reason.slice(textStart)); 22224 return state.bold + result.join('') + state.normalIntensity 22225} 22226function fatalToLabel(value) { 22227 return value ? 'error' : value === false ? 'warning' : 'info' 22228} 22229function serializeRows(rows) { 22230 const sizes = []; 22231 let index = -1; 22232 while (++index < rows.length) { 22233 const row = rows[index]; 22234 if (typeof row === 'string') ; else { 22235 let cellIndex = -1; 22236 while (++cellIndex < row.length) { 22237 const current = sizes[cellIndex] || 0; 22238 const size = stringWidth(row[cellIndex]); 22239 if (size > current) { 22240 sizes[cellIndex] = size; 22241 } 22242 } 22243 } 22244 } 22245 const lines = []; 22246 index = -1; 22247 while (++index < rows.length) { 22248 const row = rows[index]; 22249 let line = ''; 22250 if (typeof row === 'string') { 22251 line = row; 22252 } else { 22253 let cellIndex = -1; 22254 while (++cellIndex < row.length) { 22255 const cell = row[cellIndex] || ''; 22256 const max = (sizes[cellIndex] || 0) + 1; 22257 line += cell + ' '.repeat(max - stringWidth(cell)); 22258 } 22259 } 22260 lines.push(line.trimEnd()); 22261 } 22262 return lines.join('\n') 22263} 22264 22265const paths = process.argv.slice(2); 22266if (!paths.length) { 22267 console.error('Usage: lint-md.mjs <path> [<path> ...]'); 22268 process.exit(1); 22269} 22270let format = false; 22271if (paths[0] === '--format') { 22272 paths.shift(); 22273 format = true; 22274} 22275const linter = unified() 22276 .use(remarkParse) 22277 .use(remarkPresetLintNode) 22278 .use(remarkStringify); 22279paths.forEach(async (path) => { 22280 const file = await read(path); 22281 const fileContents = file.toString(); 22282 const result = await linter.process(file); 22283 const isDifferent = fileContents !== result.toString(); 22284 if (format) { 22285 if (isDifferent) { 22286 fs.writeFileSync(path, result.toString()); 22287 } 22288 } else { 22289 if (isDifferent) { 22290 process.exitCode = 1; 22291 const cmd = process.platform === 'win32' ? 'vcbuild' : 'make'; 22292 console.error(`${path} is not formatted. Please run '${cmd} format-md'.`); 22293 } 22294 if (result.messages.length) { 22295 process.exitCode = 1; 22296 console.error(reporter(result)); 22297 } 22298 } 22299}); 22300