@readme/markdown 15.4.0 → 15.5.1

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/main.node.js CHANGED
@@ -19045,7 +19045,7 @@ module.exports = function () {
19045
19045
 
19046
19046
  /***/ },
19047
19047
 
19048
- /***/ 5814
19048
+ /***/ 8719
19049
19049
  (module, __webpack_exports__, __webpack_require__) {
19050
19050
 
19051
19051
  "use strict";
@@ -19186,6 +19186,63 @@ __webpack_require__.d(util_types_namespaceObject, {
19186
19186
  // EXTERNAL MODULE: external "react"
19187
19187
  var external_react_ = __webpack_require__(4953);
19188
19188
  var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
19189
+ ;// ./hooks/useRestartAnimatedImages/index.tsx
19190
+
19191
+ /**
19192
+ * GIF is the one extension that implies animation. `.webp` and `.png` (the extension an APNG
19193
+ * ships under) are overwhelmingly static, so matching them would reload far more images than
19194
+ * it rewinds; telling those apart needs the bytes, not the URL.
19195
+ */
19196
+ const ANIMATED_IMAGE_SRC = /\.gif(\?|#|$)/i;
19197
+ const restartAnimatedImages = (root) => {
19198
+ root?.querySelectorAll('img').forEach(img => {
19199
+ if (!ANIMATED_IMAGE_SRC.test(img.src))
19200
+ return;
19201
+ const { src } = img;
19202
+ // There's no seek API for animated images; reassigning `src` is the only reset
19203
+ img.src = '';
19204
+ img.src = src;
19205
+ });
19206
+ };
19207
+ const useRestartAfterFirstPaint = (revealKey, restart) => {
19208
+ const isFirstRender = (0,external_react_.useRef)(true);
19209
+ const latestRestart = (0,external_react_.useRef)(restart);
19210
+ latestRestart.current = restart;
19211
+ (0,external_react_.useEffect)(() => {
19212
+ if (isFirstRender.current) {
19213
+ isFirstRender.current = false;
19214
+ return;
19215
+ }
19216
+ latestRestart.current();
19217
+ }, [revealKey]);
19218
+ };
19219
+ /**
19220
+ * Restarts GIF playback inside the panel that just became active.
19221
+ *
19222
+ * Tabs keep every panel mounted, so an <img> is never re-created and a GIF is
19223
+ * shown mid-loop (or frozen on its last frame) when its tab is re-selected.
19224
+ *
19225
+ * @returns a ref to attach to each panel element, indexed by tab.
19226
+ */
19227
+ function useRestartAnimatedImages(activeIndex) {
19228
+ const panelRefs = (0,external_react_.useRef)([]);
19229
+ useRestartAfterFirstPaint(activeIndex, () => restartAnimatedImages(panelRefs.current[activeIndex]));
19230
+ return panelRefs;
19231
+ }
19232
+ /**
19233
+ * Restarts GIF playback inside an element that has just been revealed after being hidden —
19234
+ * a collapsed <details>, whose images have been animating out of sight since page load.
19235
+ */
19236
+ function useRestartAnimatedImagesOnReveal(isRevealed) {
19237
+ const contentRef = (0,external_react_.useRef)(null);
19238
+ useRestartAfterFirstPaint(isRevealed, () => {
19239
+ // Rewinding content the reader just hid would be wasted work
19240
+ if (isRevealed)
19241
+ restartAnimatedImages(contentRef.current);
19242
+ });
19243
+ return contentRef;
19244
+ }
19245
+
19189
19246
  ;// ./components/Icon/index.tsx
19190
19247
 
19191
19248
  /** @see https://docs-v5.fontawesome.com/web/reference-icons */
@@ -19210,14 +19267,16 @@ const Icon = ({ className, faClassName, icon, iconColor }) => {
19210
19267
 
19211
19268
 
19212
19269
 
19270
+
19213
19271
  const Accordion = ({ children, icon, iconColor, title }) => {
19214
19272
  const [isOpen, setIsOpen] = (0,external_react_.useState)(false);
19273
+ const contentRef = useRestartAnimatedImagesOnReveal(isOpen);
19215
19274
  return (external_react_default().createElement("details", { className: "Accordion", onToggle: () => setIsOpen(!isOpen) },
19216
19275
  external_react_default().createElement("summary", { className: "Accordion-title" },
19217
19276
  external_react_default().createElement("i", { className: `Accordion-toggleIcon${isOpen ? '_opened' : ''} fa fa-regular fa-chevron-right` }),
19218
19277
  icon && external_react_default().createElement(components_Icon, { className: "Accordion-icon", icon: icon, iconColor: iconColor }),
19219
19278
  title),
19220
- external_react_default().createElement("div", { className: "Accordion-content" }, children)));
19279
+ external_react_default().createElement("div", { ref: contentRef, className: "Accordion-content" }, children)));
19221
19280
  };
19222
19281
  /* harmony default export */ const components_Accordion = (Accordion);
19223
19282
 
@@ -25080,11 +25139,13 @@ function TableOfContents({ children }) {
25080
25139
 
25081
25140
 
25082
25141
 
25142
+
25083
25143
  const Tab = ({ children }) => {
25084
25144
  return external_react_default().createElement("div", { className: "TabContent" }, children);
25085
25145
  };
25086
25146
  const Tabs = ({ children }) => {
25087
25147
  const [activeTab, setActiveTab] = (0,external_react_.useState)(0);
25148
+ const panelRefs = useRestartAnimatedImages(activeTab);
25088
25149
  // React passes `children` as a single element when there's only one child, so normalize.
25089
25150
  const tabs = external_react_default().Children.toArray(children);
25090
25151
  return (external_react_default().createElement("div", { className: "TabGroup" },
@@ -25092,7 +25153,9 @@ const Tabs = ({ children }) => {
25092
25153
  external_react_default().createElement("nav", { className: "TabGroup-nav" }, tabs.map((tab, index) => (external_react_default().createElement("button", { key: tab.key, className: `TabGroup-tab${activeTab === index ? '_active' : ''}`, onClick: () => setActiveTab(index) },
25093
25154
  tab.props.icon && (external_react_default().createElement(components_Icon, { className: "TabGroup-icon", icon: tab.props.icon, iconColor: tab.props.iconColor })),
25094
25155
  tab.props.title))))),
25095
- external_react_default().createElement("section", null, tabs.map((tab, index) => (external_react_default().createElement("div", { key: tab.key, hidden: index !== activeTab }, tab))))));
25156
+ external_react_default().createElement("section", null, tabs.map((tab, index) => (external_react_default().createElement("div", { key: tab.key, ref: el => {
25157
+ panelRefs.current[index] = el;
25158
+ }, hidden: index !== activeTab }, tab))))));
25096
25159
  };
25097
25160
  /* harmony default export */ const components_Tabs = (Tabs);
25098
25161
 
@@ -96573,6 +96636,10 @@ function syntax_createTokenize(mode) {
96573
96636
  effects.consume(code);
96574
96637
  return inBraceExpr;
96575
96638
  }
96639
+ // A raw `<` can't sit in an opening tag (quotes/braces are handled above);
96640
+ // bailing bounds each attempt to the next `<` instead of rescanning the line.
96641
+ if (code === codes.lessThan)
96642
+ return nok(code);
96576
96643
  effects.consume(code);
96577
96644
  return afterOpenTagName;
96578
96645
  }
@@ -101745,6 +101812,17 @@ const tablesToJsx = () => tree => {
101745
101812
  ;// ./processor/transform/tailwind.tsx
101746
101813
 
101747
101814
 
101815
+
101816
+
101817
+ /** Whitespace-only text is layout between blocks, not inline flow. */
101818
+ const isInlineContent = (node) => phrasing(node) && !(node.type === 'text' && node.value.trim() === '');
101819
+ /**
101820
+ * Whether the child at `index` sits in inline flow: its parent only allows
101821
+ * phrasing content (e.g. a paragraph), or it is flanked by phrasing siblings
101822
+ * (e.g. `<div>text <Image /> text</div>`, whose children skip the paragraph).
101823
+ */
101824
+ const isInlineInContext = (index, parent) => INLINE_ONLY_PARENT_TYPES.has(parent.type) ||
101825
+ parent.children.some((sibling, siblingIndex) => siblingIndex !== index && isInlineContent(sibling));
101748
101826
  const injectTailwindRoot = ({ components = {} }) => (node, index, parent) => {
101749
101827
  if (!('name' in node))
101750
101828
  return;
@@ -101753,7 +101831,7 @@ const injectTailwindRoot = ({ components = {} }) => (node, index, parent) => {
101753
101831
  if (!('children' in parent))
101754
101832
  return;
101755
101833
  const attrs = {
101756
- flow: node.type === 'mdxJsxFlowElement',
101834
+ flow: node.type === 'mdxJsxFlowElement' && !isInlineInContext(index, parent),
101757
101835
  };
101758
101836
  const wrapper = {
101759
101837
  type: node.type,
@@ -121779,7 +121857,7 @@ const listMarkerRegex = /^(?:[*+-]|\d+[.)])(?:([\r\n]| {1,3})|$)/;
121779
121857
  * with their checkbox intact (for example, `- [ ]`) instead of dropping it
121780
121858
  * We can add more adjustments if needed
121781
121859
  */
121782
- const compile_list_item_listItem = (node, parent, state, info) => {
121860
+ const compile_list_item_listItem = ((node, parent, state, info) => {
121783
121861
  const head = node.children[0];
121784
121862
  const isCheckbox = typeof node.checked === 'boolean' && head && head.type === 'paragraph';
121785
121863
  if (!isCheckbox) {
@@ -121803,15 +121881,47 @@ const compile_list_item_listItem = (node, parent, state, info) => {
121803
121881
  return `${marker}${actualSeparator}${checkbox}`;
121804
121882
  });
121805
121883
  return value;
121806
- };
121884
+ });
121807
121885
  /* harmony default export */ const list_item = (compile_list_item_listItem);
121808
121886
 
121809
121887
  ;// ./processor/compile/plain.ts
121810
121888
  const plain_plain = (node) => node.value;
121811
121889
  /* harmony default export */ const compile_plain = (plain_plain);
121812
121890
 
121891
+ ;// ./processor/compile/table-cell-block-markers.ts
121892
+ const CELL_START_BLOCK_MARKER = /^(?:[-+](?=\s|$)|#{1,6}(?=\s|$)|>)/;
121893
+ const BR_HTML = /^\s*<br\s*\/?>\s*$/i;
121894
+ const isLineBreak = (node) => {
121895
+ if (node.type === 'break')
121896
+ return true;
121897
+ if (node.type === 'html')
121898
+ return BR_HTML.test(node.value);
121899
+ return node.type === 'mdxJsxTextElement' && 'name' in node && node.name?.toLowerCase() === 'br';
121900
+ };
121901
+ const followsLineBreak = (node, parent) => {
121902
+ const siblings = (parent?.children ?? []);
121903
+ const previous = siblings[siblings.indexOf(node) - 1];
121904
+ return !!previous && isLineBreak(previous);
121905
+ };
121906
+ /**
121907
+ * Re-escapes a leading block marker (`-`, `+`, `#`, `>`) at the start of a table cell, or
121908
+ * after a `<br />` within one.
121909
+ *
121910
+ * A cell is serialized mid-line, so the `atBreak` patterns that escape these characters
121911
+ * never fire and an author's `| \- one |` round trips to `| - one |` (RM-17203). Cells are
121912
+ * serialized as `containerPhrasing(cell, { before: '|' })`, so `|` marks the cell start.
121913
+ */
121914
+ const escapeCellStartBlockMarker = (serialized, node, parent, state, info) => {
121915
+ if (serialized.startsWith('\\') || !CELL_START_BLOCK_MARKER.test(serialized))
121916
+ return serialized;
121917
+ if (!state.stack.includes('tableCell') || !(info.before === '|' || followsLineBreak(node, parent)))
121918
+ return serialized;
121919
+ return `\\${serialized}`;
121920
+ };
121921
+
121813
121922
  ;// ./processor/compile/text.ts
121814
121923
 
121924
+
121815
121925
  // A `_` flanked by word characters can never open or close emphasis under
121816
121926
  // CommonMark's flanking rules, so the escape mdast-util-to-markdown adds to
121817
121927
  // intraword underscores is unnecessary and only produces noisy `\_` diffs.
@@ -121819,9 +121929,10 @@ const plain_plain = (node) => node.value;
121819
121929
  const INTRAWORD_UNDERSCORE_ESCAPE = /(?<=[\p{L}\p{N}_])\\_(?=[\p{L}\p{N}_]|\\_)/gu;
121820
121930
  const compile_text_text = (node, parent, state, info) => {
121821
121931
  const serialized = handle.text(node, parent, state, info);
121822
- return serialized.replace(INTRAWORD_UNDERSCORE_ESCAPE, '_');
121932
+ return escapeCellStartBlockMarker(serialized, node, parent, state, info);
121823
121933
  };
121824
- /* harmony default export */ const compile_text = (compile_text_text);
121934
+ const mdxishText = (node, parent, state, info) => compile_text_text(node, parent, state, info).replace(INTRAWORD_UNDERSCORE_ESCAPE, '_');
121935
+ /* harmony default export */ const compile_text = (mdxishText);
121825
121936
 
121826
121937
  ;// ./processor/compile/index.ts
121827
121938
 
@@ -121853,6 +121964,7 @@ function compilers(mdxish = false) {
121853
121964
  html: compile_compatibility,
121854
121965
  i: compile_compatibility,
121855
121966
  plain: compile_plain,
121967
+ text: compile_text_text,
121856
121968
  yaml: compile_compatibility,
121857
121969
  // needed only for mdxish
121858
121970
  ...(mdxish && { list: compile_list }),
@@ -123921,13 +124033,14 @@ function restoreCodeBlocks(content, protectedCode) {
123921
124033
  *
123922
124034
  * The attribute portion skips over quoted strings (`"..."` and `'...'`) so that
123923
124035
  * a `/>` inside an attribute value (e.g. `title="use /> here"`) does not cause
123924
- * a premature match.
124036
+ * a premature match, and stops at an unquoted `<` so a stray `<x` in prose
124037
+ * doesn't scan to the end of the document (quadratic).
123925
124038
  *
123926
124039
  * Only matches lowercase tag names to avoid interfering with PascalCase
123927
124040
  * JSX custom components (e.g. `<MyComponent />`), which are handled
123928
124041
  * separately by components/mdx-blocks.
123929
124042
  */
123930
- const SELF_CLOSING_TAG_RE = /<([a-z][a-z0-9-]*)((?:\s+(?:[^>"']*(?:"[^"]*"|'[^']*'))*[^>"']*)?)?\s*\/>/g;
124043
+ const SELF_CLOSING_TAG_RE = /<([a-z][a-z0-9-]*)((?:\s+(?:[^<>"']*(?:"[^"]*"|'[^']*'))*[^<>"']*)?)?\s*\/>/g;
123931
124044
  /**
123932
124045
  * String-level preprocessor that converts self-closing non-void HTML tags
123933
124046
  * into explicitly closed tags.
@@ -124592,8 +124705,9 @@ function terminateHtmlFlowBlocks(content) {
124592
124705
 
124593
124706
 
124594
124707
 
124595
- // Matches a JSX attribute expression (e.g. `key={i}`) anywhere in a string. */
124596
- const NESTED_ATTR_EXPRESSION_RE = /[\w-]+\s*=\s*\{/;
124708
+ // Matches a JSX attribute expression (e.g. `key={i}`) anywhere in a string. One name
124709
+ // char suffices for existence — `[\w-]+` backtracked quadratically over huge attributes.
124710
+ const NESTED_ATTR_EXPRESSION_RE = /[\w-]\s*=\s*\{/;
124597
124711
  // Name shape mirrors `componentTagPattern`; the lookbehind skips the inner tag
124598
124712
  // of a legacy `<<VARIABLE>>`.
124599
124713
  const NESTED_COMPONENT_TAG_RE = /(?<!<)<([A-Z][A-Za-z0-9_]*)[\s/>]/g;
@@ -124892,150 +125006,6 @@ const mdxishMdxComponentBlocks = (opts = {}) => (tree, file) => {
124892
125006
  };
124893
125007
  /* harmony default export */ const mdx_blocks = (mdxishMdxComponentBlocks);
124894
125008
 
124895
- ;// ./processor/transform/mdxish/components/self-closing-blocks.ts
124896
-
124897
-
124898
- /**
124899
- * Tags to process as self-closing blocks.
124900
- * These components use simple string attributes (no JSX expressions like `data={[...]}`).
124901
- * Components with JSX expression attributes should NOT be added here as parseAttributes
124902
- * cannot handle them correctly.
124903
- */
124904
- const SELF_CLOSING_BLOCK_TAGS = new Set(['Embed', 'Recipe']);
124905
- // Regex to match self-closing PascalCase tags (handles multi-line)
124906
- const selfClosingTagPattern = /^<([A-Z][A-Za-z0-9_]*)([\s\S]*?)\/>$/;
124907
- /**
124908
- * Try to convert a paragraph node containing a self-closing JSX component into an mdxJsxFlowElement.
124909
- * Returns the new node if conversion succeeded, or null if the node doesn't match.
124910
- */
124911
- const tryConvertToMdxNode = (node) => {
124912
- if (node.children.length !== 1)
124913
- return null;
124914
- const child = node.children[0];
124915
- if (child.type !== 'html')
124916
- return null;
124917
- const value = child.value?.trim();
124918
- if (!value)
124919
- return null;
124920
- const match = value.match(selfClosingTagPattern);
124921
- if (!match)
124922
- return null;
124923
- const [, tag, attrString] = match;
124924
- if (!SELF_CLOSING_BLOCK_TAGS.has(tag))
124925
- return null;
124926
- return {
124927
- type: 'mdxJsxFlowElement',
124928
- name: tag,
124929
- attributes: parseAttributes(attrString),
124930
- children: [],
124931
- position: node.position,
124932
- };
124933
- };
124934
- /**
124935
- * Transform paragraph-wrapped self-closing JSX components into mdxJsxFlowElement nodes.
124936
- *
124937
- * CommonMark wraps multi-line JSX in paragraphs when the opening tag isn't complete
124938
- * on one line. This plugin detects these structures and unwraps them for components
124939
- * in the SELF_CLOSING_BLOCK_TAGS allowlist.
124940
- *
124941
- * Input structure:
124942
- * ```
124943
- * paragraph > html: "<Embed\n typeOfEmbed=\"youtube\"\n/>"
124944
- * ```
124945
- *
124946
- * Output structure:
124947
- * ```
124948
- * mdxJsxFlowElement: { name: "Embed", attributes: [...], children: [] }
124949
- * ```
124950
- */
124951
- const mdxishSelfClosingBlocks = () => tree => {
124952
- visit(tree, 'paragraph', (node, index, parent) => {
124953
- if (index === undefined || !parent)
124954
- return;
124955
- const mdxNode = tryConvertToMdxNode(node);
124956
- if (mdxNode) {
124957
- parent.children.splice(index, 1, mdxNode);
124958
- }
124959
- });
124960
- };
124961
- /* harmony default export */ const self_closing_blocks = (mdxishSelfClosingBlocks);
124962
-
124963
- ;// ./processor/transform/mdxish/components/snake-case-components.ts
124964
-
124965
-
124966
- /**
124967
- * Replaces snake_case component names with valid HTML placeholders.
124968
- * Required because remark-parse rejects tags with underscores.
124969
- * Example: `<Snake_case />` → `<MDXishSnakeCase0 />`
124970
- *
124971
- * Code blocks and inline code are protected and will not be transformed.
124972
- *
124973
- * @param content - The markdown content to process
124974
- * @param options - Options including knownComponents to filter by
124975
- */
124976
- function processSnakeCaseComponent(content, options = {}) {
124977
- const { knownComponents } = options;
124978
- // Early exit if no potential snake_case components
124979
- if (!/[A-Z][A-Za-z0-9]*_[A-Za-z0-9_]*/.test(content)) {
124980
- return { content, mapping: {} };
124981
- }
124982
- // Step 1: Extract code blocks to protect them from transformation
124983
- const { protectedCode, protectedContent } = protectCodeBlocks(content);
124984
- // Find the highest existing placeholder number to avoid collisions
124985
- // e.g., if content has <MDXishSnakeCase0 />, start counter from 1
124986
- const placeholderPattern = /MDXishSnakeCase(\d+)/g;
124987
- let startCounter = 0;
124988
- let placeholderMatch;
124989
- while ((placeholderMatch = placeholderPattern.exec(content)) !== null) {
124990
- const num = parseInt(placeholderMatch[1], 10);
124991
- if (num >= startCounter) {
124992
- startCounter = num + 1;
124993
- }
124994
- }
124995
- const mapping = {};
124996
- const reverseMap = new Map();
124997
- let counter = startCounter;
124998
- // Step 2: Transform snake_case components in non-code content
124999
- const processedContent = protectedContent.replace(componentTagPattern, (match, tagName, attrs, selfClosing) => {
125000
- if (!tagName.includes('_')) {
125001
- return match;
125002
- }
125003
- const isClosing = tagName.startsWith('/');
125004
- const cleanTagName = isClosing ? tagName.slice(1) : tagName;
125005
- // Only transform if it's a known component (or if no filter is provided)
125006
- if (knownComponents && !knownComponents.has(cleanTagName)) {
125007
- return match;
125008
- }
125009
- let placeholder = reverseMap.get(cleanTagName);
125010
- if (!placeholder) {
125011
- // eslint-disable-next-line no-plusplus
125012
- placeholder = `MDXishSnakeCase${counter++}`;
125013
- mapping[placeholder] = cleanTagName;
125014
- reverseMap.set(cleanTagName, placeholder);
125015
- }
125016
- const processedTagName = isClosing ? `/${placeholder}` : placeholder;
125017
- return `<${processedTagName}${attrs}${selfClosing}>`;
125018
- });
125019
- // Step 3: Restore code blocks (untouched)
125020
- const finalContent = restoreCodeBlocks(processedContent, protectedCode);
125021
- return {
125022
- content: finalContent,
125023
- mapping,
125024
- };
125025
- }
125026
- /**
125027
- * Restores placeholder name to original snake_case name.
125028
- * Uses case-insensitive matching since HTML parsers normalize to lowercase.
125029
- */
125030
- function restoreSnakeCase(placeholderName, mapping) {
125031
- if (mapping[placeholderName]) {
125032
- return mapping[placeholderName];
125033
- }
125034
- const lowerName = placeholderName.toLowerCase();
125035
- const matchingKey = Object.keys(mapping).find(key => key.toLowerCase() === lowerName);
125036
- return matchingKey ? mapping[matchingKey] : placeholderName;
125037
- }
125038
-
125039
125009
  ;// ./processor/transform/mdxish/resolve-esm-imports.ts
125040
125010
 
125041
125011
  // We provide React as a default module so that components can use hooks
@@ -125220,6 +125190,54 @@ const containsJsxNode = (value) => {
125220
125190
  return true;
125221
125191
  return Object.values(value).some(containsJsxNode);
125222
125192
  };
125193
+ /** Read the component name off a JSX element name node (`Foo`, `Foo.Bar`, `foo:Bar`). */
125194
+ const jsxElementName = (name) => {
125195
+ if (name === null || typeof name !== 'object')
125196
+ return undefined;
125197
+ const node = name;
125198
+ if (node.type === 'JSXIdentifier')
125199
+ return typeof node.name === 'string' ? node.name : undefined;
125200
+ // `<Foo.Bar/>` and `<foo:Bar/>` resolve through their leftmost part.
125201
+ if (node.type === 'JSXMemberExpression')
125202
+ return jsxElementName(node.object);
125203
+ if (node.type === 'JSXNamespacedName')
125204
+ return jsxElementName(node.namespace);
125205
+ return undefined;
125206
+ };
125207
+ /**
125208
+ * Collect the capitalized names an expression uses as JSX tags. Parsed rather than pattern
125209
+ * matched: `{count < Max ? <Foo/> : <Bar/>}` puts a capitalized name straight after a `<` without
125210
+ * it being a tag, and only the parser can tell the two apart. Unparseable input yields nothing —
125211
+ * evaluation is about to throw on it anyway.
125212
+ */
125213
+ const jsxComponentNames = (expression) => {
125214
+ let program;
125215
+ try {
125216
+ program = parseExpression(expression);
125217
+ }
125218
+ catch {
125219
+ return [];
125220
+ }
125221
+ const names = new Set();
125222
+ const walk = (value) => {
125223
+ if (Array.isArray(value)) {
125224
+ value.forEach(walk);
125225
+ return;
125226
+ }
125227
+ if (value === null || typeof value !== 'object')
125228
+ return;
125229
+ const node = value;
125230
+ if (node.type === 'JSXOpeningElement') {
125231
+ const name = jsxElementName(node.name);
125232
+ // Lowercase tags compile to a string type, never a variable reference.
125233
+ if (name && /^[A-Z]/.test(name))
125234
+ names.add(name);
125235
+ }
125236
+ Object.values(node).forEach(walk);
125237
+ };
125238
+ walk(program);
125239
+ return Array.from(names);
125240
+ };
125223
125241
  /** Convert a program's JSX into `React.createElement` calls and evaluate it. `scope` must provide `React`. */
125224
125242
  const evalJsxProgram = (program, scope) => {
125225
125243
  buildJsx(program, { runtime: 'classic', pragma: 'React.createElement', pragmaFrag: 'React.Fragment' });
@@ -125425,6 +125443,28 @@ function reactElementToHast(node) {
125425
125443
 
125426
125444
 
125427
125445
 
125446
+
125447
+
125448
+
125449
+
125450
+ /**
125451
+ * Bind the components a given expression actually uses as tags. Scoped per expression on purpose:
125452
+ * binding the whole hash would shadow same-named globals (a `math` component would break
125453
+ * `{Math.max(1, 2)}`) and pad `evaluate`'s `new Function` parameter list. Resolution defers to
125454
+ * `getComponentName` so an expression and a plain tag always reach the same component.
125455
+ */
125456
+ const componentScope = (expression, components) => {
125457
+ const scope = {};
125458
+ jsxComponentNames(expression).forEach(name => {
125459
+ // `getComponentName` normalizes the tag, never the key, so it can't match `<MyBlock/>` to a
125460
+ // `my_block` entry; compare the key's PascalCase form for that direction.
125461
+ const tagName = getComponentName(name, components) ?? Object.keys(components).find(k => toPascalCase(k) === name);
125462
+ if (!tagName)
125463
+ return;
125464
+ scope[name] = (props) => external_react_default().createElement(tagName, props);
125465
+ });
125466
+ return scope;
125467
+ };
125428
125468
  /**
125429
125469
  * We divide the result of an expression into two categories:
125430
125470
  * 1. Renderable values: HTML, JSX, e.g. .map() returning JSX
@@ -125435,6 +125475,17 @@ const isRenderable = (value) => {
125435
125475
  return true;
125436
125476
  return Array.isArray(value) && value.some(isRenderable);
125437
125477
  };
125478
+ /**
125479
+ * Whether an expression evaluated to block-level content. Components count as block-level
125480
+ * unless they're on the inline list, matching the assumption the rest of the component
125481
+ * pipeline makes.
125482
+ */
125483
+ const isBlockResult = (children) => children.some(child => {
125484
+ if (child.type !== 'element' && child.type !== 'mdx-jsx')
125485
+ return false;
125486
+ const { tagName } = child;
125487
+ return !STANDARD_HTML_TAGS.has(tagName.toLowerCase()) && !INLINE_COMPONENT_TAGS.has(tagName);
125488
+ });
125438
125489
  /** Turn a non-renderable evaluation result into a text node. */
125439
125490
  const createTextNode = (result, position) => {
125440
125491
  if (result === null || result === undefined)
@@ -125446,13 +125497,22 @@ const createTextNode = (result, position) => {
125446
125497
  /**
125447
125498
  * AST transformer to evaluate MDX expressions.
125448
125499
  * Replaces mdxFlowExpression and mdxTextExpression nodes with their evaluated values.
125449
- * Self-contained expressions resolve directly (e.g. `{1+1}`); expressions that
125450
- * reference identifiers can resolve if those identifiers were introduced by an
125451
- * earlier `export const/function` (collected onto `file.data.mdxishScope`).
125452
- * Anything else falls through to the error branch and is kept as literal `{...}` text.
125453
- */
125454
- const evaluateExpressions = () => (tree, file) => {
125455
- const scope = { ...(file.data.mdxishScope), React: (external_react_default()) };
125500
+ * Self-contained expressions resolve directly (e.g. `{1+1}`); expressions that reference
125501
+ * identifiers can resolve if those identifiers are a custom component, the `user` variables
125502
+ * object, or were introduced by an earlier `export const/function` (collected onto
125503
+ * `file.data.mdxishScope`). Anything else falls through to the error branch and is kept as
125504
+ * literal `{...}` text.
125505
+ */
125506
+ const evaluateExpressions = ({ components, variables } = {}) => (tree, file) => {
125507
+ const baseScope = {
125508
+ // `User` matches the fallback the MDX path binds in `run.tsx`. Only when variables were
125509
+ // supplied: the proxy never throws, so an unconditional bind would resolve `user.*` on
125510
+ // surfaces that render without them instead of leaving literal text.
125511
+ ...(variables ? { user: user(variables) } : {}),
125512
+ // In-document exports win, matching `renderMdxish`.
125513
+ ...file.data.mdxishScope,
125514
+ React: (external_react_default()),
125515
+ };
125456
125516
  visit(tree, ['mdxFlowExpression', 'mdxTextExpression'], (node, index, parent) => {
125457
125517
  if (!parent || index === null || index === undefined)
125458
125518
  return;
@@ -125462,6 +125522,7 @@ const evaluateExpressions = () => (tree, file) => {
125462
125522
  if (!expression)
125463
125523
  return;
125464
125524
  try {
125525
+ const scope = { ...componentScope(expression, components ?? {}), ...baseScope };
125465
125526
  const result = evalExpression(expression, scope);
125466
125527
  if (isRenderable(result)) {
125467
125528
  // Stash hast built straight from the React tree; `mdxExpressionHandler` emits it and it
@@ -125482,6 +125543,22 @@ const evaluateExpressions = () => (tree, file) => {
125482
125543
  parent.children.splice(index, 1, { type: 'text', value: `{${processed}}`, position });
125483
125544
  }
125484
125545
  });
125546
+ // A text expression is parsed inside a paragraph, but its result can be block content: a
125547
+ // `<Tabs>` renders a `<div>`, and a browser closes the `<p>` before it, so the DOM it builds
125548
+ // no longer matches what was rendered and hydration fails. Lift the expression out when
125549
+ // that's all the paragraph holds.
125550
+ visit(tree, 'paragraph', (node, index, parent) => {
125551
+ if (!parent || index === null || index === undefined)
125552
+ return;
125553
+ const meaningful = node.children.filter(child => !(child.type === 'text' && !child.value.trim()));
125554
+ const [only] = meaningful;
125555
+ if (meaningful.length !== 1 || only.type !== 'mdxTextExpression')
125556
+ return;
125557
+ const hChildren = only.data?.hChildren;
125558
+ if (!hChildren || !isBlockResult(hChildren))
125559
+ return;
125560
+ parent.children.splice(index, 1, only);
125561
+ });
125485
125562
  return tree;
125486
125563
  };
125487
125564
  /* harmony default export */ const evaluate_expressions = (evaluateExpressions);
@@ -127176,12 +127253,20 @@ function removeJSXComments(content) {
127176
127253
  const OPAQUE_CONTAINERS = new Set(['pre', 'textarea', 'htmlblock']);
127177
127254
  /** The missing-slash typo shape: an attribute-less, non-self-closing opener. */
127178
127255
  const BARE_OPENER_SOURCE_RE = /^<[A-Za-z]+\s*>$/;
127179
- /** The opener shares its line with nothing but whitespace. */
127180
- const isAloneOnLine = (content, start, end) => {
127181
- const lineStart = content.lastIndexOf('\n', start - 1) + 1;
127256
+ /** The opener is immediately preceded by a complete tag, so the prefix is markup and not prose. */
127257
+ const PREFIX_ENDS_WITH_TAG_RE = /<[^<>]*>\s*$/;
127258
+ /**
127259
+ * The opener finishes its line, preceded by nothing but whitespace or by markup.
127260
+ * Requiring markup (not merely "something") keeps a markdown block prefix such as
127261
+ * a `>` quote marker from qualifying, while allowing the closer to trail a cell or
127262
+ * `</thead>` on a single-line table.
127263
+ */
127264
+ const endsLineAfterMarkup = (content, start, end) => {
127182
127265
  const lineEnd = content.indexOf('\n', end);
127183
- return (content.slice(lineStart, start).trim() === '' &&
127184
- content.slice(end, lineEnd === -1 ? content.length : lineEnd).trim() === '');
127266
+ if (content.slice(end, lineEnd === -1 ? content.length : lineEnd).trim() !== '')
127267
+ return false;
127268
+ const prefix = content.slice(content.lastIndexOf('\n', start - 1) + 1, start);
127269
+ return prefix.trim() === '' || PREFIX_ENDS_WITH_TAG_RE.test(prefix);
127185
127270
  };
127186
127271
  /**
127187
127272
  * Rewrites a bare `<table>` that is almost certainly a missing-slash closer
@@ -127189,7 +127274,7 @@ const isAloneOnLine = (content, start, end) => {
127189
127274
  * Customer docs (CX-3850) close tables with a second bare opener; without this,
127190
127275
  * the never-terminated HTML flow block swallows the markdown that follows.
127191
127276
  *
127192
- * A candidate is a bare opener alone on its line while a table is already open.
127277
+ * A candidate is a bare opener that finishes its line while a table is already open.
127193
127278
  * It is judged a typo only when its element ends implicitly (no explicit
127194
127279
  * `</table>`) without ever acquiring table-structure children — so genuine
127195
127280
  * nested tables, whatever precedes their rows, are left alone.
@@ -127218,7 +127303,7 @@ function repairMistakenTableClosers(content) {
127218
127303
  start,
127219
127304
  end,
127220
127305
  hasStructureChild: false,
127221
- isCandidate: stack.length > 0 && BARE_OPENER_SOURCE_RE.test(source) && isAloneOnLine(content, start, end),
127306
+ isCandidate: stack.length > 0 && BARE_OPENER_SOURCE_RE.test(source) && endsLineAfterMarkup(content, start, end),
127222
127307
  });
127223
127308
  }
127224
127309
  else if (opaqueDepth === 0 && tableTags.has(lower) && stack.length > 0) {
@@ -127289,45 +127374,6 @@ const resolveDeferredAttributeExpressionProps = () => (tree, file) => {
127289
127374
  };
127290
127375
  /* harmony default export */ const resolve_deferred_attribute_expression_props = (resolveDeferredAttributeExpressionProps);
127291
127376
 
127292
- ;// ./processor/transform/mdxish/restore-snake-case-component-name.ts
127293
-
127294
-
127295
- /**
127296
- * Restores snake_case component names from placeholders after parsing.
127297
- * Runs after mdxishComponentBlocks converts HTML nodes to mdxJsxFlowElement.
127298
- */
127299
- const restoreSnakeCaseComponentNames = (options) => {
127300
- const { mapping } = options;
127301
- return tree => {
127302
- if (!mapping || Object.keys(mapping).length === 0) {
127303
- return tree;
127304
- }
127305
- visit(tree, 'mdxJsxFlowElement', (node) => {
127306
- if (node.name) {
127307
- node.name = restoreSnakeCase(node.name, mapping);
127308
- }
127309
- });
127310
- // Pre-compile regex patterns for better performance
127311
- const regexPatterns = Object.entries(mapping).map(([placeholder, original]) => ({
127312
- regex: new RegExp(`(<\\/?)(${placeholder})(\\s|\\/?>)`, 'gi'),
127313
- original,
127314
- }));
127315
- visit(tree, 'html', (node) => {
127316
- if (node.value) {
127317
- let newValue = node.value;
127318
- regexPatterns.forEach(({ regex, original }) => {
127319
- newValue = newValue.replace(regex, `$1${original}$3`);
127320
- });
127321
- if (newValue !== node.value) {
127322
- node.value = newValue;
127323
- }
127324
- }
127325
- });
127326
- return tree;
127327
- };
127328
- };
127329
- /* harmony default export */ const restore_snake_case_component_name = (restoreSnakeCaseComponentNames);
127330
-
127331
127377
  ;// ./processor/transform/mdxish/retain-boolean-attributes.ts
127332
127378
 
127333
127379
  // Private Use Area character (U+E000) which is extremely unlikely to appear in real content.
@@ -127869,9 +127915,6 @@ function loadComponents() {
127869
127915
 
127870
127916
 
127871
127917
 
127872
-
127873
-
127874
-
127875
127918
 
127876
127919
 
127877
127920
 
@@ -127893,10 +127936,8 @@ const defaultTransformers = [
127893
127936
  * 5. Terminate HTML flow blocks so subsequent content isn't swallowed
127894
127937
  * 6. Close invalid "self-closing" HTML tags (e.g., `<i />` → `<i></i>`)
127895
127938
  * 7. Normalize compact ATX headings (e.g., `#Heading` → `# Heading`)
127896
- * 8. Replace snake_case component names with parser-safe placeholders
127897
127939
  */
127898
- function preprocessContent(content, opts) {
127899
- const { knownComponents } = opts;
127940
+ function preprocessContent(content) {
127900
127941
  // Runs first so `jsxTable` sees a literal `</table>` (and the HTML-line
127901
127942
  // classification in `terminateHtmlFlowBlocks` is accurate)
127902
127943
  let result = normalizeClosingTagWhitespace(content);
@@ -127909,7 +127950,7 @@ function preprocessContent(content, opts) {
127909
127950
  result = terminateHtmlFlowBlocks(result);
127910
127951
  result = closeSelfClosingHtmlTags(result);
127911
127952
  result = normalizeCompactHeadings(result);
127912
- return processSnakeCaseComponent(result, { knownComponents });
127953
+ return result;
127913
127954
  }
127914
127955
  function mdxishAstProcessor(mdContent, opts = {}) {
127915
127956
  const { components: userComponents = {}, hardBreaks: enableHardBreaks = true, newEditorTypes = false, safeMode = false, useTailwind, } = opts;
@@ -127917,9 +127958,7 @@ function mdxishAstProcessor(mdContent, opts = {}) {
127917
127958
  ...loadComponents(),
127918
127959
  ...userComponents,
127919
127960
  };
127920
- // Build set of known component names for snake_case filtering
127921
- const knownComponents = new Set(Object.keys(components));
127922
- const { content: parserReadyContent, mapping: snakeCaseMapping } = preprocessContent(mdContent, { knownComponents });
127961
+ const parserReadyContent = preprocessContent(mdContent);
127923
127962
  // Create string map for tailwind transformer
127924
127963
  const tempComponentsMap = Object.entries(components).reduce((acc, [key, value]) => {
127925
127964
  acc[key] = String(value);
@@ -127932,10 +127971,8 @@ function mdxishAstProcessor(mdContent, opts = {}) {
127932
127971
  .use(remarkParse)
127933
127972
  .use(remarkFrontmatter)
127934
127973
  .use(normalize_malformed_md_syntax)
127935
- .use(self_closing_blocks)
127936
127974
  .use(mdx_blocks, { safeMode })
127937
127975
  .use(inline_html, { safeMode })
127938
- .use(restore_snake_case_component_name, { mapping: snakeCaseMapping })
127939
127976
  .use(mdxish_tables)
127940
127977
  .use(mdxish_html_blocks) // Convert every <HTMLBlock> shape → html-block
127941
127978
  // The next few transformers must appear after mdxishMdxComponentBlocks
@@ -128011,7 +128048,7 @@ function mdxish(mdContent, opts = {}) {
128011
128048
  processor
128012
128049
  .use(safeMode ? undefined : evaluate_exports) // Evaluate `export const/function` and stash scope on file.data.mdxishScope
128013
128050
  .use(enableHardBreaks ? hard_breaks : undefined) // Must precede evaluateExpressions to avoid splitting the \n in an evaluated template literal into a <br> node
128014
- .use(safeMode ? undefined : evaluate_expressions) // Evaluate self-contained MDX expressions (e.g. `{1+1}`)
128051
+ .use(safeMode ? undefined : evaluate_expressions, { components, variables }) // Evaluate self-contained MDX expressions (e.g. `{1+1}`)
128015
128052
  .use(safeMode ? undefined : evaluate_style_block_expressions) // Evaluate `<style>{`...`}</style>` template literals into plain CSS
128016
128053
  .use(variables_code, { variables }) // Resolve <<...>> and {user.*} inside code and inline code nodes
128017
128054
  .use(remarkRehype, { allowDangerousHtml: true, handlers: mdxComponentHandlers })
@@ -129057,7 +129094,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"*":["about","acceptCharset","accessK
129057
129094
  /******/ // startup
129058
129095
  /******/ // Load entry module and return exports
129059
129096
  /******/ // This entry module used 'module' so it can't be inlined
129060
- /******/ let __webpack_exports__ = __webpack_require__(5814);
129097
+ /******/ let __webpack_exports__ = __webpack_require__(8719);
129061
129098
  /******/ module.exports = __webpack_exports__;
129062
129099
  /******/
129063
129100
  /******/ })()