@ai-matrx/content-ir 0.15.0 → 0.15.1
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 +8 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +8 -3
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +7 -2
- package/dist/source.d.ts +7 -2
- package/dist/source.js +8 -3
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.cjs
CHANGED
|
@@ -321,15 +321,20 @@ var STRUCTURAL_MARKDOWN = /\]\(|https?:\/\/|\*\*|(?:^|\n)[ \t]{0,3}#{1,6}[ \t]|(
|
|
|
321
321
|
var LATEX_COMMAND = /\\[a-zA-Z]/;
|
|
322
322
|
var PROSE_WORD = /[A-Za-z]{3,}/g;
|
|
323
323
|
var PROSE_WORD_LIMIT = 6;
|
|
324
|
-
function
|
|
324
|
+
function opensFlowBlock(text, open) {
|
|
325
|
+
for (let k = open - 1; k >= 0 && text[k] !== "\n"; k--) if (text[k] !== " " && text[k] !== " ") return false;
|
|
326
|
+
for (let k = open + 2; k < text.length && text[k] !== "\n"; k++) if (text[k] !== " " && text[k] !== " " && text[k] !== "\r") return false;
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
function looksLikeDisplayMath(inner, flow = false) {
|
|
325
330
|
const s = inner.trim();
|
|
326
331
|
if (!s) return false;
|
|
327
332
|
if (STRUCTURAL_MARKDOWN.test(s)) return false;
|
|
328
333
|
if (s.length > MAX_MATH_SPAN) return false;
|
|
334
|
+
if (!flow && /\n[ \t]*\n/.test(inner)) return false;
|
|
329
335
|
if (LATEX_COMMAND.test(s)) {
|
|
330
336
|
return (s.match(PROSE_WORD) ?? []).length < PROSE_WORD_LIMIT * 3;
|
|
331
337
|
}
|
|
332
|
-
if (/\n[ \t]*\n/.test(s)) return false;
|
|
333
338
|
return (s.match(PROSE_WORD) ?? []).length < PROSE_WORD_LIMIT;
|
|
334
339
|
}
|
|
335
340
|
function codeRanges(text) {
|
|
@@ -363,7 +368,7 @@ function pairDisplayMath(text) {
|
|
|
363
368
|
const open = tokens[j];
|
|
364
369
|
const close = tokens[j + 1];
|
|
365
370
|
if (close === void 0) break;
|
|
366
|
-
if (looksLikeDisplayMath(text.slice(open + 2, close))) {
|
|
371
|
+
if (looksLikeDisplayMath(text.slice(open + 2, close), opensFlowBlock(text, open))) {
|
|
367
372
|
pairs.set(open, close);
|
|
368
373
|
j += 2;
|
|
369
374
|
continue;
|