@ai-matrx/content-ir 0.19.8 → 0.19.10
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 +12 -0
- package/dist/index.cjs +95 -9
- 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 +93 -10
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +95 -9
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +33 -10
- package/dist/source.d.ts +33 -10
- package/dist/source.js +93 -10
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.19.10
|
|
4
|
+
|
|
5
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
6
|
+
`git diff npm/content-ir-core/v0.19.9..npm/content-ir-core/v0.19.10 -- apps/shared/content-ir-core`).
|
|
7
|
+
No source changes intended and no consumer action required.
|
|
8
|
+
|
|
9
|
+
## 0.19.9
|
|
10
|
+
### Unreleased
|
|
11
|
+
|
|
12
|
+
- `/source` **A table ends where GFM ends it (verify-RC-B4 round 9):** `continuesTable` / `findTableEnd` end a table at an HTML block start (all seven CommonMark 4.6 conditions — `<script`/`<pre`/`<style`/`<textarea`, `<!--`, `<?`, `<!X`, `<![CDATA[`, a block tag name, or any other complete tag alone on its line such as `</artifact>`) and at indented code: a line 4+ columns past the table's container. New `startsHtmlBlock`, `lineIndent`, `tableContainerIndent` (the content column of the list item a table sits in); `continuesTable(line, containerIndent = 0)`. A lone `|` is a row (one empty cell) — `rowCells("|")` is `[""]`, no longer `[]`. Since 0.19.4 an HTML line or an indented line after a table was read as a table row. Shared vectors gain `tableEnds` (30 cases, each judged against remark-gfm in matrx-frontend); the Python twin moved with them.
|
|
13
|
+
- `/source` **A table never opens on a lazy continuation line (verify-RC-B4 round 9):** `opensTable` / `tableStartsAt` / `findTableStart` refuse a header that lazily continues a list item's or a block quote's paragraph (no blank line above, not indented to the item's content column, or missing the quote's `>`) — GFM reads it as paragraph text (`- item` then `| a | b |` is no table). Vectors gain `tableStarts` (15 cases, judged against remark-gfm).
|
|
14
|
+
|
|
3
15
|
## 0.19.8
|
|
4
16
|
|
|
5
17
|
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
package/dist/index.cjs
CHANGED
|
@@ -7687,14 +7687,61 @@ function rowCells(line) {
|
|
|
7687
7687
|
const cells = splitRowSegments(line).map((cell) => cell.trim());
|
|
7688
7688
|
if (cells.length > 1 && cells[0] === "") cells.shift();
|
|
7689
7689
|
if (cells.length > 1 && cells[cells.length - 1] === "") cells.pop();
|
|
7690
|
-
else if (cells.length === 1 && cells[0] === "") cells.pop();
|
|
7690
|
+
else if (cells.length === 1 && cells[0] === "" && !line.includes("|")) cells.pop();
|
|
7691
7691
|
return cells;
|
|
7692
7692
|
}
|
|
7693
7693
|
function unescapeCellPipes(cell) {
|
|
7694
7694
|
return cell.replace(/\\\|/g, "|");
|
|
7695
7695
|
}
|
|
7696
7696
|
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$)/;
|
|
7697
|
-
var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed);
|
|
7697
|
+
var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
7698
|
+
var HTML_RAW = /^<(?:script|pre|style|textarea)(?:[\s>]|$)/i;
|
|
7699
|
+
var HTML_COMMENT_ETC = /^(?:<!--|<\?|<![A-Za-z]|<!\[CDATA\[)/;
|
|
7700
|
+
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";
|
|
7701
|
+
var HTML_BLOCK_TAG = new RegExp(`^</?(?:${HTML_BLOCK_NAMES})(?:[\\s>]|/>|$)`, "i");
|
|
7702
|
+
var ATTRIBUTE = `\\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:\\s*=\\s*(?:[^\\s"'=<>\`]+|'[^']*'|"[^"]*"))?`;
|
|
7703
|
+
var HTML_COMPLETE_TAG = new RegExp(`^(?:<[A-Za-z][A-Za-z0-9-]*(?:${ATTRIBUTE})*\\s*/?>|</[A-Za-z][A-Za-z0-9-]*\\s*>)\\s*$`);
|
|
7704
|
+
function startsHtmlBlock(trimmed) {
|
|
7705
|
+
if (!trimmed.startsWith("<")) return false;
|
|
7706
|
+
return HTML_RAW.test(trimmed) || HTML_COMMENT_ETC.test(trimmed) || HTML_BLOCK_TAG.test(trimmed) || HTML_COMPLETE_TAG.test(trimmed);
|
|
7707
|
+
}
|
|
7708
|
+
function lineIndent(line) {
|
|
7709
|
+
let column = 0;
|
|
7710
|
+
for (const ch of line) {
|
|
7711
|
+
if (ch === " ") column += 1;
|
|
7712
|
+
else if (ch === " ") column += 4 - column % 4;
|
|
7713
|
+
else break;
|
|
7714
|
+
}
|
|
7715
|
+
return column;
|
|
7716
|
+
}
|
|
7717
|
+
var LIST_MARKER = /^([ \t]*)([-+*]|\d{1,9}[.)])([ \t]+|$)/;
|
|
7718
|
+
function markerContentColumn(marker) {
|
|
7719
|
+
const markerEnd = lineIndent(marker[1] ?? "") + (marker[2] ?? "").length;
|
|
7720
|
+
const gap = marker[3] ? lineIndent(" ".repeat(markerEnd) + marker[3]) - markerEnd : 1;
|
|
7721
|
+
return markerEnd + (gap >= 1 && gap <= 4 ? gap : 1);
|
|
7722
|
+
}
|
|
7723
|
+
function tableContainerIndent(lines, start) {
|
|
7724
|
+
return tableContainerIndentOf(lines, start, false);
|
|
7725
|
+
}
|
|
7726
|
+
function tableContainerIndentOf(lines, start, ownItem) {
|
|
7727
|
+
const own = ownItem ? LIST_MARKER.exec(lines[start] ?? "") : null;
|
|
7728
|
+
if (own) return markerContentColumn(own);
|
|
7729
|
+
const header = lineIndent(lines[start] ?? "");
|
|
7730
|
+
if (header === 0) return 0;
|
|
7731
|
+
for (let k = start - 1; k >= 0; k -= 1) {
|
|
7732
|
+
const line = lines[k] ?? "";
|
|
7733
|
+
if (!line.trim()) continue;
|
|
7734
|
+
const indent = lineIndent(line);
|
|
7735
|
+
const marker = LIST_MARKER.exec(line);
|
|
7736
|
+
if (marker && indent < header) {
|
|
7737
|
+
const content = markerContentColumn(marker);
|
|
7738
|
+
if (content <= header) return content;
|
|
7739
|
+
continue;
|
|
7740
|
+
}
|
|
7741
|
+
if (indent === 0) return 0;
|
|
7742
|
+
}
|
|
7743
|
+
return 0;
|
|
7744
|
+
}
|
|
7698
7745
|
var DELIMITER_CELL = /^:?-+:?$/;
|
|
7699
7746
|
function isGfmDelimiterRow(line) {
|
|
7700
7747
|
const trimmed = line.trim();
|
|
@@ -7706,32 +7753,68 @@ function isPipeLedRow(line) {
|
|
|
7706
7753
|
const trimmed = line.trim();
|
|
7707
7754
|
return trimmed.startsWith("|") && trimmed.includes("|", 1);
|
|
7708
7755
|
}
|
|
7756
|
+
function isTableDelimiter(line) {
|
|
7757
|
+
if (line === void 0 || !isGfmDelimiterRow(line)) return false;
|
|
7758
|
+
return !BLOCK_START.test(line.trim());
|
|
7759
|
+
}
|
|
7709
7760
|
function startsPipelessTable(header, delimiter) {
|
|
7710
7761
|
const head = header.trim();
|
|
7711
|
-
if (!head || head.startsWith("|")
|
|
7712
|
-
if (
|
|
7713
|
-
if (delimiter === void 0 || !isGfmDelimiterRow(delimiter)) return false;
|
|
7762
|
+
if (!head || isPipeLedRow(head) || !head.startsWith("|") && startsBlock(head)) return false;
|
|
7763
|
+
if (!isTableDelimiter(delimiter)) return false;
|
|
7714
7764
|
return rowCells(head).length === rowCells(delimiter.trim()).length;
|
|
7715
7765
|
}
|
|
7716
|
-
function continuesTable(line) {
|
|
7766
|
+
function continuesTable(line, containerIndent = 0) {
|
|
7717
7767
|
const trimmed = line.trim();
|
|
7718
7768
|
if (!trimmed) return false;
|
|
7769
|
+
if (lineIndent(line) - containerIndent >= 4) return false;
|
|
7719
7770
|
return trimmed.startsWith("|") || !startsBlock(trimmed);
|
|
7720
7771
|
}
|
|
7721
7772
|
function opensTable(lines, index) {
|
|
7722
7773
|
const line = lines[index] ?? "";
|
|
7723
|
-
|
|
7774
|
+
if (!isPipeLedRow(line) && !startsPipelessTable(line, lines[index + 1])) return false;
|
|
7775
|
+
return !isLazyContinuation(lines, index);
|
|
7776
|
+
}
|
|
7777
|
+
var QUOTE_LINE = /^ {0,3}>/;
|
|
7778
|
+
var THEMATIC_BREAK = /^(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
7779
|
+
var breaksParagraph = (trimmed) => /^#{1,6}(?:\s|$)/.test(trimmed) || THEMATIC_BREAK.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
7780
|
+
function isLazyContinuation(lines, index) {
|
|
7781
|
+
const header = lines[index] ?? "";
|
|
7782
|
+
let first = -1;
|
|
7783
|
+
for (let k = index - 1; k >= 0; k -= 1) {
|
|
7784
|
+
const line = lines[k] ?? "";
|
|
7785
|
+
const trimmed = line.trim();
|
|
7786
|
+
if (!trimmed) break;
|
|
7787
|
+
if (breaksParagraph(trimmed)) break;
|
|
7788
|
+
const marker = LIST_MARKER.exec(line);
|
|
7789
|
+
if (marker) {
|
|
7790
|
+
const rest = line.slice(marker[0].length).trim();
|
|
7791
|
+
if (!rest || breaksParagraph(rest)) break;
|
|
7792
|
+
first = k;
|
|
7793
|
+
break;
|
|
7794
|
+
}
|
|
7795
|
+
first = k;
|
|
7796
|
+
if (QUOTE_LINE.test(line)) break;
|
|
7797
|
+
}
|
|
7798
|
+
if (first < 0) return false;
|
|
7799
|
+
const start = lines[first] ?? "";
|
|
7800
|
+
if (QUOTE_LINE.test(start)) return !QUOTE_LINE.test(header);
|
|
7801
|
+
return lineIndent(header) < tableContainerIndentOf(lines, first, true);
|
|
7724
7802
|
}
|
|
7725
7803
|
function tableStartsAt(lines, index) {
|
|
7726
|
-
|
|
7804
|
+
const header = lines[index] ?? "";
|
|
7805
|
+
const delimiter = lines[index + 1];
|
|
7806
|
+
if (!opensTable(lines, index) || !isTableDelimiter(delimiter)) return false;
|
|
7807
|
+
if (rowCells(header).length !== rowCells(delimiter).length) return false;
|
|
7808
|
+
return lineIndent(header) - tableContainerIndent(lines, index) < 4;
|
|
7727
7809
|
}
|
|
7728
7810
|
function findTableStart(lines, from = 0) {
|
|
7729
7811
|
for (let i = Math.max(0, from); i < lines.length; i += 1) if (opensTable(lines, i)) return i;
|
|
7730
7812
|
return -1;
|
|
7731
7813
|
}
|
|
7732
7814
|
function findTableEnd(lines, start) {
|
|
7815
|
+
const container = tableContainerIndent(lines, start);
|
|
7733
7816
|
let end = Math.min(lines.length, start + 2);
|
|
7734
|
-
while (end < lines.length && continuesTable(lines[end] ?? "")) end += 1;
|
|
7817
|
+
while (end < lines.length && continuesTable(lines[end] ?? "", container)) end += 1;
|
|
7735
7818
|
return end;
|
|
7736
7819
|
}
|
|
7737
7820
|
|
|
@@ -7847,6 +7930,7 @@ exports.kindSchemaToJsonSchema = kindSchemaToJsonSchema;
|
|
|
7847
7930
|
exports.kindSchemaToStorage = kindSchemaToStorage;
|
|
7848
7931
|
exports.kindVerdictOf = kindVerdictOf;
|
|
7849
7932
|
exports.legacyShellUses = legacyShellUses;
|
|
7933
|
+
exports.lineIndent = lineIndent;
|
|
7850
7934
|
exports.listIslands = listIslands;
|
|
7851
7935
|
exports.looksLikeDirectiveHead = looksLikeDirectiveHead;
|
|
7852
7936
|
exports.looksLikeDisplayMath = looksLikeDisplayMath;
|
|
@@ -7895,9 +7979,11 @@ exports.singleDollarMathEnd = singleDollarMathEnd;
|
|
|
7895
7979
|
exports.spliceSave = spliceSave;
|
|
7896
7980
|
exports.splitRowSegments = splitRowSegments;
|
|
7897
7981
|
exports.splitsSurrogatePair = splitsSurrogatePair;
|
|
7982
|
+
exports.startsHtmlBlock = startsHtmlBlock;
|
|
7898
7983
|
exports.startsPipelessTable = startsPipelessTable;
|
|
7899
7984
|
exports.storageToKindSchema = storageToKindSchema;
|
|
7900
7985
|
exports.stripKindDeep = stripKindDeep;
|
|
7986
|
+
exports.tableContainerIndent = tableContainerIndent;
|
|
7901
7987
|
exports.tableStartsAt = tableStartsAt;
|
|
7902
7988
|
exports.titleCaseToken = titleCaseToken;
|
|
7903
7989
|
exports.toCodePointOffset = toCodePointOffset;
|