plutonium 0.16.1 → 0.16.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -144,8 +144,8 @@
144
144
  return NAN;
145
145
  }
146
146
  if (isObject(value)) {
147
- var other = typeof value.valueOf == "function" ? value.valueOf() : value;
148
- value = isObject(other) ? other + "" : other;
147
+ var other2 = typeof value.valueOf == "function" ? value.valueOf() : value;
148
+ value = isObject(other2) ? other2 + "" : other2;
149
149
  }
150
150
  if (typeof value != "string") {
151
151
  return value === 0 ? value : +value;
@@ -3364,7 +3364,6 @@
3364
3364
  window.Collapse = Collapse;
3365
3365
  window.initCollapses = initCollapses;
3366
3366
  }
3367
- var collapse_default = Collapse;
3368
3367
 
3369
3368
  // node_modules/flowbite/lib/esm/components/carousel/index.js
3370
3369
  var __assign3 = function() {
@@ -7269,19 +7268,27 @@
7269
7268
  static targets = ["trigger", "menu"];
7270
7269
  connect() {
7271
7270
  console.log(`resource-collapse connected: ${this.element}`);
7272
- this.collapse = new collapse_default(this.menuTarget, this.triggerTarget);
7273
- }
7274
- disconnect() {
7275
- this.collapse = null;
7271
+ if (!this.element.hasAttribute("data-visible")) {
7272
+ this.element.setAttribute("data-visible", "false");
7273
+ }
7274
+ this.#updateState();
7276
7275
  }
7277
7276
  toggle() {
7278
- this.collapse.toggle();
7279
- }
7280
- show() {
7281
- this.collapse.show();
7282
- }
7283
- hide() {
7284
- this.collapse.hide();
7277
+ const isVisible = this.element.getAttribute("data-visible") === "true";
7278
+ this.element.setAttribute("data-visible", (!isVisible).toString());
7279
+ this.#updateState();
7280
+ }
7281
+ #updateState() {
7282
+ const isVisible = this.element.getAttribute("data-visible") === "true";
7283
+ if (isVisible) {
7284
+ this.menuTarget.classList.remove("hidden");
7285
+ this.triggerTarget.setAttribute("aria-expanded", "true");
7286
+ this.dispatch("expand");
7287
+ } else {
7288
+ this.menuTarget.classList.add("hidden");
7289
+ this.triggerTarget.setAttribute("aria-expanded", "false");
7290
+ this.dispatch("collapse");
7291
+ }
7285
7292
  }
7286
7293
  };
7287
7294
 
@@ -8430,10 +8437,200 @@
8430
8437
  function changeDefaults(newDefaults) {
8431
8438
  _defaults = newDefaults;
8432
8439
  }
