@ai-matrx/content-ir 0.19.17 → 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/CHANGELOG.md +5 -0
- package/dist/index.cjs +201 -198
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +201 -198
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +201 -198
- package/dist/source.cjs.map +1 -1
- package/dist/source.js +201 -198
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.19.18
|
|
4
|
+
### Unreleased
|
|
5
|
+
|
|
6
|
+
- `/source` **An unclosed HTML block tag owns nothing** (verify-RC-B4 round 9): a line-leading `<div>`, `<section>`, `<details>`… that never closes is no `xml_container` island running to the end of the text — GFM ends that HTML block at the blank line, so the text after it stays prose (the Visual editor showed a whole note swallowed as a "Section · div, not closed" island). The tag stays an inline `xml_tag` island; a closed container is still one island; an unclosed custom tag still owns the rest. Python twin moved; island vectors +5.
|
|
7
|
+
|
|
3
8
|
## 0.19.17
|
|
4
9
|
### Unreleased
|
|
5
10
|
|
package/dist/index.cjs
CHANGED
|
@@ -6059,6 +6059,204 @@ var XmlContainerTracker = class {
|
|
|
6059
6059
|
}
|
|
6060
6060
|
};
|
|
6061
6061
|
|
|
6062
|
+
// source/gfm-table.ts
|
|
6063
|
+
function splitRowSegments(line) {
|
|
6064
|
+
const segments = [];
|
|
6065
|
+
let start = 0;
|
|
6066
|
+
for (let i = 0; i < line.length; i += 1) {
|
|
6067
|
+
const ch = line[i];
|
|
6068
|
+
if (ch === "\\") {
|
|
6069
|
+
i += 1;
|
|
6070
|
+
continue;
|
|
6071
|
+
}
|
|
6072
|
+
if (ch === "|") {
|
|
6073
|
+
segments.push(line.slice(start, i));
|
|
6074
|
+
start = i + 1;
|
|
6075
|
+
}
|
|
6076
|
+
}
|
|
6077
|
+
segments.push(line.slice(start));
|
|
6078
|
+
return segments;
|
|
6079
|
+
}
|
|
6080
|
+
function rowCells(line) {
|
|
6081
|
+
const cells = splitRowSegments(line).map((cell) => cell.trim());
|
|
6082
|
+
if (cells.length > 1 && cells[0] === "") cells.shift();
|
|
6083
|
+
if (cells.length > 1 && cells[cells.length - 1] === "") cells.pop();
|
|
6084
|
+
else if (cells.length === 1 && cells[0] === "" && !line.includes("|")) cells.pop();
|
|
6085
|
+
return cells;
|
|
6086
|
+
}
|
|
6087
|
+
function unescapeCellPipes(cell) {
|
|
6088
|
+
return cell.replace(/\\\|/g, "|");
|
|
6089
|
+
}
|
|
6090
|
+
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$|\[\^[^\]\s]+\]:)/;
|
|
6091
|
+
var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
6092
|
+
var HTML_RAW = /^<(?:script|pre|style|textarea)(?:[\s>]|$)/i;
|
|
6093
|
+
var HTML_COMMENT_ETC = /^(?:<!--|<\?|<![A-Za-z]|<!\[CDATA\[)/;
|
|
6094
|
+
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";
|
|
6095
|
+
var HTML_BLOCK_TAG = new RegExp(`^</?(?:${HTML_BLOCK_NAMES})(?:[\\s>]|/>|$)`, "i");
|
|
6096
|
+
var ATTRIBUTE = `\\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:\\s*=\\s*(?:[^\\s"'=<>\`]+|'[^']*'|"[^"]*"))?`;
|
|
6097
|
+
var HTML_COMPLETE_TAG = new RegExp(`^(?:<[A-Za-z][A-Za-z0-9-]*(?:${ATTRIBUTE})*\\s*/?>|</[A-Za-z][A-Za-z0-9-]*\\s*>)\\s*$`);
|
|
6098
|
+
var HTML_BLOCK_NAME_SET = /* @__PURE__ */ new Set([
|
|
6099
|
+
// Condition 1 (raw text) and condition 6 (block) tag names — CommonMark 0.31.
|
|
6100
|
+
"script",
|
|
6101
|
+
"pre",
|
|
6102
|
+
"style",
|
|
6103
|
+
"textarea",
|
|
6104
|
+
...HTML_BLOCK_NAMES.replace("h[1-6]", "h1|h2|h3|h4|h5|h6").split("|")
|
|
6105
|
+
]);
|
|
6106
|
+
function isHtmlBlockTagName(name) {
|
|
6107
|
+
return HTML_BLOCK_NAME_SET.has(name.toLowerCase());
|
|
6108
|
+
}
|
|
6109
|
+
function startsHtmlBlock(trimmed) {
|
|
6110
|
+
if (!trimmed.startsWith("<")) return false;
|
|
6111
|
+
return HTML_RAW.test(trimmed) || HTML_COMMENT_ETC.test(trimmed) || HTML_BLOCK_TAG.test(trimmed) || HTML_COMPLETE_TAG.test(trimmed);
|
|
6112
|
+
}
|
|
6113
|
+
function lineIndent(line) {
|
|
6114
|
+
let column = 0;
|
|
6115
|
+
for (const ch of line) {
|
|
6116
|
+
if (ch === " ") column += 1;
|
|
6117
|
+
else if (ch === " ") column += 4 - column % 4;
|
|
6118
|
+
else break;
|
|
6119
|
+
}
|
|
6120
|
+
return column;
|
|
6121
|
+
}
|
|
6122
|
+
var LIST_MARKER = /^([ \t]*)([-+*]|\d{1,9}[.)])([ \t]+|$)/;
|
|
6123
|
+
function markerContentColumn(marker) {
|
|
6124
|
+
const markerEnd = lineIndent(marker[1] ?? "") + (marker[2] ?? "").length;
|
|
6125
|
+
const gap = marker[3] ? lineIndent(" ".repeat(markerEnd) + marker[3]) - markerEnd : 1;
|
|
6126
|
+
return markerEnd + (gap >= 1 && gap <= 4 ? gap : 1);
|
|
6127
|
+
}
|
|
6128
|
+
function tableContainerIndent(lines, start) {
|
|
6129
|
+
return tableContainerIndentOf(lines, start, false);
|
|
6130
|
+
}
|
|
6131
|
+
function tableContainerIndentOf(lines, start, ownItem) {
|
|
6132
|
+
const own = ownItem ? LIST_MARKER.exec(lines[start] ?? "") : null;
|
|
6133
|
+
if (own) return markerContentColumn(own);
|
|
6134
|
+
const header = lineIndent(lines[start] ?? "");
|
|
6135
|
+
if (header === 0) return 0;
|
|
6136
|
+
for (let k = start - 1; k >= 0; k -= 1) {
|
|
6137
|
+
const line = lines[k] ?? "";
|
|
6138
|
+
if (!line.trim()) continue;
|
|
6139
|
+
const indent = lineIndent(line);
|
|
6140
|
+
const marker = LIST_MARKER.exec(line);
|
|
6141
|
+
if (marker && indent < header) {
|
|
6142
|
+
const content = markerContentColumn(marker);
|
|
6143
|
+
if (content <= header) return content;
|
|
6144
|
+
continue;
|
|
6145
|
+
}
|
|
6146
|
+
if (indent === 0) return 0;
|
|
6147
|
+
}
|
|
6148
|
+
return 0;
|
|
6149
|
+
}
|
|
6150
|
+
var DELIMITER_CELL = /^:?-+:?$/;
|
|
6151
|
+
function isGfmDelimiterRow(line) {
|
|
6152
|
+
const trimmed = line.trim();
|
|
6153
|
+
if (!trimmed.includes("|")) return false;
|
|
6154
|
+
const cells = rowCells(trimmed);
|
|
6155
|
+
return cells.length > 0 && cells.every((cell) => DELIMITER_CELL.test(cell));
|
|
6156
|
+
}
|
|
6157
|
+
function isPipeLedRow(line) {
|
|
6158
|
+
const trimmed = line.trim();
|
|
6159
|
+
return trimmed.startsWith("|") && trimmed.includes("|", 1);
|
|
6160
|
+
}
|
|
6161
|
+
function isTableDelimiter(line) {
|
|
6162
|
+
if (line === void 0 || !isGfmDelimiterRow(line)) return false;
|
|
6163
|
+
return !BLOCK_START.test(line.trim());
|
|
6164
|
+
}
|
|
6165
|
+
function startsPipelessTable(header, delimiter) {
|
|
6166
|
+
const head = header.trim();
|
|
6167
|
+
if (!head || isPipeLedRow(head) || !head.startsWith("|") && startsBlock(head)) return false;
|
|
6168
|
+
if (!isTableDelimiter(delimiter)) return false;
|
|
6169
|
+
return rowCells(head).length === rowCells(delimiter.trim()).length;
|
|
6170
|
+
}
|
|
6171
|
+
function continuesTable(line, containerIndent = 0) {
|
|
6172
|
+
const trimmed = line.trim();
|
|
6173
|
+
if (!trimmed) return false;
|
|
6174
|
+
if (lineIndent(line) - containerIndent >= 4) return false;
|
|
6175
|
+
return trimmed.startsWith("|") || !startsBlock(trimmed);
|
|
6176
|
+
}
|
|
6177
|
+
function opensTable(lines, index) {
|
|
6178
|
+
const line = lines[index] ?? "";
|
|
6179
|
+
if (!isPipeLedRow(line) && !startsPipelessTable(line, lines[index + 1])) return false;
|
|
6180
|
+
return !isLazyContinuation(lines, index) && !insideHtmlBlock(lines, index);
|
|
6181
|
+
}
|
|
6182
|
+
var QUOTE_LINE = /^ {0,3}>/;
|
|
6183
|
+
var THEMATIC_BREAK = /^(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
6184
|
+
var breaksParagraph = (trimmed) => /^#{1,6}(?:\s|$)/.test(trimmed) || THEMATIC_BREAK.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
6185
|
+
function htmlBlockEnd(trimmed) {
|
|
6186
|
+
if (HTML_RAW.test(trimmed)) return /<\/(?:script|pre|style|textarea)>/i;
|
|
6187
|
+
if (trimmed.startsWith("<!--")) return /-->/;
|
|
6188
|
+
if (trimmed.startsWith("<?")) return /\?>/;
|
|
6189
|
+
if (trimmed.startsWith("<![CDATA[")) return /\]\]>/;
|
|
6190
|
+
if (/^<![A-Za-z]/.test(trimmed)) return />/;
|
|
6191
|
+
if (HTML_BLOCK_TAG.test(trimmed)) return null;
|
|
6192
|
+
if (HTML_COMPLETE_TAG.test(trimmed)) return null;
|
|
6193
|
+
return void 0;
|
|
6194
|
+
}
|
|
6195
|
+
function insideHtmlBlock(lines, index) {
|
|
6196
|
+
let start = index;
|
|
6197
|
+
while (start > 0 && (lines[start - 1] ?? "").trim()) start -= 1;
|
|
6198
|
+
let open;
|
|
6199
|
+
let paragraph = false;
|
|
6200
|
+
for (let k = start; k < index; k += 1) {
|
|
6201
|
+
const line = lines[k] ?? "";
|
|
6202
|
+
if (open !== void 0) {
|
|
6203
|
+
if (open && open.test(line)) open = void 0;
|
|
6204
|
+
continue;
|
|
6205
|
+
}
|
|
6206
|
+
const trimmed = line.trim();
|
|
6207
|
+
const end = lineIndent(line) < 4 ? htmlBlockEnd(trimmed) : void 0;
|
|
6208
|
+
const type7 = end === null && !HTML_BLOCK_TAG.test(trimmed);
|
|
6209
|
+
const interrupts = end !== void 0 && !(paragraph && type7);
|
|
6210
|
+
if (!interrupts) {
|
|
6211
|
+
paragraph = true;
|
|
6212
|
+
continue;
|
|
6213
|
+
}
|
|
6214
|
+
paragraph = false;
|
|
6215
|
+
open = end && end.test(trimmed.slice(2)) ? void 0 : end;
|
|
6216
|
+
}
|
|
6217
|
+
return open !== void 0;
|
|
6218
|
+
}
|
|
6219
|
+
function isLazyContinuation(lines, index) {
|
|
6220
|
+
const header = lines[index] ?? "";
|
|
6221
|
+
let first = -1;
|
|
6222
|
+
for (let k = index - 1; k >= 0; k -= 1) {
|
|
6223
|
+
const line = lines[k] ?? "";
|
|
6224
|
+
const trimmed = line.trim();
|
|
6225
|
+
if (!trimmed) break;
|
|
6226
|
+
if (breaksParagraph(trimmed)) break;
|
|
6227
|
+
const marker = LIST_MARKER.exec(line);
|
|
6228
|
+
if (marker) {
|
|
6229
|
+
const rest = line.slice(marker[0].length).trim();
|
|
6230
|
+
if (!rest || breaksParagraph(rest)) break;
|
|
6231
|
+
first = k;
|
|
6232
|
+
break;
|
|
6233
|
+
}
|
|
6234
|
+
first = k;
|
|
6235
|
+
if (QUOTE_LINE.test(line)) break;
|
|
6236
|
+
}
|
|
6237
|
+
if (first < 0) return false;
|
|
6238
|
+
const start = lines[first] ?? "";
|
|
6239
|
+
if (QUOTE_LINE.test(start)) return !QUOTE_LINE.test(header);
|
|
6240
|
+
return lineIndent(header) < tableContainerIndentOf(lines, first, true);
|
|
6241
|
+
}
|
|
6242
|
+
function tableStartsAt(lines, index) {
|
|
6243
|
+
const header = lines[index] ?? "";
|
|
6244
|
+
const delimiter = lines[index + 1];
|
|
6245
|
+
if (!opensTable(lines, index) || !isTableDelimiter(delimiter)) return false;
|
|
6246
|
+
if (rowCells(header).length !== rowCells(delimiter).length) return false;
|
|
6247
|
+
return lineIndent(header) - tableContainerIndent(lines, index) < 4;
|
|
6248
|
+
}
|
|
6249
|
+
function findTableStart(lines, from = 0) {
|
|
6250
|
+
for (let i = Math.max(0, from); i < lines.length; i += 1) if (opensTable(lines, i)) return i;
|
|
6251
|
+
return -1;
|
|
6252
|
+
}
|
|
6253
|
+
function findTableEnd(lines, start) {
|
|
6254
|
+
const container = tableContainerIndent(lines, start);
|
|
6255
|
+
let end = Math.min(lines.length, start + 2);
|
|
6256
|
+
while (end < lines.length && continuesTable(lines[end] ?? "", container)) end += 1;
|
|
6257
|
+
return end;
|
|
6258
|
+
}
|
|
6259
|
+
|
|
6062
6260
|
// source/tokenize.ts
|
|
6063
6261
|
var NOT_WHITESPACE = /\S/;
|
|
6064
6262
|
var DIRECTIVE_OPEN = /^(:{2,})([A-Za-z][\w-]*)/;
|
|
@@ -6900,9 +7098,12 @@ var Tokenizer = class {
|
|
|
6900
7098
|
});
|
|
6901
7099
|
}
|
|
6902
7100
|
}
|
|
7101
|
+
if (isHtmlBlockTagName(root)) return null;
|
|
6903
7102
|
return this.island("xml_container", p, this.n, false, { tag: root });
|
|
6904
7103
|
}
|
|
6905
7104
|
if (isUnclosedGenericXmlOpening(seg)) {
|
|
7105
|
+
const name = /^\s*<([A-Za-z_][\w.:-]*)/.exec(seg)?.[1] ?? "";
|
|
7106
|
+
if (isHtmlBlockTagName(name)) return null;
|
|
6906
7107
|
return this.island("xml_container", p, this.n, false, {});
|
|
6907
7108
|
}
|
|
6908
7109
|
return null;
|
|
@@ -7726,204 +7927,6 @@ function resolveReferenceLinks(fragment, defs) {
|
|
|
7726
7927
|
return resolved.replace(new RegExp(`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`, "g"), (_m, i) => spans[Number(i)] ?? "");
|
|
7727
7928
|
}
|
|
7728
7929
|
|
|
7729
|
-
// source/gfm-table.ts
|
|
7730
|
-
function splitRowSegments(line) {
|
|
7731
|
-
const segments = [];
|
|
7732
|
-
let start = 0;
|
|
7733
|
-
for (let i = 0; i < line.length; i += 1) {
|
|
7734
|
-
const ch = line[i];
|
|
7735
|
-
if (ch === "\\") {
|
|
7736
|
-
i += 1;
|
|
7737
|
-
continue;
|
|
7738
|
-
}
|
|
7739
|
-
if (ch === "|") {
|
|
7740
|
-
segments.push(line.slice(start, i));
|
|
7741
|
-
start = i + 1;
|
|
7742
|
-
}
|
|
7743
|
-
}
|
|
7744
|
-
segments.push(line.slice(start));
|
|
7745
|
-
return segments;
|
|
7746
|
-
}
|
|
7747
|
-
function rowCells(line) {
|
|
7748
|
-
const cells = splitRowSegments(line).map((cell) => cell.trim());
|
|
7749
|
-
if (cells.length > 1 && cells[0] === "") cells.shift();
|
|
7750
|
-
if (cells.length > 1 && cells[cells.length - 1] === "") cells.pop();
|
|
7751
|
-
else if (cells.length === 1 && cells[0] === "" && !line.includes("|")) cells.pop();
|
|
7752
|
-
return cells;
|
|
7753
|
-
}
|
|
7754
|
-
function unescapeCellPipes(cell) {
|
|
7755
|
-
return cell.replace(/\\\|/g, "|");
|
|
7756
|
-
}
|
|
7757
|
-
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$|\[\^[^\]\s]+\]:)/;
|
|
7758
|
-
var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
7759
|
-
var HTML_RAW = /^<(?:script|pre|style|textarea)(?:[\s>]|$)/i;
|
|
7760
|
-
var HTML_COMMENT_ETC = /^(?:<!--|<\?|<![A-Za-z]|<!\[CDATA\[)/;
|
|
7761
|
-
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";
|
|
7762
|
-
var HTML_BLOCK_TAG = new RegExp(`^</?(?:${HTML_BLOCK_NAMES})(?:[\\s>]|/>|$)`, "i");
|
|
7763
|
-
var ATTRIBUTE = `\\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:\\s*=\\s*(?:[^\\s"'=<>\`]+|'[^']*'|"[^"]*"))?`;
|
|
7764
|
-
var HTML_COMPLETE_TAG = new RegExp(`^(?:<[A-Za-z][A-Za-z0-9-]*(?:${ATTRIBUTE})*\\s*/?>|</[A-Za-z][A-Za-z0-9-]*\\s*>)\\s*$`);
|
|
7765
|
-
var HTML_BLOCK_NAME_SET = /* @__PURE__ */ new Set([
|
|
7766
|
-
// Condition 1 (raw text) and condition 6 (block) tag names — CommonMark 0.31.
|
|
7767
|
-
"script",
|
|
7768
|
-
"pre",
|
|
7769
|
-
"style",
|
|
7770
|
-
"textarea",
|
|
7771
|
-
...HTML_BLOCK_NAMES.replace("h[1-6]", "h1|h2|h3|h4|h5|h6").split("|")
|
|
7772
|
-
]);
|
|
7773
|
-
function isHtmlBlockTagName(name) {
|
|
7774
|
-
return HTML_BLOCK_NAME_SET.has(name.toLowerCase());
|
|
7775
|
-
}
|
|
7776
|
-
function startsHtmlBlock(trimmed) {
|
|
7777
|
-
if (!trimmed.startsWith("<")) return false;
|
|
7778
|
-
return HTML_RAW.test(trimmed) || HTML_COMMENT_ETC.test(trimmed) || HTML_BLOCK_TAG.test(trimmed) || HTML_COMPLETE_TAG.test(trimmed);
|
|
7779
|
-
}
|
|
7780
|
-
function lineIndent(line) {
|
|
7781
|
-
let column = 0;
|
|
7782
|
-
for (const ch of line) {
|
|
7783
|
-
if (ch === " ") column += 1;
|
|
7784
|
-
else if (ch === " ") column += 4 - column % 4;
|
|
7785
|
-
else break;
|
|
7786
|
-
}
|
|
7787
|
-
return column;
|
|
7788
|
-
}
|
|
7789
|
-
var LIST_MARKER = /^([ \t]*)([-+*]|\d{1,9}[.)])([ \t]+|$)/;
|
|
7790
|
-
function markerContentColumn(marker) {
|
|
7791
|
-
const markerEnd = lineIndent(marker[1] ?? "") + (marker[2] ?? "").length;
|
|
7792
|
-
const gap = marker[3] ? lineIndent(" ".repeat(markerEnd) + marker[3]) - markerEnd : 1;
|
|
7793
|
-
return markerEnd + (gap >= 1 && gap <= 4 ? gap : 1);
|
|
7794
|
-
}
|
|
7795
|
-
function tableContainerIndent(lines, start) {
|
|
7796
|
-
return tableContainerIndentOf(lines, start, false);
|
|
7797
|
-
}
|
|
7798
|
-
function tableContainerIndentOf(lines, start, ownItem) {
|
|
7799
|
-
const own = ownItem ? LIST_MARKER.exec(lines[start] ?? "") : null;
|
|
7800
|
-
if (own) return markerContentColumn(own);
|
|
7801
|
-
const header = lineIndent(lines[start] ?? "");
|
|
7802
|
-
if (header === 0) return 0;
|
|
7803
|
-
for (let k = start - 1; k >= 0; k -= 1) {
|
|
7804
|
-
const line = lines[k] ?? "";
|
|
7805
|
-
if (!line.trim()) continue;
|
|
7806
|
-
const indent = lineIndent(line);
|
|
7807
|
-
const marker = LIST_MARKER.exec(line);
|
|
7808
|
-
if (marker && indent < header) {
|
|
7809
|
-
const content = markerContentColumn(marker);
|
|
7810
|
-
if (content <= header) return content;
|
|
7811
|
-
continue;
|
|
7812
|
-
}
|
|
7813
|
-
if (indent === 0) return 0;
|
|
7814
|
-
}
|
|
7815
|
-
return 0;
|
|
7816
|
-
}
|
|
7817
|
-
var DELIMITER_CELL = /^:?-+:?$/;
|
|
7818
|
-
function isGfmDelimiterRow(line) {
|
|
7819
|
-
const trimmed = line.trim();
|
|
7820
|
-
if (!trimmed.includes("|")) return false;
|
|
7821
|
-
const cells = rowCells(trimmed);
|
|
7822
|
-
return cells.length > 0 && cells.every((cell) => DELIMITER_CELL.test(cell));
|
|
7823
|
-
}
|
|
7824
|
-
function isPipeLedRow(line) {
|
|
7825
|
-
const trimmed = line.trim();
|
|
7826
|
-
return trimmed.startsWith("|") && trimmed.includes("|", 1);
|
|
7827
|
-
}
|
|
7828
|
-
function isTableDelimiter(line) {
|
|
7829
|
-
if (line === void 0 || !isGfmDelimiterRow(line)) return false;
|
|
7830
|
-
return !BLOCK_START.test(line.trim());
|
|
7831
|
-
}
|
|
7832
|
-
function startsPipelessTable(header, delimiter) {
|
|
7833
|
-
const head = header.trim();
|
|
7834
|
-
if (!head || isPipeLedRow(head) || !head.startsWith("|") && startsBlock(head)) return false;
|
|
7835
|
-
if (!isTableDelimiter(delimiter)) return false;
|
|
7836
|
-
return rowCells(head).length === rowCells(delimiter.trim()).length;
|
|
7837
|
-
}
|
|
7838
|
-
function continuesTable(line, containerIndent = 0) {
|
|
7839
|
-
const trimmed = line.trim();
|
|
7840
|
-
if (!trimmed) return false;
|
|
7841
|
-
if (lineIndent(line) - containerIndent >= 4) return false;
|
|
7842
|
-
return trimmed.startsWith("|") || !startsBlock(trimmed);
|
|
7843
|
-
}
|
|
7844
|
-
function opensTable(lines, index) {
|
|
7845
|
-
const line = lines[index] ?? "";
|
|
7846
|
-
if (!isPipeLedRow(line) && !startsPipelessTable(line, lines[index + 1])) return false;
|
|
7847
|
-
return !isLazyContinuation(lines, index) && !insideHtmlBlock(lines, index);
|
|
7848
|
-
}
|
|
7849
|
-
var QUOTE_LINE = /^ {0,3}>/;
|
|
7850
|
-
var THEMATIC_BREAK = /^(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
7851
|
-
var breaksParagraph = (trimmed) => /^#{1,6}(?:\s|$)/.test(trimmed) || THEMATIC_BREAK.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
7852
|
-
function htmlBlockEnd(trimmed) {
|
|
7853
|
-
if (HTML_RAW.test(trimmed)) return /<\/(?:script|pre|style|textarea)>/i;
|
|
7854
|
-
if (trimmed.startsWith("<!--")) return /-->/;
|
|
7855
|
-
if (trimmed.startsWith("<?")) return /\?>/;
|
|
7856
|
-
if (trimmed.startsWith("<![CDATA[")) return /\]\]>/;
|
|
7857
|
-
if (/^<![A-Za-z]/.test(trimmed)) return />/;
|
|
7858
|
-
if (HTML_BLOCK_TAG.test(trimmed)) return null;
|
|
7859
|
-
if (HTML_COMPLETE_TAG.test(trimmed)) return null;
|
|
7860
|
-
return void 0;
|
|
7861
|
-
}
|
|
7862
|
-
function insideHtmlBlock(lines, index) {
|
|
7863
|
-
let start = index;
|
|
7864
|
-
while (start > 0 && (lines[start - 1] ?? "").trim()) start -= 1;
|
|
7865
|
-
let open;
|
|
7866
|
-
let paragraph = false;
|
|
7867
|
-
for (let k = start; k < index; k += 1) {
|
|
7868
|
-
const line = lines[k] ?? "";
|
|
7869
|
-
if (open !== void 0) {
|
|
7870
|
-
if (open && open.test(line)) open = void 0;
|
|
7871
|
-
continue;
|
|
7872
|
-
}
|
|
7873
|
-
const trimmed = line.trim();
|
|
7874
|
-
const end = lineIndent(line) < 4 ? htmlBlockEnd(trimmed) : void 0;
|
|
7875
|
-
const type7 = end === null && !HTML_BLOCK_TAG.test(trimmed);
|
|
7876
|
-
const interrupts = end !== void 0 && !(paragraph && type7);
|
|
7877
|
-
if (!interrupts) {
|
|
7878
|
-
paragraph = true;
|
|
7879
|
-
continue;
|
|
7880
|
-
}
|
|
7881
|
-
paragraph = false;
|
|
7882
|
-
open = end && end.test(trimmed.slice(2)) ? void 0 : end;
|
|
7883
|
-
}
|
|
7884
|
-
return open !== void 0;
|
|
7885
|
-
}
|
|
7886
|
-
function isLazyContinuation(lines, index) {
|
|
7887
|
-
const header = lines[index] ?? "";
|
|
7888
|
-
let first = -1;
|
|
7889
|
-
for (let k = index - 1; k >= 0; k -= 1) {
|
|
7890
|
-
const line = lines[k] ?? "";
|
|
7891
|
-
const trimmed = line.trim();
|
|
7892
|
-
if (!trimmed) break;
|
|
7893
|
-
if (breaksParagraph(trimmed)) break;
|
|
7894
|
-
const marker = LIST_MARKER.exec(line);
|
|
7895
|
-
if (marker) {
|
|
7896
|
-
const rest = line.slice(marker[0].length).trim();
|
|
7897
|
-
if (!rest || breaksParagraph(rest)) break;
|
|
7898
|
-
first = k;
|
|
7899
|
-
break;
|
|
7900
|
-
}
|
|
7901
|
-
first = k;
|
|
7902
|
-
if (QUOTE_LINE.test(line)) break;
|
|
7903
|
-
}
|
|
7904
|
-
if (first < 0) return false;
|
|
7905
|
-
const start = lines[first] ?? "";
|
|
7906
|
-
if (QUOTE_LINE.test(start)) return !QUOTE_LINE.test(header);
|
|
7907
|
-
return lineIndent(header) < tableContainerIndentOf(lines, first, true);
|
|
7908
|
-
}
|
|
7909
|
-
function tableStartsAt(lines, index) {
|
|
7910
|
-
const header = lines[index] ?? "";
|
|
7911
|
-
const delimiter = lines[index + 1];
|
|
7912
|
-
if (!opensTable(lines, index) || !isTableDelimiter(delimiter)) return false;
|
|
7913
|
-
if (rowCells(header).length !== rowCells(delimiter).length) return false;
|
|
7914
|
-
return lineIndent(header) - tableContainerIndent(lines, index) < 4;
|
|
7915
|
-
}
|
|
7916
|
-
function findTableStart(lines, from = 0) {
|
|
7917
|
-
for (let i = Math.max(0, from); i < lines.length; i += 1) if (opensTable(lines, i)) return i;
|
|
7918
|
-
return -1;
|
|
7919
|
-
}
|
|
7920
|
-
function findTableEnd(lines, start) {
|
|
7921
|
-
const container = tableContainerIndent(lines, start);
|
|
7922
|
-
let end = Math.min(lines.length, start + 2);
|
|
7923
|
-
while (end < lines.length && continuesTable(lines[end] ?? "", container)) end += 1;
|
|
7924
|
-
return end;
|
|
7925
|
-
}
|
|
7926
|
-
|
|
7927
7930
|
exports.ACTION_BY_CLASS = ACTION_BY_CLASS;
|
|
7928
7931
|
exports.AFTER_WINDOW = AFTER_WINDOW;
|
|
7929
7932
|
exports.BacktickRuns = BacktickRuns;
|