@readme/markdown 14.11.3 → 14.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Tabs/index.tsx +9 -2
- package/dist/339.node.js +2 -2
- package/dist/486.node.js +4 -4
- package/dist/main.js +470 -150
- package/dist/main.node.js +470 -150
- package/dist/main.node.js.map +1 -1
- package/dist/processor/transform/mdxish/react-element-to-hast.d.ts +8 -0
- package/dist/processor/transform/mdxish/tables/escape-crossing-emphasis.d.ts +15 -0
- package/dist/processor/transform/mdxish/tables/remap-positions.d.ts +3 -5
- package/dist/processor/transform/mdxish/tables/split-nested-tables.d.ts +11 -0
- package/dist/processor/utils.d.ts +7 -0
- package/dist/render-fixture.node.js +468 -148
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +1 -1
package/dist/main.node.js
CHANGED
|
@@ -25257,10 +25257,10 @@ const Tabs = ({ children }) => {
|
|
|
25257
25257
|
const tabs = external_react_default().Children.toArray(children);
|
|
25258
25258
|
return (external_react_default().createElement("div", { className: "TabGroup" },
|
|
25259
25259
|
external_react_default().createElement("header", null,
|
|
25260
|
-
external_react_default().createElement("nav", { className: "TabGroup-nav" }, tabs.map((tab, index) => (external_react_default().createElement("button", { key: tab.
|
|
25260
|
+
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) },
|
|
25261
25261
|
tab.props.icon && (external_react_default().createElement(components_Icon, { className: "TabGroup-icon", icon: tab.props.icon, iconColor: tab.props.iconColor })),
|
|
25262
25262
|
tab.props.title))))),
|
|
25263
|
-
external_react_default().createElement("section", null, tabs
|
|
25263
|
+
external_react_default().createElement("section", null, tabs.map((tab, index) => (external_react_default().createElement("div", { key: tab.key, hidden: index !== activeTab }, tab))))));
|
|
25264
25264
|
};
|
|
25265
25265
|
/* harmony default export */ const components_Tabs = (Tabs);
|
|
25266
25266
|
|
|
@@ -74751,6 +74751,21 @@ function evaluate(source, scope = {}) {
|
|
|
74751
74751
|
// eslint-disable-next-line no-new-func
|
|
74752
74752
|
return new Function(...names, `return (${source})`)(...values);
|
|
74753
74753
|
}
|
|
74754
|
+
/**
|
|
74755
|
+
* Advance a `Point` by the `consumed` substring that follows it, returning the
|
|
74756
|
+
* point at the consumed string's end. Lets split-out sub-nodes carry accurate
|
|
74757
|
+
* document positions so downstream offset shifting stays correct.
|
|
74758
|
+
*/
|
|
74759
|
+
const pointAfter = (start, consumed) => {
|
|
74760
|
+
const newlineIndex = consumed.lastIndexOf('\n');
|
|
74761
|
+
const newlineCount = newlineIndex === -1 ? 0 : consumed.split('\n').length - 1;
|
|
74762
|
+
return {
|
|
74763
|
+
line: start.line + newlineCount,
|
|
74764
|
+
// Same line → advance the base column; a later line → column is the run since its newline.
|
|
74765
|
+
column: newlineCount === 0 ? start.column + consumed.length : consumed.length - newlineIndex,
|
|
74766
|
+
offset: (start.offset ?? 0) + consumed.length,
|
|
74767
|
+
};
|
|
74768
|
+
};
|
|
74754
74769
|
/**
|
|
74755
74770
|
* Formats the hProperties of a node as a string, so they can be compiled back into JSX/MDX.
|
|
74756
74771
|
* This currently sets all the values to a string since we process/compile the MDX on the fly
|
|
@@ -96019,6 +96034,108 @@ const applyInserts = (html, inserts) => {
|
|
|
96019
96034
|
return { value: out + html.slice(cursor), inserts: sorted };
|
|
96020
96035
|
};
|
|
96021
96036
|
|
|
96037
|
+
;// ./processor/transform/mdxish/tables/escape-crossing-emphasis.ts
|
|
96038
|
+
|
|
96039
|
+
|
|
96040
|
+
|
|
96041
|
+
// Maximal run of a single emphasis delimiter (`_`, `*`, `**`, `***`, …).
|
|
96042
|
+
const EMPHASIS_RUN_RE = /([*_])\1*/g;
|
|
96043
|
+
// String bounds (undefined) count as whitespace, not punctuation, per the
|
|
96044
|
+
// CommonMark flanking definition.
|
|
96045
|
+
const escape_crossing_emphasis_isWhitespace = (ch) => ch === undefined || unicodeWhitespace(ch.charCodeAt(0));
|
|
96046
|
+
const isPunctuation = (ch) => ch !== undefined && unicodePunctuation(ch.charCodeAt(0));
|
|
96047
|
+
/**
|
|
96048
|
+
* Whether a delimiter run can open and/or close emphasis, per CommonMark's
|
|
96049
|
+
* left/right-flanking rules. The extra `_` conditions forbid intraword
|
|
96050
|
+
* emphasis, which keeps `snake_case` from being treated as a delimiter.
|
|
96051
|
+
*/
|
|
96052
|
+
const analyzeFlanking = (source, char, start, end) => {
|
|
96053
|
+
const before = source[start - 1];
|
|
96054
|
+
const after = source[end];
|
|
96055
|
+
const leftFlanking = !escape_crossing_emphasis_isWhitespace(after) && (!isPunctuation(after) || escape_crossing_emphasis_isWhitespace(before) || isPunctuation(before));
|
|
96056
|
+
const rightFlanking = !escape_crossing_emphasis_isWhitespace(before) && (!isPunctuation(before) || escape_crossing_emphasis_isWhitespace(after) || isPunctuation(after));
|
|
96057
|
+
if (char === '_') {
|
|
96058
|
+
return {
|
|
96059
|
+
canOpen: leftFlanking && (!rightFlanking || isPunctuation(before)),
|
|
96060
|
+
canClose: rightFlanking && (!leftFlanking || isPunctuation(after)),
|
|
96061
|
+
};
|
|
96062
|
+
}
|
|
96063
|
+
return { canOpen: leftFlanking, canClose: rightFlanking };
|
|
96064
|
+
};
|
|
96065
|
+
/**
|
|
96066
|
+
* Collect HTML tag boundaries (via htmlparser2) and emphasis delimiter runs
|
|
96067
|
+
* (via regex over the masked source, so code spans and escaped `<` are skipped)
|
|
96068
|
+
* into one list ordered by position. At a shared offset a tag opener sorts
|
|
96069
|
+
* before a closer, so a self-closing tag brackets rather than swallows a run.
|
|
96070
|
+
*/
|
|
96071
|
+
const collectEvents = (html) => {
|
|
96072
|
+
const masked = maskNonTagRegions(html);
|
|
96073
|
+
const events = [];
|
|
96074
|
+
walkTags(html, {
|
|
96075
|
+
onOpen: ({ start }) => events.push({ kind: 'tagOpen', offset: start }),
|
|
96076
|
+
onClose: ({ start }) => events.push({ kind: 'tagClose', offset: start }),
|
|
96077
|
+
});
|
|
96078
|
+
EMPHASIS_RUN_RE.lastIndex = 0;
|
|
96079
|
+
let match;
|
|
96080
|
+
while ((match = EMPHASIS_RUN_RE.exec(masked)) !== null) {
|
|
96081
|
+
const [run, char] = match;
|
|
96082
|
+
const start = match.index;
|
|
96083
|
+
// eslint-disable-next-line no-continue
|
|
96084
|
+
if (html[start - 1] === '\\')
|
|
96085
|
+
continue; // already escaped
|
|
96086
|
+
events.push({ kind: 'emphasis', offset: start, char, length: run.length, flanking: analyzeFlanking(html, char, start, start + run.length) });
|
|
96087
|
+
}
|
|
96088
|
+
return events.sort((a, b) => a.offset - b.offset || (a.kind === 'tagClose' ? 1 : 0) - (b.kind === 'tagClose' ? 1 : 0));
|
|
96089
|
+
};
|
|
96090
|
+
/**
|
|
96091
|
+
* mdxjs rejects a table when a markdown emphasis run opens at one HTML
|
|
96092
|
+
* tag-nesting depth and closes at another — e.g. `_<ul><li>text_</li></ul>`,
|
|
96093
|
+
* where the `_` opens outside the list but closes inside a `<li>`. It throws
|
|
96094
|
+
* "Expected a closing tag for `<li>` before the end of `emphasis`" and the
|
|
96095
|
+
* whole `<Table>` fails to parse.
|
|
96096
|
+
*
|
|
96097
|
+
* We walk tags and emphasis together, tracking tag depth and a stack of open
|
|
96098
|
+
* emphasis. A delimiter only closes an opener at the same depth; any emphasis
|
|
96099
|
+
* still open when its enclosing tag closes (or at end of input), and any closer
|
|
96100
|
+
* with no same-depth opener, is escaped so mdxjs treats it as literal text.
|
|
96101
|
+
* Scoped to the malformed-retry path.
|
|
96102
|
+
*/
|
|
96103
|
+
const escapeCrossingEmphasis = (html) => {
|
|
96104
|
+
const open = [];
|
|
96105
|
+
const orphans = [];
|
|
96106
|
+
let depth = 0;
|
|
96107
|
+
collectEvents(html).forEach(event => {
|
|
96108
|
+
if (event.kind === 'tagOpen') {
|
|
96109
|
+
depth += 1;
|
|
96110
|
+
return;
|
|
96111
|
+
}
|
|
96112
|
+
if (event.kind === 'tagClose') {
|
|
96113
|
+
depth -= 1;
|
|
96114
|
+
// Emphasis opened deeper than the surviving depth was inside the tag that
|
|
96115
|
+
// just closed, so it crosses the boundary.
|
|
96116
|
+
while (open.length > 0 && open[open.length - 1].depth > depth) {
|
|
96117
|
+
const crossed = open.pop();
|
|
96118
|
+
if (crossed)
|
|
96119
|
+
orphans.push(crossed);
|
|
96120
|
+
}
|
|
96121
|
+
return;
|
|
96122
|
+
}
|
|
96123
|
+
const top = open[open.length - 1];
|
|
96124
|
+
if (event.flanking.canClose && top?.char === event.char && top.depth === depth) {
|
|
96125
|
+
open.pop();
|
|
96126
|
+
}
|
|
96127
|
+
else if (event.flanking.canOpen) {
|
|
96128
|
+
open.push({ char: event.char, depth, offset: event.offset, length: event.length });
|
|
96129
|
+
}
|
|
96130
|
+
else if (event.flanking.canClose) {
|
|
96131
|
+
orphans.push({ offset: event.offset, length: event.length });
|
|
96132
|
+
}
|
|
96133
|
+
});
|
|
96134
|
+
orphans.push(...open); // anything still open never closed
|
|
96135
|
+
const inserts = orphans.flatMap(({ offset, length }) => Array.from({ length }, (_unused, i) => ({ offset: offset + i, text: '\\' })));
|
|
96136
|
+
return applyInserts(html, inserts);
|
|
96137
|
+
};
|
|
96138
|
+
|
|
96022
96139
|
;// ./processor/transform/mdxish/tables/escape-stray-less-than.ts
|
|
96023
96140
|
|
|
96024
96141
|
|
|
@@ -96171,6 +96288,21 @@ const buildOffsetMapper = (inserts) => {
|
|
|
96171
96288
|
return repaired - shift;
|
|
96172
96289
|
};
|
|
96173
96290
|
};
|
|
96291
|
+
/**
|
|
96292
|
+
* Compose the per-repair offset mappers into one that maps an offset in the
|
|
96293
|
+
* fully-repaired string back to the original. `layers` are in application
|
|
96294
|
+
* order; each maps its own output space to its input space, so we apply them
|
|
96295
|
+
* last-repair-first to peel every edit back to the original coordinates.
|
|
96296
|
+
*/
|
|
96297
|
+
const composeOffsetMapper = (layers) => {
|
|
96298
|
+
const mappers = layers.map(buildOffsetMapper);
|
|
96299
|
+
return (repaired) => {
|
|
96300
|
+
let offset = repaired;
|
|
96301
|
+
for (let i = mappers.length - 1; i >= 0; i -= 1)
|
|
96302
|
+
offset = mappers[i](offset);
|
|
96303
|
+
return offset;
|
|
96304
|
+
};
|
|
96305
|
+
};
|
|
96174
96306
|
/**
|
|
96175
96307
|
* Map an offset in `source` to its 1-based `{ line, column }`. `lineStarts`
|
|
96176
96308
|
* is the precomputed array of offsets where each line begins.
|
|
@@ -96198,14 +96330,11 @@ const computeLineStarts = (source) => {
|
|
|
96198
96330
|
};
|
|
96199
96331
|
/**
|
|
96200
96332
|
* Walk `tree`, translating every node's position from the repaired source's
|
|
96201
|
-
* coordinate space back to the original source
|
|
96202
|
-
*
|
|
96203
|
-
*
|
|
96333
|
+
* coordinate space back to the original source via `mapOffset`. Line/column
|
|
96334
|
+
* are recomputed from the original source so they remain accurate even if
|
|
96335
|
+
* repairs introduced newlines.
|
|
96204
96336
|
*/
|
|
96205
|
-
const
|
|
96206
|
-
if (inserts.length === 0)
|
|
96207
|
-
return;
|
|
96208
|
-
const mapOffset = buildOffsetMapper(inserts);
|
|
96337
|
+
const remapWithMapper = (tree, originalSource, mapOffset) => {
|
|
96209
96338
|
const lineStarts = computeLineStarts(originalSource);
|
|
96210
96339
|
visit(tree, child => {
|
|
96211
96340
|
if (child.position?.start) {
|
|
@@ -96224,6 +96353,15 @@ const remapPositionsToOriginal = (tree, originalSource, inserts) => {
|
|
|
96224
96353
|
}
|
|
96225
96354
|
});
|
|
96226
96355
|
};
|
|
96356
|
+
/**
|
|
96357
|
+
* Remap positions produced after a chain of repairs (each applied to the prior
|
|
96358
|
+
* one's output) back to the original source coordinates.
|
|
96359
|
+
*/
|
|
96360
|
+
const remapPositionsThroughLayers = (tree, originalSource, layers) => {
|
|
96361
|
+
if (layers.length === 0)
|
|
96362
|
+
return;
|
|
96363
|
+
remapWithMapper(tree, originalSource, composeOffsetMapper(layers));
|
|
96364
|
+
};
|
|
96227
96365
|
|
|
96228
96366
|
;// ./processor/transform/mdxish/tables/repair-expression-escapes.ts
|
|
96229
96367
|
|
|
@@ -96523,6 +96661,83 @@ const repairUnclosedTags = (html) => {
|
|
|
96523
96661
|
return applyInserts(html, inserts);
|
|
96524
96662
|
};
|
|
96525
96663
|
|
|
96664
|
+
;// ./processor/transform/mdxish/tables/split-nested-tables.ts
|
|
96665
|
+
|
|
96666
|
+
|
|
96667
|
+
const TOP_LEVEL_TABLE_TAG_RE = /^<(?:table|Table)(?=[\s/>])/;
|
|
96668
|
+
/**
|
|
96669
|
+
* Find every balanced, depth-matched `<table>…</table>` range in an html string.
|
|
96670
|
+
* Uses `walkTags` so `<table>`s inside code spans / fenced blocks (masked away)
|
|
96671
|
+
* are never matched.
|
|
96672
|
+
*
|
|
96673
|
+
* Note: An implicitly-closed table (no `</table>`, so htmlparser2 synthesizes the
|
|
96674
|
+
* close at a later tag) is skipped: splitting there would swallow whatever
|
|
96675
|
+
* followed the table into the fragment and drop it, so we leave such a node
|
|
96676
|
+
* whole for downstream raw-HTML handling instead.
|
|
96677
|
+
*/
|
|
96678
|
+
const findTableRanges = (html) => {
|
|
96679
|
+
const ranges = [];
|
|
96680
|
+
let depth = 0;
|
|
96681
|
+
let start = 0;
|
|
96682
|
+
walkTags(html, {
|
|
96683
|
+
onOpen: ({ name, start: openStart, isStrayCloser }) => {
|
|
96684
|
+
if (name.toLowerCase() !== 'table' || isStrayCloser)
|
|
96685
|
+
return;
|
|
96686
|
+
if (depth === 0)
|
|
96687
|
+
start = openStart;
|
|
96688
|
+
depth += 1;
|
|
96689
|
+
},
|
|
96690
|
+
onClose: ({ name, end, implicit }) => {
|
|
96691
|
+
if (implicit || name.toLowerCase() !== 'table' || depth === 0)
|
|
96692
|
+
return;
|
|
96693
|
+
depth -= 1;
|
|
96694
|
+
if (depth === 0)
|
|
96695
|
+
ranges.push({ start, end });
|
|
96696
|
+
},
|
|
96697
|
+
});
|
|
96698
|
+
return ranges;
|
|
96699
|
+
};
|
|
96700
|
+
/**
|
|
96701
|
+
* Given an HTML node that might contain table sequences inside it, split
|
|
96702
|
+
* the node based on the table boundaries so they become a top level node.
|
|
96703
|
+
*
|
|
96704
|
+
* The surrounding raw HTML (the wrapper's open/close tags) would be re-nested
|
|
96705
|
+
* around the parsed tables by rehype-raw.
|
|
96706
|
+
*
|
|
96707
|
+
* Returns null when there is no wrapped table to extract.
|
|
96708
|
+
*/
|
|
96709
|
+
const splitHtmlWithNestedTables = (node) => {
|
|
96710
|
+
const { value } = node;
|
|
96711
|
+
// This is a top-level table, so we don't need to split it
|
|
96712
|
+
if (TOP_LEVEL_TABLE_TAG_RE.test(value))
|
|
96713
|
+
return null;
|
|
96714
|
+
// No table text anywhere in the value → skip the htmlparser2 walk entirely.
|
|
96715
|
+
if (!/<\/?table/i.test(value))
|
|
96716
|
+
return null;
|
|
96717
|
+
const ranges = findTableRanges(value);
|
|
96718
|
+
if (ranges.length === 0)
|
|
96719
|
+
return null;
|
|
96720
|
+
const base = node.position?.start;
|
|
96721
|
+
const sliceToHtml = (from, to) => ({
|
|
96722
|
+
type: 'html',
|
|
96723
|
+
value: value.slice(from, to),
|
|
96724
|
+
...(base && {
|
|
96725
|
+
position: { start: pointAfter(base, value.slice(0, from)), end: pointAfter(base, value.slice(0, to)) },
|
|
96726
|
+
}),
|
|
96727
|
+
});
|
|
96728
|
+
const parts = [];
|
|
96729
|
+
let cursor = 0;
|
|
96730
|
+
ranges.forEach(({ start, end }) => {
|
|
96731
|
+
if (start > cursor)
|
|
96732
|
+
parts.push(sliceToHtml(cursor, start));
|
|
96733
|
+
parts.push(sliceToHtml(start, end)); // starts with `<table` → picked up by the main pass
|
|
96734
|
+
cursor = end;
|
|
96735
|
+
});
|
|
96736
|
+
if (cursor < value.length)
|
|
96737
|
+
parts.push(sliceToHtml(cursor, value.length));
|
|
96738
|
+
return parts;
|
|
96739
|
+
};
|
|
96740
|
+
|
|
96526
96741
|
;// ./processor/transform/mdxish/tables/mdxish-tables.ts
|
|
96527
96742
|
|
|
96528
96743
|
|
|
@@ -96544,6 +96759,8 @@ const repairUnclosedTags = (html) => {
|
|
|
96544
96759
|
|
|
96545
96760
|
|
|
96546
96761
|
|
|
96762
|
+
|
|
96763
|
+
|
|
96547
96764
|
|
|
96548
96765
|
|
|
96549
96766
|
|
|
@@ -96573,6 +96790,21 @@ const buildTableNodeProcessor = (withMdx) => unified()
|
|
|
96573
96790
|
.use(remarkGfm);
|
|
96574
96791
|
const tableNodeProcessor = buildTableNodeProcessor(true);
|
|
96575
96792
|
const fallbackTableNodeProcessor = buildTableNodeProcessor(false);
|
|
96793
|
+
// Targeted repairs for tables mdxjs rejects, tried cumulatively (each runs on
|
|
96794
|
+
// the prior's output) since one table can carry independent per-cell defects.
|
|
96795
|
+
// Each was added after seeing real customer content fail to parse:
|
|
96796
|
+
// - repairUnclosedTags: unclosed/orphan HTML tags
|
|
96797
|
+
// - normalizeTagSpacing: a line mixing text and an opening tag
|
|
96798
|
+
// - repairExpressionEscapes: backslash escapes inside a `{…}` expression
|
|
96799
|
+
// - escapeStrayLessThan: a `<` that doesn't begin a valid tag (`word <`)
|
|
96800
|
+
// - escapeCrossingEmphasis: emphasis opening/closing at different tag depths
|
|
96801
|
+
const tableRepairs = [
|
|
96802
|
+
repairUnclosedTags,
|
|
96803
|
+
normalizeTagSpacing,
|
|
96804
|
+
repairExpressionEscapes,
|
|
96805
|
+
escapeStrayLessThan,
|
|
96806
|
+
escapeCrossingEmphasis,
|
|
96807
|
+
];
|
|
96576
96808
|
/**
|
|
96577
96809
|
* Parse the HTML node that contains the full table substring
|
|
96578
96810
|
* into the table parts (headers, rows, cells).
|
|
@@ -96588,10 +96820,10 @@ const parseTableNode = (processor, node, repair) => {
|
|
|
96588
96820
|
return undefined;
|
|
96589
96821
|
}
|
|
96590
96822
|
// If `node.value` was repaired before parsing, first remap positions back to
|
|
96591
|
-
// the original (unrepaired) coordinates via the insert
|
|
96823
|
+
// the original (unrepaired) coordinates via the insert layers — otherwise the
|
|
96592
96824
|
// shift would land on synthetic characters and be inaccurate
|
|
96593
96825
|
if (repair) {
|
|
96594
|
-
|
|
96826
|
+
remapPositionsThroughLayers(parsed, repair.originalSource, repair.layers);
|
|
96595
96827
|
}
|
|
96596
96828
|
// The subparser produces positions relative to `node.value`; shift them by
|
|
96597
96829
|
// the outer node's offset/line so consumers can slice the full source.
|
|
@@ -96688,9 +96920,7 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
96688
96920
|
visit(node, isMDXElement, (child) => {
|
|
96689
96921
|
if (child.name === 'thead')
|
|
96690
96922
|
hasThead = true;
|
|
96691
|
-
if (tableTags.has(child.name) &&
|
|
96692
|
-
Array.isArray(child.attributes) &&
|
|
96693
|
-
child.attributes.length > 0) {
|
|
96923
|
+
if (tableTags.has(child.name) && Array.isArray(child.attributes) && child.attributes.length > 0) {
|
|
96694
96924
|
hasStructuralAttributes = true;
|
|
96695
96925
|
}
|
|
96696
96926
|
});
|
|
@@ -96801,6 +97031,26 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
96801
97031
|
};
|
|
96802
97032
|
parent.children[index] = mdNode;
|
|
96803
97033
|
};
|
|
97034
|
+
/**
|
|
97035
|
+
* Apply `tableRepairs` cumulatively, re-parsing after every change and stopping
|
|
97036
|
+
* once the accumulated result parses. Each layer's inserts are relative to the
|
|
97037
|
+
* string that repair received, so they stay ordered for position remapping.
|
|
97038
|
+
*/
|
|
97039
|
+
const repairAndReparse = (node) => {
|
|
97040
|
+
let repairedValue = node.value;
|
|
97041
|
+
const layers = [];
|
|
97042
|
+
let parsed;
|
|
97043
|
+
tableRepairs.some(repair => {
|
|
97044
|
+
const { value, inserts } = repair(repairedValue);
|
|
97045
|
+
if (value === repairedValue)
|
|
97046
|
+
return false;
|
|
97047
|
+
repairedValue = value;
|
|
97048
|
+
layers.push(inserts);
|
|
97049
|
+
parsed = parseTableNode(tableNodeProcessor, { ...node, value: repairedValue }, { layers, originalSource: node.value });
|
|
97050
|
+
return Boolean(parsed);
|
|
97051
|
+
});
|
|
97052
|
+
return parsed;
|
|
97053
|
+
};
|
|
96804
97054
|
/**
|
|
96805
97055
|
* Converts JSX Table elements to markdown table nodes and re-parses markdown in cells.
|
|
96806
97056
|
*
|
|
@@ -96813,42 +97063,30 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
96813
97063
|
* is kept as a JSX <Table> element so that remarkRehype can properly handle the flow content.
|
|
96814
97064
|
*/
|
|
96815
97065
|
const mdxishTables = () => tree => {
|
|
97066
|
+
// Pre-pass: lift `<table>`s wrapped in a raw HTML block out into their own
|
|
97067
|
+
// html nodes so the main pass below treats them like top-level tables.
|
|
97068
|
+
visit(tree, 'html', (_node, index, parent) => {
|
|
97069
|
+
const node = _node;
|
|
97070
|
+
if (typeof index !== 'number' || !parent || !('children' in parent))
|
|
97071
|
+
return;
|
|
97072
|
+
const parts = splitHtmlWithNestedTables(node);
|
|
97073
|
+
if (!parts)
|
|
97074
|
+
return;
|
|
97075
|
+
// The inserted parts can't re-trigger a split (table parts start with
|
|
97076
|
+
// `<table`; the wrapper slices hold no table), so plain in-place splicing
|
|
97077
|
+
// visits each once without looping.
|
|
97078
|
+
parent.children.splice(index, 1, ...parts);
|
|
97079
|
+
});
|
|
96816
97080
|
visit(tree, 'html', (_node, index, parent) => {
|
|
96817
97081
|
const node = _node;
|
|
96818
97082
|
if (typeof index !== 'number' || !parent || !('children' in parent))
|
|
96819
97083
|
return;
|
|
96820
97084
|
if (!node.value.startsWith('<Table') && !node.value.startsWith('<table'))
|
|
96821
97085
|
return;
|
|
96822
|
-
// Main logic to transform table node to its parts
|
|
96823
97086
|
// Because the processor uses remarkMdx, it is stricter in what it accepts
|
|
96824
|
-
// and only accepts valid MDX syntax
|
|
96825
|
-
//
|
|
96826
|
-
|
|
96827
|
-
if (!parsed) {
|
|
96828
|
-
// Try a sequence of targeted repairs and re-parse
|
|
96829
|
-
// after each, stopping at the first that yields a parseable tree:
|
|
96830
|
-
// - repairUnclosedTags: unclosed/orphan HTML tags
|
|
96831
|
-
// - normalizeTagSpacing: a line mixing text and an opening tag
|
|
96832
|
-
// (e.g. `text <div> \n <div> text`)
|
|
96833
|
-
// - repairExpressionEscapes: backslash escapes inside a `{…}` expression
|
|
96834
|
-
// - escapeStrayLessThan: a `<` that doesn't begin a valid tag
|
|
96835
|
-
// (e.g. `word <`, `a <1>`)
|
|
96836
|
-
// These repairs are created after seeing real customer content that has failed to parse
|
|
96837
|
-
const repairs = [
|
|
96838
|
-
repairUnclosedTags,
|
|
96839
|
-
normalizeTagSpacing,
|
|
96840
|
-
repairExpressionEscapes,
|
|
96841
|
-
escapeStrayLessThan,
|
|
96842
|
-
];
|
|
96843
|
-
// Stops at the first repair that yields a parseable tree
|
|
96844
|
-
repairs.some(repair => {
|
|
96845
|
-
const { value, inserts } = repair(node.value);
|
|
96846
|
-
if (value !== node.value) {
|
|
96847
|
-
parsed = parseTableNode(tableNodeProcessor, { ...node, value }, { inserts, originalSource: node.value });
|
|
96848
|
-
}
|
|
96849
|
-
return Boolean(parsed);
|
|
96850
|
-
});
|
|
96851
|
-
}
|
|
97087
|
+
// and only accepts valid MDX syntax in the table node. To get around that,
|
|
97088
|
+
// fall back to the cumulative repairs when the first parse fails.
|
|
97089
|
+
const parsed = parseTableNode(tableNodeProcessor, node) ?? repairAndReparse(node);
|
|
96852
97090
|
if (parsed) {
|
|
96853
97091
|
// If the table is parsed successfully, we can now process it further
|
|
96854
97092
|
// to build on the markdown / JSX table
|
|
@@ -119137,11 +119375,10 @@ const rehypeMdxishComponents = ({ components, processMarkdown }) => {
|
|
|
119137
119375
|
;// ./processor/plugin/mdxish-handlers.ts
|
|
119138
119376
|
|
|
119139
119377
|
|
|
119140
|
-
//
|
|
119141
|
-
|
|
119142
|
-
|
|
119143
|
-
|
|
119144
|
-
});
|
|
119378
|
+
// If hChildren is populated, it means the node holds a renderable value (e.g. React)
|
|
119379
|
+
// See evaluate-expressions.ts for more details
|
|
119380
|
+
// Otherwise, it's a simple value and we fall back to text
|
|
119381
|
+
const mdxExpressionHandler = (_state, node) => node.data?.hChildren ?? { type: 'text', value: node.value || '' };
|
|
119145
119382
|
// Convert MDX JSX elements to a custom mdx-jsx hast node that bypasses rehypeRaw's
|
|
119146
119383
|
// HTML serialization round-trip; downstream normalization rewrites it to `element`.
|
|
119147
119384
|
const mdxJsxElementHandler = (state, node) => {
|
|
@@ -122208,6 +122445,7 @@ const mdxishInlineMdxComponents = () => tree => {
|
|
|
122208
122445
|
|
|
122209
122446
|
|
|
122210
122447
|
|
|
122448
|
+
|
|
122211
122449
|
/** Matches a JSX attribute expression (e.g. `key={i}`) anywhere in a string. */
|
|
122212
122450
|
const NESTED_ATTR_EXPRESSION_RE = /[\w-]+\s*=\s*\{/;
|
|
122213
122451
|
/**
|
|
@@ -122251,18 +122489,6 @@ const parseSibling = (stack, parent, index, sibling, safeMode) => {
|
|
|
122251
122489
|
stack.push(parent);
|
|
122252
122490
|
}
|
|
122253
122491
|
};
|
|
122254
|
-
/**
|
|
122255
|
-
* Advance a point by the substring of source consumed from it.
|
|
122256
|
-
*/
|
|
122257
|
-
const pointAfter = (start, consumed) => {
|
|
122258
|
-
const newlineIndex = consumed.lastIndexOf('\n');
|
|
122259
|
-
const newlineCount = newlineIndex === -1 ? 0 : consumed.split('\n').length - 1;
|
|
122260
|
-
return {
|
|
122261
|
-
line: start.line + newlineCount,
|
|
122262
|
-
column: newlineCount === 0 ? start.column + consumed.length : consumed.length - newlineIndex,
|
|
122263
|
-
offset: start.offset + consumed.length,
|
|
122264
|
-
};
|
|
122265
|
-
};
|
|
122266
122492
|
/**
|
|
122267
122493
|
* Build a position ending at `consumedLength` into the html node's value, so the
|
|
122268
122494
|
* component doesn't claim trailing content the tokenizer swallowed into one node.
|
|
@@ -122765,8 +122991,6 @@ const evaluateExports = () => (tree, file) => {
|
|
|
122765
122991
|
};
|
|
122766
122992
|
/* harmony default export */ const evaluate_exports = (evaluateExports);
|
|
122767
122993
|
|
|
122768
|
-
// EXTERNAL MODULE: ./node_modules/react-dom/server.node.js
|
|
122769
|
-
var server_node = __webpack_require__(4362);
|
|
122770
122994
|
;// ./lib/utils/mdxish/mdxish-expression.ts
|
|
122771
122995
|
|
|
122772
122996
|
|
|
@@ -122812,26 +123036,185 @@ const evalExpression = (expression, scope) => {
|
|
|
122812
123036
|
return evalJsxProgram(program, scope);
|
|
122813
123037
|
};
|
|
122814
123038
|
|
|
122815
|
-
|
|
123039
|
+
// EXTERNAL MODULE: ./node_modules/react-dom/server.node.js
|
|
123040
|
+
var server_node = __webpack_require__(4362);
|
|
123041
|
+
;// ./processor/transform/mdxish/style-object-to-css.ts
|
|
122816
123042
|
|
|
123043
|
+
/**
|
|
123044
|
+
* CSS properties React treats as unitless — a bare number stays as-is instead of
|
|
123045
|
+
* getting `px` appended. Mirrors React DOM's `isUnitlessNumber` whitelist.
|
|
123046
|
+
* @see https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/shared/CSSProperty.js
|
|
123047
|
+
*/
|
|
123048
|
+
const UNITLESS_CSS_PROPERTIES = new Set([
|
|
123049
|
+
'animationIterationCount',
|
|
123050
|
+
'aspectRatio',
|
|
123051
|
+
'borderImageOutset',
|
|
123052
|
+
'borderImageSlice',
|
|
123053
|
+
'borderImageWidth',
|
|
123054
|
+
'boxFlex',
|
|
123055
|
+
'boxFlexGroup',
|
|
123056
|
+
'boxOrdinalGroup',
|
|
123057
|
+
'columnCount',
|
|
123058
|
+
'columns',
|
|
123059
|
+
'flex',
|
|
123060
|
+
'flexGrow',
|
|
123061
|
+
'flexPositive',
|
|
123062
|
+
'flexShrink',
|
|
123063
|
+
'flexNegative',
|
|
123064
|
+
'flexOrder',
|
|
123065
|
+
'gridArea',
|
|
123066
|
+
'gridRow',
|
|
123067
|
+
'gridRowEnd',
|
|
123068
|
+
'gridRowSpan',
|
|
123069
|
+
'gridRowStart',
|
|
123070
|
+
'gridColumn',
|
|
123071
|
+
'gridColumnEnd',
|
|
123072
|
+
'gridColumnSpan',
|
|
123073
|
+
'gridColumnStart',
|
|
123074
|
+
'fontWeight',
|
|
123075
|
+
'lineClamp',
|
|
123076
|
+
'lineHeight',
|
|
123077
|
+
'opacity',
|
|
123078
|
+
'order',
|
|
123079
|
+
'orphans',
|
|
123080
|
+
'tabSize',
|
|
123081
|
+
'widows',
|
|
123082
|
+
'zIndex',
|
|
123083
|
+
'zoom',
|
|
123084
|
+
'fillOpacity',
|
|
123085
|
+
'floodOpacity',
|
|
123086
|
+
'stopOpacity',
|
|
123087
|
+
'strokeDasharray',
|
|
123088
|
+
'strokeDashoffset',
|
|
123089
|
+
'strokeMiterlimit',
|
|
123090
|
+
'strokeOpacity',
|
|
123091
|
+
'strokeWidth',
|
|
123092
|
+
]);
|
|
123093
|
+
/** Convert a camelCase (or CSS custom property) key into its kebab-case CSS name. */
|
|
123094
|
+
const cssPropertyName = (key) => (key.startsWith('--') ? key : key.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`));
|
|
123095
|
+
/** React appends `px` to non-zero numeric values, except unitless and custom properties. */
|
|
123096
|
+
const cssPropertyValue = (key, value) => typeof value === 'number' && value !== 0 && !key.startsWith('--') && !UNITLESS_CSS_PROPERTIES.has(key)
|
|
123097
|
+
? `${value}px`
|
|
123098
|
+
: `${value}`;
|
|
123099
|
+
/**
|
|
123100
|
+
* True for a value that should be serialized as a style object rather than passed through
|
|
123101
|
+
* as an already-CSS string. React elements are excluded since they're valid objects too.
|
|
123102
|
+
*/
|
|
123103
|
+
const style_object_to_css_isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value) && !external_react_default().isValidElement(value);
|
|
123104
|
+
/**
|
|
123105
|
+
* Serialize a React-style inline style object (`{ color: "red", fontSize: 12 }`) into a
|
|
123106
|
+
* CSS declaration string (`color:red;font-size:12px`), the shape hast/HTML expects for a
|
|
123107
|
+
* `style` attribute. Empty (`undefined`/`null`/`''`) entries are dropped.
|
|
123108
|
+
*/
|
|
123109
|
+
const styleObjectToCssText = (style) => Object.entries(style)
|
|
123110
|
+
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
|
123111
|
+
.map(([key, value]) => `${cssPropertyName(key)}:${cssPropertyValue(key, value)}`)
|
|
123112
|
+
.join(';');
|
|
122817
123113
|
|
|
123114
|
+
;// ./processor/transform/mdxish/react-element-to-hast.ts
|
|
122818
123115
|
|
|
122819
123116
|
|
|
122820
|
-
|
|
122821
|
-
|
|
122822
|
-
|
|
122823
|
-
|
|
122824
|
-
|
|
122825
|
-
|
|
123117
|
+
|
|
123118
|
+
// React props that never map to an HTML/hast attribute.
|
|
123119
|
+
const RESERVED_PROPS = new Set(['children', 'key', 'ref']);
|
|
123120
|
+
/**
|
|
123121
|
+
* Translate React props into hast `properties`: reserved and function props (event handlers)
|
|
123122
|
+
* are dropped (known gap), `style` objects flatten to CSS text. Names stay as authored (`className`); the
|
|
123123
|
+
* hast → HTML boundary maps them to `class`/`for` downstream.
|
|
123124
|
+
*/
|
|
123125
|
+
function propsToHastProperties(props) {
|
|
123126
|
+
const properties = {};
|
|
123127
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
123128
|
+
if (RESERVED_PROPS.has(key) || typeof value === 'function' || value === undefined)
|
|
123129
|
+
return;
|
|
123130
|
+
properties[key] = key === 'style' && style_object_to_css_isPlainObject(value) ? styleObjectToCssText(value) : value;
|
|
123131
|
+
});
|
|
123132
|
+
// Values are resolved React props, wider than hast's HTML-attribute `PropertyValue` union.
|
|
123133
|
+
return properties;
|
|
123134
|
+
}
|
|
123135
|
+
/**
|
|
123136
|
+
* Render an element with React's own renderer as a last resort, wrapped as a hast `raw` node —
|
|
123137
|
+
* the same node type markdown's literal HTML blocks produce, so it re-enters rehypeRaw's
|
|
123138
|
+
* parse5 pass normally. Used for element types this converter can't resolve on its own (wrapped
|
|
123139
|
+
* component types, or a function component that throws when called outside React, e.g. one
|
|
123140
|
+
* using hooks). It's not immune to the invalid-HTML-nesting this module otherwise avoids, but
|
|
123141
|
+
* that's a fair trade against silently dropping the content.
|
|
123142
|
+
*/
|
|
123143
|
+
function renderFallbackHtml(element) {
|
|
123144
|
+
try {
|
|
123145
|
+
const rawNode = { type: 'raw', value: (0,server_node/* renderToStaticMarkup */.qV)(element) };
|
|
123146
|
+
return [rawNode];
|
|
122826
123147
|
}
|
|
122827
|
-
|
|
122828
|
-
|
|
122829
|
-
// representation. This must come before the object check as both are a subset of it.
|
|
122830
|
-
return { type: 'html', value: (0,server_node/* renderToStaticMarkup */.qV)(external_react_default().createElement((external_react_default()).Fragment, null, result)), position };
|
|
123148
|
+
catch {
|
|
123149
|
+
return [];
|
|
122831
123150
|
}
|
|
122832
|
-
|
|
122833
|
-
|
|
123151
|
+
}
|
|
123152
|
+
/**
|
|
123153
|
+
* Convert a React element tree into hast. Emitting `mdx-jsx` nodes (rehypeRaw passthrough, later normalized to `element`)
|
|
123154
|
+
* preserves nesting that is valid JSX but not valid HTML, which parse5 would otherwise
|
|
123155
|
+
* restructure — e.g. an `<a>` wrapping another `<a>`.
|
|
123156
|
+
* Recursively converts the tree into an array of hast nodes, dealing with arrays and null/undefined/boolean values.
|
|
123157
|
+
*/
|
|
123158
|
+
function reactElementToHast(node) {
|
|
123159
|
+
if (Array.isArray(node))
|
|
123160
|
+
return node.flatMap(reactElementToHast);
|
|
123161
|
+
if (node === null || node === undefined || typeof node === 'boolean')
|
|
123162
|
+
return [];
|
|
123163
|
+
if (typeof node === 'string' || typeof node === 'number') {
|
|
123164
|
+
const textNode = { type: 'text', value: String(node) };
|
|
123165
|
+
return [textNode];
|
|
122834
123166
|
}
|
|
123167
|
+
if (!external_react_default().isValidElement(node))
|
|
123168
|
+
return [];
|
|
123169
|
+
const { type, props } = node;
|
|
123170
|
+
// Fragments contribute their children with no wrapper element.
|
|
123171
|
+
if (type === (external_react_default()).Fragment)
|
|
123172
|
+
return reactElementToHast(props.children);
|
|
123173
|
+
// Resolve function components to their rendered output so the tree is plain intrinsic
|
|
123174
|
+
// elements. If invoking it directly throws (e.g. it uses hooks, which need React's own
|
|
123175
|
+
// render context), fall back to React's renderer for just this subtree.
|
|
123176
|
+
if (typeof type === 'function') {
|
|
123177
|
+
try {
|
|
123178
|
+
return reactElementToHast(type(props));
|
|
123179
|
+
}
|
|
123180
|
+
catch {
|
|
123181
|
+
return renderFallbackHtml(node);
|
|
123182
|
+
}
|
|
123183
|
+
}
|
|
123184
|
+
// Non-intrinsic, non-callable element types — `React.memo`, `React.forwardRef`,
|
|
123185
|
+
// `Context.Provider`/`Consumer`, `React.lazy` — have no `type` we can resolve ourselves.
|
|
123186
|
+
if (typeof type !== 'string')
|
|
123187
|
+
return renderFallbackHtml(node);
|
|
123188
|
+
const mdxJsxNode = {
|
|
123189
|
+
type: 'mdx-jsx',
|
|
123190
|
+
tagName: type,
|
|
123191
|
+
properties: propsToHastProperties(props),
|
|
123192
|
+
children: reactElementToHast(props.children),
|
|
123193
|
+
};
|
|
123194
|
+
return [mdxJsxNode];
|
|
123195
|
+
}
|
|
123196
|
+
|
|
123197
|
+
;// ./processor/transform/mdxish/evaluate-expressions.ts
|
|
123198
|
+
|
|
123199
|
+
|
|
123200
|
+
|
|
123201
|
+
|
|
123202
|
+
/**
|
|
123203
|
+
* We divide the result of an expression into two categories:
|
|
123204
|
+
* 1. Renderable values: HTML, JSX, e.g. .map() returning JSX
|
|
123205
|
+
* 2. Non-renderable values: a string, number, or object, regular JS values
|
|
123206
|
+
*/
|
|
123207
|
+
const isRenderable = (value) => {
|
|
123208
|
+
if (external_react_default().isValidElement(value))
|
|
123209
|
+
return true;
|
|
123210
|
+
return Array.isArray(value) && value.some(isRenderable);
|
|
123211
|
+
};
|
|
123212
|
+
/** Turn a non-renderable evaluation result into a text node. */
|
|
123213
|
+
const createTextNode = (result, position) => {
|
|
123214
|
+
if (result === null || result === undefined)
|
|
123215
|
+
return { type: 'text', value: '', position };
|
|
123216
|
+
if (typeof result === 'object')
|
|
123217
|
+
return { type: 'text', value: JSON.stringify(result), position };
|
|
122835
123218
|
return { type: 'text', value: String(result), position };
|
|
122836
123219
|
};
|
|
122837
123220
|
/**
|
|
@@ -122847,13 +123230,23 @@ const evaluateExpressions = () => (tree, file) => {
|
|
|
122847
123230
|
visit(tree, ['mdxFlowExpression', 'mdxTextExpression'], (node, index, parent) => {
|
|
122848
123231
|
if (!parent || index === null || index === undefined)
|
|
122849
123232
|
return;
|
|
122850
|
-
const
|
|
123233
|
+
const expressionNode = node;
|
|
123234
|
+
const { value, position } = expressionNode;
|
|
122851
123235
|
const expression = value?.trim();
|
|
122852
123236
|
if (!expression)
|
|
122853
123237
|
return;
|
|
122854
123238
|
try {
|
|
122855
123239
|
const result = evalExpression(expression, scope);
|
|
122856
|
-
|
|
123240
|
+
if (isRenderable(result)) {
|
|
123241
|
+
// Stash hast built straight from the React tree; `mdxExpressionHandler` emits it and it
|
|
123242
|
+
// passes through rehypeRaw/parse5 step later in the pipeline. This ensures that the
|
|
123243
|
+
// expression result is not parsed by parse5 and fragmenting the nesting that is valid JSX
|
|
123244
|
+
// but invalid HTML — e.g. an `<a>` wrapping `<a>`.
|
|
123245
|
+
expressionNode.data = { ...expressionNode.data, hChildren: reactElementToHast(result) };
|
|
123246
|
+
}
|
|
123247
|
+
else {
|
|
123248
|
+
parent.children.splice(index, 1, createTextNode(result, position));
|
|
123249
|
+
}
|
|
122857
123250
|
}
|
|
122858
123251
|
catch (_error) {
|
|
122859
123252
|
// Evaluation failed — fall back to literal `{...}` text. The expression
|
|
@@ -124764,79 +125157,6 @@ function removeJSXComments(content) {
|
|
|
124764
125157
|
return content.replace(JSX_COMMENT_REGEX, '');
|
|
124765
125158
|
}
|
|
124766
125159
|
|
|
124767
|
-
;// ./processor/transform/mdxish/style-object-to-css.ts
|
|
124768
|
-
|
|
124769
|
-
/**
|
|
124770
|
-
* CSS properties React treats as unitless — a bare number stays as-is instead of
|
|
124771
|
-
* getting `px` appended. Mirrors React DOM's `isUnitlessNumber` whitelist.
|
|
124772
|
-
* @see https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/shared/CSSProperty.js
|
|
124773
|
-
*/
|
|
124774
|
-
const UNITLESS_CSS_PROPERTIES = new Set([
|
|
124775
|
-
'animationIterationCount',
|
|
124776
|
-
'aspectRatio',
|
|
124777
|
-
'borderImageOutset',
|
|
124778
|
-
'borderImageSlice',
|
|
124779
|
-
'borderImageWidth',
|
|
124780
|
-
'boxFlex',
|
|
124781
|
-
'boxFlexGroup',
|
|
124782
|
-
'boxOrdinalGroup',
|
|
124783
|
-
'columnCount',
|
|
124784
|
-
'columns',
|
|
124785
|
-
'flex',
|
|
124786
|
-
'flexGrow',
|
|
124787
|
-
'flexPositive',
|
|
124788
|
-
'flexShrink',
|
|
124789
|
-
'flexNegative',
|
|
124790
|
-
'flexOrder',
|
|
124791
|
-
'gridArea',
|
|
124792
|
-
'gridRow',
|
|
124793
|
-
'gridRowEnd',
|
|
124794
|
-
'gridRowSpan',
|
|
124795
|
-
'gridRowStart',
|
|
124796
|
-
'gridColumn',
|
|
124797
|
-
'gridColumnEnd',
|
|
124798
|
-
'gridColumnSpan',
|
|
124799
|
-
'gridColumnStart',
|
|
124800
|
-
'fontWeight',
|
|
124801
|
-
'lineClamp',
|
|
124802
|
-
'lineHeight',
|
|
124803
|
-
'opacity',
|
|
124804
|
-
'order',
|
|
124805
|
-
'orphans',
|
|
124806
|
-
'tabSize',
|
|
124807
|
-
'widows',
|
|
124808
|
-
'zIndex',
|
|
124809
|
-
'zoom',
|
|
124810
|
-
'fillOpacity',
|
|
124811
|
-
'floodOpacity',
|
|
124812
|
-
'stopOpacity',
|
|
124813
|
-
'strokeDasharray',
|
|
124814
|
-
'strokeDashoffset',
|
|
124815
|
-
'strokeMiterlimit',
|
|
124816
|
-
'strokeOpacity',
|
|
124817
|
-
'strokeWidth',
|
|
124818
|
-
]);
|
|
124819
|
-
/** Convert a camelCase (or CSS custom property) key into its kebab-case CSS name. */
|
|
124820
|
-
const cssPropertyName = (key) => (key.startsWith('--') ? key : key.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`));
|
|
124821
|
-
/** React appends `px` to non-zero numeric values, except unitless and custom properties. */
|
|
124822
|
-
const cssPropertyValue = (key, value) => typeof value === 'number' && value !== 0 && !key.startsWith('--') && !UNITLESS_CSS_PROPERTIES.has(key)
|
|
124823
|
-
? `${value}px`
|
|
124824
|
-
: `${value}`;
|
|
124825
|
-
/**
|
|
124826
|
-
* True for a value that should be serialized as a style object rather than passed through
|
|
124827
|
-
* as an already-CSS string. React elements are excluded since they're valid objects too.
|
|
124828
|
-
*/
|
|
124829
|
-
const style_object_to_css_isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value) && !external_react_default().isValidElement(value);
|
|
124830
|
-
/**
|
|
124831
|
-
* Serialize a React-style inline style object (`{ color: "red", fontSize: 12 }`) into a
|
|
124832
|
-
* CSS declaration string (`color:red;font-size:12px`), the shape hast/HTML expects for a
|
|
124833
|
-
* `style` attribute. Empty (`undefined`/`null`/`''`) entries are dropped.
|
|
124834
|
-
*/
|
|
124835
|
-
const styleObjectToCssText = (style) => Object.entries(style)
|
|
124836
|
-
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
|
124837
|
-
.map(([key, value]) => `${cssPropertyName(key)}:${cssPropertyValue(key, value)}`)
|
|
124838
|
-
.join(';');
|
|
124839
|
-
|
|
124840
125160
|
;// ./processor/transform/mdxish/resolve-deferred-attribute-expression-props.ts
|
|
124841
125161
|
|
|
124842
125162
|
|