8433
- var escapeTest = /[&<>"']/;
8434
- var escapeReplace = new RegExp(escapeTest.source, "g");
8435
- var escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
8436
- var escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, "g");
8440
+ var noopTest = { exec: () => null };
8441
+ function edit(regex, opt = "") {
8442
+ let source = typeof regex === "string" ? regex : regex.source;
8443
+ const obj = {
8444
+ replace: (name, val) => {
8445
+ let valSource = typeof val === "string" ? val : val.source;
8446
+ valSource = valSource.replace(other.caret, "$1");
8447
+ source = source.replace(name, valSource);
8448
+ return obj;
8449
+ },
8450
+ getRegex: () => {
8451
+ return new RegExp(source, opt);
8452
+ }
8453
+ };
8454
+ return obj;
8455
+ }
8456
+ var other = {
8457
+ codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
8458
+ outputLinkReplace: /\\([\[\]])/g,
8459
+ indentCodeCompensation: /^(\s+)(?:```)/,
8460
+ beginningSpace: /^\s+/,
8461
+ endingHash: /#$/,
8462
+ startingSpaceChar: /^ /,
8463
+ endingSpaceChar: / $/,
8464
+ nonSpaceChar: /[^ ]/,
8465
+ newLineCharGlobal: /\n/g,
8466
+ tabCharGlobal: /\t/g,
8467
+ multipleSpaceGlobal: /\s+/g,
8468
+ blankLine: /^[ \t]*$/,
8469
+ doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
8470
+ blockquoteStart: /^ {0,3}>/,
8471
+ blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
8472
+ blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
8473
+ listReplaceTabs: /^\t+/,
8474
+ listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
8475
+ listIsTask: /^\[[ xX]\] /,
8476
+ listReplaceTask: /^\[[ xX]\] +/,
8477
+ anyLine: /\n.*\n/,
8478
+ hrefBrackets: /^<(.*)>$/,
8479
+ tableDelimiter: /[:|]/,
8480
+ tableAlignChars: /^\||\| *$/g,
8481
+ tableRowBlankLine: /\n[ \t]*$/,
8482
+ tableAlignRight: /^ *-+: *$/,
8483
+ tableAlignCenter: /^ *:-+: *$/,
8484
+ tableAlignLeft: /^ *:-+ *$/,
8485
+ startATag: /^<a /i,
8486
+ endATag: /^<\/a>/i,
8487
+ startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
8488
+ endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
8489
+ startAngleBracket: /^</,
8490
+ endAngleBracket: />$/,
8491
+ pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
8492
+ unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
8493
+ escapeTest: /[&<>"']/,
8494
+ escapeReplace: /[&<>"']/g,
8495
+ escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
8496
+ escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
8497
+ unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
8498
+ caret: /(^|[^\[])\^/g,
8499
+ percentDecode: /%25/g,
8500
+ findPipe: /\|/g,
8501
+ splitPipe: / \|/,
8502
+ slashPipe: /\\\|/g,
8503
+ carriageReturn: /\r\n|\r/g,
8504
+ spaceLine: /^ +$/gm,
8505
+ notSpaceStart: /^\S*/,
8506
+ endingNewline: /\n$/,
8507
+ listItemRegex: (bull) => new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`),
8508
+ nextBulletRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
8509
+ hrRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
8510
+ fencesBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`),
8511
+ headingBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`),
8512
+ htmlBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}<(?:[a-z].*>|!--)`, "i")
8513
+ };
8514
+ var newline = /^(?:[ \t]*(?:\n|$))+/;
8515
+ var blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
8516
+ var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
8517
+ var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
8518
+ var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
8519
+ var bullet = /(?:[*+-]|\d{1,9}[.)])/;
8520
+ var lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).getRegex();
8521
+ var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
8522
+ var blockText = /^[^\n]+/;
8523
+ var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
8524
+ var def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
8525
+ var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
8526
+ var _tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
8527
+ var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
8528
+ var html2 = edit("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
8529
+ var paragraph = edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
8530
+ var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
8531
+ var blockNormal = {
8532
+ blockquote,
8533
+ code: blockCode,
8534
+ def,
8535
+ fences,
8536
+ heading,
8537
+ hr,
8538
+ html: html2,
8539
+ lheading,
8540
+ list,
8541
+ newline,
8542
+ paragraph,
8543
+ table: noopTest,
8544
+ text: blockText
8545
+ };
8546
+ var gfmTable = edit("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
8547
+ var blockGfm = {
8548
+ ...blockNormal,
8549
+ table: gfmTable,
8550
+ paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex()
8551
+ };
8552
+ var blockPedantic = {
8553
+ ...blockNormal,
8554
+ html: edit(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", _comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
8555
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
8556
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
8557
+ fences: noopTest,
8558
+ // fences not supported
8559
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
8560
+ paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", lheading).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
8561
+ };
8562
+ var escape$1 = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
8563
+ var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
8564
+ var br = /^( {2,}|\\)\n(?!\s*$)/;
8565
+ var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
8566
+ var _punctuation = /[\p{P}\p{S}]/u;
8567
+ var _punctuationOrSpace = /[\s\p{P}\p{S}]/u;
8568
+ var _notPunctuationOrSpace = /[^\s\p{P}\p{S}]/u;
8569
+ var punctuation = edit(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, _punctuationOrSpace).getRegex();
8570
+ var blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
8571
+ var emStrongLDelim = edit(/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, "u").replace(/punct/g, _punctuation).getRegex();
8572
+ var emStrongRDelimAst = edit("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
8573
+ var emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
8574
+ var anyPunctuation = edit(/\\(punct)/, "gu").replace(/punct/g, _punctuation).getRegex();
8575
+ var autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
8576
+ var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
8577
+ var tag = edit("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
8578
+ var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
8579
+ var link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
8580
+ var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
8581
+ var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
8582
+ var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
8583
+ var inlineNormal = {
8584
+ _backpedal: noopTest,
8585
+ // only used for GFM url
8586
+ anyPunctuation,
8587
+ autolink,
8588
+ blockSkip,
8589
+ br,
8590
+ code: inlineCode,
8591
+ del: noopTest,
8592
+ emStrongLDelim,
8593
+ emStrongRDelimAst,
8594
+ emStrongRDelimUnd,
8595
+ escape: escape$1,
8596
+ link,
8597
+ nolink,
8598
+ punctuation,
8599
+ reflink,
8600
+ reflinkSearch,
8601
+ tag,
8602
+ text: inlineText,
8603
+ url: noopTest
8604
+ };
8605
+ var inlinePedantic = {
8606
+ ...inlineNormal,
8607
+ link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
8608
+ reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
8609
+ };
8610
+ var inlineGfm = {
8611
+ ...inlineNormal,
8612
+ escape: edit(escape$1).replace("])", "~|])").getRegex(),
8613
+ url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
8614
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
8615
+ del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
8616
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
8617
+ };
8618
+ var inlineBreaks = {
8619
+ ...inlineGfm,
8620
+ br: edit(br).replace("{2,}", "*").getRegex(),
8621
+ text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
8622
+ };
8623
+ var block = {
8624
+ normal: blockNormal,
8625
+ gfm: blockGfm,
8626
+ pedantic: blockPedantic
8627
+ };
8628
+ var inline = {
8629
+ normal: inlineNormal,
8630
+ gfm: inlineGfm,
8631
+ breaks: inlineBreaks,
8632
+ pedantic: inlinePedantic
8633
+ };
8437
8634
  var escapeReplacements = {
8438
8635
  "&": "&amp;",
8439
8636
  "<": "&lt;",
@@ -8442,58 +8639,28 @@
8442
8639
  "'": "&#39;"
8443
8640
  };
8444
8641
  var getEscapeReplacement = (ch) => escapeReplacements[ch];
8445
- function escape$1(html3, encode) {
8642
+ function escape(html3, encode) {
8446
8643
  if (encode) {
8447
- if (escapeTest.test(html3)) {
8448
- return html3.replace(escapeReplace, getEscapeReplacement);
8644
+ if (other.escapeTest.test(html3)) {
8645
+ return html3.replace(other.escapeReplace, getEscapeReplacement);
8449
8646
  }
8450
8647
  } else {
8451
- if (escapeTestNoEncode.test(html3)) {
8452
- return html3.replace(escapeReplaceNoEncode, getEscapeReplacement);
8648
+ if (other.escapeTestNoEncode.test(html3)) {
8649
+ return html3.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
8453
8650
  }
8454
8651
  }
8455
8652
  return html3;
8456
8653
  }
8457
- var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
8458
- function unescape(html3) {
8459
- return html3.replace(unescapeTest, (_, n) => {
8460
- n = n.toLowerCase();
8461
- if (n === "colon")
8462
- return ":";
8463
- if (n.charAt(0) === "#") {
8464
- return n.charAt(1) === "x" ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
8465
- }
8466
- return "";
8467
- });
8468
- }
8469
- var caret = /(^|[^\[])\^/g;
8470
- function edit(regex, opt) {
8471
- let source = typeof regex === "string" ? regex : regex.source;
8472
- opt = opt || "";
8473
- const obj = {
8474
- replace: (name, val) => {
8475
- let valSource = typeof val === "string" ? val : val.source;
8476
- valSource = valSource.replace(caret, "$1");
8477
- source = source.replace(name, valSource);
8478
- return obj;
8479
- },
8480
- getRegex: () => {
8481
- return new RegExp(source, opt);
8482
- }
8483
- };
8484
- return obj;
8485
- }
8486
8654
  function cleanUrl(href) {
8487
8655
  try {
8488
- href = encodeURI(href).replace(/%25/g, "%");
8656
+ href = encodeURI(href).replace(other.percentDecode, "%");
8489
8657
  } catch {
8490
8658
  return null;
8491
8659
  }
8492
8660
  return href;
8493
8661
  }
8494
- var noopTest = { exec: () => null };
8495
8662
  function splitCells(tableRow, count) {
8496
- const row = tableRow.replace(/\|/g, (match, offset2, str) => {
8663
+ const row = tableRow.replace(other.findPipe, (match, offset2, str) => {
8497
8664
  let escaped = false;
8498
8665
  let curr = offset2;
8499
8666
  while (--curr >= 0 && str[curr] === "\\")
@@ -8503,12 +8670,12 @@
8503
8670
  } else {
8504
8671
  return " |";
8505
8672
  }
8506
- }), cells = row.split(/ \|/);
8673
+ }), cells = row.split(other.splitPipe);
8507
8674
  let i = 0;
8508
8675
  if (!cells[0].trim()) {
8509
8676
  cells.shift();
8510
8677
  }
8511
- if (cells.length > 0 && !cells[cells.length - 1].trim()) {
8678
+ if (cells.length > 0 && !cells.at(-1)?.trim()) {
8512
8679
  cells.pop();
8513
8680
  }
8514
8681
  if (count) {
@@ -8520,7 +8687,7 @@
8520
8687
  }
8521
8688
  }
8522
8689
  for (; i < cells.length; i++) {
8523
- cells[i] = cells[i].trim().replace(/\\\|/g, "|");
8690
+ cells[i] = cells[i].trim().replace(other.slashPipe, "|");
8524
8691
  }
8525
8692
  return cells;
8526
8693
  }
@@ -8561,10 +8728,10 @@
8561
8728
  }
8562
8729
  return -1;
8563
8730
  }
8564
- function outputLink(cap, link2, raw, lexer2) {
8731
+ function outputLink(cap, link2, raw, lexer2, rules) {
8565
8732
  const href = link2.href;
8566
- const title = link2.title ? escape$1(link2.title) : null;
8567
- const text2 = cap[1].replace(/\\([\[\]])/g, "$1");
8733
+ const title = link2.title || null;
8734
+ const text2 = cap[1].replace(rules.other.outputLinkReplace, "$1");
8568
8735
  if (cap[0].charAt(0) !== "!") {
8569
8736
  lexer2.state.inLink = true;
8570
8737
  const token = {
@@ -8583,17 +8750,17 @@
8583
8750
  raw,
8584
8751
  href,
8585
8752
  title,
8586
- text: escape$1(text2)
8753
+ text: text2
8587
8754
  };
8588
8755
  }
8589
- function indentCodeCompensation(raw, text2) {
8590
- const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
8756
+ function indentCodeCompensation(raw, text2, rules) {
8757
+ const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);
8591
8758
  if (matchIndentToCode === null) {
8592
8759
  return text2;
8593
8760
  }
8594
8761
  const indentToCode = matchIndentToCode[1];
8595
8762
  return text2.split("\n").map((node) => {
8596
- const matchIndentInNode = node.match(/^\s+/);
8763
+ const matchIndentInNode = node.match(rules.other.beginningSpace);
8597
8764
  if (matchIndentInNode === null) {
8598
8765
  return node;
8599
8766
  }
@@ -8625,7 +8792,7 @@
8625
8792
  code(src) {
8626
8793
  const cap = this.rules.block.code.exec(src);
8627
8794
  if (cap) {
8628
- const text2 = cap[0].replace(/^ {1,4}/gm, "");
8795
+ const text2 = cap[0].replace(this.rules.other.codeRemoveIndent, "");
8629
8796
  return {
8630
8797
  type: "code",
8631
8798
  raw: cap[0],
@@ -8638,7 +8805,7 @@
8638
8805
  const cap = this.rules.block.fences.exec(src);
8639
8806
  if (cap) {
8640
8807
  const raw = cap[0];
8641
- const text2 = indentCodeCompensation(raw, cap[3] || "");
8808
+ const text2 = indentCodeCompensation(raw, cap[3] || "", this.rules);
8642
8809
  return {
8643
8810
  type: "code",
8644
8811
  raw,
@@ -8651,11 +8818,11 @@
8651
8818
  const cap = this.rules.block.heading.exec(src);
8652
8819
  if (cap) {
8653
8820
  let text2 = cap[2].trim();
8654
- if (/#$/.test(text2)) {
8821
+ if (this.rules.other.endingHash.test(text2)) {
8655
8822
  const trimmed = rtrim(text2, "#");
8656
8823
  if (this.options.pedantic) {
8657
8824
  text2 = trimmed.trim();
8658
- } else if (!trimmed || / $/.test(trimmed)) {
8825
+ } else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {
8659
8826
  text2 = trimmed.trim();
8660
8827
  }
8661
8828
  }
@@ -8689,7 +8856,7 @@
8689
8856
  const currentLines = [];
8690
8857
  let i;
8691
8858
  for (i = 0; i < lines.length; i++) {
8692
- if (/^ {0,3}>/.test(lines[i])) {
8859
+ if (this.rules.other.blockquoteStart.test(lines[i])) {
8693
8860
  currentLines.push(lines[i]);
8694
8861
  inBlockquote = true;
8695
8862
  } else if (!inBlockquote) {
@@ -8700,7 +8867,7 @@
8700
8867
  }
8701
8868
  lines = lines.slice(i);
8702
8869
  const currentRaw = currentLines.join("\n");
8703
- const currentText = currentRaw.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, "\n $1").replace(/^ {0,3}>[ \t]?/gm, "");
8870
+ const currentText = currentRaw.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
8704
8871
  raw = raw ? `${raw}
