@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.19.19
|
|
4
|
+
### Unreleased
|
|
5
|
+
|
|
6
|
+
- `/source` **THE ONE DELIBERATE GFM DEVIATION** (verify-RC-B4 round 16 ruling: content never silently disappears): a line opening an HTML block whose element every sanitizer strips — `STRIPPED_HTML_BLOCK_NAMES` (`link`, `nav`, `header`, `footer`, `article`, `aside`, `main`, `form`, `iframe`, `title`, … the type-6 names neither the screen's raw-HTML allow-list nor print's GitHub schema keeps) — ends that block at its own line, so a table or list under it is read as markdown (`insideHtmlBlock`; new `opensStrippedHtmlBlock(trimmed)`). GFM keeps such lines as raw HTML the sanitizer then empties; a stored answer quoting `<link rel="canonical" …/>` above its content lost every list that way. Python twin moved; `tableStarts` vectors +4 (the frontend's GFM judge applies the deviation). Documented in FEATURE.md § `source/`.
|
|
7
|
+
|
|
8
|
+
## 0.19.18
|
|
9
|
+
### Unreleased
|
|
10
|
+
|
|
11
|
+
- `/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.
|
|
12
|
+
|
|
3
13
|
## 0.19.17
|
|
4
14
|
### Unreleased
|
|
5
15
|
|
package/dist/index.cjs
CHANGED
|
@@ -6059,6 +6059,210 @@ 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 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";
|
|
6099
|
+
var STRIPPED_HTML_BLOCK_TAG = new RegExp(`^</?(?:${STRIPPED_HTML_BLOCK_NAMES})(?:[\\s>]|/>|$)`, "i");
|
|
6100
|
+
function opensStrippedHtmlBlock(trimmed) {
|
|
6101
|
+
return STRIPPED_HTML_BLOCK_TAG.test(trimmed);
|
|
6102
|
+
}
|
|
6103
|
+
var HTML_BLOCK_NAME_SET = /* @__PURE__ */ new Set([
|
|
6104
|
+
// Condition 1 (raw text) and condition 6 (block) tag names — CommonMark 0.31.
|
|
6105
|
+
"script",
|
|
6106
|
+
"pre",
|
|
6107
|
+
"style",
|
|
6108
|
+
"textarea",
|
|
6109
|
+
...HTML_BLOCK_NAMES.replace("h[1-6]", "h1|h2|h3|h4|h5|h6").split("|")
|
|
6110
|
+
]);
|
|
6111
|
+
function isHtmlBlockTagName(name) {
|
|
6112
|
+
return HTML_BLOCK_NAME_SET.has(name.toLowerCase());
|
|
6113
|
+
}
|
|
6114
|
+
function startsHtmlBlock(trimmed) {
|
|
6115
|
+
if (!trimmed.startsWith("<")) return false;
|
|
6116
|
+
return HTML_RAW.test(trimmed) || HTML_COMMENT_ETC.test(trimmed) || HTML_BLOCK_TAG.test(trimmed) || HTML_COMPLETE_TAG.test(trimmed);
|
|
6117
|
+
}
|
|
6118
|
+
function lineIndent(line) {
|
|
6119
|
+
let column = 0;
|
|
6120
|
+
for (const ch of line) {
|
|
6121
|
+
if (ch === " ") column += 1;
|
|
6122
|
+
else if (ch === " ") column += 4 - column % 4;
|
|
6123
|
+
else break;
|
|
6124
|
+
}
|
|
6125
|
+
return column;
|
|
6126
|
+
}
|
|
6127
|
+
var LIST_MARKER = /^([ \t]*)([-+*]|\d{1,9}[.)])([ \t]+|$)/;
|
|
6128
|
+
function markerContentColumn(marker) {
|
|
6129
|
+
const markerEnd = lineIndent(marker[1] ?? "") + (marker[2] ?? "").length;
|
|
6130
|
+
const gap = marker[3] ? lineIndent(" ".repeat(markerEnd) + marker[3]) - markerEnd : 1;
|
|
6131
|
+
return markerEnd + (gap >= 1 && gap <= 4 ? gap : 1);
|
|
6132
|
+
}
|
|
6133
|
+
function tableContainerIndent(lines, start) {
|
|
6134
|
+
return tableContainerIndentOf(lines, start, false);
|
|
6135
|
+
}
|
|
6136
|
+
function tableContainerIndentOf(lines, start, ownItem) {
|
|
6137
|
+
const own = ownItem ? LIST_MARKER.exec(lines[start] ?? "") : null;
|
|
6138
|
+
if (own) return markerContentColumn(own);
|
|
6139
|
+
const header = lineIndent(lines[start] ?? "");
|
|
6140
|
+
if (header === 0) return 0;
|
|
6141
|
+
for (let k = start - 1; k >= 0; k -= 1) {
|
|
6142
|
+
const line = lines[k] ?? "";
|
|
6143
|
+
if (!line.trim()) continue;
|
|
6144
|
+
const indent = lineIndent(line);
|
|
6145
|
+
const marker = LIST_MARKER.exec(line);
|
|
6146
|
+
if (marker && indent < header) {
|
|
6147
|
+
const content = markerContentColumn(marker);
|
|
6148
|
+
if (content <= header) return content;
|
|
6149
|
+
continue;
|
|
6150
|
+
}
|
|
6151
|
+
if (indent === 0) return 0;
|
|
6152
|
+
}
|
|
6153
|
+
return 0;
|
|
6154
|
+
}
|
|
6155
|
+
var DELIMITER_CELL = /^:?-+:?$/;
|
|
6156
|
+
function isGfmDelimiterRow(line) {
|
|
6157
|
+
const trimmed = line.trim();
|
|
6158
|
+
if (!trimmed.includes("|")) return false;
|
|
6159
|
+
const cells = rowCells(trimmed);
|
|
6160
|
+
return cells.length > 0 && cells.every((cell) => DELIMITER_CELL.test(cell));
|
|
6161
|
+
}
|
|
6162
|
+
function isPipeLedRow(line) {
|
|
6163
|
+
const trimmed = line.trim();
|
|
6164
|
+
return trimmed.startsWith("|") && trimmed.includes("|", 1);
|
|
6165
|
+
}
|
|
6166
|
+
function isTableDelimiter(line) {
|
|
6167
|
+
if (line === void 0 || !isGfmDelimiterRow(line)) return false;
|
|
6168
|
+
return !BLOCK_START.test(line.trim());
|
|
6169
|
+
}
|
|
6170
|
+
function startsPipelessTable(header, delimiter) {
|
|
6171
|
+
const head = header.trim();
|
|
6172
|
+
if (!head || isPipeLedRow(head) || !head.startsWith("|") && startsBlock(head)) return false;
|
|
6173
|
+
if (!isTableDelimiter(delimiter)) return false;
|
|
6174
|
+
return rowCells(head).length === rowCells(delimiter.trim()).length;
|
|
6175
|
+
}
|
|
6176
|
+
function continuesTable(line, containerIndent = 0) {
|
|
6177
|
+
const trimmed = line.trim();
|
|
6178
|
+
if (!trimmed) return false;
|
|
6179
|
+
if (lineIndent(line) - containerIndent >= 4) return false;
|
|
6180
|
+
return trimmed.startsWith("|") || !startsBlock(trimmed);
|
|
6181
|
+
}
|
|
6182
|
+
function opensTable(lines, index) {
|
|
6183
|
+
const line = lines[index] ?? "";
|
|
6184
|
+
if (!isPipeLedRow(line) && !startsPipelessTable(line, lines[index + 1])) return false;
|
|
6185
|
+
return !isLazyContinuation(lines, index) && !insideHtmlBlock(lines, index);
|
|
6186
|
+
}
|
|
6187
|
+
var QUOTE_LINE = /^ {0,3}>/;
|
|
6188
|
+
var THEMATIC_BREAK = /^(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
6189
|
+
var breaksParagraph = (trimmed) => /^#{1,6}(?:\s|$)/.test(trimmed) || THEMATIC_BREAK.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
6190
|
+
function htmlBlockEnd(trimmed) {
|
|
6191
|
+
if (HTML_RAW.test(trimmed)) return /<\/(?:script|pre|style|textarea)>/i;
|
|
6192
|
+
if (trimmed.startsWith("<!--")) return /-->/;
|
|
6193
|
+
if (trimmed.startsWith("<?")) return /\?>/;
|
|
6194
|
+
if (trimmed.startsWith("<![CDATA[")) return /\]\]>/;
|
|
6195
|
+
if (/^<![A-Za-z]/.test(trimmed)) return />/;
|
|
6196
|
+
if (HTML_BLOCK_TAG.test(trimmed)) return null;
|
|
6197
|
+
if (HTML_COMPLETE_TAG.test(trimmed)) return null;
|
|
6198
|
+
return void 0;
|
|
6199
|
+
}
|
|
6200
|
+
function insideHtmlBlock(lines, index) {
|
|
6201
|
+
let start = index;
|
|
6202
|
+
while (start > 0 && (lines[start - 1] ?? "").trim()) start -= 1;
|
|
6203
|
+
let open;
|
|
6204
|
+
let paragraph = false;
|
|
6205
|
+
for (let k = start; k < index; k += 1) {
|
|
6206
|
+
const line = lines[k] ?? "";
|
|
6207
|
+
if (open !== void 0) {
|
|
6208
|
+
if (open && open.test(line)) open = void 0;
|
|
6209
|
+
continue;
|
|
6210
|
+
}
|
|
6211
|
+
const trimmed = line.trim();
|
|
6212
|
+
const end = lineIndent(line) < 4 ? htmlBlockEnd(trimmed) : void 0;
|
|
6213
|
+
const type7 = end === null && !HTML_BLOCK_TAG.test(trimmed);
|
|
6214
|
+
const interrupts = end !== void 0 && !(paragraph && type7);
|
|
6215
|
+
if (!interrupts) {
|
|
6216
|
+
paragraph = true;
|
|
6217
|
+
continue;
|
|
6218
|
+
}
|
|
6219
|
+
paragraph = false;
|
|
6220
|
+
if (opensStrippedHtmlBlock(trimmed)) continue;
|
|
6221
|
+
open = end && end.test(trimmed.slice(2)) ? void 0 : end;
|
|
6222
|
+
}
|
|
6223
|
+
return open !== void 0;
|
|
6224
|
+
}
|
|
6225
|
+
function isLazyContinuation(lines, index) {
|
|
6226
|
+
const header = lines[index] ?? "";
|
|
6227
|
+
let first = -1;
|
|
6228
|
+
for (let k = index - 1; k >= 0; k -= 1) {
|
|
6229
|
+
const line = lines[k] ?? "";
|
|
6230
|
+
const trimmed = line.trim();
|
|
6231
|
+
if (!trimmed) break;
|
|
6232
|
+
if (breaksParagraph(trimmed)) break;
|
|
6233
|
+
const marker = LIST_MARKER.exec(line);
|
|
6234
|
+
if (marker) {
|
|
6235
|
+
const rest = line.slice(marker[0].length).trim();
|
|
6236
|
+
if (!rest || breaksParagraph(rest)) break;
|
|
6237
|
+
first = k;
|
|
6238
|
+
break;
|
|
6239
|
+
}
|
|
6240
|
+
first = k;
|
|
6241
|
+
if (QUOTE_LINE.test(line)) break;
|
|
6242
|
+
}
|
|
6243
|
+
if (first < 0) return false;
|
|
6244
|
+
const start = lines[first] ?? "";
|
|
6245
|
+
if (QUOTE_LINE.test(start)) return !QUOTE_LINE.test(header);
|
|
6246
|
+
return lineIndent(header) < tableContainerIndentOf(lines, first, true);
|
|
6247
|
+
}
|
|
6248
|
+
function tableStartsAt(lines, index) {
|
|
6249
|
+
const header = lines[index] ?? "";
|
|
6250
|
+
const delimiter = lines[index + 1];
|
|
6251
|
+
if (!opensTable(lines, index) || !isTableDelimiter(delimiter)) return false;
|
|
6252
|
+
if (rowCells(header).length !== rowCells(delimiter).length) return false;
|
|
6253
|
+
return lineIndent(header) - tableContainerIndent(lines, index) < 4;
|
|
6254
|
+
}
|
|
6255
|
+
function findTableStart(lines, from = 0) {
|
|
6256
|
+
for (let i = Math.max(0, from); i < lines.length; i += 1) if (opensTable(lines, i)) return i;
|
|
6257
|
+
return -1;
|
|
6258
|
+
}
|
|
6259
|
+
function findTableEnd(lines, start) {
|
|
6260
|
+
const container = tableContainerIndent(lines, start);
|
|
6261
|
+
let end = Math.min(lines.length, start + 2);
|
|
6262
|
+
while (end < lines.length && continuesTable(lines[end] ?? "", container)) end += 1;
|
|
6263
|
+
return end;
|
|
6264
|
+
}
|
|
6265
|
+
|
|
6062
6266
|
// source/tokenize.ts
|
|
6063
6267
|
var NOT_WHITESPACE = /\S/;
|
|
6064
6268
|
var DIRECTIVE_OPEN = /^(:{2,})([A-Za-z][\w-]*)/;
|
|
@@ -6900,9 +7104,12 @@ var Tokenizer = class {
|
|
|
6900
7104
|
});
|
|
6901
7105
|
}
|
|
6902
7106
|
}
|
|
7107
|
+
if (isHtmlBlockTagName(root)) return null;
|
|
6903
7108
|
return this.island("xml_container", p, this.n, false, { tag: root });
|
|
6904
7109
|
}
|
|
6905
7110
|
if (isUnclosedGenericXmlOpening(seg)) {
|
|
7111
|
+
const name = /^\s*<([A-Za-z_][\w.:-]*)/.exec(seg)?.[1] ?? "";
|
|
7112
|
+
if (isHtmlBlockTagName(name)) return null;
|
|
6906
7113
|
return this.island("xml_container", p, this.n, false, {});
|
|
6907
7114
|
}
|
|
6908
7115
|
return null;
|
|
@@ -7726,204 +7933,6 @@ function resolveReferenceLinks(fragment, defs) {
|
|
|
7726
7933
|
return resolved.replace(new RegExp(`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`, "g"), (_m, i) => spans[Number(i)] ?? "");
|
|
7727
7934
|
}
|
|
7728
7935
|
|
|
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
7936
|
exports.ACTION_BY_CLASS = ACTION_BY_CLASS;
|
|
7928
7937
|
exports.AFTER_WINDOW = AFTER_WINDOW;
|
|
7929
7938
|
exports.BacktickRuns = BacktickRuns;
|
|
@@ -8057,6 +8066,7 @@ exports.nounFamily = nounFamily;
|
|
|
8057
8066
|
exports.nounLabel = nounLabel;
|
|
8058
8067
|
exports.nounTitleColumn = nounTitleColumn;
|
|
8059
8068
|
exports.openParseSession = openParseSession;
|
|
8069
|
+
exports.opensStrippedHtmlBlock = opensStrippedHtmlBlock;
|
|
8060
8070
|
exports.opensTable = opensTable;
|
|
8061
8071
|
exports.pairDisplayMath = pairDisplayMath;
|
|
8062
8072
|
exports.parseDirectiveSlug = parseDirectiveSlug;
|