@ai-matrx/content-ir 0.19.15 → 0.19.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/source.cjs CHANGED
@@ -999,6 +999,204 @@ var XmlContainerTracker = class {
999
999
  }
1000
1000
  };
1001
1001
 
1002
+ // source/gfm-table.ts
1003
+ function splitRowSegments(line) {
1004
+ const segments = [];
1005
+ let start = 0;
1006
+ for (let i = 0; i < line.length; i += 1) {
1007
+ const ch = line[i];
1008
+ if (ch === "\\") {
1009
+ i += 1;
1010
+ continue;
1011
+ }
1012
+ if (ch === "|") {
1013
+ segments.push(line.slice(start, i));
1014
+ start = i + 1;
1015
+ }
1016
+ }
1017
+ segments.push(line.slice(start));
1018
+ return segments;
1019
+ }
1020
+ function rowCells(line) {
1021
+ const cells = splitRowSegments(line).map((cell) => cell.trim());
1022
+ if (cells.length > 1 && cells[0] === "") cells.shift();
1023
+ if (cells.length > 1 && cells[cells.length - 1] === "") cells.pop();
1024
+ else if (cells.length === 1 && cells[0] === "" && !line.includes("|")) cells.pop();
1025
+ return cells;
1026
+ }
1027
+ function unescapeCellPipes(cell) {
1028
+ return cell.replace(/\\\|/g, "|");
1029
+ }
1030
+ var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$|\[\^[^\]\s]+\]:)/;
1031
+ var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
1032
+ var HTML_RAW = /^<(?:script|pre|style|textarea)(?:[\s>]|$)/i;
1033
+ var HTML_COMMENT_ETC = /^(?:<!--|<\?|<![A-Za-z]|<!\[CDATA\[)/;
1034
+ var HTML_BLOCK_NAMES = "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|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
1035
+ var HTML_BLOCK_TAG = new RegExp(`^</?(?:${HTML_BLOCK_NAMES})(?:[\\s>]|/>|$)`, "i");
1036
+ var ATTRIBUTE = `\\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:\\s*=\\s*(?:[^\\s"'=<>\`]+|'[^']*'|"[^"]*"))?`;
1037
+ var HTML_COMPLETE_TAG = new RegExp(`^(?:<[A-Za-z][A-Za-z0-9-]*(?:${ATTRIBUTE})*\\s*/?>|</[A-Za-z][A-Za-z0-9-]*\\s*>)\\s*$`);
1038
+ var HTML_BLOCK_NAME_SET = /* @__PURE__ */ new Set([
1039
+ // Condition 1 (raw text) and condition 6 (block) tag names — CommonMark 0.31.
1040
+ "script",
1041
+ "pre",
1042
+ "style",
1043
+ "textarea",
1044
+ ...HTML_BLOCK_NAMES.replace("h[1-6]", "h1|h2|h3|h4|h5|h6").split("|")
1045
+ ]);
1046
+ function isHtmlBlockTagName(name) {
1047
+ return HTML_BLOCK_NAME_SET.has(name.toLowerCase());
1048
+ }
1049
+ function startsHtmlBlock(trimmed) {
1050
+ if (!trimmed.startsWith("<")) return false;
1051
+ return HTML_RAW.test(trimmed) || HTML_COMMENT_ETC.test(trimmed) || HTML_BLOCK_TAG.test(trimmed) || HTML_COMPLETE_TAG.test(trimmed);
1052
+ }
1053
+ function lineIndent(line) {
1054
+ let column = 0;
1055
+ for (const ch of line) {
1056
+ if (ch === " ") column += 1;
1057
+ else if (ch === " ") column += 4 - column % 4;
1058
+ else break;
1059
+ }
1060
+ return column;
1061
+ }
1062
+ var LIST_MARKER = /^([ \t]*)([-+*]|\d{1,9}[.)])([ \t]+|$)/;
1063
+ function markerContentColumn(marker) {
1064
+ const markerEnd = lineIndent(marker[1] ?? "") + (marker[2] ?? "").length;
1065
+ const gap = marker[3] ? lineIndent(" ".repeat(markerEnd) + marker[3]) - markerEnd : 1;
1066
+ return markerEnd + (gap >= 1 && gap <= 4 ? gap : 1);
1067
+ }
1068
+ function tableContainerIndent(lines, start) {
1069
+ return tableContainerIndentOf(lines, start, false);
1070
+ }
1071
+ function tableContainerIndentOf(lines, start, ownItem) {
1072
+ const own = ownItem ? LIST_MARKER.exec(lines[start] ?? "") : null;
1073
+ if (own) return markerContentColumn(own);
1074
+ const header = lineIndent(lines[start] ?? "");
1075
+ if (header === 0) return 0;
1076
+ for (let k = start - 1; k >= 0; k -= 1) {
1077
+ const line = lines[k] ?? "";
1078
+ if (!line.trim()) continue;
1079
+ const indent = lineIndent(line);
1080
+ const marker = LIST_MARKER.exec(line);
1081
+ if (marker && indent < header) {
1082
+ const content = markerContentColumn(marker);
1083
+ if (content <= header) return content;
1084
+ continue;
1085
+ }
1086
+ if (indent === 0) return 0;
1087
+ }
1088
+ return 0;
1089
+ }
1090
+ var DELIMITER_CELL = /^:?-+:?$/;
1091
+ function isGfmDelimiterRow(line) {
1092
+ const trimmed = line.trim();
1093
+ if (!trimmed.includes("|")) return false;
1094
+ const cells = rowCells(trimmed);
1095
+ return cells.length > 0 && cells.every((cell) => DELIMITER_CELL.test(cell));
1096
+ }
1097
+ function isPipeLedRow(line) {
1098
+ const trimmed = line.trim();
1099
+ return trimmed.startsWith("|") && trimmed.includes("|", 1);
1100
+ }
1101
+ function isTableDelimiter(line) {
1102
+ if (line === void 0 || !isGfmDelimiterRow(line)) return false;
1103
+ return !BLOCK_START.test(line.trim());
1104
+ }
1105
+ function startsPipelessTable(header, delimiter) {
1106
+ const head = header.trim();
1107
+ if (!head || isPipeLedRow(head) || !head.startsWith("|") && startsBlock(head)) return false;
1108
+ if (!isTableDelimiter(delimiter)) return false;
1109
+ return rowCells(head).length === rowCells(delimiter.trim()).length;
1110
+ }
1111
+ function continuesTable(line, containerIndent = 0) {
1112
+ const trimmed = line.trim();
1113
+ if (!trimmed) return false;
1114
+ if (lineIndent(line) - containerIndent >= 4) return false;
1115
+ return trimmed.startsWith("|") || !startsBlock(trimmed);
1116
+ }
1117
+ function opensTable(lines, index) {
1118
+ const line = lines[index] ?? "";
1119
+ if (!isPipeLedRow(line) && !startsPipelessTable(line, lines[index + 1])) return false;
1120
+ return !isLazyContinuation(lines, index) && !insideHtmlBlock(lines, index);
1121
+ }
1122
+ var QUOTE_LINE = /^ {0,3}>/;
1123
+ var THEMATIC_BREAK = /^(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
1124
+ var breaksParagraph = (trimmed) => /^#{1,6}(?:\s|$)/.test(trimmed) || THEMATIC_BREAK.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
1125
+ function htmlBlockEnd(trimmed) {
1126
+ if (HTML_RAW.test(trimmed)) return /<\/(?:script|pre|style|textarea)>/i;
1127
+ if (trimmed.startsWith("<!--")) return /-->/;
1128
+ if (trimmed.startsWith("<?")) return /\?>/;
1129
+ if (trimmed.startsWith("<![CDATA[")) return /\]\]>/;
1130
+ if (/^<![A-Za-z]/.test(trimmed)) return />/;
1131
+ if (HTML_BLOCK_TAG.test(trimmed)) return null;
1132
+ if (HTML_COMPLETE_TAG.test(trimmed)) return null;
1133
+ return void 0;
1134
+ }
1135
+ function insideHtmlBlock(lines, index) {
1136
+ let start = index;
1137
+ while (start > 0 && (lines[start - 1] ?? "").trim()) start -= 1;
1138
+ let open;
1139
+ let paragraph = false;
1140
+ for (let k = start; k < index; k += 1) {
1141
+ const line = lines[k] ?? "";
1142
+ if (open !== void 0) {
1143
+ if (open && open.test(line)) open = void 0;
1144
+ continue;
1145
+ }
1146
+ const trimmed = line.trim();
1147
+ const end = lineIndent(line) < 4 ? htmlBlockEnd(trimmed) : void 0;
1148
+ const type7 = end === null && !HTML_BLOCK_TAG.test(trimmed);
1149
+ const interrupts = end !== void 0 && !(paragraph && type7);
1150
+ if (!interrupts) {
1151
+ paragraph = true;
1152
+ continue;
1153
+ }
1154
+ paragraph = false;
1155
+ open = end && end.test(trimmed.slice(2)) ? void 0 : end;
1156
+ }
1157
+ return open !== void 0;
1158
+ }
1159
+ function isLazyContinuation(lines, index) {
1160
+ const header = lines[index] ?? "";
1161
+ let first = -1;
1162
+ for (let k = index - 1; k >= 0; k -= 1) {
1163
+ const line = lines[k] ?? "";
1164
+ const trimmed = line.trim();
1165
+ if (!trimmed) break;
1166
+ if (breaksParagraph(trimmed)) break;
1167
+ const marker = LIST_MARKER.exec(line);
1168
+ if (marker) {
1169
+ const rest = line.slice(marker[0].length).trim();
1170
+ if (!rest || breaksParagraph(rest)) break;
1171
+ first = k;
1172
+ break;
1173
+ }
1174
+ first = k;
1175
+ if (QUOTE_LINE.test(line)) break;
1176
+ }
1177
+ if (first < 0) return false;
1178
+ const start = lines[first] ?? "";
1179
+ if (QUOTE_LINE.test(start)) return !QUOTE_LINE.test(header);
1180
+ return lineIndent(header) < tableContainerIndentOf(lines, first, true);
1181
+ }
1182
+ function tableStartsAt(lines, index) {
1183
+ const header = lines[index] ?? "";
1184
+ const delimiter = lines[index + 1];
1185
+ if (!opensTable(lines, index) || !isTableDelimiter(delimiter)) return false;
1186
+ if (rowCells(header).length !== rowCells(delimiter).length) return false;
1187
+ return lineIndent(header) - tableContainerIndent(lines, index) < 4;
1188
+ }
1189
+ function findTableStart(lines, from = 0) {
1190
+ for (let i = Math.max(0, from); i < lines.length; i += 1) if (opensTable(lines, i)) return i;
1191
+ return -1;
1192
+ }
1193
+ function findTableEnd(lines, start) {
1194
+ const container = tableContainerIndent(lines, start);
1195
+ let end = Math.min(lines.length, start + 2);
1196
+ while (end < lines.length && continuesTable(lines[end] ?? "", container)) end += 1;
1197
+ return end;
1198
+ }
1199
+
1002
1200
  // source/tokenize.ts
