@readme/markdown 15.5.2 → 15.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +164 -23
- package/dist/main.node.js +164 -23
- package/dist/main.node.js.map +1 -1
- package/dist/processor/transform/mdxish/images-to-jsx.d.ts +10 -0
- package/dist/processor/transform/mdxish/unwrap-pins.d.ts +9 -0
- package/dist/render-fixture.node.js +155 -23
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +5 -0
package/dist/main.js
CHANGED
|
@@ -11423,7 +11423,7 @@ module.exports = function () {
|
|
|
11423
11423
|
|
|
11424
11424
|
/***/ },
|
|
11425
11425
|
|
|
11426
|
-
/***/
|
|
11426
|
+
/***/ 7070
|
|
11427
11427
|
(module, __webpack_exports__, __webpack_require__) {
|
|
11428
11428
|
|
|
11429
11429
|
"use strict";
|
|
@@ -81088,6 +81088,8 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
81088
81088
|
type: 'table',
|
|
81089
81089
|
position,
|
|
81090
81090
|
children,
|
|
81091
|
+
// Remember the author's spelling so the serializer can write `<table>` back instead of `<Table>`
|
|
81092
|
+
...(node.name === 'table' && { data: { lowercaseTable: true } }),
|
|
81091
81093
|
};
|
|
81092
81094
|
parent.children[index] = mdNode;
|
|
81093
81095
|
};
|
|
@@ -96690,7 +96692,7 @@ const rehypeToc = ({ components = {} }) => {
|
|
|
96690
96692
|
});
|
|
96691
96693
|
};
|
|
96692
96694
|
};
|
|
96693
|
-
const MAX_DEPTH =
|
|
96695
|
+
const MAX_DEPTH = 3;
|
|
96694
96696
|
/**
|
|
96695
96697
|
* Get the depth of a heading element based on its tag name.
|
|
96696
96698
|
*
|
|
@@ -105688,6 +105690,106 @@ const generateSlugForHeadings = () => (tree) => {
|
|
|
105688
105690
|
};
|
|
105689
105691
|
/* harmony default export */ const heading_slugs = (generateSlugForHeadings);
|
|
105690
105692
|
|
|
105693
|
+
;// ./processor/transform/mdxish/images-to-jsx.ts
|
|
105694
|
+
|
|
105695
|
+
|
|
105696
|
+
|
|
105697
|
+
|
|
105698
|
+
|
|
105699
|
+
const IMAGE_ATTRS = ['align', 'alt', 'border', 'caption', 'className', 'height', 'lazy', 'src', 'title', 'width'];
|
|
105700
|
+
/** The three attributes markdown's `` can carry. Anything else forces JSX. */
|
|
105701
|
+
const PLAIN_IMAGE_ATTRS = ['alt', 'src', 'title'];
|
|
105702
|
+
const EMOJI_COLONS = /^:(.*):$/;
|
|
105703
|
+
const hasExtra = (attributes) => attributes.some(attr => !PLAIN_IMAGE_ATTRS.includes(attr.name));
|
|
105704
|
+
const toImageJsx = (attributes, children = []) => ({
|
|
105705
|
+
type: 'mdxJsxFlowElement',
|
|
105706
|
+
name: 'Image',
|
|
105707
|
+
attributes,
|
|
105708
|
+
children,
|
|
105709
|
+
});
|
|
105710
|
+
/**
|
|
105711
|
+
* An `image` is phrasing content, but the nodes it replaces here (`image-block`, and a plain
|
|
105712
|
+
* `[block:image]`) sit where flow content belongs. `mdast-util-to-markdown` picks a block separator
|
|
105713
|
+
* from the two node types around it and has no rule for phrasing-next-to-flow, so it emits none and
|
|
105714
|
+
* glues the image to whatever follows (`# Heading`), which then cascades through the rest
|
|
105715
|
+
* of the document. Wrapping restores a block for it to join against.
|
|
105716
|
+
*/
|
|
105717
|
+
const placeImage = (parent, index, image) => {
|
|
105718
|
+
const wrapped = { type: 'paragraph', children: [image] };
|
|
105719
|
+
parent.children[index] = INLINE_ONLY_PARENT_TYPES.has(parent.type) ? image : wrapped;
|
|
105720
|
+
};
|
|
105721
|
+
/**
|
|
105722
|
+
* Serializes the three image shapes a parsed document carries. An image that picked up readme
|
|
105723
|
+
* attributes has no markdown spelling left and goes out as `<Image>`, a plain one stays
|
|
105724
|
+
* ``.
|
|
105725
|
+
*
|
|
105726
|
+
* Order matters: `figure` unwraps into the `image` its caption belongs to, so it runs first.
|
|
105727
|
+
*/
|
|
105728
|
+
const imagesToJsx = () => tree => {
|
|
105729
|
+
visit(tree, NodeTypes.figure, (node, index, parent) => {
|
|
105730
|
+
if (!parent || index === undefined)
|
|
105731
|
+
return;
|
|
105732
|
+
const [image, caption] = node.children;
|
|
105733
|
+
const { align, className, width } = image.data.hProperties;
|
|
105734
|
+
parent.children[index] = toImageJsx(toAttributes({ ...image, align, width, ...(className === 'border' && { border: true }), src: image.src || image.url }, IMAGE_ATTRS),
|
|
105735
|
+
// The caption stays a child rather than a pre-serialized `caption` attribute, so readme nodes
|
|
105736
|
+
// inside it (emoji, variables, glossary) reach their own handlers instead of the bare
|
|
105737
|
+
// `toMarkdown` in `compatibility.figureToImageBlock`, which throws on them.
|
|
105738
|
+
caption.children);
|
|
105739
|
+
});
|
|
105740
|
+
visit(tree, 'image', (n, index, parent) => {
|
|
105741
|
+
const node = n;
|
|
105742
|
+
if (!parent || index === undefined)
|
|
105743
|
+
return undefined;
|
|
105744
|
+
const hProperties = node.data?.hProperties;
|
|
105745
|
+
// A `:joy:`-style shortcode round-trips as a gemoji rather than the image it parsed into.
|
|
105746
|
+
if (hProperties?.className === 'emoji' && node.title) {
|
|
105747
|
+
const emoji = {
|
|
105748
|
+
type: NodeTypes.emoji,
|
|
105749
|
+
name: node.title.replace(EMOJI_COLONS, '$1'),
|
|
105750
|
+
value: node.title,
|
|
105751
|
+
};
|
|
105752
|
+
parent.children[index] = emoji;
|
|
105753
|
+
return undefined;
|
|
105754
|
+
}
|
|
105755
|
+
if (hProperties) {
|
|
105756
|
+
const attributes = toAttributes({ ...node, ...hProperties, src: node.url }, IMAGE_ATTRS);
|
|
105757
|
+
if (hasExtra(attributes)) {
|
|
105758
|
+
parent.children[index] = toImageJsx(attributes);
|
|
105759
|
+
return undefined;
|
|
105760
|
+
}
|
|
105761
|
+
}
|
|
105762
|
+
// An attribute-less `[block:image]` parses straight to an `image` in a flow slot, so it needs
|
|
105763
|
+
// the same wrap. Editor images always arrive inside a paragraph and are left alone.
|
|
105764
|
+
if (INLINE_ONLY_PARENT_TYPES.has(parent.type))
|
|
105765
|
+
return undefined;
|
|
105766
|
+
placeImage(parent, index, node);
|
|
105767
|
+
// Step over the paragraph just created, or the visitor walks back into the same image.
|
|
105768
|
+
return [(/* inlined export .SKIP */"skip"), index + 1];
|
|
105769
|
+
});
|
|
105770
|
+
visit(tree, NodeTypes.imageBlock, (node, index, parent) => {
|
|
105771
|
+
if (!parent || index === undefined)
|
|
105772
|
+
return;
|
|
105773
|
+
// An image-block keeps its caption as children, so it has to be re-serialized back into the
|
|
105774
|
+
// `caption` attribute before the node is replaced.
|
|
105775
|
+
const captionChildren = node.children ?? [];
|
|
105776
|
+
const caption = captionChildren.length ? toMarkdown({ type: 'root', children: captionChildren }).trim() : '';
|
|
105777
|
+
const attributes = toAttributes({ ...node, ...node.data.hProperties, ...(caption && { caption }) }, IMAGE_ATTRS);
|
|
105778
|
+
if (hasExtra(attributes)) {
|
|
105779
|
+
parent.children[index] = toImageJsx(attributes);
|
|
105780
|
+
return;
|
|
105781
|
+
}
|
|
105782
|
+
placeImage(parent, index, {
|
|
105783
|
+
type: 'image',
|
|
105784
|
+
url: node.src,
|
|
105785
|
+
...(node.title && { title: node.title }),
|
|
105786
|
+
...(node.alt && { alt: node.alt }),
|
|
105787
|
+
});
|
|
105788
|
+
});
|
|
105789
|
+
return tree;
|
|
105790
|
+
};
|
|
105791
|
+
/* harmony default export */ const images_to_jsx = (imagesToJsx);
|
|
105792
|
+
|
|
105691
105793
|
// EXTERNAL MODULE: external "@readme/variable"
|
|
105692
105794
|
var variable_ = __webpack_require__(8167);
|
|
105693
105795
|
var variable_default = /*#__PURE__*/__webpack_require__.n(variable_);
|
|
@@ -107566,13 +107668,22 @@ const mdxishTablesToJsx = () => tree => {
|
|
|
107566
107668
|
gfmCells.push([cell, normalized]);
|
|
107567
107669
|
return undefined;
|
|
107568
107670
|
});
|
|
107569
|
-
|
|
107671
|
+
const stayLowercase = table.data?.lowercaseTable === true;
|
|
107672
|
+
// We transform to GFM tables if:
|
|
107673
|
+
// 1. If it doesn't contain complex elements that the syntax can't represent
|
|
107674
|
+
// 2. The original table is not lowercase HTML <table>, because we want to
|
|
107675
|
+
// preserve original tables as much as possible
|
|
107676
|
+
if (!requiresJsxTable && !stayLowercase) {
|
|
107570
107677
|
gfmCells.forEach(([cell, children]) => {
|
|
107571
107678
|
cell.children = children;
|
|
107572
107679
|
});
|
|
107573
107680
|
table.type = 'table';
|
|
107574
107681
|
return;
|
|
107575
107682
|
}
|
|
107683
|
+
// Nothing to build a JSX table from; leave the empty node to the GFM stringifier.
|
|
107684
|
+
const [headerRow, ...bodyRows] = table.children;
|
|
107685
|
+
if (!headerRow)
|
|
107686
|
+
return;
|
|
107576
107687
|
visit(table, mdxish_tables_to_jsx_isTableCell, flattenBreaksToNewlines);
|
|
107577
107688
|
const styles = table.align.map(mdxish_tables_to_jsx_alignToStyle);
|
|
107578
107689
|
const head = {
|
|
@@ -107584,7 +107695,7 @@ const mdxishTablesToJsx = () => tree => {
|
|
|
107584
107695
|
attributes: [],
|
|
107585
107696
|
type: 'mdxJsxFlowElement',
|
|
107586
107697
|
name: 'tr',
|
|
107587
|
-
children:
|
|
107698
|
+
children: headerRow.children.map((cell, cellIndex) => {
|
|
107588
107699
|
return {
|
|
107589
107700
|
attributes: [],
|
|
107590
107701
|
type: 'mdxJsxFlowElement',
|
|
@@ -107600,7 +107711,7 @@ const mdxishTablesToJsx = () => tree => {
|
|
|
107600
107711
|
attributes: [],
|
|
107601
107712
|
type: 'mdxJsxFlowElement',
|
|
107602
107713
|
name: 'tbody',
|
|
107603
|
-
children:
|
|
107714
|
+
children: bodyRows.map(row => {
|
|
107604
107715
|
return {
|
|
107605
107716
|
attributes: [],
|
|
107606
107717
|
type: 'mdxJsxFlowElement',
|
|
@@ -107628,8 +107739,8 @@ const mdxishTablesToJsx = () => tree => {
|
|
|
107628
107739
|
];
|
|
107629
107740
|
const jsx = {
|
|
107630
107741
|
type: 'mdxJsxFlowElement',
|
|
107631
|
-
name: 'Table',
|
|
107632
|
-
attributes: table.align.find(a => a) ? attributes : [],
|
|
107742
|
+
name: stayLowercase ? 'table' : 'Table',
|
|
107743
|
+
attributes: !stayLowercase && table.align.find(a => a) ? attributes : [],
|
|
107633
107744
|
children: [head, body],
|
|
107634
107745
|
};
|
|
107635
107746
|
parent.children[index] = jsx;
|
|
@@ -107724,6 +107835,24 @@ function normalizeTableSeparator(content) {
|
|
|
107724
107835
|
}
|
|
107725
107836
|
/* harmony default export */ const normalize_table_separator = ((/* unused pure expression or super */ null && (normalizeTableSeparator)));
|
|
107726
107837
|
|
|
107838
|
+
;// ./processor/transform/mdxish/unwrap-pins.ts
|
|
107839
|
+
|
|
107840
|
+
/**
|
|
107841
|
+
* A `sidebar: true` magic block (e.g. `[block:code]`) parses into an `rdme-pin` wrapper via
|
|
107842
|
+
* `wrapPinnedBlocks`, and remark-stringify throws on any node type without a handler. The mdxish
|
|
107843
|
+
* dialect has no spelling for a pin, so the wrapper serializes as its content instead — the same
|
|
107844
|
+
* (lossy) unwrap `readmeToMdx` has always done, trading the `sidebar` flag for not crashing.
|
|
107845
|
+
*/
|
|
107846
|
+
const unwrapPins = () => tree => {
|
|
107847
|
+
visit(tree, 'rdme-pin', (node, index, parent) => {
|
|
107848
|
+
if (!parent || index === undefined)
|
|
107849
|
+
return;
|
|
107850
|
+
parent.children.splice(index, 1, ...node.children);
|
|
107851
|
+
});
|
|
107852
|
+
return tree;
|
|
107853
|
+
};
|
|
107854
|
+
/* harmony default export */ const unwrap_pins = (unwrapPins);
|
|
107855
|
+
|
|
107727
107856
|
;// ./processor/transform/mdxish/variables-code.ts
|
|
107728
107857
|
|
|
107729
107858
|
|
|
@@ -107870,6 +107999,10 @@ function loadComponents() {
|
|
|
107870
107999
|
|
|
107871
108000
|
|
|
107872
108001
|
|
|
108002
|
+
|
|
108003
|
+
|
|
108004
|
+
|
|
108005
|
+
|
|
107873
108006
|
|
|
107874
108007
|
|
|
107875
108008
|
|
|
@@ -107953,35 +108086,43 @@ function mdxishAstProcessor(mdContent, opts = {}) {
|
|
|
107953
108086
|
};
|
|
107954
108087
|
}
|
|
107955
108088
|
/**
|
|
107956
|
-
* Registers
|
|
107957
|
-
*
|
|
108089
|
+
* Registers serialization for the node types remark-stringify can't write on its own:
|
|
108090
|
+
* JSX elements (e.g. `<Table>`), MDX expressions, and ESM exports.
|
|
107958
108091
|
*/
|
|
107959
|
-
function
|
|
108092
|
+
function mdxStringifyExtensions() {
|
|
107960
108093
|
const data = this.data();
|
|
107961
108094
|
const extensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
107962
|
-
extensions.push({ extensions: [mdxJsxToMarkdown()] });
|
|
108095
|
+
extensions.push({ extensions: [mdxJsxToMarkdown(), mdxExpressionToMarkdown(), mdxjsEsmToMarkdown()] });
|
|
107963
108096
|
}
|
|
108097
|
+
const stringifyOptions = {
|
|
108098
|
+
bullet: (/* inlined export .DEFAULT_BULLET */"-"),
|
|
108099
|
+
emphasis: '_',
|
|
108100
|
+
// Escape literal braces in text so they don't parse as (often
|
|
108101
|
+
// unterminated) MDX expressions on the next round trip.
|
|
108102
|
+
unsafe: [
|
|
108103
|
+
{ character: '{', inConstruct: 'phrasing' },
|
|
108104
|
+
{ character: '}', inConstruct: 'phrasing' },
|
|
108105
|
+
],
|
|
108106
|
+
};
|
|
107964
108107
|
/**
|
|
107965
108108
|
* Serializes an Mdast back into a markdown string.
|
|
107966
108109
|
*/
|
|
107967
108110
|
function mdxishMdastToMd(mdast) {
|
|
107968
108111
|
const processor = unified()
|
|
107969
108112
|
.use(remarkGfm)
|
|
108113
|
+
// Readme nodes with no markdown spelling go out as JSX, the same tags mdxish re-parses.
|
|
107970
108114
|
.use(callout_to_jsx)
|
|
107971
108115
|
.use(mdxish_tables_to_jsx)
|
|
107972
108116
|
.use(anchor_to_jsx)
|
|
108117
|
+
// The rest only a PARSER tree carries.
|
|
108118
|
+
// A `sidebar: true` block parses into an `rdme-pin` wrapper the dialect can't spell.
|
|
108119
|
+
.use(unwrap_pins)
|
|
108120
|
+
// Figures, image blocks, and images that picked up readme attributes while parsing.
|
|
108121
|
+
.use(images_to_jsx)
|
|
108122
|
+
// Handlers for the readme nodes that stay themselves (variables, emoji, html-blocks, lists).
|
|
107973
108123
|
.use(mdxishCompilers)
|
|
107974
|
-
.use(
|
|
107975
|
-
.use(remarkStringify,
|
|
107976
|
-
bullet: (/* inlined export .DEFAULT_BULLET */"-"),
|
|
107977
|
-
emphasis: '_',
|
|
107978
|
-
// Escape literal braces in text so they don't parse as (often
|
|
107979
|
-
// unterminated) MDX expressions on the next round trip.
|
|
107980
|
-
unsafe: [
|
|
107981
|
-
{ character: '{', inConstruct: 'phrasing' },
|
|
107982
|
-
{ character: '}', inConstruct: 'phrasing' },
|
|
107983
|
-
],
|
|
107984
|
-
});
|
|
108124
|
+
.use(mdxStringifyExtensions)
|
|
108125
|
+
.use(remarkStringify, stringifyOptions);
|
|
107985
108126
|
return processor.stringify(processor.runSync(mdast));
|
|
107986
108127
|
}
|
|
107987
108128
|
/**
|
|
@@ -108991,7 +109132,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"*":["about","acceptCharset","accessK
|
|
|
108991
109132
|
/******/ // startup
|
|
108992
109133
|
/******/ // Load entry module and return exports
|
|
108993
109134
|
/******/ // This entry module used 'module' so it can't be inlined
|
|
108994
|
-
/******/ let __webpack_exports__ = __webpack_require__(
|
|
109135
|
+
/******/ let __webpack_exports__ = __webpack_require__(7070);
|
|
108995
109136
|
/******/
|
|
108996
109137
|
/******/ return __webpack_exports__;
|
|
108997
109138
|
/******/ })()
|
package/dist/main.node.js
CHANGED
|
@@ -19045,7 +19045,7 @@ module.exports = function () {
|
|
|
19045
19045
|
|
|
19046
19046
|
/***/ },
|
|
19047
19047
|
|
|
19048
|
-
/***/
|
|
19048
|
+
/***/ 6817
|
|
19049
19049
|
(module, __webpack_exports__, __webpack_require__) {
|
|
19050
19050
|
|
|
19051
19051
|
"use strict";
|
|
@@ -101271,6 +101271,8 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
101271
101271
|
type: 'table',
|
|
101272
101272
|
position,
|
|
101273
101273
|
children,
|
|
101274
|
+
// Remember the author's spelling so the serializer can write `<table>` back instead of `<Table>`
|
|
101275
|
+
...(node.name === 'table' && { data: { lowercaseTable: true } }),
|
|
101274
101276
|
};
|
|
101275
101277
|
parent.children[index] = mdNode;
|
|
101276
101278
|
};
|
|
@@ -116873,7 +116875,7 @@ const rehypeToc = ({ components = {} }) => {
|
|
|
116873
116875
|
});
|
|
116874
116876
|
};
|
|
116875
116877
|
};
|
|
116876
|
-
const MAX_DEPTH =
|
|
116878
|
+
const MAX_DEPTH = 3;
|
|
116877
116879
|
/**
|
|
116878
116880
|
* Get the depth of a heading element based on its tag name.
|
|
116879
116881
|
*
|
|
@@ -125871,6 +125873,106 @@ const generateSlugForHeadings = () => (tree) => {
|
|
|
125871
125873
|
};
|
|
125872
125874
|
/* harmony default export */ const heading_slugs = (generateSlugForHeadings);
|
|
125873
125875
|
|
|
125876
|
+
;// ./processor/transform/mdxish/images-to-jsx.ts
|
|
125877
|
+
|
|
125878
|
+
|
|
125879
|
+
|
|
125880
|
+
|
|
125881
|
+
|
|
125882
|
+
const IMAGE_ATTRS = ['align', 'alt', 'border', 'caption', 'className', 'height', 'lazy', 'src', 'title', 'width'];
|
|
125883
|
+
/** The three attributes markdown's `` can carry. Anything else forces JSX. */
|
|
125884
|
+
const PLAIN_IMAGE_ATTRS = ['alt', 'src', 'title'];
|
|
125885
|
+
const EMOJI_COLONS = /^:(.*):$/;
|
|
125886
|
+
const hasExtra = (attributes) => attributes.some(attr => !PLAIN_IMAGE_ATTRS.includes(attr.name));
|
|
125887
|
+
const toImageJsx = (attributes, children = []) => ({
|
|
125888
|
+
type: 'mdxJsxFlowElement',
|
|
125889
|
+
name: 'Image',
|
|
125890
|
+
attributes,
|
|
125891
|
+
children,
|
|
125892
|
+
});
|
|
125893
|
+
/**
|
|
125894
|
+
* An `image` is phrasing content, but the nodes it replaces here (`image-block`, and a plain
|
|
125895
|
+
* `[block:image]`) sit where flow content belongs. `mdast-util-to-markdown` picks a block separator
|
|
125896
|
+
* from the two node types around it and has no rule for phrasing-next-to-flow, so it emits none and
|
|
125897
|
+
* glues the image to whatever follows (`# Heading`), which then cascades through the rest
|
|
125898
|
+
* of the document. Wrapping restores a block for it to join against.
|
|
125899
|
+
*/
|
|
125900
|
+
const placeImage = (parent, index, image) => {
|
|
125901
|
+
const wrapped = { type: 'paragraph', children: [image] };
|
|
125902
|
+
parent.children[index] = INLINE_ONLY_PARENT_TYPES.has(parent.type) ? image : wrapped;
|
|
125903
|
+
};
|
|
125904
|
+
/**
|
|
125905
|
+
* Serializes the three image shapes a parsed document carries. An image that picked up readme
|
|
125906
|
+
* attributes has no markdown spelling left and goes out as `<Image>`, a plain one stays
|
|
125907
|
+
* ``.
|
|
125908
|
+
*
|
|
125909
|
+
* Order matters: `figure` unwraps into the `image` its caption belongs to, so it runs first.
|
|
125910
|
+
*/
|
|
125911
|
+
const imagesToJsx = () => tree => {
|
|
125912
|
+
visit(tree, NodeTypes.figure, (node, index, parent) => {
|
|
125913
|
+
if (!parent || index === undefined)
|
|
125914
|
+
return;
|
|
125915
|
+
const [image, caption] = node.children;
|
|
125916
|
+
const { align, className, width } = image.data.hProperties;
|
|
125917
|
+
parent.children[index] = toImageJsx(toAttributes({ ...image, align, width, ...(className === 'border' && { border: true }), src: image.src || image.url }, IMAGE_ATTRS),
|
|
125918
|
+
// The caption stays a child rather than a pre-serialized `caption` attribute, so readme nodes
|
|
125919
|
+
// inside it (emoji, variables, glossary) reach their own handlers instead of the bare
|
|
125920
|
+
// `toMarkdown` in `compatibility.figureToImageBlock`, which throws on them.
|
|
125921
|
+
caption.children);
|
|
125922
|
+
});
|
|
125923
|
+
visit(tree, 'image', (n, index, parent) => {
|
|
125924
|
+
const node = n;
|
|
125925
|
+
if (!parent || index === undefined)
|
|
125926
|
+
return undefined;
|
|
125927
|
+
const hProperties = node.data?.hProperties;
|
|
125928
|
+
// A `:joy:`-style shortcode round-trips as a gemoji rather than the image it parsed into.
|
|
125929
|
+
if (hProperties?.className === 'emoji' && node.title) {
|
|
125930
|
+
const emoji = {
|
|
125931
|
+
type: NodeTypes.emoji,
|
|
125932
|
+
name: node.title.replace(EMOJI_COLONS, '$1'),
|
|
125933
|
+
value: node.title,
|
|
125934
|
+
};
|
|
125935
|
+
parent.children[index] = emoji;
|
|
125936
|
+
return undefined;
|
|
125937
|
+
}
|
|
125938
|
+
if (hProperties) {
|
|
125939
|
+
const attributes = toAttributes({ ...node, ...hProperties, src: node.url }, IMAGE_ATTRS);
|
|
125940
|
+
if (hasExtra(attributes)) {
|
|
125941
|
+
parent.children[index] = toImageJsx(attributes);
|
|
125942
|
+
return undefined;
|
|
125943
|
+
}
|
|
125944
|
+
}
|
|
125945
|
+
// An attribute-less `[block:image]` parses straight to an `image` in a flow slot, so it needs
|
|
125946
|
+
// the same wrap. Editor images always arrive inside a paragraph and are left alone.
|
|
125947
|
+
if (INLINE_ONLY_PARENT_TYPES.has(parent.type))
|
|
125948
|
+
return undefined;
|
|
125949
|
+
placeImage(parent, index, node);
|
|
125950
|
+
// Step over the paragraph just created, or the visitor walks back into the same image.
|
|
125951
|
+
return [(/* inlined export .SKIP */"skip"), index + 1];
|
|
125952
|
+
});
|
|
125953
|
+
visit(tree, NodeTypes.imageBlock, (node, index, parent) => {
|
|
125954
|
+
if (!parent || index === undefined)
|
|
125955
|
+
return;
|
|
125956
|
+
// An image-block keeps its caption as children, so it has to be re-serialized back into the
|
|
125957
|
+
// `caption` attribute before the node is replaced.
|
|
125958
|
+
const captionChildren = node.children ?? [];
|
|
125959
|
+
const caption = captionChildren.length ? toMarkdown({ type: 'root', children: captionChildren }).trim() : '';
|
|
125960
|
+
const attributes = toAttributes({ ...node, ...node.data.hProperties, ...(caption && { caption }) }, IMAGE_ATTRS);
|
|
125961
|
+
if (hasExtra(attributes)) {
|
|
125962
|
+
parent.children[index] = toImageJsx(attributes);
|
|
125963
|
+
return;
|
|
125964
|
+
}
|
|
125965
|
+
placeImage(parent, index, {
|
|
125966
|
+
type: 'image',
|
|
125967
|
+
url: node.src,
|
|
125968
|
+
...(node.title && { title: node.title }),
|
|
125969
|
+
...(node.alt && { alt: node.alt }),
|
|
125970
|
+
});
|
|
125971
|
+
});
|
|
125972
|
+
return tree;
|
|
125973
|
+
};
|
|
125974
|
+
/* harmony default export */ const images_to_jsx = (imagesToJsx);
|
|
125975
|
+
|
|
125874
125976
|
// EXTERNAL MODULE: ./node_modules/@readme/variable/dist/index.js
|
|
125875
125977
|
var variable_dist = __webpack_require__(4355);
|
|
125876
125978
|
var variable_dist_default = /*#__PURE__*/__webpack_require__.n(variable_dist);
|
|
@@ -127749,13 +127851,22 @@ const mdxishTablesToJsx = () => tree => {
|
|
|
127749
127851
|
gfmCells.push([cell, normalized]);
|
|
127750
127852
|
return undefined;
|
|
127751
127853
|
});
|
|
127752
|
-
|
|
127854
|
+
const stayLowercase = table.data?.lowercaseTable === true;
|
|
127855
|
+
// We transform to GFM tables if:
|
|
127856
|
+
// 1. If it doesn't contain complex elements that the syntax can't represent
|
|
127857
|
+
// 2. The original table is not lowercase HTML <table>, because we want to
|
|
127858
|
+
// preserve original tables as much as possible
|
|
127859
|
+
if (!requiresJsxTable && !stayLowercase) {
|
|
127753
127860
|
gfmCells.forEach(([cell, children]) => {
|
|
127754
127861
|
cell.children = children;
|
|
127755
127862
|
});
|
|
127756
127863
|
table.type = 'table';
|
|
127757
127864
|
return;
|
|
127758
127865
|
}
|
|
127866
|
+
// Nothing to build a JSX table from; leave the empty node to the GFM stringifier.
|
|
127867
|
+
const [headerRow, ...bodyRows] = table.children;
|
|
127868
|
+
if (!headerRow)
|
|
127869
|
+
return;
|
|
127759
127870
|
visit(table, mdxish_tables_to_jsx_isTableCell, flattenBreaksToNewlines);
|
|
127760
127871
|
const styles = table.align.map(mdxish_tables_to_jsx_alignToStyle);
|
|
127761
127872
|
const head = {
|
|
@@ -127767,7 +127878,7 @@ const mdxishTablesToJsx = () => tree => {
|
|
|
127767
127878
|
attributes: [],
|
|
127768
127879
|
type: 'mdxJsxFlowElement',
|
|
127769
127880
|
name: 'tr',
|
|
127770
|
-
children:
|
|
127881
|
+
children: headerRow.children.map((cell, cellIndex) => {
|
|
127771
127882
|
return {
|
|
127772
127883
|
attributes: [],
|
|
127773
127884
|
type: 'mdxJsxFlowElement',
|
|
@@ -127783,7 +127894,7 @@ const mdxishTablesToJsx = () => tree => {
|
|
|
127783
127894
|
attributes: [],
|
|
127784
127895
|
type: 'mdxJsxFlowElement',
|
|
127785
127896
|
name: 'tbody',
|
|
127786
|
-
children:
|
|
127897
|
+
children: bodyRows.map(row => {
|
|
127787
127898
|
return {
|
|
127788
127899
|
attributes: [],
|
|
127789
127900
|
type: 'mdxJsxFlowElement',
|
|
@@ -127811,8 +127922,8 @@ const mdxishTablesToJsx = () => tree => {
|
|
|
127811
127922
|
];
|
|
127812
127923
|
const jsx = {
|
|
127813
127924
|
type: 'mdxJsxFlowElement',
|
|
127814
|
-
name: 'Table',
|
|
127815
|
-
attributes: table.align.find(a => a) ? attributes : [],
|
|
127925
|
+
name: stayLowercase ? 'table' : 'Table',
|
|
127926
|
+
attributes: !stayLowercase && table.align.find(a => a) ? attributes : [],
|
|
127816
127927
|
children: [head, body],
|
|
127817
127928
|
};
|
|
127818
127929
|
parent.children[index] = jsx;
|
|
@@ -127907,6 +128018,24 @@ function normalizeTableSeparator(content) {
|
|
|
127907
128018
|
}
|
|
127908
128019
|
/* harmony default export */ const normalize_table_separator = ((/* unused pure expression or super */ null && (normalizeTableSeparator)));
|
|
127909
128020
|
|
|
128021
|
+
;// ./processor/transform/mdxish/unwrap-pins.ts
|
|
128022
|
+
|
|
128023
|
+
/**
|
|
128024
|
+
* A `sidebar: true` magic block (e.g. `[block:code]`) parses into an `rdme-pin` wrapper via
|
|
128025
|
+
* `wrapPinnedBlocks`, and remark-stringify throws on any node type without a handler. The mdxish
|
|
128026
|
+
* dialect has no spelling for a pin, so the wrapper serializes as its content instead — the same
|
|
128027
|
+
* (lossy) unwrap `readmeToMdx` has always done, trading the `sidebar` flag for not crashing.
|
|
128028
|
+
*/
|
|
128029
|
+
const unwrapPins = () => tree => {
|
|
128030
|
+
visit(tree, 'rdme-pin', (node, index, parent) => {
|
|
128031
|
+
if (!parent || index === undefined)
|
|
128032
|
+
return;
|
|
128033
|
+
parent.children.splice(index, 1, ...node.children);
|
|
128034
|
+
});
|
|
128035
|
+
return tree;
|
|
128036
|
+
};
|
|
128037
|
+
/* harmony default export */ const unwrap_pins = (unwrapPins);
|
|
128038
|
+
|
|
127910
128039
|
;// ./processor/transform/mdxish/variables-code.ts
|
|
127911
128040
|
|
|
127912
128041
|
|
|
@@ -128053,6 +128182,10 @@ function loadComponents() {
|
|
|
128053
128182
|
|
|
128054
128183
|
|
|
128055
128184
|
|
|
128185
|
+
|
|
128186
|
+
|
|
128187
|
+
|
|
128188
|
+
|
|
128056
128189
|
|
|
128057
128190
|
|
|
128058
128191
|
|
|
@@ -128136,35 +128269,43 @@ function mdxishAstProcessor(mdContent, opts = {}) {
|
|
|
128136
128269
|
};
|
|
128137
128270
|
}
|
|
128138
128271
|
/**
|
|
128139
|
-
* Registers
|
|
128140
|
-
*
|
|
128272
|
+
* Registers serialization for the node types remark-stringify can't write on its own:
|
|
128273
|
+
* JSX elements (e.g. `<Table>`), MDX expressions, and ESM exports.
|
|
128141
128274
|
*/
|
|
128142
|
-
function
|
|
128275
|
+
function mdxStringifyExtensions() {
|
|
128143
128276
|
const data = this.data();
|
|
128144
128277
|
const extensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
128145
|
-
extensions.push({ extensions: [mdxJsxToMarkdown()] });
|
|
128278
|
+
extensions.push({ extensions: [mdxJsxToMarkdown(), mdxExpressionToMarkdown(), mdxjsEsmToMarkdown()] });
|
|
128146
128279
|
}
|
|
128280
|
+
const stringifyOptions = {
|
|
128281
|
+
bullet: (/* inlined export .DEFAULT_BULLET */"-"),
|
|
128282
|
+
emphasis: '_',
|
|
128283
|
+
// Escape literal braces in text so they don't parse as (often
|
|
128284
|
+
// unterminated) MDX expressions on the next round trip.
|
|
128285
|
+
unsafe: [
|
|
128286
|
+
{ character: '{', inConstruct: 'phrasing' },
|
|
128287
|
+
{ character: '}', inConstruct: 'phrasing' },
|
|
128288
|
+
],
|
|
128289
|
+
};
|
|
128147
128290
|
/**
|
|
128148
128291
|
* Serializes an Mdast back into a markdown string.
|
|
128149
128292
|
*/
|
|
128150
128293
|
function mdxishMdastToMd(mdast) {
|
|
128151
128294
|
const processor = unified()
|
|
128152
128295
|
.use(remarkGfm)
|
|
128296
|
+
// Readme nodes with no markdown spelling go out as JSX, the same tags mdxish re-parses.
|
|
128153
128297
|
.use(callout_to_jsx)
|
|
128154
128298
|
.use(mdxish_tables_to_jsx)
|
|
128155
128299
|
.use(anchor_to_jsx)
|
|
128300
|
+
// The rest only a PARSER tree carries.
|
|
128301
|
+
// A `sidebar: true` block parses into an `rdme-pin` wrapper the dialect can't spell.
|
|
128302
|
+
.use(unwrap_pins)
|
|
128303
|
+
// Figures, image blocks, and images that picked up readme attributes while parsing.
|
|
128304
|
+
.use(images_to_jsx)
|
|
128305
|
+
// Handlers for the readme nodes that stay themselves (variables, emoji, html-blocks, lists).
|
|
128156
128306
|
.use(mdxishCompilers)
|
|
128157
|
-
.use(
|
|
128158
|
-
.use(remarkStringify,
|
|
128159
|
-
bullet: (/* inlined export .DEFAULT_BULLET */"-"),
|
|
128160
|
-
emphasis: '_',
|
|
128161
|
-
// Escape literal braces in text so they don't parse as (often
|
|
128162
|
-
// unterminated) MDX expressions on the next round trip.
|
|
128163
|
-
unsafe: [
|
|
128164
|
-
{ character: '{', inConstruct: 'phrasing' },
|
|
128165
|
-
{ character: '}', inConstruct: 'phrasing' },
|
|
128166
|
-
],
|
|
128167
|
-
});
|
|
128307
|
+
.use(mdxStringifyExtensions)
|
|
128308
|
+
.use(remarkStringify, stringifyOptions);
|
|
128168
128309
|
return processor.stringify(processor.runSync(mdast));
|
|
128169
128310
|
}
|
|
128170
128311
|
/**
|
|
@@ -129233,7 +129374,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"*":["about","acceptCharset","accessK
|
|
|
129233
129374
|
/******/ // startup
|
|
129234
129375
|
/******/ // Load entry module and return exports
|
|
129235
129376
|
/******/ // This entry module used 'module' so it can't be inlined
|
|
129236
|
-
/******/ let __webpack_exports__ = __webpack_require__(
|
|
129377
|
+
/******/ let __webpack_exports__ = __webpack_require__(6817);
|
|
129237
129378
|
/******/ module.exports = __webpack_exports__;
|
|
129238
129379
|
/******/
|
|
129239
129380
|
/******/ })()
|