@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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.15.1
4
+
5
+ - **Fixed (`/source` `pairDisplayMath`):** a stray `$$` in prose paired with
6
+ the next paragraph's formula when a LaTeX command sat between them. A `$$`
7
+ with text beside it never crosses a blank line (TeX's rule), checked on the
8
+ untrimmed span; a `$$` alone on its line still opens a flow block that may
9
+ span blank lines. `looksLikeDisplayMath(inner, flow?)` gains the `flow`
10
+ flag. Same rule as `@ai-matrx/kit` `delimiter-guard` (one math dialect).
11
+ - Consumer action: none — refresh to latest.
12
+
3
13
  ## 0.14.3
4
14
 
5
15
  Automatic changed-only republish (docs/metadata drift since the last tag — see
package/dist/index.cjs CHANGED
@@ -5294,15 +5294,20 @@ var STRUCTURAL_MARKDOWN = /\]\(|https?:\/\/|\*\*|(?:^|\n)[ \t]{0,3}#{1,6}[ \t]|(
5294
5294
  var LATEX_COMMAND = /\\[a-zA-Z]/;
5295
5295
  var PROSE_WORD = /[A-Za-z]{3,}/g;
5296
5296
  var PROSE_WORD_LIMIT = 6;
5297
- function looksLikeDisplayMath(inner) {
5297
+ function opensFlowBlock(text, open) {
5298
+ for (let k = open - 1; k >= 0 && text[k] !== "\n"; k--) if (text[k] !== " " && text[k] !== " ") return false;
5299
+ for (let k = open + 2; k < text.length && text[k] !== "\n"; k++) if (text[k] !== " " && text[k] !== " " && text[k] !== "\r") return false;
5300
+ return true;
5301
+ }
5302
+ function looksLikeDisplayMath(inner, flow = false) {
5298
5303
  const s = inner.trim();
5299
5304
  if (!s) return false;
5300
5305
  if (STRUCTURAL_MARKDOWN.test(s)) return false;
5301
5306
  if (s.length > MAX_MATH_SPAN) return false;
5307
+ if (!flow && /\n[ \t]*\n/.test(inner)) return false;
5302
5308
  if (LATEX_COMMAND.test(s)) {
5303
5309
  return (s.match(PROSE_WORD) ?? []).length < PROSE_WORD_LIMIT * 3;
5304
5310
  }
5305
- if (/\n[ \t]*\n/.test(s)) return false;
5306
5311
  return (s.match(PROSE_WORD) ?? []).length < PROSE_WORD_LIMIT;
5307
5312
  }
5308
5313
  function codeRanges(text) {
@@ -5336,7 +5341,7 @@ function pairDisplayMath(text) {
5336
5341
  const open = tokens[j];
5337
5342
  const close = tokens[j + 1];
5338
5343
  if (close === void 0) break;
5339
- if (looksLikeDisplayMath(text.slice(open + 2, close))) {
5344
+ if (looksLikeDisplayMath(text.slice(open + 2, close), opensFlowBlock(text, open))) {
5340
5345
  pairs.set(open, close);
5341
5346
  j += 2;
5342
5347
  continue;