@readme/markdown 15.5.0 → 15.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.
@@ -19045,7 +19045,7 @@ module.exports = function () {
19045
19045
 
19046
19046
  /***/ },
19047
19047
 
19048
- /***/ 8691
19048
+ /***/ 9743
19049
19049
  (module, __webpack_exports__, __webpack_require__) {
19050
19050
 
19051
19051
  "use strict";
@@ -19208,6 +19208,8 @@ __webpack_unused_export__ = s.renderToPipeableStream;
19208
19208
  * Pattern to match component tags (PascalCase or snake_case)
19209
19209
  */
19210
19210
  const componentTagPattern = /<(\/?[A-Z][A-Za-z0-9_]*)([^>]*?)(\/?)>/g;
19211
+ /** A bare component name, the same shape `componentTagPattern` accepts inside `<…>`. */
19212
+ const componentNamePattern = /^[A-Z][A-Za-z0-9_]*$/;
19211
19213
  /**
19212
19214
  * MDAST flow (block-level) content types that cannot be represented
19213
19215
  * inside GFM table cells. Used to decide whether a table should be
@@ -96869,6 +96871,14 @@ function syntax_createTokenize(mode) {
96869
96871
  }
96870
96872
  // ── Tag detection inside body ──────────────────────────────────────────
96871
96873
  function bodyLessThan(code) {
96874
+ // A second `<` means legacy variable syntax (`<<var>>`), not a tag: the name that
96875
+ // follows belongs to the variable. Counting it as a nested opener would leave the
96876
+ // body unbalanced and lose the claim on this block.
96877
+ if (code === codes.lessThan) {
96878
+ effects.consume(code);
96879
+ atLineStart = false;
96880
+ return bodyAngleRun;
96881
+ }
96872
96882
  if (code === codes.slash) {
96873
96883
  if (onOpenerLine)
96874
96884
  openerLineCloses += 1;
@@ -96893,6 +96903,14 @@ function syntax_createTokenize(mode) {
96893
96903
  atLineStart = false;
96894
96904
  return body(code);
96895
96905
  }
96906
+ function bodyAngleRun(code) {
96907
+ if (code === codes.lessThan) {
96908
+ effects.consume(code);
96909
+ return bodyAngleRun;
96910
+ }
96911
+ atLineStart = false;
96912
+ return body(code);
96913
+ }
96896
96914
  // ── Nested opening tag ─────────────────────────────────────────────────
96897
96915
  function nestedOpenTagName(code) {
96898
96916
  if (code !== null &&
@@ -97113,11 +97131,61 @@ function mdxComponent() {
97113
97131
  ;// ./lib/micromark/mdx-expression-lenient/syntax.ts
97114
97132
 
97115
97133
 
97134
+
97135
+ /**
97136
+ * The flow constructs allowed to end a multiline run, per parser. Everything but `<`: a
97137
+ * `<Component>` on its own line is the very shape the flow construct exists to keep together.
97138
+ */
97139
+ const interrupters = new WeakMap();
97140
+ const flowInterrupters = (flow) => {
97141
+ let record = interrupters.get(flow);
97142
+ if (!record) {
97143
+ record = Object.fromEntries(Object.entries(flow).filter(([code]) => Number(code) !== codes.lessThan));
97144
+ interrupters.set(flow, record);
97145
+ }
97146
+ return record;
97147
+ };
97148
+ /**
97149
+ * Lookahead run at every line ending of a flow run, mirroring the paragraph continuation check
97150
+ * in `micromark-core-commonmark/lib/content.js`: `ok` when the next line continues the run,
97151
+ * `nok` when it would start a fenced code block, heading, or thematic break — which the run
97152
+ * must then leave alone rather than swallow. A blank line (including whitespace-only) ends the
97153
+ * run too, unless `blankContinues`: see `nestedLineContinues`.
97154
+ */
97155
+ function tokenizeLineContinues(blankContinues) {
97156
+ return function tokenize(effects, ok, nok) {
97157
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
97158
+ const self = this;
97159
+ return start;
97160
+ function start(code) {
97161
+ effects.enter(types_types.lineEnding);
97162
+ effects.consume(code);
97163
+ effects.exit(types_types.lineEnding);
97164
+ return factorySpace(effects, prefixed, types_types.linePrefix);
97165
+ }
97166
+ // The paragraph rule also exempts lines indented 4+ columns (indented code can't interrupt);
97167
+ // mdxish disables indented code, so an indented line may still start a block here.
97168
+ function prefixed(code) {
97169
+ if (code === codes.eof)
97170
+ return nok(code);
97171
+ if (markdownLineEnding(code))
97172
+ return blankContinues ? ok(code) : nok(code);
97173
+ return effects.interrupt(flowInterrupters(self.parser.constructs.flow), nok, ok)(code);
97174
+ }
97175
+ };
97176
+ }
97177
+ const lineContinues = { tokenize: tokenizeLineContinues(false), partial: true };
97178
+ /**
97179
+ * Inside an open `{`, `(` or `[` a blank line is JavaScript formatting (between statements in a
97180
+ * callback, inside a JSX branch), so it may not end the run. At depth zero it's far more likely
97181
+ * a prose paragraph break after a stray `{`, and ending the run there keeps the paragraphs apart.
97182
+ */
97183
+ const nestedLineContinues = { tokenize: tokenizeLineContinues(true), partial: true };
97116
97184
  /**
97117
- * Lenient MDX text-expression tokenizer (agnostic / no acorn).
97185
+ * Lenient MDX expression tokenizer (agnostic / no acorn).
97118
97186
  *
97119
97187
  * Matches a balanced `{ ... }` run — tracking nested braces and spanning soft
97120
- * line breaks — and emits the standard `mdxTextExpression*` tokens so the
97188
+ * line breaks — and emits the standard `mdx*Expression*` tokens so the
97121
97189
  * upstream `mdxExpressionFromMarkdown()` builds the node.
97122
97190
  *
97123
97191
  * Reimplements the official micromark mdxExpression, but an unbalanced brace that
@@ -97125,70 +97193,115 @@ function mdxComponent() {
97125
97193
  * and the `{` renders as literal text, making the pipeline forgiving of stray
97126
97194
  * braces that upstream would hard-error on.
97127
97195
  */
97128
- function tokenizeTextExpression(effects, ok, nok) {
97129
- let depth = 0;
97130
- return start;
97131
- function start(code) {
97132
- if (code !== codes.leftCurlyBrace)
97133
- return nok(code);
97134
- effects.enter('mdxTextExpression');
97135
- effects.enter('mdxTextExpressionMarker');
97136
- effects.consume(code);
97137
- effects.exit('mdxTextExpressionMarker');
97138
- return before;
97139
- }
97140
- function before(code) {
97141
- if (code === codes.eof) {
97142
- effects.exit('mdxTextExpression');
97143
- return nok(code);
97196
+ function tokenizeExpression(variant) {
97197
+ const isFlow = variant === 'mdxFlowExpression';
97198
+ return function tokenize(effects, ok, nok) {
97199
+ // Read eagerly: micromark calls `tokenize` with a fresh context per attempt, so this is the
97200
+ // value for this attempt, and the state functions below don't receive `this` at all.
97201
+ const { interrupt } = this;
97202
+ let depth = 0;
97203
+ let nesting = 0;
97204
+ let multiline = false;
97205
+ return start;
97206
+ function start(code) {
97207
+ if (code !== codes.leftCurlyBrace)
97208
+ return nok(code);
97209
+ // Never end a paragraph. A `{` continuing the line above is prose or a magic-block body
97210
+ // (`[block:callout]` puts one on the next line), not a block of its own.
97211
+ if (isFlow && interrupt)
97212
+ return nok(code);
97213
+ effects.enter(variant);
97214
+ effects.enter(`${variant}Marker`);
97215
+ effects.consume(code);
97216
+ effects.exit(`${variant}Marker`);
97217
+ return before;
97144
97218
  }
97145
- if (markdownLineEnding(code)) {
97146
- effects.enter('lineEnding');
97219
+ function before(code) {
97220
+ if (code === codes.eof)
97221
+ return end(code);
97222
+ if (markdownLineEnding(code)) {
97223
+ // A text run lives in a paragraph micromark has already bounded. A flow run bounds
97224
+ // itself: a blank line or an interrupting block ends it, so a stray `{` can't claim
97225
+ // the rest of the document, and `{\n\n}` stays two literal paragraphs.
97226
+ if (!isFlow)
97227
+ return lineEnding(code);
97228
+ return effects.check(depth > 0 || nesting > 0 ? nestedLineContinues : lineContinues, lineEnding, end)(code);
97229
+ }
97230
+ if (code === codes.rightCurlyBrace && depth === 0)
97231
+ return close(code);
97232
+ effects.enter(`${variant}Chunk`);
97233
+ return inside(code);
97234
+ }
97235
+ function lineEnding(code) {
97236
+ multiline = true;
97237
+ effects.enter(types_types.lineEnding);
97147
97238
  effects.consume(code);
97148
- effects.exit('lineEnding');
97239
+ effects.exit(types_types.lineEnding);
97149
97240
  return before;
97150
97241
  }
97151
- if (code === codes.rightCurlyBrace && depth === 0) {
97152
- return close(code);
97242
+ function end(code) {
97243
+ effects.exit(variant);
97244
+ return nok(code);
97153
97245
  }
97154
- effects.enter('mdxTextExpressionChunk');
97155
- return inside(code);
97156
- }
97157
- function inside(code) {
97158
- if (code === codes.eof || markdownLineEnding(code)) {
97159
- effects.exit('mdxTextExpressionChunk');
97160
- return before(code);
97246
+ function inside(code) {
97247
+ if (code === codes.eof || markdownLineEnding(code)) {
97248
+ effects.exit(`${variant}Chunk`);
97249
+ return before(code);
97250
+ }
97251
+ if (code === codes.rightCurlyBrace && depth === 0) {
97252
+ effects.exit(`${variant}Chunk`);
97253
+ return close(code);
97254
+ }
97255
+ if (code === codes.leftCurlyBrace)
97256
+ depth += 1;
97257
+ else if (code === codes.rightCurlyBrace)
97258
+ depth -= 1;
97259
+ else if (code === codes.leftParenthesis || code === codes.leftSquareBracket)
97260
+ nesting += 1;
97261
+ else if (code === codes.rightParenthesis || code === codes.rightSquareBracket)
97262
+ nesting -= 1;
97263
+ effects.consume(code);
97264
+ return inside;
97161
97265
  }
97162
- if (code === codes.rightCurlyBrace && depth === 0) {
97163
- effects.exit('mdxTextExpressionChunk');
97164
- return close(code);
97266
+ function close(code) {
97267
+ effects.enter(`${variant}Marker`);
97268
+ effects.consume(code);
97269
+ effects.exit(`${variant}Marker`);
97270
+ effects.exit(variant);
97271
+ if (!isFlow)
97272
+ return ok;
97273
+ // A run that closes on the line it opened stays a text expression inside its paragraph:
97274
+ // claiming it as flow would strip the `<p>` every standalone `{expr}` line renders with.
97275
+ return multiline ? after : nok;
97165
97276
  }
97166
- if (code === codes.leftCurlyBrace)
97167
- depth += 1;
97168
- else if (code === codes.rightCurlyBrace)
97169
- depth -= 1;
97170
- effects.consume(code);
97171
- return inside;
97172
- }
97173
- function close(code) {
97174
- effects.enter('mdxTextExpressionMarker');
97175
- effects.consume(code);
97176
- effects.exit('mdxTextExpressionMarker');
97177
- effects.exit('mdxTextExpression');
97178
- return ok;
97179
- }
97277
+ function after(code) {
97278
+ return markdownSpace(code) ? factorySpace(effects, lineEnd, types_types.whitespace)(code) : lineEnd(code);
97279
+ }
97280
+ function lineEnd(code) {
97281
+ return code === codes.eof || markdownLineEnding(code) ? ok(code) : nok(code);
97282
+ }
97283
+ };
97180
97284
  }
97181
97285
  function mdxExpressionLenient() {
97182
97286
  return {
97287
+ flow: {
97288
+ [codes.leftCurlyBrace]: {
97289
+ name: 'mdxFlowExpression',
97290
+ tokenize: tokenizeExpression('mdxFlowExpression'),
97291
+ },
97292
+ },
97183
97293
  text: {
97184
97294
  [codes.leftCurlyBrace]: {
97185
97295
  name: 'mdxTextExpression',
97186
- tokenize: tokenizeTextExpression,
97296
+ tokenize: tokenizeExpression('mdxTextExpression'),
97187
97297
  },
97188
97298
  },
97189
97299
  };
97190
97300
  }
97191
97301
 
97302
+ ;// ./lib/micromark/mdx-expression-lenient/index.ts
97303
+
97304
+
97192
97305
  ;// ./lib/micromark/mdxish-extensions.ts
97193
97306
 
97194
97307
 
@@ -101758,6 +101871,17 @@ const tablesToJsx = () => tree => {
101758
101871
  ;// ./processor/transform/tailwind.tsx
101759
101872
 
101760
101873
 
101874
+
101875
+
101876
+ /** Whitespace-only text is layout between blocks, not inline flow. */
101877
+ const isInlineContent = (node) => phrasing(node) && !(node.type === 'text' && node.value.trim() === '');
101878
+ /**
101879
+ * Whether the child at `index` sits in inline flow: its parent only allows
101880
+ * phrasing content (e.g. a paragraph), or it is flanked by phrasing siblings
101881
+ * (e.g. `<div>text <Image /> text</div>`, whose children skip the paragraph).
101882
+ */
101883
+ const isInlineInContext = (index, parent) => INLINE_ONLY_PARENT_TYPES.has(parent.type) ||
101884
+ parent.children.some((sibling, siblingIndex) => siblingIndex !== index && isInlineContent(sibling));
101761
101885
  const injectTailwindRoot = ({ components = {} }) => (node, index, parent) => {
101762
101886
  if (!('name' in node))
101763
101887
  return;
@@ -101766,7 +101890,7 @@ const injectTailwindRoot = ({ components = {} }) => (node, index, parent) => {
101766
101890
  if (!('children' in parent))
101767
101891
  return;
101768
101892
  const attrs = {
101769
- flow: node.type === 'mdxJsxFlowElement',
101893
+ flow: node.type === 'mdxJsxFlowElement' && !isInlineInContext(index, parent),
101770
101894
  };
101771
101895
  const wrapper = {
101772
101896
  type: node.type,
@@ -122671,6 +122795,111 @@ const parseTag = (value, opts = {}) => {
122671
122795
  };
122672
122796
  };
122673
122797
 
122798
+ ;// ./processor/transform/mdxish/variables-text.ts
122799
+
122800
+
122801
+ /**
122802
+ * Matches {user.<field>} patterns:
122803
+ * - {user.name}
122804
+ * - {user.email}
122805
+ * - {user['field']}
122806
+ * - {user["field"]}
122807
+ *
122808
+ * Captures the field name in group 1 (dot notation) or group 2 (bracket notation)
122809
+ */
122810
+ const USER_VAR_REGEX = /\{user\.(\w+)\}|\{user\[['"](\w+)['"]\]\}/g;
122811
+ /**
122812
+ * The lone `{user.<field>}` reference an expression node holds, or `null` when the node isn't an
122813
+ * expression or holds anything else (`{1 + 1}`, a CSS-looking body, two references in one brace).
122814
+ * Exported so promotion gates can tell a variable reference apart from an expression that must
122815
+ * stay literal.
122816
+ */
122817
+ function soleUserVariableExpression(node) {
122818
+ if (node.type !== 'mdxFlowExpression' && node.type !== 'mdxTextExpression')
122819
+ return null;
122820
+ const { value } = node;
122821
+ const wrapped = `{${(value ?? '').trim()}}`;
122822
+ const matches = [...wrapped.matchAll(USER_VAR_REGEX)];
122823
+ if (matches.length !== 1 || matches[0][0] !== wrapped)
122824
+ return null;
122825
+ return { name: matches[0][1] || matches[0][2], wrapped };
122826
+ }
122827
+ function makeVariableNode(varName, rawValue) {
122828
+ return {
122829
+ type: NodeTypes.variable,
122830
+ data: {
122831
+ hName: 'Variable',
122832
+ hProperties: { name: varName },
122833
+ },
122834
+ value: rawValue,
122835
+ };
122836
+ }
122837
+ /**
122838
+ * A remark plugin that parses {user.<field>} patterns from text nodes and
122839
+ * mdx expression nodes, creating Variable nodes for runtime resolution.
122840
+ *
122841
+ * Handles:
122842
+ * - `text` nodes: when safeMode is true or after expression evaluation
122843
+ * - `mdxTextExpression` nodes: when mdxExpression has parsed {user.*} before evaluation
122844
+ * - `mdxFlowExpression` nodes: when {user.*} appears on its own line (e.g. inside JSX table cells)
122845
+ *
122846
+ * Supports any user field: name, email, email_verified, exp, iat, etc.
122847
+ */
122848
+ function visitExpressionNode(node, index, parent) {
122849
+ if (index === undefined || !parent)
122850
+ return;
122851
+ const match = soleUserVariableExpression(node);
122852
+ if (!match)
122853
+ return;
122854
+ parent.children.splice(index, 1, makeVariableNode(match.name, match.wrapped));
122855
+ }
122856
+ const variablesTextTransformer = () => tree => {
122857
+ visit(tree, 'mdxTextExpression', (node, index, parent) => {
122858
+ visitExpressionNode(node, index, parent);
122859
+ });
122860
+ visit(tree, 'mdxFlowExpression', (node, index, parent) => {
122861
+ visitExpressionNode(node, index, parent);
122862
+ });
122863
+ visit(tree, 'text', (node, index, parent) => {
122864
+ if (index === undefined || !parent)
122865
+ return;
122866
+ // Skip if inside inline code
122867
+ if (parent.type === 'inlineCode')
122868
+ return;
122869
+ const text = node.value;
122870
+ if (typeof text !== 'string' || !text.trim())
122871
+ return;
122872
+ if (!text.includes('{user.') && !text.includes('{user['))
122873
+ return;
122874
+ const matches = [...text.matchAll(USER_VAR_REGEX)];
122875
+ if (matches.length === 0)
122876
+ return;
122877
+ const parts = [];
122878
+ let lastIndex = 0;
122879
+ matches.forEach(match => {
122880
+ const matchIndex = match.index ?? 0;
122881
+ // Add text before the match
122882
+ if (matchIndex > lastIndex) {
122883
+ parts.push({ type: 'text', value: text.slice(lastIndex, matchIndex) });
122884
+ }
122885
+ // Extract variable name from either capture group (dot or bracket notation)
122886
+ const varName = match[1] || match[2];
122887
+ parts.push(makeVariableNode(varName, match[0]));
122888
+ lastIndex = matchIndex + match[0].length;
122889
+ });
122890
+ // Add remaining text after last match
122891
+ if (lastIndex < text.length) {
122892
+ parts.push({ type: 'text', value: text.slice(lastIndex) });
122893
+ }
122894
+ // Replace node with parts
122895
+ if (parts.length > 1 || (parts.length === 1 && parts[0].type !== 'text')) {
122896
+ parent.children.splice(index, 1, ...parts);
122897
+ }
122898
+ });
122899
+ return tree;
122900
+ };
122901
+ /* harmony default export */ const variables_text = (variablesTextTransformer);
122902
+
122674
122903
  ;// ./processor/transform/mdxish/components/utils.ts
122675
122904
 
122676
122905
 
@@ -122748,19 +122977,15 @@ const NON_PROMOTABLE_PLAIN_TAGS = new Set([...htmlRawNames, ...tableTags, 'table
122748
122977
  const NESTED_TABLE_RE = /<table[\s>]/i;
122749
122978
  const isMarkdownPromotableHtmlTag = (tag) => !NON_PROMOTABLE_PLAIN_TAGS.has(tag);
122750
122979
  // Expression nodes count as plain so `<div>{1+1}</div>` keeps its current
122751
- // literal-brace behavior; variables/glossary already resolve inside raw html.
122752
- const PLAIN_CONTENT_TYPES = new Set([
122753
- 'paragraph',
122754
- 'text',
122755
- 'html',
122756
- 'mdxTextExpression',
122757
- 'mdxFlowExpression',
122758
- NodeTypes.variable,
122759
- NodeTypes.glossary,
122760
- ]);
122980
+ // literal-brace behavior — authors put CSS-shaped braces in these bodies, and only
122981
+ // a reference that names a real variable may resolve.
122982
+ const PLAIN_CONTENT_TYPES = new Set(['paragraph', 'text', 'html', 'mdxTextExpression', 'mdxFlowExpression']);
122761
122983
  // Promoting plain HTML is only worth bypassing rehype-raw's parse5 pass when
122762
- // the body parses into an actual markdown construct.
122984
+ // the body parses into an actual markdown construct. Variables and glossary terms
122985
+ // count: parse5 renders `<<var>>` as a stray `<` plus a `<var>` tag, so a body that
122986
+ // holds nothing else still has to be promoted to resolve.
122763
122987
  const containsMarkdownConstruct = (nodes) => nodes.some(node => !PLAIN_CONTENT_TYPES.has(node.type) ||
122988
+ soleUserVariableExpression(node) !== null ||
122764
122989
  ('children' in node && Array.isArray(node.children) && containsMarkdownConstruct(node.children)));
122765
122990
  /**
122766
122991
  * Index of the `</tag>` that balances the already-consumed opening tag (the
@@ -123526,6 +123751,7 @@ const evaluateExports = () => (tree, file) => {
123526
123751
 
123527
123752
 
123528
123753
 
123754
+
123529
123755
  const parseExpression = (expression) => jsxAcornParser.parse(expression, { ecmaVersion: 'latest', sourceType: 'module' });
123530
123756
  /**
123531
123757
  * Recursively report whether an estree value contains any JSX element or fragment node.
@@ -123542,22 +123768,16 @@ const containsJsxNode = (value) => {
123542
123768
  return true;
123543
123769
  return Object.values(value).some(containsJsxNode);
123544
123770
  };
123545
- /** Read the component name off a JSX element name node (`Foo`, `Foo.Bar`, `foo:Bar`). */
123546
123771
  const jsxElementName = (name) => {
123547
123772
  if (name === null || typeof name !== 'object')
123548
123773
  return undefined;
123549
123774
  const node = name;
123550
- if (node.type === 'JSXIdentifier')
123551
- return typeof node.name === 'string' ? node.name : undefined;
123552
- // `<Foo.Bar/>` and `<foo:Bar/>` resolve through their leftmost part.
123553
- if (node.type === 'JSXMemberExpression')
123554
- return jsxElementName(node.object);
123555
- if (node.type === 'JSXNamespacedName')
123556
- return jsxElementName(node.namespace);
123557
- return undefined;
123775
+ if (node.type !== 'JSXIdentifier' || typeof node.name !== 'string')
123776
+ return undefined;
123777
+ return componentNamePattern.test(node.name) ? node.name : undefined;
123558
123778
  };
123559
123779
  /**
123560
- * Collect the capitalized names an expression uses as JSX tags. Parsed rather than pattern
123780
+ * Collect the component names an expression uses as JSX tags. Parsed rather than pattern
123561
123781
  * matched: `{count < Max ? <Foo/> : <Bar/>}` puts a capitalized name straight after a `<` without
123562
123782
  * it being a tag, and only the parser can tell the two apart. Unparseable input yields nothing —
123563
123783
  * evaluation is about to throw on it anyway.
@@ -123581,8 +123801,7 @@ const jsxComponentNames = (expression) => {
123581
123801
  const node = value;
123582
123802
  if (node.type === 'JSXOpeningElement') {
123583
123803
  const name = jsxElementName(node.name);
123584
- // Lowercase tags compile to a string type, never a variable reference.
123585
- if (name && /^[A-Z]/.test(name))
123804
+ if (name)
123586
123805
  names.add(name);
123587
123806
  }
123588
123807
  Object.values(node).forEach(walk);
@@ -123722,7 +123941,8 @@ function renderFallbackHtml(element) {
123722
123941
  const rawNode = { type: 'raw', value: __WEBPACK_CJS_EXPORT_renderToStaticMarkup__(element) };
123723
123942
  return [rawNode];
123724
123943
  }
123725
- catch {
123944
+ catch (error) {
123945
+ console.warn('[mdxish] Could not render expression result:', error);
123726
123946
  return [];
123727
123947
  }
123728
123948
  }
@@ -123780,6 +124000,7 @@ function reactElementToHast(node) {
123780
124000
 
123781
124001
 
123782
124002
 
124003
+
123783
124004
  /**
123784
124005
  * Bind the components a given expression actually uses as tags. Scoped per expression on purpose:
123785
124006
  * binding the whole hash would shadow same-named globals (a `math` component would break
@@ -123808,17 +124029,28 @@ const isRenderable = (value) => {
123808
124029
  return true;
123809
124030
  return Array.isArray(value) && value.some(isRenderable);
123810
124031
  };
124032
+ const isPhrasingTag = (tagName) => lib_phrasing({ type: 'element', tagName, properties: {}, children: [] });
123811
124033
  /**
123812
- * Whether an expression evaluated to block-level content. Components count as block-level
123813
- * unless they're on the inline list, matching the assumption the rest of the component
123814
- * pipeline makes.
124034
+ * Whether an expression evaluated to block-level content. A capitalized tag is a component,
124035
+ * block-level unless it's on the inline list (so a `Table` component isn't mistaken for an inline
124036
+ * `<table>`); a lowercase tag is HTML, block-level unless it's phrasing content. A `raw` node is
124037
+ * HTML from `renderFallbackHtml`, so it's parsed and judged by the same rule.
123815
124038
  */
123816
124039
  const isBlockResult = (children) => children.some(child => {
124040
+ if (child.type === 'raw')
124041
+ return isBlockResult(fromHtml(child.value, { fragment: true }).children);
123817
124042
  if (child.type !== 'element' && child.type !== 'mdx-jsx')
123818
124043
  return false;
123819
124044
  const { tagName } = child;
123820
- return !STANDARD_HTML_TAGS.has(tagName.toLowerCase()) && !INLINE_COMPONENT_TAGS.has(tagName);
124045
+ return /^[A-Z]/.test(tagName) ? !INLINE_COMPONENT_TAGS.has(tagName) : !isPhrasingTag(tagName);
123821
124046
  });
124047
+ const JSX_ELEMENT_TYPES = new Set(['mdxJsxFlowElement', 'mdxJsxTextElement']);
124048
+ const wrapInParagraph = (child) => ({
124049
+ type: 'paragraph',
124050
+ children: [child],
124051
+ position: child.position,
124052
+ });
124053
+ const placeText = (text, needsBlock) => (needsBlock ? wrapInParagraph(text) : text);
123822
124054
  /** Turn a non-renderable evaluation result into a text node. */
123823
124055
  const createTextNode = (result, position) => {
123824
124056
  if (result === null || result === undefined)
@@ -123854,6 +124086,7 @@ const evaluateExpressions = ({ components, variables } = {}) => (tree, file) =>
123854
124086
  const expression = value?.trim();
123855
124087
  if (!expression)
123856
124088
  return;
124089
+ const needsBlock = expressionNode.type === 'mdxFlowExpression' && !JSX_ELEMENT_TYPES.has(parent.type);
123857
124090
  try {
123858
124091
  const scope = { ...componentScope(expression, components ?? {}), ...baseScope };
123859
124092
  const result = evalExpression(expression, scope);
@@ -123862,10 +124095,17 @@ const evaluateExpressions = ({ components, variables } = {}) => (tree, file) =>
123862
124095
  // passes through rehypeRaw/parse5 step later in the pipeline. This ensures that the
123863
124096
  // expression result is not parsed by parse5 and fragmenting the nesting that is valid JSX
123864
124097
  // but invalid HTML — e.g. an `<a>` wrapping `<a>`.
123865
- expressionNode.data = { ...expressionNode.data, hChildren: reactElementToHast(result) };
124098
+ const hChildren = reactElementToHast(result);
124099
+ expressionNode.data = { ...expressionNode.data, hChildren };
124100
+ // An inline result in a block slot renders inside a `<p>`, as its one-line form does.
124101
+ // Retyping it as a text expression makes it legal paragraph content.
124102
+ if (needsBlock && !isBlockResult(hChildren)) {
124103
+ const inline = { ...expressionNode, type: 'mdxTextExpression' };
124104
+ parent.children.splice(index, 1, wrapInParagraph(inline));
124105
+ }
123866
124106
  }
123867
124107
  else {
123868
- parent.children.splice(index, 1, createTextNode(result, position));
124108
+ parent.children.splice(index, 1, placeText(createTextNode(result, position), needsBlock));
123869
124109
  }
123870
124110
  }
123871
124111
  catch (_error) {
@@ -123873,7 +124113,8 @@ const evaluateExpressions = ({ components, variables } = {}) => (tree, file) =>
123873
124113
  // parser treats contents as code, so backslash escapes aren't applied;
123874
124114
  // restore them here so e.g. `{\!}` round-trips to `{!}`.
123875
124115
  const processed = expression.replace(/\\([!-/:-@[-`{-~])/g, '$1');
123876
- parent.children.splice(index, 1, { type: 'text', value: `{${processed}}`, position });
124116
+ const literal = { type: 'text', value: `{${processed}}`, position };
124117
+ parent.children.splice(index, 1, placeText(literal, needsBlock));
123877
124118
  }
123878
124119
  });
123879
124120
  // A text expression is parsed inside a paragraph, but its result can be block content: a
@@ -127006,12 +127247,20 @@ function removeJSXComments(content) {
127006
127247
  const OPAQUE_CONTAINERS = new Set(['pre', 'textarea', 'htmlblock']);
127007
127248
  /** The missing-slash typo shape: an attribute-less, non-self-closing opener. */
127008
127249
  const BARE_OPENER_SOURCE_RE = /^<[A-Za-z]+\s*>$/;
127009
- /** The opener shares its line with nothing but whitespace. */
127010
- const isAloneOnLine = (content, start, end) => {
127011
- const lineStart = content.lastIndexOf('\n', start - 1) + 1;
127250
+ /** The opener is immediately preceded by a complete tag, so the prefix is markup and not prose. */
127251
+ const PREFIX_ENDS_WITH_TAG_RE = /<[^<>]*>\s*$/;
127252
+ /**
127253
+ * The opener finishes its line, preceded by nothing but whitespace or by markup.
127254
+ * Requiring markup (not merely "something") keeps a markdown block prefix such as
127255
+ * a `>` quote marker from qualifying, while allowing the closer to trail a cell or
127256
+ * `</thead>` on a single-line table.
127257
+ */
127258
+ const endsLineAfterMarkup = (content, start, end) => {
127012
127259
  const lineEnd = content.indexOf('\n', end);
127013
- return (content.slice(lineStart, start).trim() === '' &&
127014
- content.slice(end, lineEnd === -1 ? content.length : lineEnd).trim() === '');
127260
+ if (content.slice(end, lineEnd === -1 ? content.length : lineEnd).trim() !== '')
127261
+ return false;
127262
+ const prefix = content.slice(content.lastIndexOf('\n', start - 1) + 1, start);
127263
+ return prefix.trim() === '' || PREFIX_ENDS_WITH_TAG_RE.test(prefix);
127015
127264
  };
127016
127265
  /**
127017
127266
  * Rewrites a bare `<table>` that is almost certainly a missing-slash closer
@@ -127019,7 +127268,7 @@ const isAloneOnLine = (content, start, end) => {
127019
127268
  * Customer docs (CX-3850) close tables with a second bare opener; without this,
127020
127269
  * the never-terminated HTML flow block swallows the markdown that follows.
127021
127270
  *
127022
- * A candidate is a bare opener alone on its line while a table is already open.
127271
+ * A candidate is a bare opener that finishes its line while a table is already open.
127023
127272
  * It is judged a typo only when its element ends implicitly (no explicit
127024
127273
  * `</table>`) without ever acquiring table-structure children — so genuine
127025
127274
  * nested tables, whatever precedes their rows, are left alone.
@@ -127048,7 +127297,7 @@ function repairMistakenTableClosers(content) {
127048
127297
  start,
127049
127298
  end,
127050
127299
  hasStructureChild: false,
127051
- isCandidate: stack.length > 0 && BARE_OPENER_SOURCE_RE.test(source) && isAloneOnLine(content, start, end),
127300
+ isCandidate: stack.length > 0 && BARE_OPENER_SOURCE_RE.test(source) && endsLineAfterMarkup(content, start, end),
127052
127301
  });
127053
127302
  }
127054
127303
  else if (opaqueDepth === 0 && tableTags.has(lower) && stack.length > 0) {
@@ -127460,97 +127709,6 @@ const variablesCodeResolver = ({ variables } = {}) => tree => {
127460
127709
  };
127461
127710
  /* harmony default export */ const variables_code = (variablesCodeResolver);
127462
127711
 
127463
- ;// ./processor/transform/mdxish/variables-text.ts
127464
-
127465
-
127466
- /**
127467
- * Matches {user.<field>} patterns:
127468
- * - {user.name}
127469
- * - {user.email}
127470
- * - {user['field']}
127471
- * - {user["field"]}
127472
- *
127473
- * Captures the field name in group 1 (dot notation) or group 2 (bracket notation)
127474
- */
127475
- const USER_VAR_REGEX = /\{user\.(\w+)\}|\{user\[['"](\w+)['"]\]\}/g;
127476
- function makeVariableNode(varName, rawValue) {
127477
- return {
127478
- type: NodeTypes.variable,
127479
- data: {
127480
- hName: 'Variable',
127481
- hProperties: { name: varName },
127482
- },
127483
- value: rawValue,
127484
- };
127485
- }
127486
- /**
127487
- * A remark plugin that parses {user.<field>} patterns from text nodes and
127488
- * mdx expression nodes, creating Variable nodes for runtime resolution.
127489
- *
127490
- * Handles:
127491
- * - `text` nodes: when safeMode is true or after expression evaluation
127492
- * - `mdxTextExpression` nodes: when mdxExpression has parsed {user.*} before evaluation
127493
- * - `mdxFlowExpression` nodes: when {user.*} appears on its own line (e.g. inside JSX table cells)
127494
- *
127495
- * Supports any user field: name, email, email_verified, exp, iat, etc.
127496
- */
127497
- function visitExpressionNode(node, index, parent) {
127498
- if (index === undefined || !parent)
127499
- return;
127500
- const wrapped = `{${(node.value ?? '').trim()}}`;
127501
- const matches = [...wrapped.matchAll(USER_VAR_REGEX)];
127502
- if (matches.length !== 1)
127503
- return;
127504
- const varName = matches[0][1] || matches[0][2];
127505
- parent.children.splice(index, 1, makeVariableNode(varName, wrapped));
127506
- }
127507
- const variablesTextTransformer = () => tree => {
127508
- visit(tree, 'mdxTextExpression', (node, index, parent) => {
127509
- visitExpressionNode(node, index, parent);
127510
- });
127511
- visit(tree, 'mdxFlowExpression', (node, index, parent) => {
127512
- visitExpressionNode(node, index, parent);
127513
- });
127514
- visit(tree, 'text', (node, index, parent) => {
127515
- if (index === undefined || !parent)
127516
- return;
127517
- // Skip if inside inline code
127518
- if (parent.type === 'inlineCode')
127519
- return;
127520
- const text = node.value;
127521
- if (typeof text !== 'string' || !text.trim())
127522
- return;
127523
- if (!text.includes('{user.') && !text.includes('{user['))
127524
- return;
127525
- const matches = [...text.matchAll(USER_VAR_REGEX)];
127526
- if (matches.length === 0)
127527
- return;
127528
- const parts = [];
127529
- let lastIndex = 0;
127530
- matches.forEach(match => {
127531
- const matchIndex = match.index ?? 0;
127532
- // Add text before the match
127533
- if (matchIndex > lastIndex) {
127534
- parts.push({ type: 'text', value: text.slice(lastIndex, matchIndex) });
127535
- }
127536
- // Extract variable name from either capture group (dot or bracket notation)
127537
- const varName = match[1] || match[2];
127538
- parts.push(makeVariableNode(varName, match[0]));
127539
- lastIndex = matchIndex + match[0].length;
127540
- });
127541
- // Add remaining text after last match
127542
- if (lastIndex < text.length) {
127543
- parts.push({ type: 'text', value: text.slice(lastIndex) });
127544
- }
127545
- // Replace node with parts
127546
- if (parts.length > 1 || (parts.length === 1 && parts[0].type !== 'text')) {
127547
- parent.children.splice(index, 1, ...parts);
127548
- }
127549
- });
127550
- return tree;
127551
- };
127552
- /* harmony default export */ const variables_text = (variablesTextTransformer);
127553
-
127554
127712
  ;// ./lib/utils/mdxish/mdxish-load-components.ts
127555
127713
 
127556
127714
 
@@ -128865,7 +129023,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"*":["about","acceptCharset","accessK
128865
129023
  /******/ // startup
128866
129024
  /******/ // Load entry module and return exports
128867
129025
  /******/ // This entry module used 'module' so it can't be inlined
128868
- /******/ let __webpack_exports__ = __webpack_require__(8691);
129026
+ /******/ let __webpack_exports__ = __webpack_require__(9743);
128869
129027
  /******/ module.exports = __webpack_exports__;
128870
129028
  /******/
128871
129029
  /******/ })()