1003
1201
  var NOT_WHITESPACE = /\S/;
1004
1202
  var DIRECTIVE_OPEN = /^(:{2,})([A-Za-z][\w-]*)/;
@@ -1840,9 +2038,12 @@ var Tokenizer = class {
1840
2038
  });
1841
2039
  }
1842
2040
  }
2041
+ if (isHtmlBlockTagName(root)) return null;
1843
2042
  return this.island("xml_container", p, this.n, false, { tag: root });
1844
2043
  }
1845
2044
  if (isUnclosedGenericXmlOpening(seg)) {
2045
+ const name = /^\s*<([A-Za-z_][\w.:-]*)/.exec(seg)?.[1] ?? "";
2046
+ if (isHtmlBlockTagName(name)) return null;
1846
2047
  return this.island("xml_container", p, this.n, false, {});
1847
2048
  }
1848
2049
  return null;
@@ -2612,20 +2813,36 @@ function normalizeLinkLabel(label) {
2612
2813
  var DEFINITION = /^ {0,3}\[((?:[^\]\\]|\\.){1,999})\]:[ \t]*(?:<([^<>\n]*)>|(\S+))(?:[ \t]+(?:"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)'|\(((?:[^()\\]|\\.)*)\)))?[ \t]*$/;
2613
2814
  function collectLinkDefinitions(text) {
2614
2815
  const defs = /* @__PURE__ */ new Map();
2615
- if (!text.includes("]:")) return defs;
2816
+ for (const { label, definition } of scanLinkDefinitions(text)) {
2817
+ const key = normalizeLinkLabel(label);
2818
+ if (key && !defs.has(key)) defs.set(key, definition);
2819
+ }
2820
+ return defs;
2821
+ }
2822
+ function findLinkDefinitionLines(text) {
2823
+ return scanLinkDefinitions(text).map(({ line }) => line);
2824
+ }
2825
+ function scanLinkDefinitions(text) {
2826
+ const found = [];
2827
+ if (!text.includes("]:")) return found;
2616
2828
  const lines = text.split("\n");
2617
2829
  const kinds = fenceLineKinds(text);
2830
+ let previousWasDefinition = false;
2618
2831
  lines.forEach((line, i) => {
2832
+ const wasDefinition = previousWasDefinition;
2833
+ previousWasDefinition = false;
2619
2834
  if (kinds[i] !== "prose") return;
2620
2835
  const m = DEFINITION.exec(line);
2621
2836
  if (!m) return;
2837
+ const above = i > 0 ? lines[i - 1] ?? "" : "";
2838
+ const opensBlock = i === 0 || !above.trim() || wasDefinition || kinds[i - 1] === "close" || /^ {0,3}(?:#{1,6}(?:\s|$)|(?:[-*_][ \t]*){3,}$)/.test(above);
2839
+ if (!opensBlock) return;
2622
2840
  const label = m[1] ?? "";
2623
2841
  if (label.startsWith("^")) return;
2624
- const key = normalizeLinkLabel(label);
2625
- if (!key || defs.has(key)) return;
2626
- defs.set(key, { url: m[2] ?? m[3] ?? "", title: m[4] ?? m[5] ?? m[6] ?? null });
2842
+ previousWasDefinition = true;
2843
+ found.push({ line: i, label, definition: { url: m[2] ?? m[3] ?? "", title: m[4] ?? m[5] ?? m[6] ?? null } });
2627
2844
  });
2628
- return defs;
2845
+ return found;
2629
2846
  }
2630
2847
  var REFERENCE = /(!?)\[((?:[^\]\\]|\\.)*)\](?:\[((?:[^\]\\]|\\.)*)\])?(?![(:[])/g;
2631
2848
  var escapeTitle = (title) => title.replace(/["\\]/g, "\\$&");
@@ -2650,204 +2867,6 @@ function resolveReferenceLinks(fragment, defs) {
2650
2867
  return resolved.replace(new RegExp(`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`, "g"), (_m, i) => spans[Number(i)] ?? "");
2651
2868
  }
2652
2869
 
2653
- // source/gfm-table.ts
2654
- function splitRowSegments(line) {
2655
- const segments = [];
2656
- let start = 0;
2657
- for (let i = 0; i < line.length; i += 1) {
2658
- const ch = line[i];
2659
- if (ch === "\\") {
2660
- i += 1;
2661
- continue;
2662
- }
2663
- if (ch === "|") {
2664
- segments.push(line.slice(start, i));
2665
- start = i + 1;
2666
- }
2667
- }
2668
- segments.push(line.slice(start));
2669
- return segments;
2670
- }
2671
- function rowCells(line) {
2672
- const cells = splitRowSegments(line).map((cell) => cell.trim());
2673
- if (cells.length > 1 && cells[0] === "") cells.shift();
2674
- if (cells.length > 1 && cells[cells.length - 1] === "") cells.pop();
2675
- else if (cells.length === 1 && cells[0] === "" && !line.includes("|")) cells.pop();
2676
- return cells;
2677
- }
2678
- function unescapeCellPipes(cell) {
2679
- return cell.replace(/\\\|/g, "|");
2680
- }
2681
- var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$|\[\^[^\]\s]+\]:)/;
2682
- var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
2683
- var HTML_RAW = /^<(?:script|pre|style|textarea)(?:[\s>]|$)/i;
2684
- var HTML_COMMENT_ETC = /^(?:<!--|<\?|<![A-Za-z]|<!\[CDATA\[)/;
2685
- var HTML_BLOCK_NAMES = "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|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
2686
- var HTML_BLOCK_TAG = new RegExp(`^</?(?:${HTML_BLOCK_NAMES})(?:[\\s>]|/>|$)`, "i");
2687
- var ATTRIBUTE = `\\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:\\s*=\\s*(?:[^\\s"'=<>\`]+|'[^']*'|"[^"]*"))?`;
2688
- var HTML_COMPLETE_TAG = new RegExp(`^(?:<[A-Za-z][A-Za-z0-9-]*(?:${ATTRIBUTE})*\\s*/?>|</[A-Za-z][A-Za-z0-9-]*\\s*>)\\s*$`);
2689
- var HTML_BLOCK_NAME_SET = /* @__PURE__ */ new Set([
2690
- // Condition 1 (raw text) and condition 6 (block) tag names — CommonMark 0.31.
2691
- "script",
2692
- "pre",
2693
- "style",
2694
- "textarea",
2695
- ...HTML_BLOCK_NAMES.replace("h[1-6]", "h1|h2|h3|h4|h5|h6").split("|")
2696
- ]);
2697
- function isHtmlBlockTagName(name) {
2698
- return HTML_BLOCK_NAME_SET.has(name.toLowerCase());
2699
- }
2700
- function startsHtmlBlock(trimmed) {
2701
- if (!trimmed.startsWith("<")) return false;
2702
- return HTML_RAW.test(trimmed) || HTML_COMMENT_ETC.test(trimmed) || HTML_BLOCK_TAG.test(trimmed) || HTML_COMPLETE_TAG.test(trimmed);
2703
- }
2704
- function lineIndent(line) {
2705
- let column = 0;
2706
- for (const ch of line) {
2707
- if (ch === " ") column += 1;
2708
- else if (ch === " ") column += 4 - column % 4;
2709
- else break;
2710
- }
2711
- return column;
2712
- }
2713
- var LIST_MARKER = /^([ \t]*)([-+*]|\d{1,9}[.)])([ \t]+|$)/;
2714
- function markerContentColumn(marker) {
2715
- const markerEnd = lineIndent(marker[1] ?? "") + (marker[2] ?? "").length;
2716
- const gap = marker[3] ? lineIndent(" ".repeat(markerEnd) + marker[3]) - markerEnd : 1;
2717
- return markerEnd + (gap >= 1 && gap <= 4 ? gap : 1);
2718
- }
2719
- function tableContainerIndent(lines, start) {
2720
- return tableContainerIndentOf(lines, start, false);
2721
- }
2722
- function tableContainerIndentOf(lines, start, ownItem) {
2723
- const own = ownItem ? LIST_MARKER.exec(lines[start] ?? "") : null;
2724
- if (own) return markerContentColumn(own);
2725
- const header = lineIndent(lines[start] ?? "");
2726
- if (header === 0) return 0;
2727
- for (let k = start - 1; k >= 0; k -= 1) {
2728
- const line = lines[k] ?? "";
2729
- if (!line.trim()) continue;
2730
- const indent = lineIndent(line);
2731
- const marker = LIST_MARKER.exec(line);
2732
- if (marker && indent < header) {
2733
- const content = markerContentColumn(marker);
2734
- if (content <= header) return content;
2735
- continue;
2736
- }
2737
- if (indent === 0) return 0;
2738
- }
2739
- return 0;
2740
- }
2741
- var DELIMITER_CELL = /^:?-+:?$/;
2742
- function isGfmDelimiterRow(line) {
2743
- const trimmed = line.trim();
2744
- if (!trimmed.includes("|")) return false;
2745
- const cells = rowCells(trimmed);
2746
- return cells.length > 0 && cells.every((cell) => DELIMITER_CELL.test(cell));
2747
- }
2748
- function isPipeLedRow(line) {
2749
- const trimmed = line.trim();
2750
- return trimmed.startsWith("|") && trimmed.includes("|", 1);
2751
- }
2752
- function isTableDelimiter(line) {
2753
- if (line === void 0 || !isGfmDelimiterRow(line)) return false;
2754
- return !BLOCK_START.test(line.trim());
2755
- }
2756
- function startsPipelessTable(header, delimiter) {
2757
- const head = header.trim();
2758
- if (!head || isPipeLedRow(head) || !head.startsWith("|") && startsBlock(head)) return false;
2759
- if (!isTableDelimiter(delimiter)) return false;
2760
- return rowCells(head).length === rowCells(delimiter.trim()).length;
2761
- }
2762
- function continuesTable(line, containerIndent = 0) {
2763
- const trimmed = line.trim();
2764
- if (!trimmed) return false;
2765
- if (lineIndent(line) - containerIndent >= 4) return false;
2766
- return trimmed.startsWith("|") || !startsBlock(trimmed);
2767
- }
2768
- function opensTable(lines, index) {
2769
- const line = lines[index] ?? "";
2770
- if (!isPipeLedRow(line) && !startsPipelessTable(line, lines[index + 1])) return false;
2771
- return !isLazyContinuation(lines, index) && !insideHtmlBlock(lines, index);
2772
- }
2773
- var QUOTE_LINE = /^ {0,3}>/;
2774
- var THEMATIC_BREAK = /^(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
2775
- var breaksParagraph = (trimmed) => /^#{1,6}(?:\s|$)/.test(trimmed) || THEMATIC_BREAK.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
2776
- function htmlBlockEnd(trimmed) {
2777
- if (HTML_RAW.test(trimmed)) return /<\/(?:script|pre|style|textarea)>/i;
2778
- if (trimmed.startsWith("<!--")) return /-->/;
2779
- if (trimmed.startsWith("<?")) return /\?>/;
2780
- if (trimmed.startsWith("<![CDATA[")) return /\]\]>/;
2781
- if (/^<![A-Za-z]/.test(trimmed)) return />/;
2782
- if (HTML_BLOCK_TAG.test(trimmed)) return null;
2783
- if (HTML_COMPLETE_TAG.test(trimmed)) return null;
2784
- return void 0;
2785
- }
2786
- function insideHtmlBlock(lines, index) {
2787
- let start = index;
2788
- while (start > 0 && (lines[start - 1] ?? "").trim()) start -= 1;
2789
- let open;
2790
- let paragraph = false;
2791
- for (let k = start; k < index; k += 1) {
2792
- const line = lines[k] ?? "";
2793
- if (open !== void 0) {
2794
- if (open && open.test(line)) open = void 0;
2795
- continue;
2796
- }
2797
- const trimmed = line.trim();
2798
- const end = lineIndent(line) < 4 ? htmlBlockEnd(trimmed) : void 0;
2799
- const type7 = end === null && !HTML_BLOCK_TAG.test(trimmed);
2800
- const interrupts = end !== void 0 && !(paragraph && type7);
2801
- if (!interrupts) {
2802
- paragraph = true;
2803
- continue;
2804
- }
2805
- paragraph = false;
2806
- open = end && end.test(trimmed.slice(2)) ? void 0 : end;
2807
- }
2808
- return open !== void 0;
2809
- }
2810
- function isLazyContinuation(lines, index) {
2811
- const header = lines[index] ?? "";
2812
- let first = -1;
2813
- for (let k = index - 1; k >= 0; k -= 1) {
2814
- const line = lines[k] ?? "";
2815
- const trimmed = line.trim();
2816
- if (!trimmed) break;
2817
- if (breaksParagraph(trimmed)) break;
2818
- const marker = LIST_MARKER.exec(line);
2819
- if (marker) {
2820
- const rest = line.slice(marker[0].length).trim();
2821
- if (!rest || breaksParagraph(rest)) break;
2822
- first = k;
2823
- break;
2824
- }
2825
- first = k;
2826
- if (QUOTE_LINE.test(line)) break;
2827
- }
2828
- if (first < 0) return false;
2829
- const start = lines[first] ?? "";
2830
- if (QUOTE_LINE.test(start)) return !QUOTE_LINE.test(header);
2831
- return lineIndent(header) < tableContainerIndentOf(lines, first, true);
2832
- }
2833
- function tableStartsAt(lines, index) {
2834
- const header = lines[index] ?? "";
2835
- const delimiter = lines[index + 1];
2836
- if (!opensTable(lines, index) || !isTableDelimiter(delimiter)) return false;
2837
- if (rowCells(header).length !== rowCells(delimiter).length) return false;
2838
- return lineIndent(header) - tableContainerIndent(lines, index) < 4;
2839
- }
2840
- function findTableStart(lines, from = 0) {
2841
- for (let i = Math.max(0, from); i < lines.length; i += 1) if (opensTable(lines, i)) return i;
2842
- return -1;
2843
- }
2844
- function findTableEnd(lines, start) {
2845
- const container = tableContainerIndent(lines, start);
2846
- let end = Math.min(lines.length, start + 2);
2847
- while (end < lines.length && continuesTable(lines[end] ?? "", container)) end += 1;
2848
- return end;
2849
- }
2850
-
2851
2870
  exports.AFTER_WINDOW = AFTER_WINDOW;
2852
2871
  exports.BacktickRuns = BacktickRuns;
2853
2872
  exports.CALLOUT_NAMES = CALLOUT_NAMES;
@@ -2872,6 +2891,7 @@ exports.fenceOpenerOf = fenceOpenerOf;
2872
2891
  exports.fenceParts = fenceParts;
2873
2892
  exports.findCodeRanges = findCodeRanges;
2874
2893
  exports.findInlineCodeSpans = findInlineCodeSpans;
2894
+ exports.findLinkDefinitionLines = findLinkDefinitionLines;
2875
2895
  exports.findTableEnd = findTableEnd;
2876
2896
  exports.findTableStart = findTableStart;
2877
2897
  exports.isEscapedBracketMath = isEscapedBracketMath;