@ai-matrx/content-ir 0.19.17 → 0.19.19
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/CHANGELOG.md +10 -0
- package/dist/index.cjs +208 -198
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +208 -199
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +208 -198
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +6 -1
- package/dist/source.d.ts +6 -1
- package/dist/source.js +208 -199
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.d.cts
CHANGED
|
@@ -678,6 +678,11 @@ declare function splitRowSegments(line: string): string[];
|
|
|
678
678
|
declare function rowCells(line: string): string[];
|
|
679
679
|
/** GFM's table-level unescape: a cell's `\|` is a pipe, in code spans too. */
|
|
680
680
|
declare function unescapeCellPipes(cell: string): string;
|
|
681
|
+
/**
|
|
682
|
+
* The trimmed line opens an HTML block whose element every sanitizer strips: the
|
|
683
|
+
* block ends at this line (the one deliberate GFM deviation, above).
|
|
684
|
+
*/
|
|
685
|
+
declare function opensStrippedHtmlBlock(trimmed: string): boolean;
|
|
681
686
|
/**
|
|
682
687
|
* A tag name CommonMark reads as an HTML BLOCK when it opens a line (conditions
|
|
683
688
|
* 1 and 6: `div`, `details`, `section`, `script`, …; case-insensitive). A
|
|
@@ -726,4 +731,4 @@ declare function findTableStart(lines: readonly string[], from?: number): number
|
|
|
726
731
|
/** Index just past the table whose header is at `start` (header, delimiter, then continuation rows). */
|
|
727
732
|
declare function findTableEnd(lines: readonly string[], start: number): number;
|
|
728
733
|
|
|
729
|
-
export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type LinkDefinition, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, collectLinkDefinitions, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findLinkDefinitionLines, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isHtmlBlockTagName, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, lineIndent, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, normalizeLinkLabel, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, resolveReferenceLinks, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsHtmlBlock, startsPipelessTable, tableContainerIndent, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
|
|
734
|
+
export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type LinkDefinition, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, collectLinkDefinitions, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findLinkDefinitionLines, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isHtmlBlockTagName, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, lineIndent, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, normalizeLinkLabel, opensStrippedHtmlBlock, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, resolveReferenceLinks, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsHtmlBlock, startsPipelessTable, tableContainerIndent, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
|
package/dist/source.d.ts
CHANGED
|
@@ -678,6 +678,11 @@ declare function splitRowSegments(line: string): string[];
|
|
|
678
678
|
declare function rowCells(line: string): string[];
|
|
679
679
|
/** GFM's table-level unescape: a cell's `\|` is a pipe, in code spans too. */
|
|
680
680
|
declare function unescapeCellPipes(cell: string): string;
|
|
681
|
+
/**
|
|
682
|
+
* The trimmed line opens an HTML block whose element every sanitizer strips: the
|
|
683
|
+
* block ends at this line (the one deliberate GFM deviation, above).
|
|
684
|
+
*/
|
|
685
|
+
declare function opensStrippedHtmlBlock(trimmed: string): boolean;
|
|
681
686
|
/**
|
|
682
687
|
* A tag name CommonMark reads as an HTML BLOCK when it opens a line (conditions
|
|
683
688
|
* 1 and 6: `div`, `details`, `section`, `script`, …; case-insensitive). A
|
|
@@ -726,4 +731,4 @@ declare function findTableStart(lines: readonly string[], from?: number): number
|
|
|
726
731
|
/** Index just past the table whose header is at `start` (header, delimiter, then continuation rows). */
|
|
727
732
|
declare function findTableEnd(lines: readonly string[], start: number): number;
|
|
728
733
|
|
|
729
|
-
export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type LinkDefinition, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, collectLinkDefinitions, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findLinkDefinitionLines, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isHtmlBlockTagName, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, lineIndent, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, normalizeLinkLabel, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, resolveReferenceLinks, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsHtmlBlock, startsPipelessTable, tableContainerIndent, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
|
|
734
|
+
export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type LinkDefinition, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, collectLinkDefinitions, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findLinkDefinitionLines, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isHtmlBlockTagName, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, lineIndent, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, normalizeLinkLabel, opensStrippedHtmlBlock, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, resolveReferenceLinks, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsHtmlBlock, startsPipelessTable, tableContainerIndent, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
|
package/dist/source.js
CHANGED
|
@@ -997,6 +997,210 @@ var XmlContainerTracker = class {
|
|
|
997
997
|
}
|
|
998
998
|
};
|
|
999
999
|
|
|
1000
|
+
// source/gfm-table.ts
|
|
1001
|
+
function splitRowSegments(line) {
|
|
1002
|
+
const segments = [];
|
|
1003
|
+
let start = 0;
|
|
1004
|
+
for (let i = 0; i < line.length; i += 1) {
|
|
1005
|
+
const ch = line[i];
|
|
1006
|
+
if (ch === "\\") {
|
|
1007
|
+
i += 1;
|
|
1008
|
+
continue;
|
|
1009
|
+
}
|
|
1010
|
+
if (ch === "|") {
|
|
1011
|
+
segments.push(line.slice(start, i));
|
|
1012
|
+
start = i + 1;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
segments.push(line.slice(start));
|
|
1016
|
+
return segments;
|
|
1017
|
+
}
|
|
1018
|
+
function rowCells(line) {
|
|
1019
|
+
const cells = splitRowSegments(line).map((cell) => cell.trim());
|
|
1020
|
+
if (cells.length > 1 && cells[0] === "") cells.shift();
|
|
1021
|
+
if (cells.length > 1 && cells[cells.length - 1] === "") cells.pop();
|
|
1022
|
+
else if (cells.length === 1 && cells[0] === "" && !line.includes("|")) cells.pop();
|
|
1023
|
+
return cells;
|
|
1024
|
+
}
|
|
1025
|
+
function unescapeCellPipes(cell) {
|
|
1026
|
+
return cell.replace(/\\\|/g, "|");
|
|
1027
|
+
}
|
|
1028
|
+
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$|\[\^[^\]\s]+\]:)/;
|
|
1029
|
+
var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
1030
|
+
var HTML_RAW = /^<(?:script|pre|style|textarea)(?:[\s>]|$)/i;
|
|
1031
|
+
var HTML_COMMENT_ETC = /^(?:<!--|<\?|<![A-Za-z]|<!\[CDATA\[)/;
|
|
1032
|
+
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";
|
|
1033
|
+
var HTML_BLOCK_TAG = new RegExp(`^</?(?:${HTML_BLOCK_NAMES})(?:[\\s>]|/>|$)`, "i");
|
|
1034
|
+
var ATTRIBUTE = `\\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:\\s*=\\s*(?:[^\\s"'=<>\`]+|'[^']*'|"[^"]*"))?`;
|
|
1035
|
+
var HTML_COMPLETE_TAG = new RegExp(`^(?:<[A-Za-z][A-Za-z0-9-]*(?:${ATTRIBUTE})*\\s*/?>|</[A-Za-z][A-Za-z0-9-]*\\s*>)\\s*$`);
|
|
1036
|
+
var STRIPPED_HTML_BLOCK_NAMES = "address|article|aside|base|basefont|body|center|dialog|dir|fieldset|footer|form|frame|frameset|head|header|html|iframe|legend|link|main|menu|menuitem|nav|noframes|optgroup|option|param|search|title|track";
|
|
1037
|
+
var STRIPPED_HTML_BLOCK_TAG = new RegExp(`^</?(?:${STRIPPED_HTML_BLOCK_NAMES})(?:[\\s>]|/>|$)`, "i");
|
|
1038
|
+
function opensStrippedHtmlBlock(trimmed) {
|
|
1039
|
+
return STRIPPED_HTML_BLOCK_TAG.test(trimmed);
|
|
1040
|
+
}
|
|
1041
|
+
var HTML_BLOCK_NAME_SET = /* @__PURE__ */ new Set([
|
|
1042
|
+
// Condition 1 (raw text) and condition 6 (block) tag names — CommonMark 0.31.
|
|
1043
|
+
"script",
|
|
1044
|
+
"pre",
|
|
1045
|
+
"style",
|
|
1046
|
+
"textarea",
|
|
1047
|
+
...HTML_BLOCK_NAMES.replace("h[1-6]", "h1|h2|h3|h4|h5|h6").split("|")
|
|
1048
|
+
]);
|
|
1049
|
+
function isHtmlBlockTagName(name) {
|
|
1050
|
+
return HTML_BLOCK_NAME_SET.has(name.toLowerCase());
|
|
1051
|
+
}
|
|
1052
|
+
function startsHtmlBlock(trimmed) {
|
|
1053
|
+
if (!trimmed.startsWith("<")) return false;
|
|
1054
|
+
return HTML_RAW.test(trimmed) || HTML_COMMENT_ETC.test(trimmed) || HTML_BLOCK_TAG.test(trimmed) || HTML_COMPLETE_TAG.test(trimmed);
|
|
1055
|
+
}
|
|
1056
|
+
function lineIndent(line) {
|
|
1057
|
+
let column = 0;
|
|
1058
|
+
for (const ch of line) {
|
|
1059
|
+
if (ch === " ") column += 1;
|
|
1060
|
+
else if (ch === " ") column += 4 - column % 4;
|
|
1061
|
+
else break;
|
|
1062
|
+
}
|
|
1063
|
+
return column;
|
|
1064
|
+
}
|
|
1065
|
+
var LIST_MARKER = /^([ \t]*)([-+*]|\d{1,9}[.)])([ \t]+|$)/;
|
|
1066
|
+
function markerContentColumn(marker) {
|
|
1067
|
+
const markerEnd = lineIndent(marker[1] ?? "") + (marker[2] ?? "").length;
|
|
1068
|
+
const gap = marker[3] ? lineIndent(" ".repeat(markerEnd) + marker[3]) - markerEnd : 1;
|
|
1069
|
+
return markerEnd + (gap >= 1 && gap <= 4 ? gap : 1);
|
|
1070
|
+
}
|
|
1071
|
+
function tableContainerIndent(lines, start) {
|
|
1072
|
+
return tableContainerIndentOf(lines, start, false);
|
|
1073
|
+
}
|
|
1074
|
+
function tableContainerIndentOf(lines, start, ownItem) {
|
|
1075
|
+
const own = ownItem ? LIST_MARKER.exec(lines[start] ?? "") : null;
|
|
1076
|
+
if (own) return markerContentColumn(own);
|
|
1077
|
+
const header = lineIndent(lines[start] ?? "");
|
|
1078
|
+
if (header === 0) return 0;
|
|
1079
|
+
for (let k = start - 1; k >= 0; k -= 1) {
|
|
1080
|
+
const line = lines[k] ?? "";
|
|
1081
|
+
if (!line.trim()) continue;
|
|
1082
|
+
const indent = lineIndent(line);
|
|
1083
|
+
const marker = LIST_MARKER.exec(line);
|
|
1084
|
+
if (marker && indent < header) {
|
|
1085
|
+
const content = markerContentColumn(marker);
|
|
1086
|
+
if (content <= header) return content;
|
|
1087
|
+
continue;
|
|
1088
|
+
}
|
|
1089
|
+
if (indent === 0) return 0;
|
|
1090
|
+
}
|
|
1091
|
+
return 0;
|
|
1092
|
+
}
|
|
1093
|
+
var DELIMITER_CELL = /^:?-+:?$/;
|
|
1094
|
+
function isGfmDelimiterRow(line) {
|
|
1095
|
+
const trimmed = line.trim();
|
|
1096
|
+
if (!trimmed.includes("|")) return false;
|
|
1097
|
+
const cells = rowCells(trimmed);
|
|
1098
|
+
return cells.length > 0 && cells.every((cell) => DELIMITER_CELL.test(cell));
|
|
1099
|
+
}
|
|
1100
|
+
function isPipeLedRow(line) {
|
|
1101
|
+
const trimmed = line.trim();
|
|
1102
|
+
return trimmed.startsWith("|") && trimmed.includes("|", 1);
|
|
1103
|
+
}
|
|
1104
|
+
function isTableDelimiter(line) {
|
|
1105
|
+
if (line === void 0 || !isGfmDelimiterRow(line)) return false;
|
|
1106
|
+
return !BLOCK_START.test(line.trim());
|
|
1107
|
+
}
|
|
1108
|
+
function startsPipelessTable(header, delimiter) {
|
|
1109
|
+
const head = header.trim();
|
|
1110
|
+
if (!head || isPipeLedRow(head) || !head.startsWith("|") && startsBlock(head)) return false;
|
|
1111
|
+
if (!isTableDelimiter(delimiter)) return false;
|
|
1112
|
+
return rowCells(head).length === rowCells(delimiter.trim()).length;
|
|
1113
|
+
}
|
|
1114
|
+
function continuesTable(line, containerIndent = 0) {
|
|
1115
|
+
const trimmed = line.trim();
|
|
1116
|
+
if (!trimmed) return false;
|
|
1117
|
+
if (lineIndent(line) - containerIndent >= 4) return false;
|
|
1118
|
+
return trimmed.startsWith("|") || !startsBlock(trimmed);
|
|
1119
|
+
}
|
|
1120
|
+
function opensTable(lines, index) {
|
|
1121
|
+
const line = lines[index] ?? "";
|
|
1122
|
+
if (!isPipeLedRow(line) && !startsPipelessTable(line, lines[index + 1])) return false;
|
|
1123
|
+
return !isLazyContinuation(lines, index) && !insideHtmlBlock(lines, index);
|
|
1124
|
+
}
|
|
1125
|
+
var QUOTE_LINE = /^ {0,3}>/;
|
|
1126
|
+
var THEMATIC_BREAK = /^(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
1127
|
+
var breaksParagraph = (trimmed) => /^#{1,6}(?:\s|$)/.test(trimmed) || THEMATIC_BREAK.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
1128
|
+
function htmlBlockEnd(trimmed) {
|
|
1129
|
+
if (HTML_RAW.test(trimmed)) return /<\/(?:script|pre|style|textarea)>/i;
|
|
1130
|
+
if (trimmed.startsWith("<!--")) return /-->/;
|
|
1131
|
+
if (trimmed.startsWith("<?")) return /\?>/;
|
|
1132
|
+
if (trimmed.startsWith("<![CDATA[")) return /\]\]>/;
|
|
1133
|
+
if (/^<![A-Za-z]/.test(trimmed)) return />/;
|
|
1134
|
+
if (HTML_BLOCK_TAG.test(trimmed)) return null;
|
|
1135
|
+
if (HTML_COMPLETE_TAG.test(trimmed)) return null;
|
|
1136
|
+
return void 0;
|
|
1137
|
+
}
|
|
1138
|
+
function insideHtmlBlock(lines, index) {
|
|
1139
|
+
let start = index;
|
|
1140
|
+
while (start > 0 && (lines[start - 1] ?? "").trim()) start -= 1;
|
|
1141
|
+
let open;
|
|
1142
|
+
let paragraph = false;
|
|
1143
|
+
for (let k = start; k < index; k += 1) {
|
|
1144
|
+
const line = lines[k] ?? "";
|
|
1145
|
+
if (open !== void 0) {
|
|
1146
|
+
if (open && open.test(line)) open = void 0;
|
|
1147
|
+
continue;
|
|
1148
|
+
}
|
|
1149
|
+
const trimmed = line.trim();
|
|
1150
|
+
const end = lineIndent(line) < 4 ? htmlBlockEnd(trimmed) : void 0;
|
|
1151
|
+
const type7 = end === null && !HTML_BLOCK_TAG.test(trimmed);
|
|
1152
|
+
const interrupts = end !== void 0 && !(paragraph && type7);
|
|
1153
|
+
if (!interrupts) {
|
|
1154
|
+
paragraph = true;
|
|
1155
|
+
continue;
|
|
1156
|
+
}
|
|
1157
|
+
paragraph = false;
|
|
1158
|
+
if (opensStrippedHtmlBlock(trimmed)) continue;
|
|
1159
|
+
open = end && end.test(trimmed.slice(2)) ? void 0 : end;
|
|
1160
|
+
}
|
|
1161
|
+
return open !== void 0;
|
|
1162
|
+
}
|
|
1163
|
+
function isLazyContinuation(lines, index) {
|
|
1164
|
+
const header = lines[index] ?? "";
|
|
1165
|
+
let first = -1;
|
|
1166
|
+
for (let k = index - 1; k >= 0; k -= 1) {
|
|
1167
|
+
const line = lines[k] ?? "";
|
|
1168
|
+
const trimmed = line.trim();
|
|
1169
|
+
if (!trimmed) break;
|
|
1170
|
+
if (breaksParagraph(trimmed)) break;
|
|
1171
|
+
const marker = LIST_MARKER.exec(line);
|
|
1172
|
+
if (marker) {
|
|
1173
|
+
const rest = line.slice(marker[0].length).trim();
|
|
1174
|
+
if (!rest || breaksParagraph(rest)) break;
|
|
1175
|
+
first = k;
|
|
1176
|
+
break;
|
|
1177
|
+
}
|
|
1178
|
+
first = k;
|
|
1179
|
+
if (QUOTE_LINE.test(line)) break;
|
|
1180
|
+
}
|
|
1181
|
+
if (first < 0) return false;
|
|
1182
|
+
const start = lines[first] ?? "";
|
|
1183
|
+
if (QUOTE_LINE.test(start)) return !QUOTE_LINE.test(header);
|
|
1184
|
+
return lineIndent(header) < tableContainerIndentOf(lines, first, true);
|
|
1185
|
+
}
|
|
1186
|
+
function tableStartsAt(lines, index) {
|
|
1187
|
+
const header = lines[index] ?? "";
|
|
1188
|
+
const delimiter = lines[index + 1];
|
|
1189
|
+
if (!opensTable(lines, index) || !isTableDelimiter(delimiter)) return false;
|
|
1190
|
+
if (rowCells(header).length !== rowCells(delimiter).length) return false;
|
|
1191
|
+
return lineIndent(header) - tableContainerIndent(lines, index) < 4;
|
|
1192
|
+
}
|
|
1193
|
+
function findTableStart(lines, from = 0) {
|
|
1194
|
+
for (let i = Math.max(0, from); i < lines.length; i += 1) if (opensTable(lines, i)) return i;
|
|
1195
|
+
return -1;
|
|
1196
|
+
}
|
|
1197
|
+
function findTableEnd(lines, start) {
|
|
1198
|
+
const container = tableContainerIndent(lines, start);
|
|
1199
|
+
let end = Math.min(lines.length, start + 2);
|
|
1200
|
+
while (end < lines.length && continuesTable(lines[end] ?? "", container)) end += 1;
|
|
1201
|
+
return end;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1000
1204
|
// source/tokenize.ts
|
|
1001
1205
|
var NOT_WHITESPACE = /\S/;
|
|
1002
1206
|
var DIRECTIVE_OPEN = /^(:{2,})([A-Za-z][\w-]*)/;
|
|
@@ -1838,9 +2042,12 @@ var Tokenizer = class {
|
|
|
1838
2042
|
});
|
|
1839
2043
|
}
|
|
1840
2044
|
}
|
|
2045
|
+
if (isHtmlBlockTagName(root)) return null;
|
|
1841
2046
|
return this.island("xml_container", p, this.n, false, { tag: root });
|
|
1842
2047
|
}
|
|
1843
2048
|
if (isUnclosedGenericXmlOpening(seg)) {
|
|
2049
|
+
const name = /^\s*<([A-Za-z_][\w.:-]*)/.exec(seg)?.[1] ?? "";
|
|
2050
|
+
if (isHtmlBlockTagName(name)) return null;
|
|
1844
2051
|
return this.island("xml_container", p, this.n, false, {});
|
|
1845
2052
|
}
|
|
1846
2053
|
return null;
|
|
@@ -2664,204 +2871,6 @@ function resolveReferenceLinks(fragment, defs) {
|
|
|
2664
2871
|
return resolved.replace(new RegExp(`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`, "g"), (_m, i) => spans[Number(i)] ?? "");
|
|
2665
2872
|
}
|
|
2666
2873
|
|
|
2667
|
-
|
|
2668
|
-
function splitRowSegments(line) {
|
|
2669
|
-
const segments = [];
|
|
2670
|
-
let start = 0;
|
|
2671
|
-
for (let i = 0; i < line.length; i += 1) {
|
|
2672
|
-
const ch = line[i];
|
|
2673
|
-
if (ch === "\\") {
|
|
2674
|
-
i += 1;
|
|
2675
|
-
continue;
|
|
2676
|
-
}
|
|
2677
|
-
if (ch === "|") {
|
|
2678
|
-
segments.push(line.slice(start, i));
|
|
2679
|
-
start = i + 1;
|
|
2680
|
-
}
|
|
2681
|
-
}
|
|
2682
|
-
segments.push(line.slice(start));
|
|
2683
|
-
return segments;
|
|
2684
|
-
}
|
|
2685
|
-
function rowCells(line) {
|
|
2686
|
-
const cells = splitRowSegments(line).map((cell) => cell.trim());
|
|
2687
|
-
if (cells.length > 1 && cells[0] === "") cells.shift();
|
|
2688
|
-
if (cells.length > 1 && cells[cells.length - 1] === "") cells.pop();
|
|
2689
|
-
else if (cells.length === 1 && cells[0] === "" && !line.includes("|")) cells.pop();
|
|
2690
|
-
return cells;
|
|
2691
|
-
}
|
|
2692
|
-
function unescapeCellPipes(cell) {
|
|
2693
|
-
return cell.replace(/\\\|/g, "|");
|
|
2694
|
-
}
|
|
2695
|
-
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$|\[\^[^\]\s]+\]:)/;
|
|
2696
|
-
var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
2697
|
-
var HTML_RAW = /^<(?:script|pre|style|textarea)(?:[\s>]|$)/i;
|
|
2698
|
-
var HTML_COMMENT_ETC = /^(?:<!--|<\?|<![A-Za-z]|<!\[CDATA\[)/;
|
|
2699
|
-
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";
|
|
2700
|
-
var HTML_BLOCK_TAG = new RegExp(`^</?(?:${HTML_BLOCK_NAMES})(?:[\\s>]|/>|$)`, "i");
|
|
2701
|
-
var ATTRIBUTE = `\\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:\\s*=\\s*(?:[^\\s"'=<>\`]+|'[^']*'|"[^"]*"))?`;
|
|
2702
|
-
var HTML_COMPLETE_TAG = new RegExp(`^(?:<[A-Za-z][A-Za-z0-9-]*(?:${ATTRIBUTE})*\\s*/?>|</[A-Za-z][A-Za-z0-9-]*\\s*>)\\s*$`);
|
|
2703
|
-
var HTML_BLOCK_NAME_SET = /* @__PURE__ */ new Set([
|
|
2704
|
-
// Condition 1 (raw text) and condition 6 (block) tag names — CommonMark 0.31.
|
|
2705
|
-
"script",
|
|
2706
|
-
"pre",
|
|
2707
|
-
"style",
|
|
2708
|
-
"textarea",
|
|
2709
|
-
...HTML_BLOCK_NAMES.replace("h[1-6]", "h1|h2|h3|h4|h5|h6").split("|")
|
|
2710
|
-
]);
|
|
2711
|
-
function isHtmlBlockTagName(name) {
|
|
2712
|
-
return HTML_BLOCK_NAME_SET.has(name.toLowerCase());
|
|
2713
|
-
}
|
|
2714
|
-
function startsHtmlBlock(trimmed) {
|
|
2715
|
-
if (!trimmed.startsWith("<")) return false;
|
|
2716
|
-
return HTML_RAW.test(trimmed) || HTML_COMMENT_ETC.test(trimmed) || HTML_BLOCK_TAG.test(trimmed) || HTML_COMPLETE_TAG.test(trimmed);
|
|
2717
|
-
}
|
|
2718
|
-
function lineIndent(line) {
|
|
2719
|
-
let column = 0;
|
|
2720
|
-
for (const ch of line) {
|
|
2721
|
-
if (ch === " ") column += 1;
|
|
2722
|
-
else if (ch === " ") column += 4 - column % 4;
|
|
2723
|
-
else break;
|
|
2724
|
-
}
|
|
2725
|
-
return column;
|
|
2726
|
-
}
|
|
2727
|
-
var LIST_MARKER = /^([ \t]*)([-+*]|\d{1,9}[.)])([ \t]+|$)/;
|
|
2728
|
-
function markerContentColumn(marker) {
|
|
2729
|
-
const markerEnd = lineIndent(marker[1] ?? "") + (marker[2] ?? "").length;
|
|
2730
|
-
const gap = marker[3] ? lineIndent(" ".repeat(markerEnd) + marker[3]) - markerEnd : 1;
|
|
2731
|
-
return markerEnd + (gap >= 1 && gap <= 4 ? gap : 1);
|
|
2732
|
-
}
|
|
2733
|
-
function tableContainerIndent(lines, start) {
|
|
2734
|
-
return tableContainerIndentOf(lines, start, false);
|
|
2735
|
-
}
|
|
2736
|
-
function tableContainerIndentOf(lines, start, ownItem) {
|
|
2737
|
-
const own = ownItem ? LIST_MARKER.exec(lines[start] ?? "") : null;
|
|
2738
|
-
if (own) return markerContentColumn(own);
|
|
2739
|
-
const header = lineIndent(lines[start] ?? "");
|
|
2740
|
-
if (header === 0) return 0;
|
|
2741
|
-
for (let k = start - 1; k >= 0; k -= 1) {
|
|
2742
|
-
const line = lines[k] ?? "";
|
|
2743
|
-
if (!line.trim()) continue;
|
|
2744
|
-
const indent = lineIndent(line);
|
|
2745
|
-
const marker = LIST_MARKER.exec(line);
|
|
2746
|
-
if (marker && indent < header) {
|
|
2747
|
-
const content = markerContentColumn(marker);
|
|
2748
|
-
if (content <= header) return content;
|
|
2749
|
-
continue;
|
|
2750
|
-
}
|
|
2751
|
-
if (indent === 0) return 0;
|
|
2752
|
-
}
|
|
2753
|
-
return 0;
|
|
2754
|
-
}
|
|
2755
|
-
var DELIMITER_CELL = /^:?-+:?$/;
|
|
2756
|
-
function isGfmDelimiterRow(line) {
|
|
2757
|
-
const trimmed = line.trim();
|
|
2758
|
-
if (!trimmed.includes("|")) return false;
|
|
2759
|
-
const cells = rowCells(trimmed);
|
|
2760
|
-
return cells.length > 0 && cells.every((cell) => DELIMITER_CELL.test(cell));
|
|
2761
|
-
}
|
|
2762
|
-
function isPipeLedRow(line) {
|
|
2763
|
-
const trimmed = line.trim();
|
|
2764
|
-
return trimmed.startsWith("|") && trimmed.includes("|", 1);
|
|
2765
|
-
}
|
|
2766
|
-
function isTableDelimiter(line) {
|
|
2767
|
-
if (line === void 0 || !isGfmDelimiterRow(line)) return false;
|
|
2768
|
-
return !BLOCK_START.test(line.trim());
|
|
2769
|
-
}
|
|
2770
|
-
function startsPipelessTable(header, delimiter) {
|
|
2771
|
-
const head = header.trim();
|
|
2772
|
-
if (!head || isPipeLedRow(head) || !head.startsWith("|") && startsBlock(head)) return false;
|
|
2773
|
-
if (!isTableDelimiter(delimiter)) return false;
|
|
2774
|
-
return rowCells(head).length === rowCells(delimiter.trim()).length;
|
|
2775
|
-
}
|
|
2776
|
-
function continuesTable(line, containerIndent = 0) {
|
|
2777
|
-
const trimmed = line.trim();
|
|
2778
|
-
if (!trimmed) return false;
|
|
2779
|
-
if (lineIndent(line) - containerIndent >= 4) return false;
|
|
2780
|
-
return trimmed.startsWith("|") || !startsBlock(trimmed);
|
|
2781
|
-
}
|
|
2782
|
-
function opensTable(lines, index) {
|
|
2783
|
-
const line = lines[index] ?? "";
|
|
2784
|
-
if (!isPipeLedRow(line) && !startsPipelessTable(line, lines[index + 1])) return false;
|
|
2785
|
-
return !isLazyContinuation(lines, index) && !insideHtmlBlock(lines, index);
|
|
2786
|
-
}
|
|
2787
|
-
var QUOTE_LINE = /^ {0,3}>/;
|
|
2788
|
-
var THEMATIC_BREAK = /^(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
2789
|
-
var breaksParagraph = (trimmed) => /^#{1,6}(?:\s|$)/.test(trimmed) || THEMATIC_BREAK.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
2790
|
-
function htmlBlockEnd(trimmed) {
|
|
2791
|
-
if (HTML_RAW.test(trimmed)) return /<\/(?:script|pre|style|textarea)>/i;
|
|
2792
|
-
if (trimmed.startsWith("<!--")) return /-->/;
|
|
2793
|
-
if (trimmed.startsWith("<?")) return /\?>/;
|
|
2794
|
-
if (trimmed.startsWith("<![CDATA[")) return /\]\]>/;
|
|
2795
|
-
if (/^<![A-Za-z]/.test(trimmed)) return />/;
|
|
2796
|
-
if (HTML_BLOCK_TAG.test(trimmed)) return null;
|
|
2797
|
-
if (HTML_COMPLETE_TAG.test(trimmed)) return null;
|
|
2798
|
-
return void 0;
|
|
2799
|
-
}
|
|
2800
|
-
function insideHtmlBlock(lines, index) {
|
|
2801
|
-
let start = index;
|
|
2802
|
-
while (start > 0 && (lines[start - 1] ?? "").trim()) start -= 1;
|
|
2803
|
-
let open;
|
|
2804
|
-
let paragraph = false;
|
|
2805
|
-
for (let k = start; k < index; k += 1) {
|
|
2806
|
-
const line = lines[k] ?? "";
|
|
2807
|
-
if (open !== void 0) {
|
|
2808
|
-
if (open && open.test(line)) open = void 0;
|
|
2809
|
-
continue;
|
|
2810
|
-
}
|
|
2811
|
-
const trimmed = line.trim();
|
|
2812
|
-
const end = lineIndent(line) < 4 ? htmlBlockEnd(trimmed) : void 0;
|
|
2813
|
-
const type7 = end === null && !HTML_BLOCK_TAG.test(trimmed);
|
|
2814
|
-
const interrupts = end !== void 0 && !(paragraph && type7);
|
|
2815
|
-
if (!interrupts) {
|
|
2816
|
-
paragraph = true;
|
|
2817
|
-
continue;
|
|
2818
|
-
}
|
|
2819
|
-
paragraph = false;
|
|
2820
|
-
open = end && end.test(trimmed.slice(2)) ? void 0 : end;
|
|
2821
|
-
}
|
|
2822
|
-
return open !== void 0;
|
|
2823
|
-
}
|
|
2824
|
-
function isLazyContinuation(lines, index) {
|
|
2825
|
-
const header = lines[index] ?? "";
|
|
2826
|
-
let first = -1;
|
|
2827
|
-
for (let k = index - 1; k >= 0; k -= 1) {
|
|
2828
|
-
const line = lines[k] ?? "";
|
|
2829
|
-
const trimmed = line.trim();
|
|
2830
|
-
if (!trimmed) break;
|
|
2831
|
-
if (breaksParagraph(trimmed)) break;
|
|
2832
|
-
const marker = LIST_MARKER.exec(line);
|
|
2833
|
-
if (marker) {
|
|
2834
|
-
const rest = line.slice(marker[0].length).trim();
|
|
2835
|
-
if (!rest || breaksParagraph(rest)) break;
|
|
2836
|
-
first = k;
|
|
2837
|
-
break;
|
|
2838
|
-
}
|
|
2839
|
-
first = k;
|
|
2840
|
-
if (QUOTE_LINE.test(line)) break;
|
|
2841
|
-
}
|
|
2842
|
-
if (first < 0) return false;
|
|
2843
|
-
const start = lines[first] ?? "";
|
|
2844
|
-
if (QUOTE_LINE.test(start)) return !QUOTE_LINE.test(header);
|
|
2845
|
-
return lineIndent(header) < tableContainerIndentOf(lines, first, true);
|
|
2846
|
-
}
|
|
2847
|
-
function tableStartsAt(lines, index) {
|
|
2848
|
-
const header = lines[index] ?? "";
|
|
2849
|
-
const delimiter = lines[index + 1];
|
|
2850
|
-
if (!opensTable(lines, index) || !isTableDelimiter(delimiter)) return false;
|
|
2851
|
-
if (rowCells(header).length !== rowCells(delimiter).length) return false;
|
|
2852
|
-
return lineIndent(header) - tableContainerIndent(lines, index) < 4;
|
|
2853
|
-
}
|
|
2854
|
-
function findTableStart(lines, from = 0) {
|
|
2855
|
-
for (let i = Math.max(0, from); i < lines.length; i += 1) if (opensTable(lines, i)) return i;
|
|
2856
|
-
return -1;
|
|
2857
|
-
}
|
|
2858
|
-
function findTableEnd(lines, start) {
|
|
2859
|
-
const container = tableContainerIndent(lines, start);
|
|
2860
|
-
let end = Math.min(lines.length, start + 2);
|
|
2861
|
-
while (end < lines.length && continuesTable(lines[end] ?? "", container)) end += 1;
|
|
2862
|
-
return end;
|
|
2863
|
-
}
|
|
2864
|
-
|
|
2865
|
-
export { AFTER_WINDOW, BacktickRuns, CALLOUT_NAMES, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceReader, NESTING_FENCE_LANGUAGES, SourceSpliceError, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, collectLinkDefinitions, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findLinkDefinitionLines, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isHtmlBlockTagName, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, lineIndent, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, normalizeLinkLabel, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, resolveReferenceLinks, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsHtmlBlock, startsPipelessTable, tableContainerIndent, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
|
|
2874
|
+
export { AFTER_WINDOW, BacktickRuns, CALLOUT_NAMES, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceReader, NESTING_FENCE_LANGUAGES, SourceSpliceError, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, collectLinkDefinitions, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findLinkDefinitionLines, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isHtmlBlockTagName, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, lineIndent, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, normalizeLinkLabel, opensStrippedHtmlBlock, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, resolveReferenceLinks, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsHtmlBlock, startsPipelessTable, tableContainerIndent, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
|
|
2866
2875
|
//# sourceMappingURL=source.js.map
|
|
2867
2876
|
//# sourceMappingURL=source.js.map
|