@ai-react-markdown/engine 2.5.1 → 2.5.2
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/index.cjs +17 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.dev.cjs +17 -28
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +15 -28
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +15 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1460,6 +1460,28 @@ declare const defaultEnginePlugins: readonly AIMarkdownEnginePlugin[];
|
|
|
1460
1460
|
* `tagName === 'section'` AND presence of the `dataFootnotes` property.
|
|
1461
1461
|
*/
|
|
1462
1462
|
declare function isFootnoteSection(node: Element): boolean;
|
|
1463
|
+
/**
|
|
1464
|
+
* Whitespace-only text node. `mdast-util-to-hast`'s `state.wrap(content,
|
|
1465
|
+
* true)` interleaves `\n` text nodes between (and around) the block-level
|
|
1466
|
+
* children of an `<li>`, so any code reasoning about a list item's real
|
|
1467
|
+
* children has to look past them.
|
|
1468
|
+
*/
|
|
1469
|
+
declare function isWhitespaceText(c: ElementContent): boolean;
|
|
1470
|
+
/**
|
|
1471
|
+
* Index of the last child that is not a whitespace-only text node, or -1 if
|
|
1472
|
+
* there is none.
|
|
1473
|
+
*
|
|
1474
|
+
* Both footnote-footer paths need exactly this and for the same reason.
|
|
1475
|
+
* Appending a backref follows mdast-util-to-hast's contract — "if the tail of
|
|
1476
|
+
* the `<li>`'s content is a `<p>`, push into it, else push onto the `<li>`" —
|
|
1477
|
+
* and stripping one has to find that tail again. Read the trailing
|
|
1478
|
+
* wrap-emitted `\n` as the tail and the `<p>` path is bypassed in one case
|
|
1479
|
+
* and the wrong node stripped in the other.
|
|
1480
|
+
*
|
|
1481
|
+
* Lived in two copies until 2.5.2 (core's aggregate footer and the engine's
|
|
1482
|
+
* body extractor), one on each side of the 2.3.0 package split.
|
|
1483
|
+
*/
|
|
1484
|
+
declare function lastMeaningfulIdx(children: ElementContent[]): number;
|
|
1463
1485
|
|
|
1464
1486
|
declare function normalizeId(s: string): string;
|
|
1465
1487
|
/**
|
|
@@ -2021,4 +2043,4 @@ type RemendPreprocessorOptions = Omit<RemendOptions, 'katex' | 'inlineKatex'>;
|
|
|
2021
2043
|
*/
|
|
2022
2044
|
declare function createRemendPreprocessor(options?: RemendPreprocessorOptions): AIMDContentPreprocessor;
|
|
2023
2045
|
|
|
2024
|
-
export { type AIMDContentPreprocessor, type AIMarkdownEnginePlugin, type AIMarkdownEnginePluginName, type AdvanceOptions, type AdvanceResult, type AllowElement, type ChunkData, type Contribution, type CrossChunkHandlerOptions, DEFAULT_PAYLOAD, type DefLabelScanner, type DefLabels, type Deprecation, type EnginePluginInternals, type EnginePluginStage, type ExtractContributionsOptions, type FootnoteDef, type FreezeBoundaryOptions, type IncrementalParseState, type IncrementalStage, type LinkDef, PIPELINE_STAGES, type ParsedMarkdown, type PhantomLabels, type PipelineOptions, type PipelineStage, type RefKind, type RefRecord, type Registry, type RegistryInternal, type RehypePlugins, type RehypeRebaseHashLinksOptions, type RemarkPlugins, type RemarkRehypeOptions, type RemendPreprocessorOptions, SENTINEL_FN_CONTENT, SENTINEL_LINK_URL, SMOOTH_STREAM_PACING_PRESETS, STAGE_MEASURE_PREFIX, type SanitizeSchema, type SmoothStreamController, type SmoothStreamOptions, type SmoothStreamPacing, type SmoothStreamPacingParams, type TransformContext, type UrlAttrKey, type UrlAttrTag, type UrlTransform, advanceIncrementalParse, attributeHastChildren, buildCoreRehypePlugins, buildCoreRemarkPlugins, buildCoreRemarkRehypeOptions, buildCrossChunkHandlers, buildPhantomSuffix, buildTransform, codePointSnapshots, collectDefLabels, computeFreezeBoundary, createDefLabelScanner, createFile, createIncrementalLatexPreprocessor, createProcessor, createRegistry, createRemendPreprocessor, createSmoothStreamController, defaultEnginePlugins, defaultUrlTransform, definitionList, extendSanitizeSchema, extractContributions, extractDefBodiesFromHast, footnoteSafeId, getEnginePluginInternals, hasLoneSurrogate, highlight, isFootnoteSection, measureStage, mergeClassNameAllowlist, normalizeForMatch, normalizeId, pangu, parseStage, phantomSuffixCloser, preprocessAIMDContent, preprocessLaTeX, rehypeFooterAdorn, rehypeRebaseHashLinks, removeComments, sanitizeCrossChunkUrl, sanitizeSchema, shortenDocumentId, smartypants, sourceIdFromFootnoteLiId, splitByProtectedRegions, subscribeStageTimings, transformStage, withDefs };
|
|
2046
|
+
export { type AIMDContentPreprocessor, type AIMarkdownEnginePlugin, type AIMarkdownEnginePluginName, type AdvanceOptions, type AdvanceResult, type AllowElement, type ChunkData, type Contribution, type CrossChunkHandlerOptions, DEFAULT_PAYLOAD, type DefLabelScanner, type DefLabels, type Deprecation, type EnginePluginInternals, type EnginePluginStage, type ExtractContributionsOptions, type FootnoteDef, type FreezeBoundaryOptions, type IncrementalParseState, type IncrementalStage, type LinkDef, PIPELINE_STAGES, type ParsedMarkdown, type PhantomLabels, type PipelineOptions, type PipelineStage, type RefKind, type RefRecord, type Registry, type RegistryInternal, type RehypePlugins, type RehypeRebaseHashLinksOptions, type RemarkPlugins, type RemarkRehypeOptions, type RemendPreprocessorOptions, SENTINEL_FN_CONTENT, SENTINEL_LINK_URL, SMOOTH_STREAM_PACING_PRESETS, STAGE_MEASURE_PREFIX, type SanitizeSchema, type SmoothStreamController, type SmoothStreamOptions, type SmoothStreamPacing, type SmoothStreamPacingParams, type TransformContext, type UrlAttrKey, type UrlAttrTag, type UrlTransform, advanceIncrementalParse, attributeHastChildren, buildCoreRehypePlugins, buildCoreRemarkPlugins, buildCoreRemarkRehypeOptions, buildCrossChunkHandlers, buildPhantomSuffix, buildTransform, codePointSnapshots, collectDefLabels, computeFreezeBoundary, createDefLabelScanner, createFile, createIncrementalLatexPreprocessor, createProcessor, createRegistry, createRemendPreprocessor, createSmoothStreamController, defaultEnginePlugins, defaultUrlTransform, definitionList, extendSanitizeSchema, extractContributions, extractDefBodiesFromHast, footnoteSafeId, getEnginePluginInternals, hasLoneSurrogate, highlight, isFootnoteSection, isWhitespaceText, lastMeaningfulIdx, measureStage, mergeClassNameAllowlist, normalizeForMatch, normalizeId, pangu, parseStage, phantomSuffixCloser, preprocessAIMDContent, preprocessLaTeX, rehypeFooterAdorn, rehypeRebaseHashLinks, removeComments, sanitizeCrossChunkUrl, sanitizeSchema, shortenDocumentId, smartypants, sourceIdFromFootnoteLiId, splitByProtectedRegions, subscribeStageTimings, transformStage, withDefs };
|
package/dist/index.d.ts
CHANGED
|
@@ -1460,6 +1460,28 @@ declare const defaultEnginePlugins: readonly AIMarkdownEnginePlugin[];
|
|
|
1460
1460
|
* `tagName === 'section'` AND presence of the `dataFootnotes` property.
|
|
1461
1461
|
*/
|
|
1462
1462
|
declare function isFootnoteSection(node: Element): boolean;
|
|
1463
|
+
/**
|
|
1464
|
+
* Whitespace-only text node. `mdast-util-to-hast`'s `state.wrap(content,
|
|
1465
|
+
* true)` interleaves `\n` text nodes between (and around) the block-level
|
|
1466
|
+
* children of an `<li>`, so any code reasoning about a list item's real
|
|
1467
|
+
* children has to look past them.
|
|
1468
|
+
*/
|
|
1469
|
+
declare function isWhitespaceText(c: ElementContent): boolean;
|
|
1470
|
+
/**
|
|
1471
|
+
* Index of the last child that is not a whitespace-only text node, or -1 if
|
|
1472
|
+
* there is none.
|
|
1473
|
+
*
|
|
1474
|
+
* Both footnote-footer paths need exactly this and for the same reason.
|
|
1475
|
+
* Appending a backref follows mdast-util-to-hast's contract — "if the tail of
|
|
1476
|
+
* the `<li>`'s content is a `<p>`, push into it, else push onto the `<li>`" —
|
|
1477
|
+
* and stripping one has to find that tail again. Read the trailing
|
|
1478
|
+
* wrap-emitted `\n` as the tail and the `<p>` path is bypassed in one case
|
|
1479
|
+
* and the wrong node stripped in the other.
|
|
1480
|
+
*
|
|
1481
|
+
* Lived in two copies until 2.5.2 (core's aggregate footer and the engine's
|
|
1482
|
+
* body extractor), one on each side of the 2.3.0 package split.
|
|
1483
|
+
*/
|
|
1484
|
+
declare function lastMeaningfulIdx(children: ElementContent[]): number;
|
|
1463
1485
|
|
|
1464
1486
|
declare function normalizeId(s: string): string;
|
|
1465
1487
|
/**
|
|
@@ -2021,4 +2043,4 @@ type RemendPreprocessorOptions = Omit<RemendOptions, 'katex' | 'inlineKatex'>;
|
|
|
2021
2043
|
*/
|
|
2022
2044
|
declare function createRemendPreprocessor(options?: RemendPreprocessorOptions): AIMDContentPreprocessor;
|
|
2023
2045
|
|
|
2024
|
-
export { type AIMDContentPreprocessor, type AIMarkdownEnginePlugin, type AIMarkdownEnginePluginName, type AdvanceOptions, type AdvanceResult, type AllowElement, type ChunkData, type Contribution, type CrossChunkHandlerOptions, DEFAULT_PAYLOAD, type DefLabelScanner, type DefLabels, type Deprecation, type EnginePluginInternals, type EnginePluginStage, type ExtractContributionsOptions, type FootnoteDef, type FreezeBoundaryOptions, type IncrementalParseState, type IncrementalStage, type LinkDef, PIPELINE_STAGES, type ParsedMarkdown, type PhantomLabels, type PipelineOptions, type PipelineStage, type RefKind, type RefRecord, type Registry, type RegistryInternal, type RehypePlugins, type RehypeRebaseHashLinksOptions, type RemarkPlugins, type RemarkRehypeOptions, type RemendPreprocessorOptions, SENTINEL_FN_CONTENT, SENTINEL_LINK_URL, SMOOTH_STREAM_PACING_PRESETS, STAGE_MEASURE_PREFIX, type SanitizeSchema, type SmoothStreamController, type SmoothStreamOptions, type SmoothStreamPacing, type SmoothStreamPacingParams, type TransformContext, type UrlAttrKey, type UrlAttrTag, type UrlTransform, advanceIncrementalParse, attributeHastChildren, buildCoreRehypePlugins, buildCoreRemarkPlugins, buildCoreRemarkRehypeOptions, buildCrossChunkHandlers, buildPhantomSuffix, buildTransform, codePointSnapshots, collectDefLabels, computeFreezeBoundary, createDefLabelScanner, createFile, createIncrementalLatexPreprocessor, createProcessor, createRegistry, createRemendPreprocessor, createSmoothStreamController, defaultEnginePlugins, defaultUrlTransform, definitionList, extendSanitizeSchema, extractContributions, extractDefBodiesFromHast, footnoteSafeId, getEnginePluginInternals, hasLoneSurrogate, highlight, isFootnoteSection, measureStage, mergeClassNameAllowlist, normalizeForMatch, normalizeId, pangu, parseStage, phantomSuffixCloser, preprocessAIMDContent, preprocessLaTeX, rehypeFooterAdorn, rehypeRebaseHashLinks, removeComments, sanitizeCrossChunkUrl, sanitizeSchema, shortenDocumentId, smartypants, sourceIdFromFootnoteLiId, splitByProtectedRegions, subscribeStageTimings, transformStage, withDefs };
|
|
2046
|
+
export { type AIMDContentPreprocessor, type AIMarkdownEnginePlugin, type AIMarkdownEnginePluginName, type AdvanceOptions, type AdvanceResult, type AllowElement, type ChunkData, type Contribution, type CrossChunkHandlerOptions, DEFAULT_PAYLOAD, type DefLabelScanner, type DefLabels, type Deprecation, type EnginePluginInternals, type EnginePluginStage, type ExtractContributionsOptions, type FootnoteDef, type FreezeBoundaryOptions, type IncrementalParseState, type IncrementalStage, type LinkDef, PIPELINE_STAGES, type ParsedMarkdown, type PhantomLabels, type PipelineOptions, type PipelineStage, type RefKind, type RefRecord, type Registry, type RegistryInternal, type RehypePlugins, type RehypeRebaseHashLinksOptions, type RemarkPlugins, type RemarkRehypeOptions, type RemendPreprocessorOptions, SENTINEL_FN_CONTENT, SENTINEL_LINK_URL, SMOOTH_STREAM_PACING_PRESETS, STAGE_MEASURE_PREFIX, type SanitizeSchema, type SmoothStreamController, type SmoothStreamOptions, type SmoothStreamPacing, type SmoothStreamPacingParams, type TransformContext, type UrlAttrKey, type UrlAttrTag, type UrlTransform, advanceIncrementalParse, attributeHastChildren, buildCoreRehypePlugins, buildCoreRemarkPlugins, buildCoreRemarkRehypeOptions, buildCrossChunkHandlers, buildPhantomSuffix, buildTransform, codePointSnapshots, collectDefLabels, computeFreezeBoundary, createDefLabelScanner, createFile, createIncrementalLatexPreprocessor, createProcessor, createRegistry, createRemendPreprocessor, createSmoothStreamController, defaultEnginePlugins, defaultUrlTransform, definitionList, extendSanitizeSchema, extractContributions, extractDefBodiesFromHast, footnoteSafeId, getEnginePluginInternals, hasLoneSurrogate, highlight, isFootnoteSection, isWhitespaceText, lastMeaningfulIdx, measureStage, mergeClassNameAllowlist, normalizeForMatch, normalizeId, pangu, parseStage, phantomSuffixCloser, preprocessAIMDContent, preprocessLaTeX, rehypeFooterAdorn, rehypeRebaseHashLinks, removeComments, sanitizeCrossChunkUrl, sanitizeSchema, shortenDocumentId, smartypants, sourceIdFromFootnoteLiId, splitByProtectedRegions, subscribeStageTimings, transformStage, withDefs };
|
package/dist/index.dev.cjs
CHANGED
|
@@ -65,6 +65,8 @@ __export(src_exports, {
|
|
|
65
65
|
hasLoneSurrogate: () => hasLoneSurrogate,
|
|
66
66
|
highlight: () => highlight,
|
|
67
67
|
isFootnoteSection: () => isFootnoteSection,
|
|
68
|
+
isWhitespaceText: () => isWhitespaceText,
|
|
69
|
+
lastMeaningfulIdx: () => lastMeaningfulIdx,
|
|
68
70
|
measureStage: () => measureStage,
|
|
69
71
|
mergeClassNameAllowlist: () => mergeClassNameAllowlist,
|
|
70
72
|
normalizeForMatch: () => normalizeForMatch,
|
|
@@ -1199,6 +1201,15 @@ function isFootnoteSection(node) {
|
|
|
1199
1201
|
const props = node.properties;
|
|
1200
1202
|
return props?.dataFootnotes !== void 0;
|
|
1201
1203
|
}
|
|
1204
|
+
function isWhitespaceText(c) {
|
|
1205
|
+
return c.type === "text" && /^\s*$/.test(c.value);
|
|
1206
|
+
}
|
|
1207
|
+
function lastMeaningfulIdx(children) {
|
|
1208
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
1209
|
+
if (!isWhitespaceText(children[i])) return i;
|
|
1210
|
+
}
|
|
1211
|
+
return -1;
|
|
1212
|
+
}
|
|
1202
1213
|
|
|
1203
1214
|
// src/components/incrementalParse/attributeHastChildren.ts
|
|
1204
1215
|
function attributeHastChildren(mdast, hast, stopAt = Infinity) {
|
|
@@ -1981,16 +1992,6 @@ function isBackrefAnchor(c) {
|
|
|
1981
1992
|
if (el.tagName !== "a") return false;
|
|
1982
1993
|
return Boolean(el.properties && "dataFootnoteBackref" in el.properties);
|
|
1983
1994
|
}
|
|
1984
|
-
function isWhitespaceText(c) {
|
|
1985
|
-
if (c.type !== "text") return false;
|
|
1986
|
-
return /^\s*$/.test(c.value);
|
|
1987
|
-
}
|
|
1988
|
-
function lastMeaningfulIdx(children) {
|
|
1989
|
-
for (let i = children.length - 1; i >= 0; i--) {
|
|
1990
|
-
if (!isWhitespaceText(children[i])) return i;
|
|
1991
|
-
}
|
|
1992
|
-
return -1;
|
|
1993
|
-
}
|
|
1994
1995
|
function dropTrailingBackrefs(children) {
|
|
1995
1996
|
let trailingWsStart = children.length;
|
|
1996
1997
|
while (trailingWsStart > 0 && isWhitespaceText(children[trailingWsStart - 1])) {
|
|
@@ -4669,21 +4670,7 @@ function convertSingleToDoubleDollar(text) {
|
|
|
4669
4670
|
}
|
|
4670
4671
|
function preprocessLaTeX(str) {
|
|
4671
4672
|
if (!hasLatexTrigger(str)) return str;
|
|
4672
|
-
|
|
4673
|
-
const result = segments.map((segment) => {
|
|
4674
|
-
if (segment.isCode) return segment.text;
|
|
4675
|
-
let text = segment.text;
|
|
4676
|
-
text = escapeMhchemCommands(text);
|
|
4677
|
-
text = escapeCurrencyDollarSigns(text);
|
|
4678
|
-
text = convertLatexDelimiters(text);
|
|
4679
|
-
text = escapeLatexPipes(text);
|
|
4680
|
-
text = escapeLatexPipesInUnclosed(text);
|
|
4681
|
-
text = escapeTextUnderscores(text);
|
|
4682
|
-
text = convertSingleToDoubleDollar(text);
|
|
4683
|
-
text = truncateUnclosedLatexBlock(text);
|
|
4684
|
-
return text;
|
|
4685
|
-
});
|
|
4686
|
-
return result.join("");
|
|
4673
|
+
return processSlice(str, false).out;
|
|
4687
4674
|
}
|
|
4688
4675
|
function hasLatexTrigger(str) {
|
|
4689
4676
|
return str.includes("$") || str.includes("\\[") || str.includes("\\(");
|
|
@@ -4712,7 +4699,7 @@ function hasUnclosedTextCommand(text) {
|
|
|
4712
4699
|
}
|
|
4713
4700
|
var RESIDUAL_OPEN_BRACKET_RE = /(?<!!)\\\[/;
|
|
4714
4701
|
var LEADING_DOUBLE_DOLLAR_RE = /^\s*\$\$/;
|
|
4715
|
-
function
|
|
4702
|
+
function processSlice(slice, probe = true) {
|
|
4716
4703
|
const segments = splitByProtectedRegions(slice);
|
|
4717
4704
|
const parts = [];
|
|
4718
4705
|
let quiescent = true;
|
|
@@ -4836,13 +4823,13 @@ function createIncrementalLatexPreprocessor(options) {
|
|
|
4836
4823
|
};
|
|
4837
4824
|
const cut = findRawSafeCut(active);
|
|
4838
4825
|
if (cut > 0) {
|
|
4839
|
-
const candidate =
|
|
4826
|
+
const candidate = processSlice(active.slice(0, cut));
|
|
4840
4827
|
if (candidate.quiescent) freeze(cut, candidate);
|
|
4841
4828
|
}
|
|
4842
4829
|
nextAttemptLen = advanced || !backoff ? 0 : active.length * 2;
|
|
4843
4830
|
onAttempt?.({ activeLength, frozenBytes });
|
|
4844
4831
|
}
|
|
4845
|
-
const tail =
|
|
4832
|
+
const tail = processSlice(active, false);
|
|
4846
4833
|
const head = tail.truncatedAtSeamStart ? frozenOut.replace(/\s+$/, "") : frozenOut;
|
|
4847
4834
|
const out = head + tail.out;
|
|
4848
4835
|
prevSource = source;
|
|
@@ -4907,6 +4894,8 @@ function createRemendPreprocessor(options) {
|
|
|
4907
4894
|
hasLoneSurrogate,
|
|
4908
4895
|
highlight,
|
|
4909
4896
|
isFootnoteSection,
|
|
4897
|
+
isWhitespaceText,
|
|
4898
|
+
lastMeaningfulIdx,
|
|
4910
4899
|
measureStage,
|
|
4911
4900
|
mergeClassNameAllowlist,
|
|
4912
4901
|
normalizeForMatch,
|