@ai-matrx/content-ir 0.18.3 → 0.18.4
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 +22 -0
- package/dist/index.cjs +9 -1
- 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 +9 -2
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +9 -1
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +14 -1
- package/dist/source.d.ts +14 -1
- package/dist/source.js +9 -2
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.d.cts
CHANGED
|
@@ -349,6 +349,19 @@ declare function looksLikeOpenInlineMath(partial: string): boolean;
|
|
|
349
349
|
* {@link isSingleDollarMath}. Returns the offset just past the closing `$`.
|
|
350
350
|
*/
|
|
351
351
|
declare function singleDollarMathEnd(text: string, open: number, limit?: number): number;
|
|
352
|
+
/**
|
|
353
|
+
* THE escaped-bracket rule — whether a closed `\[ … \]` is display math or
|
|
354
|
+
* CommonMark's escaped brackets (literal `[ … ]`). The tokenizer, the
|
|
355
|
+
* renderer's normalizer and the editor all ask it.
|
|
356
|
+
*
|
|
357
|
+
* Math only when the content is real TeX (BRACKET_TEX_SIGNAL) and the `\[`
|
|
358
|
+
* is not an index on an identifier (`arr\[i+1\]`, `f(x)\[k\]`).
|
|
359
|
+
* Everything a person writes with escaped brackets stays text: citations
|
|
360
|
+
* `\[1\]`, dates `\[2026-09-25\]`, task boxes `- \[x\]`, editorial
|
|
361
|
+
* insertions `\[was\]`, placeholders `\[site name\]` (verify-RC-B4 R3-2).
|
|
362
|
+
* `before` is the character just before the `\[` (undefined at the start).
|
|
363
|
+
*/
|
|
364
|
+
declare function isEscapedBracketMath(content: string, before: string | undefined): boolean;
|
|
352
365
|
|
|
353
366
|
interface ReadXmlTag {
|
|
354
367
|
tagName: string;
|
|
@@ -572,4 +585,4 @@ declare function pendingDisplayMathOpener(text: string): number;
|
|
|
572
585
|
/** Map of `$$` opener offset → closer offset for every pair the renderer shows as math. */
|
|
573
586
|
declare function pairDisplayMath(text: string): Map<number, number>;
|
|
574
587
|
|
|
575
|
-
export { 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, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
|
|
588
|
+
export { 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, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, isEscapedBracketMath, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
|
package/dist/source.d.ts
CHANGED
|
@@ -349,6 +349,19 @@ declare function looksLikeOpenInlineMath(partial: string): boolean;
|
|
|
349
349
|
* {@link isSingleDollarMath}. Returns the offset just past the closing `$`.
|
|
350
350
|
*/
|
|
351
351
|
declare function singleDollarMathEnd(text: string, open: number, limit?: number): number;
|
|
352
|
+
/**
|
|
353
|
+
* THE escaped-bracket rule — whether a closed `\[ … \]` is display math or
|
|
354
|
+
* CommonMark's escaped brackets (literal `[ … ]`). The tokenizer, the
|
|
355
|
+
* renderer's normalizer and the editor all ask it.
|
|
356
|
+
*
|
|
357
|
+
* Math only when the content is real TeX (BRACKET_TEX_SIGNAL) and the `\[`
|
|
358
|
+
* is not an index on an identifier (`arr\[i+1\]`, `f(x)\[k\]`).
|
|
359
|
+
* Everything a person writes with escaped brackets stays text: citations
|
|
360
|
+
* `\[1\]`, dates `\[2026-09-25\]`, task boxes `- \[x\]`, editorial
|
|
361
|
+
* insertions `\[was\]`, placeholders `\[site name\]` (verify-RC-B4 R3-2).
|
|
362
|
+
* `before` is the character just before the `\[` (undefined at the start).
|
|
363
|
+
*/
|
|
364
|
+
declare function isEscapedBracketMath(content: string, before: string | undefined): boolean;
|
|
352
365
|
|
|
353
366
|
interface ReadXmlTag {
|
|
354
367
|
tagName: string;
|
|
@@ -572,4 +585,4 @@ declare function pendingDisplayMathOpener(text: string): number;
|
|
|
572
585
|
/** Map of `$$` opener offset → closer offset for every pair the renderer shows as math. */
|
|
573
586
|
declare function pairDisplayMath(text: string): Map<number, number>;
|
|
574
587
|
|
|
575
|
-
export { 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, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
|
|
588
|
+
export { 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, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, isEscapedBracketMath, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
|
package/dist/source.js
CHANGED
|
@@ -799,6 +799,12 @@ function singleDollarMathEnd(text, open, limit = text.length) {
|
|
|
799
799
|
const content = text.slice(open + 1, close);
|
|
800
800
|
return isSingleDollarMath(content, text[close + 1]) ? close + 1 : -1;
|
|
801
801
|
}
|
|
802
|
+
var BRACKET_TEX_SIGNAL = /\\[A-Za-z]+|[\^{}=<>+]|_\{|(?:^|[^A-Za-z0-9])[A-Za-z]_[A-Za-z0-9](?![A-Za-z0-9])/;
|
|
803
|
+
function isEscapedBracketMath(content, before) {
|
|
804
|
+
if (!content.trim()) return false;
|
|
805
|
+
if (before !== void 0 && /[A-Za-z0-9_)\]]/.test(before)) return false;
|
|
806
|
+
return BRACKET_TEX_SIGNAL.test(content);
|
|
807
|
+
}
|
|
802
808
|
|
|
803
809
|
// source/xml-tag.ts
|
|
804
810
|
var XML_NAME_START = /[A-Za-z_]/;
|
|
@@ -1855,7 +1861,8 @@ var Tokenizer = class {
|
|
|
1855
1861
|
const nextCh = text[i + 1];
|
|
1856
1862
|
if (nextCh === "(" || nextCh === "[") {
|
|
1857
1863
|
const close = within(nextCh === "(" ? "\\)" : "\\]", i + 2);
|
|
1858
|
-
|
|
1864
|
+
const isMath = close !== -1 && (nextCh === "(" || isEscapedBracketMath(text.slice(i + 2, close), i > 0 ? text[i - 1] : void 0));
|
|
1865
|
+
if (close !== -1 && isMath) {
|
|
1859
1866
|
inlines.push(this.island("math_inline", i, close + 2, true, { delimiter: nextCh === "(" ? "\\(" : "\\[" }));
|
|
1860
1867
|
i = close + 2;
|
|
1861
1868
|
continue;
|
|
@@ -2382,6 +2389,6 @@ function mapRange(changes, start, end, unit = "utf16") {
|
|
|
2382
2389
|
return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
|
|
2383
2390
|
}
|
|
2384
2391
|
|
|
2385
|
-
export { BacktickRuns, CALLOUT_NAMES, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceReader, NESTING_FENCE_LANGUAGES, SourceSpliceError, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
|
|
2392
|
+
export { BacktickRuns, CALLOUT_NAMES, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceReader, NESTING_FENCE_LANGUAGES, SourceSpliceError, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, isEscapedBracketMath, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
|
|
2386
2393
|
//# sourceMappingURL=source.js.map
|
|
2387
2394
|
//# sourceMappingURL=source.js.map
|