@ai-matrx/content-ir 0.19.5 → 0.19.7
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 +28 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +27 -7
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +28 -6
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +13 -2
- package/dist/source.d.ts +13 -2
- package/dist/source.js +27 -7
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.d.cts
CHANGED
|
@@ -457,7 +457,9 @@ declare const FENCE_OPENER_WHITESPACE = "\t\n\v\f\r \u00A0\u1680\u2000\u2001\u20
|
|
|
457
457
|
/**
|
|
458
458
|
* Parse a backtick fence OPENER line the way the renderer does: trim the line,
|
|
459
459
|
* count the backtick run (3+), trim the rest, and take the first
|
|
460
|
-
* whitespace-separated word as the language. null when the line opens nothing
|
|
460
|
+
* whitespace-separated word as the language. null when the line opens nothing —
|
|
461
|
+
* including when the info string holds a backtick (GFM / CommonMark 4.5:
|
|
462
|
+
* "```` code ````" and "``` `x` | b" are code spans, never fences).
|
|
461
463
|
*/
|
|
462
464
|
declare function parseFenceOpener(line: string): {
|
|
463
465
|
ticks: number;
|
|
@@ -562,6 +564,15 @@ declare function findCodeRanges(text: string): CodeRange[];
|
|
|
562
564
|
* placeholder code in markdown — never a private /```…```/ regex.
|
|
563
565
|
*/
|
|
564
566
|
declare function mapCodeRanges(text: string, fn: (range: CodeRange, raw: string) => string): string;
|
|
567
|
+
/**
|
|
568
|
+
* The code SPANS in one piece of INLINE content — a table cell, a heading's
|
|
569
|
+
* text, a link label — where no block structure exists, so a line opening with
|
|
570
|
+
* three or more backticks is a code span, never a fence (```` `` code `` ```` in a
|
|
571
|
+
* GFM cell). Same scanner and escape rules as `findCodeRanges`' span pass.
|
|
572
|
+
*/
|
|
573
|
+
declare function findInlineCodeSpans(text: string): CodeRange[];
|
|
574
|
+
/** Rewrite every code SPAN of inline content through `fn` (see `findInlineCodeSpans`); other text is kept byte for byte. */
|
|
575
|
+
declare function mapInlineCodeSpans(text: string, fn: (range: CodeRange, raw: string) => string): string;
|
|
565
576
|
/** 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
577
|
declare function codeSpanText(raw: string): string;
|
|
567
578
|
/**
|
|
@@ -655,4 +666,4 @@ declare function findTableStart(lines: readonly string[], from?: number): number
|
|
|
655
666
|
/** Index just past the table whose header is at `start` (header, delimiter, then continuation rows). */
|
|
656
667
|
declare function findTableEnd(lines: readonly string[], start: number): number;
|
|
657
668
|
|
|
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 };
|
|
669
|
+
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
|
@@ -457,7 +457,9 @@ declare const FENCE_OPENER_WHITESPACE = "\t\n\v\f\r \u00A0\u1680\u2000\u2001\u20
|
|
|
457
457
|
/**
|
|
458
458
|
* Parse a backtick fence OPENER line the way the renderer does: trim the line,
|
|
459
459
|
* count the backtick run (3+), trim the rest, and take the first
|
|
460
|
-
* whitespace-separated word as the language. null when the line opens nothing
|
|
460
|
+
* whitespace-separated word as the language. null when the line opens nothing —
|
|
461
|
+
* including when the info string holds a backtick (GFM / CommonMark 4.5:
|
|
462
|
+
* "```` code ````" and "``` `x` | b" are code spans, never fences).
|
|
461
463
|
*/
|
|
462
464
|
declare function parseFenceOpener(line: string): {
|
|
463
465
|
ticks: number;
|
|
@@ -562,6 +564,15 @@ declare function findCodeRanges(text: string): CodeRange[];
|
|
|
562
564
|
* placeholder code in markdown — never a private /```…```/ regex.
|
|
563
565
|
*/
|
|
564
566
|
declare function mapCodeRanges(text: string, fn: (range: CodeRange, raw: string) => string): string;
|
|
567
|
+
/**
|
|
568
|
+
* The code SPANS in one piece of INLINE content — a table cell, a heading's
|
|
569
|
+
* text, a link label — where no block structure exists, so a line opening with
|
|
570
|
+
* three or more backticks is a code span, never a fence (```` `` code `` ```` in a
|
|
571
|
+
* GFM cell). Same scanner and escape rules as `findCodeRanges`' span pass.
|
|
572
|
+
*/
|
|
573
|
+
declare function findInlineCodeSpans(text: string): CodeRange[];
|
|
574
|
+
/** Rewrite every code SPAN of inline content through `fn` (see `findInlineCodeSpans`); other text is kept byte for byte. */
|
|
575
|
+
declare function mapInlineCodeSpans(text: string, fn: (range: CodeRange, raw: string) => string): string;
|
|
565
576
|
/** 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
577
|
declare function codeSpanText(raw: string): string;
|
|
567
578
|
/**
|
|
@@ -655,4 +666,4 @@ declare function findTableStart(lines: readonly string[], from?: number): number
|
|
|
655
666
|
/** Index just past the table whose header is at `start` (header, delimiter, then continuation rows). */
|
|
656
667
|
declare function findTableEnd(lines: readonly string[], start: number): number;
|
|
657
668
|
|
|
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 };
|
|
669
|
+
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
|
@@ -232,6 +232,7 @@ function parseFenceOpener(line) {
|
|
|
232
232
|
let ticks = 0;
|
|
233
233
|
while (start + ticks < end && line[start + ticks] === "`") ticks++;
|
|
234
234
|
if (ticks < 3) return null;
|
|
235
|
+
if (line.slice(start + ticks, end).includes("`")) return null;
|
|
235
236
|
let infoStart = start + ticks;
|
|
236
237
|
while (infoStart < end && isOpenerWhitespace(line[infoStart])) infoStart++;
|
|
237
238
|
let langEnd = infoStart;
|
|
@@ -256,9 +257,9 @@ function classifyInnerFenceLine(trimmed, openTicks, nests, nestedDepth) {
|
|
|
256
257
|
function fenceOpenerOf(content) {
|
|
257
258
|
const t = content.trimStart();
|
|
258
259
|
if (t.startsWith("```")) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
return { char: "`", ticks, lang:
|
|
260
|
+
const parsed = parseFenceOpener(t);
|
|
261
|
+
if (!parsed) return null;
|
|
262
|
+
return { char: "`", ticks: parsed.ticks, lang: parsed.lang };
|
|
262
263
|
}
|
|
263
264
|
if (content.length - t.length <= 3 && t.startsWith("~~~")) {
|
|
264
265
|
const open = /^(~{3,})(.*)$/.exec(t);
|
|
@@ -267,6 +268,9 @@ function fenceOpenerOf(content) {
|
|
|
267
268
|
}
|
|
268
269
|
return null;
|
|
269
270
|
}
|
|
271
|
+
function opensStrictFence(line) {
|
|
272
|
+
return fenceOpenerOf(line) !== null;
|
|
273
|
+
}
|
|
270
274
|
var FenceReader = class {
|
|
271
275
|
opener;
|
|
272
276
|
state = { inString: false, escaped: false };
|
|
@@ -553,6 +557,21 @@ function mapCodeRanges(text, fn) {
|
|
|
553
557
|
}
|
|
554
558
|
return out + text.slice(at);
|
|
555
559
|
}
|
|
560
|
+
function findInlineCodeSpans(text) {
|
|
561
|
+
const ranges = [];
|
|
562
|
+
codeSpans(text, 0, text.length, ranges);
|
|
563
|
+
return ranges.sort((a, b) => a.start - b.start);
|
|
564
|
+
}
|
|
565
|
+
function mapInlineCodeSpans(text, fn) {
|
|
566
|
+
let out = "";
|
|
567
|
+
let at = 0;
|
|
568
|
+
for (const r of findInlineCodeSpans(text)) {
|
|
569
|
+
if (r.start < at) continue;
|
|
570
|
+
out += text.slice(at, r.start) + fn(r, text.slice(r.start, r.end));
|
|
571
|
+
at = r.end;
|
|
572
|
+
}
|
|
573
|
+
return out + text.slice(at);
|
|
574
|
+
}
|
|
556
575
|
function codeSpanText(raw) {
|
|
557
576
|
const ticks = backtickRunLength(raw, 0);
|
|
558
577
|
const inner = raw.slice(ticks, raw.length - ticks);
|
|
@@ -2612,7 +2631,8 @@ function rowCells(line) {
|
|
|
2612
2631
|
function unescapeCellPipes(cell) {
|
|
2613
2632
|
return cell.replace(/\\\|/g, "|");
|
|
2614
2633
|
}
|
|
2615
|
-
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)
|
|
2634
|
+
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$)/;
|
|
2635
|
+
var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed);
|
|
2616
2636
|
var DELIMITER_CELL = /^:?-+:?$/;
|
|
2617
2637
|
function isGfmDelimiterRow(line) {
|
|
2618
2638
|
const trimmed = line.trim();
|
|
@@ -2626,7 +2646,7 @@ function isPipeLedRow(line) {
|
|
|
2626
2646
|
}
|
|
2627
2647
|
function startsPipelessTable(header, delimiter) {
|
|
2628
2648
|
const head = header.trim();
|
|
2629
|
-
if (!head || head.startsWith("|") ||
|
|
2649
|
+
if (!head || head.startsWith("|") || startsBlock(head)) return false;
|
|
2630
2650
|
if (splitRowSegments(head).length < 2) return false;
|
|
2631
2651
|
if (delimiter === void 0 || !isGfmDelimiterRow(delimiter)) return false;
|
|
2632
2652
|
return rowCells(head).length === rowCells(delimiter.trim()).length;
|
|
@@ -2634,7 +2654,7 @@ function startsPipelessTable(header, delimiter) {
|
|
|
2634
2654
|
function continuesTable(line) {
|
|
2635
2655
|
const trimmed = line.trim();
|
|
2636
2656
|
if (!trimmed) return false;
|
|
2637
|
-
return trimmed.startsWith("|") || !
|
|
2657
|
+
return trimmed.startsWith("|") || !startsBlock(trimmed);
|
|
2638
2658
|
}
|
|
2639
2659
|
function opensTable(lines, index) {
|
|
2640
2660
|
const line = lines[index] ?? "";
|
|
@@ -2653,6 +2673,6 @@ function findTableEnd(lines, start) {
|
|
|
2653
2673
|
return end;
|
|
2654
2674
|
}
|
|
2655
2675
|
|
|
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 };
|
|
2676
|
+
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
2677
|
//# sourceMappingURL=source.js.map
|
|
2658
2678
|
//# sourceMappingURL=source.js.map
|