8705
8872
  ${currentRaw}` : currentRaw;
8706
8873
  text2 = text2 ? `${text2}
@@ -8712,7 +8879,7 @@ ${currentText}` : currentText;
8712
8879
  if (lines.length === 0) {
8713
8880
  break;
8714
8881
  }
8715
- const lastToken = tokens[tokens.length - 1];
8882
+ const lastToken = tokens.at(-1);
8716
8883
  if (lastToken?.type === "code") {
8717
8884
  break;
8718
8885
  } else if (lastToken?.type === "blockquote") {
@@ -8730,7 +8897,7 @@ ${currentText}` : currentText;
8730
8897
  tokens[tokens.length - 1] = newToken;
8731
8898
  raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
8732
8899
  text2 = text2.substring(0, text2.length - oldToken.raw.length) + newToken.raw;
8733
- lines = newText.substring(tokens[tokens.length - 1].raw.length).split("\n");
8900
+ lines = newText.substring(tokens.at(-1).raw.length).split("\n");
8734
8901
  continue;
8735
8902
  }
8736
8903
  }
@@ -8759,7 +8926,7 @@ ${currentText}` : currentText;
8759
8926
  if (this.options.pedantic) {
8760
8927
  bull = isordered ? bull : "[*+-]";
8761
8928
  }
8762
- const itemRegex = new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`);
8929
+ const itemRegex = this.rules.other.listItemRegex(bull);
8763
8930
  let endsWithBlankLine = false;
8764
8931
  while (src) {
8765
8932
  let endEarly = false;
@@ -8773,7 +8940,7 @@ ${currentText}` : currentText;
8773
8940
  }
8774
8941
  raw = cap[0];
8775
8942
  src = src.substring(raw.length);
8776
- let line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t) => " ".repeat(3 * t.length));
8943
+ let line = cap[2].split("\n", 1)[0].replace(this.rules.other.listReplaceTabs, (t) => " ".repeat(3 * t.length));
8777
8944
  let nextLine = src.split("\n", 1)[0];
8778
8945
  let blankLine = !line.trim();
8779
8946
  let indent = 0;
@@ -8783,26 +8950,31 @@ ${currentText}` : currentText;
8783
8950
  } else if (blankLine) {
8784
8951
  indent = cap[1].length + 1;
8785
8952
  } else {
8786
- indent = cap[2].search(/[^ ]/);
8953
+ indent = cap[2].search(this.rules.other.nonSpaceChar);
8787
8954
  indent = indent > 4 ? 1 : indent;
8788
8955
  itemContents = line.slice(indent);
8789
8956
  indent += cap[1].length;
8790
8957
  }
