@ai-matrx/content-ir 0.19.5 → 0.19.6

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.d.cts CHANGED
@@ -562,6 +562,15 @@ declare function findCodeRanges(text: string): CodeRange[];
562
562
  * placeholder code in markdown — never a private /```…```/ regex.
563
563
  */
564
564
  declare function mapCodeRanges(text: string, fn: (range: CodeRange, raw: string) => string): string;
565
+ /**
566
+ * The code SPANS in one piece of INLINE content — a table cell, a heading's
567
+ * text, a link label — where no block structure exists, so a line opening with
568
+ * three or more backticks is a code span, never a fence (```` `` code `` ```` in a
569
+ * GFM cell). Same scanner and escape rules as `findCodeRanges`' span pass.
570
+ */
571
+ declare function findInlineCodeSpans(text: string): CodeRange[];
572
+ /** Rewrite every code SPAN of inline content through `fn` (see `findInlineCodeSpans`); other text is kept byte for byte. */
573
+ declare function mapInlineCodeSpans(text: string, fn: (range: CodeRange, raw: string) => string): string;
565
574
  /** A code span's text (CommonMark): the backtick runs off, then one padding space each side when both are there and the content is not all spaces. */
566
575
  declare function codeSpanText(raw: string): string;
567
576
  /**
@@ -655,4 +664,4 @@ declare function findTableStart(lines: readonly string[], from?: number): number
655
664
  /** Index just past the table whose header is at `start` (header, delimiter, then continuation rows). */
656
665
  declare function findTableEnd(lines: readonly string[], start: number): number;
657
666
 
658
- export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsPipelessTable, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
667
+ export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsPipelessTable, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
package/dist/source.d.ts CHANGED
@@ -562,6 +562,15 @@ declare function findCodeRanges(text: string): CodeRange[];
562
562
  * placeholder code in markdown — never a private /```…```/ regex.
563
563
  */
564
564
  declare function mapCodeRanges(text: string, fn: (range: CodeRange, raw: string) => string): string;
565
+ /**
566
+ * The code SPANS in one piece of INLINE content — a table cell, a heading's
567
+ * text, a link label — where no block structure exists, so a line opening with
568
+ * three or more backticks is a code span, never a fence (```` `` code `` ```` in a
569
+ * GFM cell). Same scanner and escape rules as `findCodeRanges`' span pass.
570
+ */
571
+ declare function findInlineCodeSpans(text: string): CodeRange[];
572
+ /** Rewrite every code SPAN of inline content through `fn` (see `findInlineCodeSpans`); other text is kept byte for byte. */
573
+ declare function mapInlineCodeSpans(text: string, fn: (range: CodeRange, raw: string) => string): string;
565
574
  /** A code span's text (CommonMark): the backtick runs off, then one padding space each side when both are there and the content is not all spaces. */
566
575
  declare function codeSpanText(raw: string): string;
567
576
  /**
@@ -655,4 +664,4 @@ declare function findTableStart(lines: readonly string[], from?: number): number
655
664
  /** Index just past the table whose header is at `start` (header, delimiter, then continuation rows). */
656
665
  declare function findTableEnd(lines: readonly string[], start: number): number;
657
666
 
658
- export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsPipelessTable, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
667
+ export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsPipelessTable, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
package/dist/source.js CHANGED
@@ -267,6 +267,13 @@ function fenceOpenerOf(content) {
267
267
  }
268
268
  return null;
269
269
  }
270
+ function opensStrictFence(line) {
271
+ const opener = fenceOpenerOf(line);
272
+ if (!opener) return false;
273
+ if (opener.char === "~") return true;
274
+ const t = line.trimStart();
275
+ return !t.slice(opener.ticks).includes("`");
276
+ }
270
277
  var FenceReader = class {
271
278
  opener;
272
279
  state = { inString: false, escaped: false };
@@ -553,6 +560,21 @@ function mapCodeRanges(text, fn) {
553
560
  }
554
561
  return out + text.slice(at);
555
562
  }
563
+ function findInlineCodeSpans(text) {
564
+ const ranges = [];
565
+ codeSpans(text, 0, text.length, ranges);
566
+ return ranges.sort((a, b) => a.start - b.start);
567
+ }
568
+ function mapInlineCodeSpans(text, fn) {
569
+ let out = "";
570
+ let at = 0;
571
+ for (const r of findInlineCodeSpans(text)) {
572
+ if (r.start < at) continue;
573
+ out += text.slice(at, r.start) + fn(r, text.slice(r.start, r.end));
574
+ at = r.end;
575
+ }
576
+ return out + text.slice(at);
577
+ }
556
578
  function codeSpanText(raw) {
557
579
  const ticks = backtickRunLength(raw, 0);
558
580
  const inner = raw.slice(ticks, raw.length - ticks);
@@ -2612,7 +2634,8 @@ function rowCells(line) {
2612
2634
  function unescapeCellPipes(cell) {
2613
2635
  return cell.replace(/\\\|/g, "|");
2614
2636
  }
2615
- var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|```|~~~|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$)/;
2637
+ var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$)/;
2638
+ var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed);
2616
2639
  var DELIMITER_CELL = /^:?-+:?$/;
2617
2640
  function isGfmDelimiterRow(line) {
2618
2641
  const trimmed = line.trim();
@@ -2626,7 +2649,7 @@ function isPipeLedRow(line) {
2626
2649
  }
2627
2650
  function startsPipelessTable(header, delimiter) {
2628
2651
  const head = header.trim();
2629
- if (!head || head.startsWith("|") || BLOCK_START.test(head)) return false;
2652
+ if (!head || head.startsWith("|") || startsBlock(head)) return false;
2630
2653
  if (splitRowSegments(head).length < 2) return false;
2631
2654
  if (delimiter === void 0 || !isGfmDelimiterRow(delimiter)) return false;
2632
2655
  return rowCells(head).length === rowCells(delimiter.trim()).length;
@@ -2634,7 +2657,7 @@ function startsPipelessTable(header, delimiter) {
2634
2657
  function continuesTable(line) {
2635
2658
  const trimmed = line.trim();
2636
2659
  if (!trimmed) return false;
2637
- return trimmed.startsWith("|") || !BLOCK_START.test(trimmed);
2660
+ return trimmed.startsWith("|") || !startsBlock(trimmed);
2638
2661
  }
2639
2662
  function opensTable(lines, index) {
2640
2663
  const line = lines[index] ?? "";
@@ -2653,6 +2676,6 @@ function findTableEnd(lines, start) {
2653
2676
  return end;
2654
2677
  }
2655
2678
 
2656
- export { AFTER_WINDOW, BacktickRuns, CALLOUT_NAMES, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceReader, NESTING_FENCE_LANGUAGES, SourceSpliceError, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsPipelessTable, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
2679
+ export { AFTER_WINDOW, BacktickRuns, CALLOUT_NAMES, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceReader, NESTING_FENCE_LANGUAGES, SourceSpliceError, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsPipelessTable, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
2657
2680
  //# sourceMappingURL=source.js.map
2658
2681
  //# sourceMappingURL=source.js.map