@ai-matrx/content-ir 0.14.1 → 0.14.3

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/source.cjs CHANGED
@@ -514,6 +514,37 @@ var NOT_WHITESPACE = /\S/;
514
514
  var DIRECTIVE_OPEN = /^(:{2,})([A-Za-z][\w-]*)/;
515
515
  var MKDOCS_OPEN = /^(!!!|\?\?\?\+?)[ \t]+([A-Za-z][\w-]*)/;
516
516
  var CALLOUT_OPEN = /^>[ \t]*\[!([A-Za-z][\w-]*)\]([+-])?/;
517
+ var CALLOUT_NAMES = /* @__PURE__ */ new Set([
518
+ "note",
519
+ "seealso",
520
+ "example",
521
+ "tip",
522
+ "hint",
523
+ "important",
524
+ "warning",
525
+ "warn",
526
+ "attention",
527
+ "caution",
528
+ "danger",
529
+ "error",
530
+ "failure",
531
+ "fail",
532
+ "missing",
533
+ "bug",
534
+ "info",
535
+ "abstract",
536
+ "summary",
537
+ "tldr",
538
+ "todo",
539
+ "success",
540
+ "check",
541
+ "done",
542
+ "question",
543
+ "help",
544
+ "faq",
545
+ "quote",
546
+ "cite"
547
+ ]);
517
548
  var FOOTNOTE_DEF = /^\[\^([^\]\s]+)\]:/;
518
549
  function countStructuralBraces(source) {
519
550
  let opens = 0;
@@ -907,7 +938,7 @@ var Tokenizer = class {
907
938
  /** A blockquote whose first line is `> [!TYPE]…` — every following `>` line belongs to it. */
908
939
  callout(p, li, t) {
909
940
  const open = CALLOUT_OPEN.exec(t);
910
- if (!open) return null;
941
+ if (!open || !CALLOUT_NAMES.has(open[1].toLowerCase())) return null;
911
942
  let last = li;
912
943
  for (let k = li + 1; k < this.lineCount; k++) {
913
944
  if (!/^ {0,3}>/.test(this.lineText(k))) break;
@@ -1032,11 +1063,41 @@ var Tokenizer = class {
1032
1063
  for (let k = li + 1; k < this.lineCount; k++) {
1033
1064
  if (this.isOpenTail(k)) continue;
1034
1065
  if (close.test(this.lineText(k))) {
1035
- return this.island("fence", p, this.contentEnds[k], true, meta);
1066
+ const tildeEnd = this.contentEnds[k];
1067
+ const end = this.rendererOverflow(li + 1, k, tildeEnd);
1068
+ return this.island("fence", p, end, end === this.n ? this.overflowComplete : true, meta);
1036
1069
  }
1037
1070
  }
1038
1071
  return this.island("fence", p, this.n, false, meta);
1039
1072
  }
1073
+ /** Completion of the last `rendererOverflow` that ran to the end of the text. */
1074
+ overflowComplete = true;
1075
+ /**
1076
+ * The renderer's splitter does not know ~~~ fences: it reads the lines inside
1077
+ * one as ordinary lines, so a ```` ``` ```` fence (or an XML section, a JSON
1078
+ * block…) that STARTS inside the tilde fence can run past its closer. The
1079
+ * editor must lock at least what the renderer draws (verify-RC-B3 residual
1080
+ * R5), so a tilde island extends over every block the renderer would detect
1081
+ * starting inside it. Returns the island's end.
1082
+ */
1083
+ rendererOverflow(firstLine, closeLine, tildeEnd) {
1084
+ let end = tildeEnd;
1085
+ this.overflowComplete = true;
1086
+ for (let j = firstLine; j <= closeLine && j < this.lineCount; j++) {
1087
+ const start = this.lineStarts[j];
1088
+ if (this.lineIsBlank(j)) continue;
1089
+ if (this.lineText(j).trimStart().startsWith("~~~")) continue;
1090
+ const inner = this.detectBlockUncached(start, j, false);
1091
+ if (!inner) continue;
1092
+ if (inner.end > end) {
1093
+ end = inner.end;
1094
+ this.overflowComplete = inner.complete;
1095
+ }
1096
+ const lastLine = this.lineOf(Math.max(start, inner.end - 1));
1097
+ if (lastLine > j) j = lastLine;
1098
+ }
1099
+ return end;
1100
+ }
1040
1101
  /**
1041
1102
  * A line-leading `$$` that OPENS a math pair (source/math-pairs.ts — the
1042
1103
  * core's rule). A closer, an unpaired `$$`, or a prose pair is never a block:
@@ -1856,6 +1917,7 @@ function mapRange(changes, start, end, unit = "utf16") {
1856
1917
  return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
1857
1918
  }
1858
1919
 
1920
+ exports.CALLOUT_NAMES = CALLOUT_NAMES;
1859
1921
  exports.FENCE_WHITESPACE = FENCE_WHITESPACE;
1860
1922
  exports.NESTING_FENCE_LANGUAGES = NESTING_FENCE_LANGUAGES;
1861
1923
  exports.SourceSpliceError = SourceSpliceError;