8791
- if (blankLine && /^ *$/.test(nextLine)) {
8958
+ if (blankLine && this.rules.other.blankLine.test(nextLine)) {
8792
8959
  raw += nextLine + "\n";
8793
8960
  src = src.substring(nextLine.length + 1);
8794
8961
  endEarly = true;
8795
8962
  }
8796
8963
  if (!endEarly) {
8797
- const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`);
8798
- const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
8799
- const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
8800
- const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
8964
+ const nextBulletRegex = this.rules.other.nextBulletRegex(indent);
8965
+ const hrRegex = this.rules.other.hrRegex(indent);
8966
+ const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);
8967
+ const headingBeginRegex = this.rules.other.headingBeginRegex(indent);
8968
+ const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);
8801
8969
  while (src) {
8802
8970
  const rawLine = src.split("\n", 1)[0];
8971
+ let nextLineWithoutTabs;
8803
8972
  nextLine = rawLine;
8804
8973
  if (this.options.pedantic) {
8805
- nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
8974
+ nextLine = nextLine.replace(this.rules.other.listReplaceNesting, " ");
8975
+ nextLineWithoutTabs = nextLine;
8976
+ } else {
8977
+ nextLineWithoutTabs = nextLine.replace(this.rules.other.tabCharGlobal, " ");
8806
8978
  }
8807
8979
  if (fencesBeginRegex.test(nextLine)) {
8808
8980
  break;
@@ -8810,19 +8982,22 @@ ${currentText}` : currentText;
8810
8982
  if (headingBeginRegex.test(nextLine)) {
8811
8983
  break;
8812
8984
  }
8985
+ if (htmlBeginRegex.test(nextLine)) {
8986
+ break;
8987
+ }
8813
8988
  if (nextBulletRegex.test(nextLine)) {
8814
8989
  break;
8815
8990
  }
8816
- if (hrRegex.test(src)) {
8991
+ if (hrRegex.test(nextLine)) {
8817
8992
  break;
8818
8993
  }
8819
- if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) {
8820
- itemContents += "\n" + nextLine.slice(indent);
8994
+ if (nextLineWithoutTabs.search(this.rules.other.nonSpaceChar) >= indent || !nextLine.trim()) {
8995
+ itemContents += "\n" + nextLineWithoutTabs.slice(indent);
8821
8996
  } else {
8822
8997
  if (blankLine) {
8823
8998
  break;
8824
8999
  }
8825
- if (line.search(/[^ ]/) >= 4) {
9000
+ if (line.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4) {
8826
9001
  break;
8827
9002
  }
8828
9003
  if (fencesBeginRegex.test(line)) {
@@ -8841,23 +9016,23 @@ ${currentText}` : currentText;
8841
9016
  }
8842
9017
  raw += rawLine + "\n";
8843
9018
  src = src.substring(rawLine.length + 1);
8844
- line = nextLine.slice(indent);
9019
+ line = nextLineWithoutTabs.slice(indent);
8845
9020
  }
8846
9021
  }
8847
9022
  if (!list2.loose) {
8848
9023
  if (endsWithBlankLine) {
8849
9024
  list2.loose = true;
8850
- } else if (/\n *\n *$/.test(raw)) {
9025
+ } else if (this.rules.other.doubleBlankLine.test(raw)) {
8851
9026
  endsWithBlankLine = true;
8852
9027
  }
8853
9028
  }
8854
9029
  let istask = null;
8855
9030
  let ischecked;
8856
9031
  if (this.options.gfm) {
8857
- istask = /^\[[ xX]\] /.exec(itemContents);
9032
+ istask = this.rules.other.listIsTask.exec(itemContents);
8858
9033
  if (istask) {
8859
9034
  ischecked = istask[0] !== "[ ] ";
8860
- itemContents = itemContents.replace(/^\[[ xX]\] +/, "");
9035
+ itemContents = itemContents.replace(this.rules.other.listReplaceTask, "");
8861
9036
  }
8862
9037
  }
8863
9038
  list2.items.push({
@@ -8871,15 +9046,18 @@ ${currentText}` : currentText;
8871
9046
  });
8872
9047
  list2.raw += raw;
8873
9048
  }
8874
- list2.items[list2.items.length - 1].raw = list2.items[list2.items.length - 1].raw.trimEnd();
8875
- list2.items[list2.items.length - 1].text = list2.items[list2.items.length - 1].text.trimEnd();
9049
+ const lastItem = list2.items.at(-1);
9050
+ if (lastItem) {
9051
+ lastItem.raw = lastItem.raw.trimEnd();
9052
+ lastItem.text = lastItem.text.trimEnd();
9053
+ }
8876
9054
  list2.raw = list2.raw.trimEnd();
8877
9055
  for (let i = 0; i < list2.items.length; i++) {
8878
9056
  this.lexer.state.top = false;
8879
9057
  list2.items[i].tokens = this.lexer.blockTokens(list2.items[i].text, []);
8880
9058
  if (!list2.loose) {
8881
9059
  const spacers = list2.items[i].tokens.filter((t) => t.type === "space");
8882
- const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => /\n.*\n/.test(t.raw));
9060
+ const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => this.rules.other.anyLine.test(t.raw));
8883
9061
  list2.loose = hasMultipleLineBreaks;
8884
9062
  }
8885
9063
  }
@@ -8907,8 +9085,8 @@ ${currentText}` : currentText;
8907
9085
  def(src) {
8908
9086
  const cap = this.rules.block.def.exec(src);
8909
9087
  if (cap) {
8910
- const tag2 = cap[1].toLowerCase().replace(/\s+/g, " ");
8911
- const href = cap[2] ? cap[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
9088
+ const tag2 = cap[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " ");
9089
+ const href = cap[2] ? cap[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
8912
9090
  const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
8913
9091
  return {
8914
9092
  type: "def",
@@ -8924,12 +9102,12 @@ ${currentText}` : currentText;
8924
9102
  if (!cap) {
8925
9103
  return;
8926
9104
  }
8927
- if (!/[:|]/.test(cap[2])) {
9105
+ if (!this.rules.other.tableDelimiter.test(cap[2])) {
8928
9106
  return;
8929
9107
  }
8930
9108
  const headers = splitCells(cap[1]);
8931
- const aligns = cap[2].replace(/^\||\| *$/g, "").split("|");
8932
- const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : [];
9109
+ const aligns = cap[2].replace(this.rules.other.tableAlignChars, "").split("|");
9110
+ const rows = cap[3]?.trim() ? cap[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [];
8933
9111
  const item = {
8934
9112
  type: "table",
8935
9113
  raw: cap[0],
@@ -8941,11 +9119,11 @@ ${currentText}` : currentText;
8941
9119
  return;
8942
9120
  }
8943
9121
  for (const align of aligns) {
8944
- if (/^ *-+: *$/.test(align)) {
9122
+ if (this.rules.other.tableAlignRight.test(align)) {
8945
9123
  item.align.push("right");
8946
- } else if (/^ *:-+: *$/.test(align)) {
9124
+ } else if (this.rules.other.tableAlignCenter.test(align)) {
8947
9125
  item.align.push("center");
8948
- } else if (/^ *:-+ *$/.test(align)) {
9126
+ } else if (this.rules.other.tableAlignLeft.test(align)) {
8949
9127
  item.align.push("left");
8950
9128
  } else {
8951
9129
  item.align.push(null);
@@ -9012,21 +9190,21 @@ ${currentText}` : currentText;
9012
9190
  return {
9013
9191
  type: "escape",
9014
9192
  raw: cap[0],
9015
- text: escape$1(cap[1])
9193
+ text: cap[1]
9016
9194
  };
9017
9195
  }
9018
9196
  }
9019
9197
  tag(src) {
9020
9198
  const cap = this.rules.inline.tag.exec(src);
9021
9199
  if (cap) {
9022
- if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
9200
+ if (!this.lexer.state.inLink && this.rules.other.startATag.test(cap[0])) {
9023
9201
  this.lexer.state.inLink = true;
9024
- } else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
9202
+ } else if (this.lexer.state.inLink && this.rules.other.endATag.test(cap[0])) {
9025
9203
  this.lexer.state.inLink = false;
9026
9204
  }
9027
- if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
9205
+ if (!this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(cap[0])) {
9028
9206
  this.lexer.state.inRawBlock = true;
9029
- } else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
9207
+ } else if (this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(cap[0])) {
9030
9208
  this.lexer.state.inRawBlock = false;
9031
9209
  }
9032
9210
  return {
@@ -9043,8 +9221,8 @@ ${currentText}` : currentText;
9043
9221
  const cap = this.rules.inline.link.exec(src);
9044
9222
  if (cap) {
9045
9223
  const trimmedUrl = cap[2].trim();
9046
- if (!this.options.pedantic && /^</.test(trimmedUrl)) {
9047
- if (!/>$/.test(trimmedUrl)) {
9224
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(trimmedUrl)) {
9225
+ if (!this.rules.other.endAngleBracket.test(trimmedUrl)) {
9048
9226
  return;
9049
9227
  }
9050
9228
  const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
@@ -9064,7 +9242,7 @@ ${currentText}` : currentText;
9064
9242
  let href = cap[2];
9065
9243
  let title = "";
9066
9244
  if (this.options.pedantic) {
9067
- const link2 = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
9245
+ const link2 = this.rules.other.pedanticHrefTitle.exec(href);
9068
9246
  if (link2) {
9069
9247
  href = link2[1];
9070
9248
  title = link2[3];
@@ -9073,8 +9251,8 @@ ${currentText}` : currentText;
9073
9251
  title = cap[3] ? cap[3].slice(1, -1) : "";
9074
9252
  }
9075
9253
  href = href.trim();
9076
- if (/^</.test(href)) {
9077
- if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
9254
+ if (this.rules.other.startAngleBracket.test(href)) {
9255
+ if (this.options.pedantic && !this.rules.other.endAngleBracket.test(trimmedUrl)) {
9078
9256
  href = href.slice(1);
9079
9257
  } else {
9080
9258
  href = href.slice(1, -1);
@@ -9083,13 +9261,13 @@ ${currentText}` : currentText;
9083
9261
  return outputLink(cap, {
9084
9262
  href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
9085
9263
  title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
9086
- }, cap[0], this.lexer);
9264
+ }, cap[0], this.lexer, this.rules);
9087
9265
  }
9088
9266
  }
9089
9267
  reflink(src, links) {
9090
9268
  let cap;
9091
9269
  if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
9092
- const linkString = (cap[2] || cap[1]).replace(/\s+/g, " ");
9270
+ const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, " ");
9093
9271
  const link2 = links[linkString.toLowerCase()];
9094
9272
  if (!link2) {
9095
9273
  const text2 = cap[0].charAt(0);
@@ -9099,14 +9277,14 @@ ${currentText}` : currentText;
9099
9277
  text: text2
9100
9278
  };
9101
9279
  }
9102
- return outputLink(cap, link2, cap[0], this.lexer);
9280
+ return outputLink(cap, link2, cap[0], this.lexer, this.rules);
9103
9281
  }
9104
9282
  }
9105
9283
  emStrong(src, maskedSrc, prevChar = "") {
9106
9284
  let match = this.rules.inline.emStrongLDelim.exec(src);
9107
9285
  if (!match)
9108
9286
  return;
9109
- if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
9287
+ if (match[3] && prevChar.match(this.rules.other.unicodeAlphaNumeric))
9110
9288
  return;
9111
9289
  const nextChar = match[1] || match[2] || "";
9112
9290
  if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
@@ -9157,13 +9335,12 @@ ${currentText}` : currentText;
9157
9335
  codespan(src) {
9158
9336
  const cap = this.rules.inline.code.exec(src);
9159
9337
  if (cap) {
9160
- let text2 = cap[2].replace(/\n/g, " ");
9161
- const hasNonSpaceChars = /[^ ]/.test(text2);
9162
- const hasSpaceCharsOnBothEnds = /^ /.test(text2) && / $/.test(text2);
9338
+ let text2 = cap[2].replace(this.rules.other.newLineCharGlobal, " ");
9339
+ const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text2);
9340
+ const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text2) && this.rules.other.endingSpaceChar.test(text2);
9163
9341
  if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
9164
9342
  text2 = text2.substring(1, text2.length - 1);
9165
9343
  }
9166
- text2 = escape$1(text2, true);
9167
9344
  return {
9168
9345
  type: "codespan",
9169
9346
  raw: cap[0],
@@ -9196,10 +9373,10 @@ ${currentText}` : currentText;
9196
9373
  if (cap) {
9197
9374
  let text2, href;
9198
9375
  if (cap[2] === "@") {
9199
- text2 = escape$1(cap[1]);
9376
+ text2 = cap[1];
9200
9377
  href = "mailto:" + text2;
9201
9378
  } else {
9202
- text2 = escape$1(cap[1]);
9379
+ text2 = cap[1];
9203
9380
  href = text2;
9204
9381
  }
9205
9382
  return {
@@ -9222,7 +9399,7 @@ ${currentText}` : currentText;
9222
9399
  if (cap = this.rules.inline.url.exec(src)) {
9223
9400
  let text2, href;
9224
9401
  if (cap[2] === "@") {
9225
- text2 = escape$1(cap[0]);
9402
+ text2 = cap[0];
9226
9403
  href = "mailto:" + text2;
9227
9404
  } else {
9228
9405
  let prevCapZero;
@@ -9230,7 +9407,7 @@ ${currentText}` : currentText;
9230
9407
  prevCapZero = cap[0];
9231
9408
  cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? "";
9232
9409
  } while (prevCapZero !== cap[0]);
9233
- text2 = escape$1(cap[0]);
9410
+ text2 = cap[0];
9234
9411
  if (cap[1] === "www.") {
9235
9412
  href = "http://" + cap[0];
9236
9413
  } else {
@@ -9255,138 +9432,16 @@ ${currentText}` : currentText;
9255
9432
  inlineText(src) {
9256
9433
  const cap = this.rules.inline.text.exec(src);
9257
9434
  if (cap) {
9258
- let text2;
9259
- if (this.lexer.state.inRawBlock) {
9260
- text2 = cap[0];
9261
- } else {
9262
- text2 = escape$1(cap[0]);
9263
- }
9435
+ const escaped = this.lexer.state.inRawBlock;
9264
9436
  return {
9265
9437
  type: "text",
9266
9438
  raw: cap[0],
9267
- text: text2
9439
+ text: cap[0],
9440
+ escaped
9268
9441
  };
9269
9442
  }
9270
9443
  }
9271
9444
  };
9272
- var newline = /^(?: *(?:\n|$))+/;
9273
- var blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/;
9274
- var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
9275
- var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
9276
- var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
9277
- var bullet = /(?:[*+-]|\d{1,9}[.)])/;
9278
- var lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).replace(/blockCode/g, / {4}/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).getRegex();
9279
- var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
9280
- var blockText = /^[^\n]+/;
9281
- var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
9282
- var def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
9283
- var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
9284
- var _tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
9285
- var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
9286
- var html2 = edit("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))", "i").replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
9287
- var paragraph = edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
9288
- var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
9289
- var blockNormal = {
9290
- blockquote,
9291
- code: blockCode,
9292
- def,
9293
- fences,
9294
- heading,
9295
- hr,
9296
- html: html2,
9297
- lheading,
9298
- list,
9299
- newline,
9300
- paragraph,
9301
- table: noopTest,
9302
- text: blockText
9303
- };
9304
- var gfmTable = edit("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
9305
- var blockGfm = {
9306
- ...blockNormal,
9307
- table: gfmTable,
9308
- paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex()
9309
- };
9310
- var blockPedantic = {
9311
- ...blockNormal,
9312
- html: edit(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", _comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
9313
- def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
9314
- heading: /^(#{1,6})(.*)(?:\n+|$)/,
9315
- fences: noopTest,
9316
- // fences not supported
9317
- lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
9318
- paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", lheading).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
9319
- };
9320
- var escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
9321
- var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
9322
- var br = /^( {2,}|\\)\n(?!\s*$)/;
9323
- var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
9324
- var _punctuation = "\\p{P}\\p{S}";
9325
- var punctuation = edit(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, _punctuation).getRegex();
9326
- var blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
9327
- var emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, _punctuation).getRegex();
9328
- var emStrongRDelimAst = edit("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, _punctuation).getRegex();
9329
- var emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, _punctuation).getRegex();
9330
- var anyPunctuation = edit(/\\([punct])/, "gu").replace(/punct/g, _punctuation).getRegex();
9331
- var autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
9332
- var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
9333
- var tag = edit("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
9334
- var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
9335
- var link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
9336
- var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
9337
- var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
9338
- var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
9339
- var inlineNormal = {
9340
- _backpedal: noopTest,
9341
- // only used for GFM url
9342
- anyPunctuation,
9343
- autolink,
9344
- blockSkip,
9345
- br,
9346
- code: inlineCode,
9347
- del: noopTest,
9348
- emStrongLDelim,
9349
- emStrongRDelimAst,
9350
- emStrongRDelimUnd,
9351
- escape,
9352
- link,
9353
- nolink,
9354
- punctuation,
9355
- reflink,
9356
- reflinkSearch,
9357
- tag,
9358
- text: inlineText,
9359
- url: noopTest
9360
- };
9361
- var inlinePedantic = {
9362
- ...inlineNormal,
9363
- link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
9364
- reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
9365
- };
9366
- var inlineGfm = {
9367
- ...inlineNormal,
9368
- escape: edit(escape).replace("])", "~|])").getRegex(),
9369
- url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
9370
- _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
9371
- del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
9372
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
9373
- };
9374
- var inlineBreaks = {
9375
- ...inlineGfm,
9376
- br: edit(br).replace("{2,}", "*").getRegex(),
9377
- text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
9378
- };
9379
- var block = {
9380
- normal: blockNormal,
9381
- gfm: blockGfm,
9382
- pedantic: blockPedantic
9383
- };
9384
- var inline = {
9385
- normal: inlineNormal,
9386
- gfm: inlineGfm,
9387
- breaks: inlineBreaks,
9388
- pedantic: inlinePedantic
9389
- };
9390
9445
  var _Lexer = class __Lexer {
9391
9446
  tokens;
9392
9447
  options;
@@ -9408,6 +9463,7 @@ ${currentText}` : currentText;
9408
9463
  top: true
9409
9464
  };
9410
9465
  const rules = {
9466
+ other,
9411
9467
  block: block.normal,
9412
9468
  inline: inline.normal
9413
9469
  };
@@ -9451,7 +9507,7 @@ ${currentText}` : currentText;
9451
9507
  * Preprocessing
9452
9508
  */
9453
9509
  lex(src) {
9454
- src = src.replace(/\r\n|\r/g, "\n");
9510
+ src = src.replace(other.carriageReturn, "\n");
9455
9511
  this.blockTokens(src, this.tokens);
9456
9512
  for (let i = 0; i < this.inlineQueue.length; i++) {
9457
9513
  const next = this.inlineQueue[i];
@@ -9462,17 +9518,11 @@ ${currentText}` : currentText;
9462
9518
  }
9463
9519
  blockTokens(src, tokens = [], lastParagraphClipped = false) {
9464
9520
  if (this.options.pedantic) {
9465
- src = src.replace(/\t/g, " ").replace(/^ +$/gm, "");
9466
- } else {
9467
- src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
9468
- return leading + " ".repeat(tabs.length);
9469
- });
9521
+ src = src.replace(other.tabCharGlobal, " ").replace(other.spaceLine, "");
9470
9522
  }
9471
- let token;
9472
- let lastToken;
9473
- let cutSrc;
9474
9523
  while (src) {
9475
- if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
9524
+ let token;
9525
+ if (this.options.extensions?.block?.some((extTokenizer) => {
9476
9526
  if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
9477
9527
  src = src.substring(token.raw.length);
9478
9528
  tokens.push(token);
@@ -9484,8 +9534,9 @@ ${currentText}` : currentText;
9484
9534
  }
9485
9535
  if (token = this.tokenizer.space(src)) {
9486
9536
  src = src.substring(token.raw.length);
9487
- if (token.raw.length === 1 && tokens.length > 0) {
9488
- tokens[tokens.length - 1].raw += "\n";
9537
+ const lastToken = tokens.at(-1);
9538
+ if (token.raw.length === 1 && lastToken !== void 0) {
9539
+ lastToken.raw += "\n";
9489
9540
  } else {
9490
9541
  tokens.push(token);
9491
9542
  }
@@ -9493,11 +9544,11 @@ ${currentText}` : currentText;
9493
9544
  }
9494
9545
  if (token = this.tokenizer.code(src)) {
9495
9546
  src = src.substring(token.raw.length);
9496
- lastToken = tokens[tokens.length - 1];
9497
- if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
9547
+ const lastToken = tokens.at(-1);
9548
+ if (lastToken?.type === "paragraph" || lastToken?.type === "text") {
9498
9549
  lastToken.raw += "\n" + token.raw;
9499
9550
  lastToken.text += "\n" + token.text;
9500
- this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
9551
+ this.inlineQueue.at(-1).src = lastToken.text;
9501
9552
  } else {
9502
9553
  tokens.push(token);
9503
9554
  }
@@ -9535,11 +9586,11 @@ ${currentText}` : currentText;
9535
9586
  }
9536
9587
  if (token = this.tokenizer.def(src)) {
9537
9588
  src = src.substring(token.raw.length);
9538
- lastToken = tokens[tokens.length - 1];
9539
- if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
9589
+ const lastToken = tokens.at(-1);
9590
+ if (lastToken?.type === "paragraph" || lastToken?.type === "text") {
9540
9591
  lastToken.raw += "\n" + token.raw;
9541
9592
  lastToken.text += "\n" + token.raw;
9542
- this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
9593
+ this.inlineQueue.at(-1).src = lastToken.text;
9543
9594
  } else if (!this.tokens.links[token.tag]) {
9544
9595
  this.tokens.links[token.tag] = {
9545
9596
  href: token.href,
@@ -9558,8 +9609,8 @@ ${currentText}` : currentText;
9558
9609
  tokens.push(token);
9559
9610
  continue;
9560
9611
  }
9561
- cutSrc = src;
9562
- if (this.options.extensions && this.options.extensions.startBlock) {
9612
+ let cutSrc = src;
9613
+ if (this.options.extensions?.startBlock) {
9563
9614
  let startIndex = Infinity;
9564
9615
  const tempSrc = src.slice(1);
9565
9616
  let tempStart;
@@ -9574,12 +9625,12 @@ ${currentText}` : currentText;
9574
9625
  }
9575
9626
  }
9576
9627
  if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
9577
- lastToken = tokens[tokens.length - 1];
9628
+ const lastToken = tokens.at(-1);
9578
9629
  if (lastParagraphClipped && lastToken?.type === "paragraph") {
9579
9630
  lastToken.raw += "\n" + token.raw;
9580
9631
  lastToken.text += "\n" + token.text;
9581
9632
  this.inlineQueue.pop();
9582
- this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
9633
+ this.inlineQueue.at(-1).src = lastToken.text;
9583
9634
  } else {
9584
9635
  tokens.push(token);
9585
9636
  }
@@ -9589,12 +9640,12 @@ ${currentText}` : currentText;
9589
9640
  }
9590
9641
  if (token = this.tokenizer.text(src)) {
9591
9642
  src = src.substring(token.raw.length);
9592
- lastToken = tokens[tokens.length - 1];
9593
- if (lastToken && lastToken.type === "text") {
9643
+ const lastToken = tokens.at(-1);
9644
+ if (lastToken?.type === "text") {
9594
9645
  lastToken.raw += "\n" + token.raw;
9595
9646
  lastToken.text += "\n" + token.text;
9596
9647
  this.inlineQueue.pop();
9597
- this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
9648
+ this.inlineQueue.at(-1).src = lastToken.text;
9598
9649
  } else {
9599
9650
  tokens.push(token);
9600
9651
  }
@@ -9621,10 +9672,8 @@ ${currentText}` : currentText;
9621
9672
  * Lexing/Compiling
9622
9673
  */
9623
9674
  inlineTokens(src, tokens = []) {
9624
- let token, lastToken, cutSrc;
9625
9675
  let maskedSrc = src;
9626
- let match;
9627
- let keepPrevChar, prevChar;
9676
+ let match = null;
9628
9677
  if (this.tokens.links) {
9629
9678
  const links = Object.keys(this.tokens.links);
9630
9679
  if (links.length > 0) {
@@ -9641,12 +9690,15 @@ ${currentText}` : currentText;
9641
9690
  while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
9642
9691
  maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
9643
9692
  }
9693
+ let keepPrevChar = false;
9694
+ let prevChar = "";
9644
9695
  while (src) {
9645
9696
  if (!keepPrevChar) {
9646
9697
  prevChar = "";
9647
9698
  }
9648
9699
  keepPrevChar = false;
9649
- if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((extTokenizer) => {
9700
+ let token;
9701
+ if (this.options.extensions?.inline?.some((extTokenizer) => {
9650
9702
  if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
9651
9703
  src = src.substring(token.raw.length);
9652
9704
  tokens.push(token);
@@ -9663,13 +9715,7 @@ ${currentText}` : currentText;
9663
9715
  }
9664
9716
  if (token = this.tokenizer.tag(src)) {
9665
9717
  src = src.substring(token.raw.length);
9666
- lastToken = tokens[tokens.length - 1];
9667
- if (lastToken && token.type === "text" && lastToken.type === "text") {
9668
- lastToken.raw += token.raw;
9669
- lastToken.text += token.text;
9670
- } else {
9671
- tokens.push(token);
9672
- }
9718
+ tokens.push(token);
9673
9719
  continue;
9674
9720
  }
9675
9721
  if (token = this.tokenizer.link(src)) {
@@ -9679,8 +9725,8 @@ ${currentText}` : currentText;
9679
9725
  }
9680
9726
  if (token = this.tokenizer.reflink(src, this.tokens.links)) {
9681
9727
  src = src.substring(token.raw.length);
9682
- lastToken = tokens[tokens.length - 1];
9683
- if (lastToken && token.type === "text" && lastToken.type === "text") {
9728
+ const lastToken = tokens.at(-1);
9729
+ if (token.type === "text" && lastToken?.type === "text") {
9684
9730
  lastToken.raw += token.raw;
9685
9731
  lastToken.text += token.text;
9686
9732
  } else {
@@ -9718,8 +9764,8 @@ ${currentText}` : currentText;
9718
9764
  tokens.push(token);
9719
9765
  continue;
9720
9766
  }
9721
- cutSrc = src;
9722
- if (this.options.extensions && this.options.extensions.startInline) {
9767
+ let cutSrc = src;
9768
+ if (this.options.extensions?.startInline) {
9723
9769
  let startIndex = Infinity;
9724
9770
  const tempSrc = src.slice(1);
9725
9771
  let tempStart;
@@ -9739,8 +9785,8 @@ ${currentText}` : currentText;
9739
9785
  prevChar = token.raw.slice(-1);
9740
9786
  }
9741
9787
  keepPrevChar = true;
9742
- lastToken = tokens[tokens.length - 1];
9743
- if (lastToken && lastToken.type === "text") {
9788
+ const lastToken = tokens.at(-1);
9789
+ if (lastToken?.type === "text") {
9744
9790
  lastToken.raw += token.raw;
9745
9791
  lastToken.text += token.text;
9746
9792
  } else {
@@ -9772,12 +9818,12 @@ ${currentText}` : currentText;
9772
9818
  return "";
9773
9819
  }
9774
9820
  code({ text: text2, lang, escaped }) {
9775
- const langString = (lang || "").match(/^\S*/)?.[0];
9776
- const code = text2.replace(/\n$/, "") + "\n";
9821
+ const langString = (lang || "").match(other.notSpaceStart)?.[0];
9822
+ const code = text2.replace(other.endingNewline, "") + "\n";
9777
9823
  if (!langString) {
9778
- return "<pre><code>" + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
9824
+ return "<pre><code>" + (escaped ? code : escape(code, true)) + "</code></pre>\n";
9779
9825
  }
9780
- return '<pre><code class="language-' + escape$1(langString) + '">' + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
9826
+ return '<pre><code class="language-' + escape(langString) + '">' + (escaped ? code : escape(code, true)) + "</code></pre>\n";
9781
9827
  }
9782
9828
  blockquote({ tokens }) {
9783
9829
  const body = this.parser.parse(tokens);
@@ -9812,16 +9858,18 @@ ${body}</blockquote>
9812
9858
  if (item.task) {
9813
9859
  const checkbox = this.checkbox({ checked: !!item.checked });
9814
9860
  if (item.loose) {
9815
- if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
9861
+ if (item.tokens[0]?.type === "paragraph") {
9816
9862
  item.tokens[0].text = checkbox + " " + item.tokens[0].text;
9817
9863
  if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
9818
- item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
9864
+ item.tokens[0].tokens[0].text = checkbox + " " + escape(item.tokens[0].tokens[0].text);
9865
+ item.tokens[0].tokens[0].escaped = true;
9819
9866
  }
9820
9867
  } else {
9821
9868
  item.tokens.unshift({
9822
9869
  type: "text",
9823
9870
  raw: checkbox + " ",
9824
- text: checkbox + " "
9871
+ text: checkbox + " ",
9872
+ escaped: true
9825
9873
  });
9826
9874
  }
9827
9875
  } else {
@@ -9881,7 +9929,7 @@ ${text2}</tr>
9881
9929
  return `<em>${this.parser.parseInline(tokens)}</em>`;
9882
9930
  }
9883
9931
  codespan({ text: text2 }) {
9884
- return `<code>${text2}</code>`;
9932
+ return `<code>${escape(text2, true)}</code>`;
9885
9933
  }
9886
9934
  br(token) {
9887
9935
  return "<br>";
@@ -9898,7 +9946,7 @@ ${text2}</tr>
9898
9946
  href = cleanHref;
9899
9947
  let out = '<a href="' + href + '"';
9900
9948
  if (title) {
9901
- out += ' title="' + title + '"';
9949
+ out += ' title="' + escape(title) + '"';
9902
9950
  }
9903
9951
  out += ">" + text2 + "</a>";
9904
9952
  return out;
@@ -9906,18 +9954,18 @@ ${text2}</tr>
9906
9954
  image({ href, title, text: text2 }) {
9907
9955
  const cleanHref = cleanUrl(href);
9908
9956
  if (cleanHref === null) {
9909
- return text2;
9957
+ return escape(text2);
9910
9958
  }
9911
9959
  href = cleanHref;
9912
9960
  let out = `<img src="${href}" alt="${text2}"`;
9913
9961
  if (title) {
9914
- out += ` title="${title}"`;
9962
+ out += ` title="${escape(title)}"`;
9915
9963
  }
9916
9964
  out += ">";
9917
9965
  return out;
9918
9966
  }
9919
9967
  text(token) {
9920
- return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : token.text;
9968
+ return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : "escaped" in token && token.escaped ? token.text : escape(token.text);
9921
9969
  }
9922
9970
  };
9923
9971
  var _TextRenderer = class {
@@ -9983,7 +10031,7 @@ ${text2}</tr>
9983
10031
  let out = "";
9984
10032
  for (let i = 0; i < tokens.length; i++) {
9985
10033
  const anyToken = tokens[i];
9986
- if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
10034
+ if (this.options.extensions?.renderers?.[anyToken.type]) {
9987
10035
  const genericToken = anyToken;
9988
10036
  const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
9989
10037
  if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
@@ -10041,7 +10089,7 @@ ${text2}</tr>
10041
10089
  type: "paragraph",
10042
10090
  raw: body,
10043
10091
  text: body,
10044
- tokens: [{ type: "text", raw: body, text: body }]
10092
+ tokens: [{ type: "text", raw: body, text: body, escaped: true }]
10045
10093
  });
10046
10094
  } else {
10047
10095
  out += body;
@@ -10064,12 +10112,11 @@ ${text2}</tr>
10064
10112
  /**
10065
10113
  * Parse Inline Tokens
10066
10114
  */
10067
- parseInline(tokens, renderer) {
10068
- renderer = renderer || this.renderer;
10115
+ parseInline(tokens, renderer = this.renderer) {
10069
10116
  let out = "";
10070
10117
  for (let i = 0; i < tokens.length; i++) {
10071
10118
  const anyToken = tokens[i];
10072
- if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
10119
+ if (this.options.extensions?.renderers?.[anyToken.type]) {
10073
10120
  const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
10074
10121
  if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) {
10075
10122
  out += ret || "";
@@ -10134,6 +10181,7 @@ ${text2}</tr>
10134
10181
  };
10135
10182
  var _Hooks = class {
10136
10183
  options;
10184
+ block;
10137
10185
  constructor(options2) {
10138
10186
  this.options = options2 || _defaults;
10139
10187
  }
@@ -10160,12 +10208,24 @@ ${text2}</tr>
10160
10208
  processAllTokens(tokens) {
10161
10209
  return tokens;
10162
10210
  }
10211
+ /**
10212
+ * Provide function to tokenize markdown
10213
+ */
10214
+ provideLexer() {
10215
+ return this.block ? _Lexer.lex : _Lexer.lexInline;
10216
+ }
10217
+ /**
10218
+ * Provide function to parse tokens
10219
+ */
10220
+ provideParser() {
10221
+ return this.block ? _Parser.parse : _Parser.parseInline;
10222
+ }
10163
10223
  };
10164
10224
  var Marked = class {
10165
10225
  defaults = _getDefaults();
10166
10226
  options = this.setOptions;
10167
- parse = this.#parseMarkdown(_Lexer.lex, _Parser.parse);
10168
- parseInline = this.#parseMarkdown(_Lexer.lexInline, _Parser.parseInline);
10227
+ parse = this.parseMarkdown(true);
10228
+ parseInline = this.parseMarkdown(false);
10169
10229
  Parser = _Parser;
10170
10230
  Renderer = _Renderer;
10171
10231
  TextRenderer = _TextRenderer;
@@ -10281,10 +10341,7 @@ ${text2}</tr>
10281
10341
  continue;
10282
10342
  }
10283
10343
  const rendererProp = prop;
10284
- let rendererFunc = pack.renderer[rendererProp];
10285
- if (!pack.useNewRenderer) {
10286
- rendererFunc = this.#convertRendererFunction(rendererFunc, rendererProp, renderer);
10287
- }
10344
+ const rendererFunc = pack.renderer[rendererProp];
10288
10345
  const prevRenderer = renderer[rendererProp];
10289
10346
  renderer[rendererProp] = (...args2) => {
10290
10347
  let ret = rendererFunc.apply(renderer, args2);
@@ -10324,7 +10381,7 @@ ${text2}</tr>
10324
10381
  if (!(prop in hooks)) {
10325
10382
  throw new Error(`hook '${prop}' does not exist`);
10326
10383
  }
10327
- if (prop === "options") {
10384
+ if (["options", "block"].includes(prop)) {
10328
10385
  continue;
10329
10386
  }
10330
10387
  const hooksProp = prop;
@@ -10368,181 +10425,6 @@ ${text2}</tr>
10368
10425
  });
10369
10426
  return this;
10370
10427
  }
10371
- // TODO: Remove this in next major release
10372
- #convertRendererFunction(func, prop, renderer) {
10373
- switch (prop) {
10374
- case "heading":
10375
- return function(token) {
10376
- if (!token.type || token.type !== prop) {
10377
- return func.apply(this, arguments);
10378
- }
10379
- return func.call(this, renderer.parser.parseInline(token.tokens), token.depth, unescape(renderer.parser.parseInline(token.tokens, renderer.parser.textRenderer)));
10380
- };
10381
- case "code":
10382
- return function(token) {
10383
- if (!token.type || token.type !== prop) {
10384
- return func.apply(this, arguments);
10385
- }
10386
- return func.call(this, token.text, token.lang, !!token.escaped);
10387
- };
10388
- case "table":
10389
- return function(token) {
10390
- if (!token.type || token.type !== prop) {
10391
- return func.apply(this, arguments);
10392
- }
10393
- let header = "";
10394
- let cell = "";
10395
- for (let j = 0; j < token.header.length; j++) {
10396
- cell += this.tablecell({
10397
- text: token.header[j].text,
10398
- tokens: token.header[j].tokens,
10399
- header: true,
10400
- align: token.align[j]
10401
- });
10402
- }
10403
- header += this.tablerow({ text: cell });
10404
- let body = "";
10405
- for (let j = 0; j < token.rows.length; j++) {
10406
- const row = token.rows[j];
10407
- cell = "";
10408
- for (let k = 0; k < row.length; k++) {
10409
- cell += this.tablecell({
10410
- text: row[k].text,
10411
- tokens: row[k].tokens,
10412
- header: false,
10413
- align: token.align[k]
10414
- });
10415
- }
10416
- body += this.tablerow({ text: cell });
10417
- }
10418
- return func.call(this, header, body);
10419
- };
10420
- case "blockquote":
10421
- return function(token) {
10422
- if (!token.type || token.type !== prop) {
10423
- return func.apply(this, arguments);
10424
- }
10425
- const body = this.parser.parse(token.tokens);
10426
- return func.call(this, body);
10427
- };
10428
- case "list":
10429
- return function(token) {
10430
- if (!token.type || token.type !== prop) {
10431
- return func.apply(this, arguments);
10432
- }
10433
- const ordered = token.ordered;
10434
- const start3 = token.start;
10435
- const loose = token.loose;
10436
- let body = "";
10437
- for (let j = 0; j < token.items.length; j++) {
10438
- const item = token.items[j];
10439
- const checked = item.checked;
10440
- const task = item.task;
10441
- let itemBody = "";
10442
- if (item.task) {
10443
- const checkbox = this.checkbox({ checked: !!checked });
10444
- if (loose) {
10445
- if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
10446
- item.tokens[0].text = checkbox + " " + item.tokens[0].text;
10447
- if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
10448
- item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
10449
- }
10450
- } else {
10451
- item.tokens.unshift({
10452
- type: "text",
10453
- text: checkbox + " "
10454
- });
10455
- }
10456
- } else {
10457
- itemBody += checkbox + " ";
10458
- }
10459
- }
10460
- itemBody += this.parser.parse(item.tokens, loose);
10461
- body += this.listitem({
10462
- type: "list_item",
10463
- raw: itemBody,
10464
- text: itemBody,
10465
- task,
10466
- checked: !!checked,
10467
- loose,
10468
- tokens: item.tokens
10469
- });
10470
- }
10471
- return func.call(this, body, ordered, start3);
10472
- };
10473
- case "html":
10474
- return function(token) {
10475
- if (!token.type || token.type !== prop) {
10476
- return func.apply(this, arguments);
10477
- }
10478
- return func.call(this, token.text, token.block);
10479
- };
10480
- case "paragraph":
10481
- return function(token) {
10482
- if (!token.type || token.type !== prop) {
10483
- return func.apply(this, arguments);
10484
- }
10485
- return func.call(this, this.parser.parseInline(token.tokens));
10486
- };
10487
- case "escape":
10488
- return function(token) {
10489
- if (!token.type || token.type !== prop) {
10490
- return func.apply(this, arguments);
10491
- }
10492
- return func.call(this, token.text);
10493
- };
10494
- case "link":
10495
- return function(token) {
10496
- if (!token.type || token.type !== prop) {
10497
- return func.apply(this, arguments);
10498
- }
10499
- return func.call(this, token.href, token.title, this.parser.parseInline(token.tokens));
10500
- };
10501
- case "image":
10502
- return function(token) {
10503
- if (!token.type || token.type !== prop) {
10504
- return func.apply(this, arguments);
10505
- }
10506
- return func.call(this, token.href, token.title, token.text);
10507
- };
10508
- case "strong":
10509
- return function(token) {
10510
- if (!token.type || token.type !== prop) {
10511
- return func.apply(this, arguments);
10512
- }
10513
- return func.call(this, this.parser.parseInline(token.tokens));
10514
- };
10515
- case "em":
10516
- return function(token) {
10517
- if (!token.type || token.type !== prop) {
10518
- return func.apply(this, arguments);
10519
- }
10520
- return func.call(this, this.parser.parseInline(token.tokens));
10521
- };
10522
- case "codespan":
10523
- return function(token) {
10524
- if (!token.type || token.type !== prop) {
10525
- return func.apply(this, arguments);
10526
- }
10527
- return func.call(this, token.text);
10528
- };
10529
- case "del":
10530
- return function(token) {
10531
- if (!token.type || token.type !== prop) {
10532
- return func.apply(this, arguments);
10533
- }
10534
- return func.call(this, this.parser.parseInline(token.tokens));
10535
- };
10536
- case "text":
10537
- return function(token) {
10538
- if (!token.type || token.type !== prop) {
10539
- return func.apply(this, arguments);
10540
- }
10541
- return func.call(this, token.text);
10542
- };
10543
- }
10544
- return func;
10545
- }
10546
10428
  setOptions(opt) {
10547
10429
  this.defaults = { ...this.defaults, ...opt };
10548
10430
  return this;
@@ -10553,17 +10435,14 @@ ${text2}</tr>
10553
10435
  parser(tokens, options2) {
10554
10436
  return _Parser.parse(tokens, options2 ?? this.defaults);
10555
10437
  }
10556
- #parseMarkdown(lexer2, parser2) {
10557
- return (src, options2) => {
10438
+ parseMarkdown(blockType) {
10439
+ const parse = (src, options2) => {
10558
10440
  const origOpt = { ...options2 };
10559
10441
  const opt = { ...this.defaults, ...origOpt };
10442
+ const throwError = this.onError(!!opt.silent, !!opt.async);
10560
10443
  if (this.defaults.async === true && origOpt.async === false) {
10561
- if (!opt.silent) {
10562
- console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.");
10563
- }
10564
- opt.async = true;
10444
+ return throwError(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
10565
10445
  }
10566
- const throwError = this.#onError(!!opt.silent, !!opt.async);
10567
10446
  if (typeof src === "undefined" || src === null) {
10568
10447
  return throwError(new Error("marked(): input parameter is undefined or null"));
10569
10448
  }
@@ -10572,7 +10451,10 @@ ${text2}</tr>
10572
10451
  }
10573
10452
  if (opt.hooks) {
10574
10453
  opt.hooks.options = opt;
10454
+ opt.hooks.block = blockType;
10575
10455
  }
10456
+ const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
10457
+ const parser2 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
10576
10458
  if (opt.async) {
10577
10459
  return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html3) => opt.hooks ? opt.hooks.postprocess(html3) : html3).catch(throwError);
10578
10460
  }
@@ -10596,12 +10478,13 @@ ${text2}</tr>
10596
10478
  return throwError(e);
10597
10479
  }
10598
10480
  };
10481
+ return parse;
10599
10482
  }
10600
- #onError(silent, async) {
10483
+ onError(silent, async) {
10601
10484
  return (e) => {
10602
10485
  e.message += "\nPlease report this to https://github.com/markedjs/marked.";
10603
10486
  if (silent) {
10604
- const msg = "<p>An error occurred:</p><pre>" + escape$1(e.message + "", true) + "</pre>";
10487
+ const msg = "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
10605
10488
  if (async) {
10606
10489
  return Promise.resolve(msg);
10607
10490
  }