@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/dist/index.js CHANGED
@@ -5288,15 +5288,20 @@ var STRUCTURAL_MARKDOWN = /\]\(|https?:\/\/|\*\*|(?:^|\n)[ \t]{0,3}#{1,6}[ \t]|(
5288
5288
  var LATEX_COMMAND = /\\[a-zA-Z]/;
5289
5289
  var PROSE_WORD = /[A-Za-z]{3,}/g;
5290
5290
  var PROSE_WORD_LIMIT = 6;
5291
- function looksLikeDisplayMath(inner) {
5291
+ function opensFlowBlock(text, open) {
5292
+ for (let k = open - 1; k >= 0 && text[k] !== "\n"; k--) if (text[k] !== " " && text[k] !== " ") return false;
5293
+ for (let k = open + 2; k < text.length && text[k] !== "\n"; k++) if (text[k] !== " " && text[k] !== " " && text[k] !== "\r") return false;
5294
+ return true;
5295
+ }
5296
+ function looksLikeDisplayMath(inner, flow = false) {
5292
5297
  const s = inner.trim();
5293
5298
  if (!s) return false;
5294
5299
  if (STRUCTURAL_MARKDOWN.test(s)) return false;
5295
5300
  if (s.length > MAX_MATH_SPAN) return false;
5301
+ if (!flow && /\n[ \t]*\n/.test(inner)) return false;
5296
5302
  if (LATEX_COMMAND.test(s)) {
5297
5303
  return (s.match(PROSE_WORD) ?? []).length < PROSE_WORD_LIMIT * 3;
5298
5304
  }
5299
- if (/\n[ \t]*\n/.test(s)) return false;
5300
5305
  return (s.match(PROSE_WORD) ?? []).length < PROSE_WORD_LIMIT;
5301
5306
  }
5302
5307
  function codeRanges(text) {
@@ -5330,7 +5335,7 @@ function pairDisplayMath(text) {
5330
5335
  const open = tokens[j];
5331
5336
  const close = tokens[j + 1];
5332
5337
  if (close === void 0) break;
5333
- if (looksLikeDisplayMath(text.slice(open + 2, close))) {
5338
+ if (looksLikeDisplayMath(text.slice(open + 2, close), opensFlowBlock(text, open))) {
5334
5339
  pairs.set(open, close);
5335
5340
  j += 2;
5336
5341
  continue;