@ai-matrx/content-ir 0.14.0 → 0.14.2
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 +30 -0
- package/dist/index.cjs +32 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +32 -1
- package/dist/source.cjs.map +1 -1
- package/dist/source.js +32 -1
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.js
CHANGED
|
@@ -264,6 +264,7 @@ function isMathShape(content) {
|
|
|
264
264
|
const words = content.match(/[A-Za-z]+/g);
|
|
265
265
|
if (!words) return false;
|
|
266
266
|
if (!words.every((w) => w.length === 1 || FUNCTION_NAMES.has(w))) return false;
|
|
267
|
+
if (/[A-Za-z]'+[A-Za-z]/.test(content) || /(?:^|[\s(,])[A-Za-z]\.(?:[A-Za-z]\.|\s|$)/.test(content)) return false;
|
|
267
268
|
return /[A-Za-z]'*\(|[A-Za-z]'|\b[A-Za-z]\s+[A-Za-z]\b|\([^)]*[A-Za-z][^)]*\)/.test(content);
|
|
268
269
|
}
|
|
269
270
|
function isSingleDollarMath(content, after) {
|
|
@@ -1029,11 +1030,41 @@ var Tokenizer = class {
|
|
|
1029
1030
|
for (let k = li + 1; k < this.lineCount; k++) {
|
|
1030
1031
|
if (this.isOpenTail(k)) continue;
|
|
1031
1032
|
if (close.test(this.lineText(k))) {
|
|
1032
|
-
|
|
1033
|
+
const tildeEnd = this.contentEnds[k];
|
|
1034
|
+
const end = this.rendererOverflow(li + 1, k, tildeEnd);
|
|
1035
|
+
return this.island("fence", p, end, end === this.n ? this.overflowComplete : true, meta);
|
|
1033
1036
|
}
|
|
1034
1037
|
}
|
|
1035
1038
|
return this.island("fence", p, this.n, false, meta);
|
|
1036
1039
|
}
|
|
1040
|
+
/** Completion of the last `rendererOverflow` that ran to the end of the text. */
|
|
1041
|
+
overflowComplete = true;
|
|
1042
|
+
/**
|
|
1043
|
+
* The renderer's splitter does not know ~~~ fences: it reads the lines inside
|
|
1044
|
+
* one as ordinary lines, so a ```` ``` ```` fence (or an XML section, a JSON
|
|
1045
|
+
* block…) that STARTS inside the tilde fence can run past its closer. The
|
|
1046
|
+
* editor must lock at least what the renderer draws (verify-RC-B3 residual
|
|
1047
|
+
* R5), so a tilde island extends over every block the renderer would detect
|
|
1048
|
+
* starting inside it. Returns the island's end.
|
|
1049
|
+
*/
|
|
1050
|
+
rendererOverflow(firstLine, closeLine, tildeEnd) {
|
|
1051
|
+
let end = tildeEnd;
|
|
1052
|
+
this.overflowComplete = true;
|
|
1053
|
+
for (let j = firstLine; j <= closeLine && j < this.lineCount; j++) {
|
|
1054
|
+
const start = this.lineStarts[j];
|
|
1055
|
+
if (this.lineIsBlank(j)) continue;
|
|
1056
|
+
if (this.lineText(j).trimStart().startsWith("~~~")) continue;
|
|
1057
|
+
const inner = this.detectBlockUncached(start, j, false);
|
|
1058
|
+
if (!inner) continue;
|
|
1059
|
+
if (inner.end > end) {
|
|
1060
|
+
end = inner.end;
|
|
1061
|
+
this.overflowComplete = inner.complete;
|
|
1062
|
+
}
|
|
1063
|
+
const lastLine = this.lineOf(Math.max(start, inner.end - 1));
|
|
1064
|
+
if (lastLine > j) j = lastLine;
|
|
1065
|
+
}
|
|
1066
|
+
return end;
|
|
1067
|
+
}
|
|
1037
1068
|
/**
|
|
1038
1069
|
* A line-leading `$$` that OPENS a math pair (source/math-pairs.ts — the
|
|
1039
1070
|
* core's rule). A closer, an unpaired `$$`, or a prose pair is never a block:
|