@readme/markdown 13.5.0 → 13.6.0
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/components/Callout/style.scss +8 -0
- package/dist/enums.d.ts +1 -0
- package/dist/lib/ast-processor.d.ts +2 -2
- package/dist/main.css +1 -1
- package/dist/main.css.map +1 -1
- package/dist/main.js +244 -52
- package/dist/main.node.js +244 -52
- package/dist/main.node.js.map +1 -1
- package/dist/processor/transform/mdxish/constants.d.ts +5 -0
- package/dist/processor/transform/mdxish/mdxish-inline-components.d.ts +11 -0
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -41028,6 +41028,7 @@ function remarkMdx(options) {
|
|
|
41028
41028
|
;// ./enums.ts
|
|
41029
41029
|
var NodeTypes;
|
|
41030
41030
|
(function (NodeTypes) {
|
|
41031
|
+
NodeTypes["anchor"] = "readme-anchor";
|
|
41031
41032
|
NodeTypes["callout"] = "rdme-callout";
|
|
41032
41033
|
NodeTypes["codeTabs"] = "code-tabs";
|
|
41033
41034
|
NodeTypes["embedBlock"] = "embed-block";
|
|
@@ -53041,6 +53042,13 @@ const extractText = (node) => {
|
|
|
53041
53042
|
|
|
53042
53043
|
|
|
53043
53044
|
|
|
53045
|
+
|
|
53046
|
+
|
|
53047
|
+
|
|
53048
|
+
|
|
53049
|
+
|
|
53050
|
+
const titleParser = unified().use(remarkParse).use(remarkGfm);
|
|
53051
|
+
const toMarkdownExtensions = [gfmStrikethroughToMarkdown()];
|
|
53044
53052
|
const callouts_regex = `^(${emoji_regex().source}|⚠)(\\s+|$)`;
|
|
53045
53053
|
const findFirst = (node) => {
|
|
53046
53054
|
if ('children' in node)
|
|
@@ -53157,31 +53165,65 @@ const processBlockquote = (node, index, parent) => {
|
|
|
53157
53165
|
// Example: "> ⚠️ **Bold heading**\nBody text here"
|
|
53158
53166
|
const bodyChildren = splitParagraphAtNewline(firstParagraph);
|
|
53159
53167
|
const didSplit = bodyChildren !== null;
|
|
53160
|
-
// Extract heading text after removing the icon prefix.
|
|
53161
|
-
// Use `plain()` to handle complex markdown structures (bold, inline code, etc.)
|
|
53162
|
-
const headingText = lib_plain(firstParagraph)
|
|
53163
|
-
.toString()
|
|
53164
|
-
.slice(match.length);
|
|
53165
|
-
// Clean up the raw AST by removing the icon prefix from the first text node
|
|
53166
53168
|
removeIconPrefix(firstParagraph, match.length);
|
|
53167
|
-
const
|
|
53169
|
+
const firstText = findFirst(firstParagraph);
|
|
53170
|
+
const rawValue = firstText?.value ?? '';
|
|
53171
|
+
const hasContent = rawValue.trim().length > 0 || firstParagraph.children.length > 1;
|
|
53172
|
+
const empty = !hasContent;
|
|
53168
53173
|
const theme = themes[icon] || 'default';
|
|
53169
|
-
|
|
53170
|
-
|
|
53171
|
-
|
|
53172
|
-
//
|
|
53173
|
-
|
|
53174
|
-
|
|
53174
|
+
if (hasContent || didSplit) {
|
|
53175
|
+
const headingMatch = rawValue.match(/^(#{1,6})\s*/);
|
|
53176
|
+
// # heading syntax is handled via direct AST manipulation so we can
|
|
53177
|
+
// set the depth while preserving the original inline children (bold, etc.)
|
|
53178
|
+
if (headingMatch) {
|
|
53179
|
+
firstText.value = rawValue.slice(headingMatch[0].length);
|
|
53180
|
+
const heading = wrapHeading(node);
|
|
53181
|
+
heading.depth = headingMatch[1].length;
|
|
53182
|
+
node.children[0] = heading;
|
|
53183
|
+
node.children[0].position.start.offset += match.length;
|
|
53184
|
+
node.children[0].position.start.column += match.length;
|
|
53185
|
+
}
|
|
53186
|
+
else {
|
|
53187
|
+
const headingText = toMarkdown({ type: 'root', children: [firstParagraph] }, {
|
|
53188
|
+
extensions: toMarkdownExtensions,
|
|
53189
|
+
})
|
|
53190
|
+
.trim()
|
|
53191
|
+
.replace(/^\\(?=[>#+\-*])/, '');
|
|
53192
|
+
const parsedTitle = titleParser.parse(headingText);
|
|
53193
|
+
const parsedFirstChild = parsedTitle.children[0];
|
|
53194
|
+
// Block-level syntax ("> quote", "- list") produces non-paragraph nodes;
|
|
53195
|
+
// inline text parses as a paragraph and falls through to wrapHeading().
|
|
53196
|
+
if (parsedFirstChild && parsedFirstChild.type !== 'paragraph') {
|
|
53197
|
+
// Strip positions from re-parsed nodes since they're relative to the heading text, not the original source
|
|
53198
|
+
visit(parsedTitle, (n) => {
|
|
53199
|
+
delete n.position;
|
|
53200
|
+
});
|
|
53201
|
+
const heading = wrapHeading(node);
|
|
53202
|
+
heading.children = parsedTitle.children;
|
|
53203
|
+
delete heading.position;
|
|
53204
|
+
node.children[0] = heading;
|
|
53205
|
+
}
|
|
53206
|
+
else {
|
|
53207
|
+
node.children[0] = wrapHeading(node);
|
|
53208
|
+
node.children[0].position.start.offset += match.length;
|
|
53209
|
+
node.children[0].position.start.column += match.length;
|
|
53210
|
+
}
|
|
53211
|
+
}
|
|
53175
53212
|
}
|
|
53176
53213
|
// Insert body content as a separate paragraph after the heading
|
|
53177
53214
|
if (bodyChildren) {
|
|
53215
|
+
const headingPosition = node.children[0].position;
|
|
53178
53216
|
node.children.splice(1, 0, {
|
|
53179
53217
|
type: 'paragraph',
|
|
53180
53218
|
children: bodyChildren,
|
|
53181
|
-
|
|
53182
|
-
|
|
53183
|
-
|
|
53184
|
-
|
|
53219
|
+
...(headingPosition && firstParagraphOriginalEnd
|
|
53220
|
+
? {
|
|
53221
|
+
position: {
|
|
53222
|
+
start: headingPosition.end,
|
|
53223
|
+
end: firstParagraphOriginalEnd,
|
|
53224
|
+
},
|
|
53225
|
+
}
|
|
53226
|
+
: {}),
|
|
53185
53227
|
});
|
|
53186
53228
|
}
|
|
53187
53229
|
Object.assign(node, {
|
|
@@ -53198,11 +53240,24 @@ const processBlockquote = (node, index, parent) => {
|
|
|
53198
53240
|
}
|
|
53199
53241
|
};
|
|
53200
53242
|
const calloutTransformer = () => {
|
|
53201
|
-
|
|
53202
|
-
visit(
|
|
53243
|
+
const processNode = (root) => {
|
|
53244
|
+
visit(root, 'blockquote', (node, index, parent) => {
|
|
53203
53245
|
processBlockquote(node, index, parent);
|
|
53246
|
+
if (node.type === NodeTypes.callout) {
|
|
53247
|
+
// SKIP prevents re-processing synthetic blockquotes in parsed title content
|
|
53248
|
+
// (e.g., blockquotes from "> Quote" titles). Recursively process body children
|
|
53249
|
+
// (index 1+, skipping the heading at 0) to handle nested callouts.
|
|
53250
|
+
for (let i = 1; i < node.children.length; i += 1) {
|
|
53251
|
+
processNode(node.children[i]);
|
|
53252
|
+
}
|
|
53253
|
+
return SKIP;
|
|
53254
|
+
}
|
|
53255
|
+
return undefined;
|
|
53204
53256
|
});
|
|
53205
53257
|
};
|
|
53258
|
+
return (tree) => {
|
|
53259
|
+
processNode(tree);
|
|
53260
|
+
};
|
|
53206
53261
|
};
|
|
53207
53262
|
/* harmony default export */ const callouts = (calloutTransformer);
|
|
53208
53263
|
|
|
@@ -53227,8 +53282,18 @@ const codeTabsTransformer = ({ copyButtons } = {}) => (tree) => {
|
|
|
53227
53282
|
const sibling = parent.children[walker];
|
|
53228
53283
|
if (!isCode(sibling))
|
|
53229
53284
|
break;
|
|
53285
|
+
// Check that the two code blocks are truly adjacent (no blank lines or
|
|
53286
|
+
// other content between them). The `gap` is the number of raw characters
|
|
53287
|
+
// between the end of the previous block and the start of this one.
|
|
53288
|
+
// For a LF-separated pair the gap equals `start.column` (the newline
|
|
53289
|
+
// char(s) plus any indentation). CRLF line endings add one extra byte
|
|
53290
|
+
// (\r) without advancing the line count, so we also accept
|
|
53291
|
+
// `start.column + 1` provided the blocks are still on consecutive lines.
|
|
53230
53292
|
const olderSibling = parent.children[walker - 1];
|
|
53231
|
-
|
|
53293
|
+
const gap = sibling.position.start.offset - olderSibling.position.end.offset;
|
|
53294
|
+
const lineDiff = sibling.position.start.line - olderSibling.position.end.line;
|
|
53295
|
+
const isCRLF = gap === sibling.position.start.column + 1 && lineDiff === 1;
|
|
53296
|
+
if (gap !== sibling.position.start.column && !isCRLF)
|
|
53232
53297
|
break;
|
|
53233
53298
|
children.push(sibling);
|
|
53234
53299
|
// eslint-disable-next-line no-plusplus
|
|
@@ -71162,6 +71227,13 @@ function legacyVariable() {
|
|
|
71162
71227
|
*/
|
|
71163
71228
|
|
|
71164
71229
|
|
|
71230
|
+
;// ./processor/transform/mdxish/constants.ts
|
|
71231
|
+
/**
|
|
71232
|
+
* Inline component tags handled by mdxish-inline-components.ts.
|
|
71233
|
+
* Also excluded from block-level handling in mdxish-component-blocks.ts.
|
|
71234
|
+
*/
|
|
71235
|
+
const INLINE_COMPONENT_TAGS = new Set(['Anchor']);
|
|
71236
|
+
|
|
71165
71237
|
;// ./processor/transform/mdxish/mdxish-component-blocks.ts
|
|
71166
71238
|
|
|
71167
71239
|
|
|
@@ -71169,6 +71241,7 @@ function legacyVariable() {
|
|
|
71169
71241
|
|
|
71170
71242
|
|
|
71171
71243
|
|
|
71244
|
+
|
|
71172
71245
|
const pascalCaseTagPattern = /^<([A-Z][A-Za-z0-9_]*)([^>]*?)(\/?)>([\s\S]*)?$/;
|
|
71173
71246
|
const tagAttributePattern = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s"'>]+))?/g;
|
|
71174
71247
|
/**
|
|
@@ -71181,10 +71254,8 @@ const MAX_LOOKAHEAD = 30;
|
|
|
71181
71254
|
* These components either have special parsing requirements that the generic component
|
|
71182
71255
|
* block transformer cannot handle correctly, or are inline components that we don't
|
|
71183
71256
|
* want to convert to mdxJsxFlowElement which is a block level element.
|
|
71184
|
-
*
|
|
71185
|
-
* Glossary and Anchor are inline components.
|
|
71186
71257
|
*/
|
|
71187
|
-
const EXCLUDED_TAGS = new Set(['HTMLBlock', 'Table', 'Glossary',
|
|
71258
|
+
const EXCLUDED_TAGS = new Set(['HTMLBlock', 'Table', 'Glossary', ...INLINE_COMPONENT_TAGS]);
|
|
71188
71259
|
const inlineMdProcessor = unified()
|
|
71189
71260
|
.data('micromarkExtensions', [legacyVariable()])
|
|
71190
71261
|
.data('fromMarkdownExtensions', [legacyVariableFromMarkdown(), emptyTaskListItemFromMarkdown()])
|
|
@@ -71448,10 +71519,10 @@ const mdxishComponentBlocks = () => tree => {
|
|
|
71448
71519
|
const extraChildren = contentAfterTag ? parseMdChildren(contentAfterTag.trimStart()) : [];
|
|
71449
71520
|
// Collect all intermediate siblings between opening tag and closing tag
|
|
71450
71521
|
const intermediateChildren = parent.children.slice(index + 1, closingIndex);
|
|
71451
|
-
// For paragraph siblings, include the paragraph
|
|
71522
|
+
// For paragraph siblings, include the full paragraph (with closing tag stripped)
|
|
71452
71523
|
// For HTML siblings, include any content parsed from before the closing tag
|
|
71453
71524
|
const closingChildren = strippedParagraph
|
|
71454
|
-
? strippedParagraph.children
|
|
71525
|
+
? (strippedParagraph.children.length > 0 ? [strippedParagraph] : [])
|
|
71455
71526
|
: extraClosingChildren;
|
|
71456
71527
|
const componentNode = createComponentNode({
|
|
71457
71528
|
tag,
|
|
@@ -93829,7 +93900,7 @@ function getComponentName(componentName, components) {
|
|
|
93829
93900
|
|
|
93830
93901
|
|
|
93831
93902
|
|
|
93832
|
-
const
|
|
93903
|
+
const mdxish_components_INLINE_COMPONENT_TAGS = new Set(['anchor', 'glossary']);
|
|
93833
93904
|
function isElementContentNode(node) {
|
|
93834
93905
|
return node.type === 'element' || node.type === 'text' || node.type === 'comment';
|
|
93835
93906
|
}
|
|
@@ -93911,7 +93982,7 @@ function parseTextChildren(node, processMarkdown, components) {
|
|
|
93911
93982
|
const hast = processMarkdown(child.value.trim());
|
|
93912
93983
|
const children = (hast.children ?? []).filter(isElementContentNode);
|
|
93913
93984
|
// For inline components, preserve plain text instead of wrapping in <p>
|
|
93914
|
-
if (
|
|
93985
|
+
if (mdxish_components_INLINE_COMPONENT_TAGS.has(node.tagName.toLowerCase()) && isSingleParagraphTextNode(children)) {
|
|
93915
93986
|
return [child];
|
|
93916
93987
|
}
|
|
93917
93988
|
return children;
|
|
@@ -94284,10 +94355,14 @@ function extractBalancedBraces(content, start) {
|
|
|
94284
94355
|
return { content: content.slice(start, pos - 1), end: pos };
|
|
94285
94356
|
}
|
|
94286
94357
|
/**
|
|
94287
|
-
* Escapes
|
|
94288
|
-
* Handles
|
|
94358
|
+
* Escapes problematic braces in content to prevent MDX expression parsing errors.
|
|
94359
|
+
* Handles three cases:
|
|
94360
|
+
* 1. Unbalanced braces (e.g., `{foo` without closing `}`)
|
|
94361
|
+
* 2. Paragraph-spanning expressions (e.g., `{\n\n}` where blank line splits paragraphs)
|
|
94362
|
+
* 3. Skips HTML elements to prevent backslashes appearing in output
|
|
94363
|
+
*
|
|
94289
94364
|
*/
|
|
94290
|
-
function
|
|
94365
|
+
function escapeProblematicBraces(content) {
|
|
94291
94366
|
// Skip HTML elements — their content should never be escaped because
|
|
94292
94367
|
// rehypeRaw parses them into hast elements, making `\` literal text in output
|
|
94293
94368
|
const htmlElements = [];
|
|
@@ -94296,16 +94371,19 @@ function escapeUnbalancedBraces(content) {
|
|
|
94296
94371
|
htmlElements.push(match);
|
|
94297
94372
|
return `___HTML_ELEM_${idx}___`;
|
|
94298
94373
|
});
|
|
94299
|
-
const
|
|
94300
|
-
const unbalanced = new Set();
|
|
94301
|
-
let strDelim = null;
|
|
94302
|
-
let strEscaped = false;
|
|
94374
|
+
const toEscape = new Set();
|
|
94303
94375
|
// Convert to array of Unicode code points to handle emojis and multi-byte characters correctly
|
|
94304
94376
|
const chars = Array.from(safe);
|
|
94377
|
+
let strDelim = null;
|
|
94378
|
+
let strEscaped = false;
|
|
94379
|
+
// Stack of open braces with their state
|
|
94380
|
+
const openStack = [];
|
|
94381
|
+
// Track position of last newline (outside strings) to detect blank lines
|
|
94382
|
+
let lastNewlinePos = -2; // -2 means no recent newline
|
|
94305
94383
|
for (let i = 0; i < chars.length; i += 1) {
|
|
94306
94384
|
const ch = chars[i];
|
|
94307
|
-
// Track
|
|
94308
|
-
if (
|
|
94385
|
+
// Track string delimiters inside expressions to ignore braces within them
|
|
94386
|
+
if (openStack.length > 0) {
|
|
94309
94387
|
if (strDelim) {
|
|
94310
94388
|
if (strEscaped)
|
|
94311
94389
|
strEscaped = false;
|
|
@@ -94321,6 +94399,20 @@ function escapeUnbalancedBraces(content) {
|
|
|
94321
94399
|
// eslint-disable-next-line no-continue
|
|
94322
94400
|
continue;
|
|
94323
94401
|
}
|
|
94402
|
+
// Track newlines to detect blank lines (paragraph boundaries)
|
|
94403
|
+
if (ch === '\n') {
|
|
94404
|
+
// Check if this newline creates a blank line (only whitespace since last newline)
|
|
94405
|
+
if (lastNewlinePos >= 0) {
|
|
94406
|
+
const between = chars.slice(lastNewlinePos + 1, i).join('');
|
|
94407
|
+
if (/^[ \t]*$/.test(between)) {
|
|
94408
|
+
// This is a blank line - mark all open expressions as paragraph-spanning
|
|
94409
|
+
openStack.forEach(entry => {
|
|
94410
|
+
entry.hasBlankLine = true;
|
|
94411
|
+
});
|
|
94412
|
+
}
|
|
94413
|
+
}
|
|
94414
|
+
lastNewlinePos = i;
|
|
94415
|
+
}
|
|
94324
94416
|
}
|
|
94325
94417
|
// Skip already-escaped braces (count preceding backslashes)
|
|
94326
94418
|
if (ch === '{' || ch === '}') {
|
|
@@ -94332,21 +94424,33 @@ function escapeUnbalancedBraces(content) {
|
|
|
94332
94424
|
continue;
|
|
94333
94425
|
}
|
|
94334
94426
|
}
|
|
94335
|
-
if (ch === '{')
|
|
94336
|
-
|
|
94427
|
+
if (ch === '{') {
|
|
94428
|
+
openStack.push({ pos: i, hasBlankLine: false });
|
|
94429
|
+
lastNewlinePos = -2; // Reset newline tracking for new expression
|
|
94430
|
+
}
|
|
94337
94431
|
else if (ch === '}') {
|
|
94338
|
-
if (
|
|
94339
|
-
|
|
94340
|
-
|
|
94341
|
-
|
|
94432
|
+
if (openStack.length > 0) {
|
|
94433
|
+
const entry = openStack.pop();
|
|
94434
|
+
// If expression spans paragraph boundary, escape both braces
|
|
94435
|
+
if (entry.hasBlankLine) {
|
|
94436
|
+
toEscape.add(entry.pos);
|
|
94437
|
+
toEscape.add(i);
|
|
94438
|
+
}
|
|
94439
|
+
}
|
|
94440
|
+
else {
|
|
94441
|
+
// Unbalanced closing brace (no matching open)
|
|
94442
|
+
toEscape.add(i);
|
|
94443
|
+
}
|
|
94342
94444
|
}
|
|
94343
94445
|
}
|
|
94344
|
-
|
|
94345
|
-
|
|
94346
|
-
//
|
|
94347
|
-
|
|
94446
|
+
// Any remaining open braces are unbalanced
|
|
94447
|
+
openStack.forEach(entry => toEscape.add(entry.pos));
|
|
94448
|
+
// If there are no problematic braces, return safe content as-is;
|
|
94449
|
+
// otherwise, escape each problematic `{` or `}` so MDX doesn't treat them as expressions.
|
|
94450
|
+
let result = toEscape.size === 0
|
|
94348
94451
|
? safe
|
|
94349
|
-
: chars.map((ch, i) => (
|
|
94452
|
+
: chars.map((ch, i) => (toEscape.has(i) ? `\\${ch}` : ch)).join('');
|
|
94453
|
+
// Restore HTML elements
|
|
94350
94454
|
if (htmlElements.length > 0) {
|
|
94351
94455
|
result = result.replace(/___HTML_ELEM_(\d+)___/g, (_m, idx) => htmlElements[parseInt(idx, 10)]);
|
|
94352
94456
|
}
|
|
@@ -94444,8 +94548,9 @@ function preprocessJSXExpressions(content, context = {}) {
|
|
|
94444
94548
|
// For inline expressions, we use a library to parse the expression & evaluate it later
|
|
94445
94549
|
// For attribute expressions, it was difficult to use a library to parse them, so do it manually
|
|
94446
94550
|
processed = evaluateAttributeExpressions(protectedContent, context, protectedCode);
|
|
94447
|
-
// Step 3: Escape
|
|
94448
|
-
|
|
94551
|
+
// Step 3: Escape problematic braces to prevent MDX expression parsing errors
|
|
94552
|
+
// This handles both unbalanced braces and paragraph-spanning expressions in one pass
|
|
94553
|
+
processed = escapeProblematicBraces(processed);
|
|
94449
94554
|
// Step 4: Restore protected code blocks
|
|
94450
94555
|
processed = restoreCodeBlocks(processed, protectedCode);
|
|
94451
94556
|
return processed;
|
|
@@ -96210,10 +96315,82 @@ const mdxishHtmlBlocks = () => tree => {
|
|
|
96210
96315
|
};
|
|
96211
96316
|
/* harmony default export */ const mdxish_html_blocks = (mdxishHtmlBlocks);
|
|
96212
96317
|
|
|
96318
|
+
;// ./processor/transform/mdxish/mdxish-inline-components.ts
|
|
96319
|
+
|
|
96320
|
+
|
|
96321
|
+
|
|
96322
|
+
// Matches any PascalCase inline component opening tag. Groups: (name, attrs).
|
|
96323
|
+
// Uses [A-Za-z0-9_]* to match block version in mdxish-component-blocks.ts
|
|
96324
|
+
const INLINE_COMPONENT_OPEN_RE = /^<([A-Z][A-Za-z0-9_]*)(\s[^>]*)?>$/;
|
|
96325
|
+
function toMdxJsxTextElement(name, attributes, children) {
|
|
96326
|
+
return {
|
|
96327
|
+
type: 'mdxJsxTextElement',
|
|
96328
|
+
name,
|
|
96329
|
+
attributes,
|
|
96330
|
+
children,
|
|
96331
|
+
};
|
|
96332
|
+
}
|
|
96333
|
+
/**
|
|
96334
|
+
* Transforms inline html component nodes (e.g. <Anchor>) into proper MDAST phrasing content.
|
|
96335
|
+
*
|
|
96336
|
+
* Inline components are excluded from mdxishComponentBlocks (which only handles block-level
|
|
96337
|
+
* elements), so they remain as scattered html/text/html sibling nodes inside a paragraph.
|
|
96338
|
+
* This plugin merges them into a single typed MDAST node.
|
|
96339
|
+
*/
|
|
96340
|
+
const mdxishInlineComponents = () => tree => {
|
|
96341
|
+
visit(tree, 'html', (node, index, parent) => {
|
|
96342
|
+
if (!parent || index === undefined)
|
|
96343
|
+
return;
|
|
96344
|
+
const match = node.value?.match(INLINE_COMPONENT_OPEN_RE);
|
|
96345
|
+
if (!match)
|
|
96346
|
+
return;
|
|
96347
|
+
const [, name, attrStr] = match;
|
|
96348
|
+
if (!INLINE_COMPONENT_TAGS.has(name))
|
|
96349
|
+
return;
|
|
96350
|
+
// Parse attributes directly - preserves all attribute types (strings, booleans, objects, arrays)
|
|
96351
|
+
const attributes = parseAttributes(attrStr ?? '');
|
|
96352
|
+
// Find closing tag with whitespace-tolerant matching
|
|
96353
|
+
let closeIdx = index + 1;
|
|
96354
|
+
while (closeIdx < parent.children.length) {
|
|
96355
|
+
const sib = parent.children[closeIdx];
|
|
96356
|
+
if (sib.type === 'html' && sib.value?.trim() === `</${name}>`)
|
|
96357
|
+
break;
|
|
96358
|
+
closeIdx += 1;
|
|
96359
|
+
}
|
|
96360
|
+
if (closeIdx >= parent.children.length)
|
|
96361
|
+
return;
|
|
96362
|
+
// Extract all nodes between opening tag (index) and closing tag (closeIdx).
|
|
96363
|
+
// These are the inline component's children (e.g., text, emphasis, links).
|
|
96364
|
+
// Example: "<Anchor>click **here**</Anchor>" → children = [text, strong]
|
|
96365
|
+
const children = parent.children.slice(index + 1, closeIdx);
|
|
96366
|
+
const newNode = toMdxJsxTextElement(name, attributes, children);
|
|
96367
|
+
parent.children.splice(index, closeIdx - index + 1, newNode);
|
|
96368
|
+
});
|
|
96369
|
+
};
|
|
96370
|
+
/* harmony default export */ const mdxish_inline_components = (mdxishInlineComponents);
|
|
96371
|
+
|
|
96213
96372
|
;// ./processor/transform/mdxish/mdxish-jsx-to-mdast.ts
|
|
96214
96373
|
|
|
96215
96374
|
|
|
96216
96375
|
|
|
96376
|
+
const transformAnchor = (jsx) => {
|
|
96377
|
+
const attrs = getAttrs(jsx);
|
|
96378
|
+
const { href = '', label, target, title } = attrs;
|
|
96379
|
+
return {
|
|
96380
|
+
type: NodeTypes.anchor,
|
|
96381
|
+
children: jsx.children,
|
|
96382
|
+
data: {
|
|
96383
|
+
hName: 'Anchor',
|
|
96384
|
+
hProperties: {
|
|
96385
|
+
href,
|
|
96386
|
+
...(label && { label }),
|
|
96387
|
+
...(target && { target }),
|
|
96388
|
+
...(title && { title }),
|
|
96389
|
+
},
|
|
96390
|
+
},
|
|
96391
|
+
position: jsx.position,
|
|
96392
|
+
};
|
|
96393
|
+
};
|
|
96217
96394
|
const transformImage = (jsx) => {
|
|
96218
96395
|
const attrs = getAttrs(jsx);
|
|
96219
96396
|
const { align, alt = '', border, caption, className, height, lazy, src = '', title = '', width } = attrs;
|
|
@@ -96267,7 +96444,7 @@ const transformCallout = (jsx) => {
|
|
|
96267
96444
|
};
|
|
96268
96445
|
const transformEmbed = (jsx) => {
|
|
96269
96446
|
const attrs = getAttrs(jsx);
|
|
96270
|
-
const { favicon, html, iframe, image, providerName, providerUrl, title = '', url = '' } = attrs;
|
|
96447
|
+
const { favicon, height, html, iframe, image, providerName, providerUrl, title = '', typeOfEmbed, url = '', width } = attrs;
|
|
96271
96448
|
return {
|
|
96272
96449
|
type: NodeTypes.embedBlock,
|
|
96273
96450
|
title,
|
|
@@ -96278,11 +96455,14 @@ const transformEmbed = (jsx) => {
|
|
|
96278
96455
|
title,
|
|
96279
96456
|
url,
|
|
96280
96457
|
...(favicon && { favicon }),
|
|
96458
|
+
...(height && { height }),
|
|
96281
96459
|
...(html && { html }),
|
|
96282
96460
|
...(iframe !== undefined && { iframe }),
|
|
96283
96461
|
...(image && { image }),
|
|
96284
96462
|
...(providerName && { providerName }),
|
|
96285
96463
|
...(providerUrl && { providerUrl }),
|
|
96464
|
+
...(typeOfEmbed && { typeOfEmbed }),
|
|
96465
|
+
...(width && { width }),
|
|
96286
96466
|
},
|
|
96287
96467
|
},
|
|
96288
96468
|
position: jsx.position,
|
|
@@ -96378,7 +96558,7 @@ const COMPONENT_MAP = {
|
|
|
96378
96558
|
* This is controlled by the `newEditorTypes` flag to maintain backwards compatibility.
|
|
96379
96559
|
*/
|
|
96380
96560
|
const mdxishJsxToMdast = () => tree => {
|
|
96381
|
-
//
|
|
96561
|
+
// Block JSX components (Image, Callout, Embed, Recipe)
|
|
96382
96562
|
visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {
|
|
96383
96563
|
if (!parent || index === undefined || !node.name)
|
|
96384
96564
|
return;
|
|
@@ -96389,6 +96569,15 @@ const mdxishJsxToMdast = () => tree => {
|
|
|
96389
96569
|
// Replace the JSX node with the MDAST node
|
|
96390
96570
|
parent.children[index] = newNode;
|
|
96391
96571
|
});
|
|
96572
|
+
// Inline JSX components (Anchor)
|
|
96573
|
+
visit(tree, 'mdxJsxTextElement', (node, index, parent) => {
|
|
96574
|
+
if (!parent || index === undefined || !node.name)
|
|
96575
|
+
return;
|
|
96576
|
+
if (node.name === 'Anchor') {
|
|
96577
|
+
const newNode = transformAnchor(node);
|
|
96578
|
+
parent.children[index] = newNode;
|
|
96579
|
+
}
|
|
96580
|
+
});
|
|
96392
96581
|
// Transform magic block images (type: 'image') to image-block
|
|
96393
96582
|
// Note: Standard markdown images are wrapped in paragraphs and handled by imageTransformer
|
|
96394
96583
|
// Magic block images are direct children of root, so we handle them here
|
|
@@ -97982,6 +98171,7 @@ function loadComponents() {
|
|
|
97982
98171
|
|
|
97983
98172
|
|
|
97984
98173
|
|
|
98174
|
+
|
|
97985
98175
|
|
|
97986
98176
|
|
|
97987
98177
|
const defaultTransformers = [callouts, code_tabs, gemoji_, transform_embeds];
|
|
@@ -98043,7 +98233,9 @@ function mdxishAstProcessor(mdContent, opts = {}) {
|
|
|
98043
98233
|
.use(restore_snake_case_component_name, { mapping: snakeCaseMapping })
|
|
98044
98234
|
.use(mdxish_tables)
|
|
98045
98235
|
.use(mdxish_html_blocks)
|
|
98046
|
-
.use(newEditorTypes ?
|
|
98236
|
+
.use(newEditorTypes ? mdxish_inline_components : undefined) // Merge inline html components (e.g. <Anchor>) into MDAST nodes
|
|
98237
|
+
.use(newEditorTypes ? mdxish_jsx_to_mdast : undefined) // Convert block JSX elements to MDAST types
|
|
98238
|
+
.use(safeMode ? undefined : evaluate_expressions, { context: jsxContext }) // Evaluate MDX expressions using jsxContext
|
|
98047
98239
|
.use(variables_text) // Parse {user.*} patterns from text nodes
|
|
98048
98240
|
.use(useTailwind ? transform_tailwind : undefined, { components: tempComponentsMap })
|
|
98049
98241
|
.use(remarkGfm);
|