@readme/markdown 15.5.2 → 15.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +147 -17
- package/dist/main.node.js +147 -17
- 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 +138 -17
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +1 -1
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";
|
|
@@ -105688,6 +105688,106 @@ const generateSlugForHeadings = () => (tree) => {
|
|
|
105688
105688
|
};
|
|
105689
105689
|
/* harmony default export */ const heading_slugs = (generateSlugForHeadings);
|
|
105690
105690
|
|
|
105691
|
+
;// ./processor/transform/mdxish/images-to-jsx.ts
|
|
105692
|
+
|
|
105693
|
+
|
|
105694
|
+
|
|
105695
|
+
|
|
105696
|
+
|
|
105697
|
+
const IMAGE_ATTRS = ['align', 'alt', 'border', 'caption', 'className', 'height', 'lazy', 'src', 'title', 'width'];
|
|
105698
|
+
/** The three attributes markdown's `` can carry. Anything else forces JSX. */
|
|
105699
|
+
const PLAIN_IMAGE_ATTRS = ['alt', 'src', 'title'];
|
|
105700
|
+
const EMOJI_COLONS = /^:(.*):$/;
|
|
105701
|
+
const hasExtra = (attributes) => attributes.some(attr => !PLAIN_IMAGE_ATTRS.includes(attr.name));
|
|
105702
|
+
const toImageJsx = (attributes, children = []) => ({
|
|
105703
|
+
type: 'mdxJsxFlowElement',
|
|
105704
|
+
name: 'Image',
|
|
105705
|
+
attributes,
|
|
105706
|
+
children,
|
|
105707
|
+
});
|
|
105708
|
+
/**
|
|
105709
|
+
* An `image` is phrasing content, but the nodes it replaces here (`image-block`, and a plain
|
|
105710
|
+
* `[block:image]`) sit where flow content belongs. `mdast-util-to-markdown` picks a block separator
|
|
105711
|
+
* from the two node types around it and has no rule for phrasing-next-to-flow, so it emits none and
|
|
105712
|
+
* glues the image to whatever follows (`# Heading`), which then cascades through the rest
|
|
105713
|
+
* of the document. Wrapping restores a block for it to join against.
|
|
105714
|
+
*/
|
|
105715
|
+
const placeImage = (parent, index, image) => {
|
|
105716
|
+
const wrapped = { type: 'paragraph', children: [image] };
|
|
105717
|
+
parent.children[index] = INLINE_ONLY_PARENT_TYPES.has(parent.type) ? image : wrapped;
|
|
105718
|
+
};
|
|
105719
|
+
/**
|
|
105720
|
+
* Serializes the three image shapes a parsed document carries. An image that picked up readme
|
|
105721
|
+
* attributes has no markdown spelling left and goes out as `<Image>`, a plain one stays
|
|
105722
|
+
* ``.
|
|
105723
|
+
*
|
|
105724
|
+
* Order matters: `figure` unwraps into the `image` its caption belongs to, so it runs first.
|
|
105725
|
+
*/
|
|
105726
|
+
const imagesToJsx = () => tree => {
|
|
105727
|
+
visit(tree, NodeTypes.figure, (node, index, parent) => {
|
|
105728
|
+
if (!parent || index === undefined)
|
|
105729
|
+
return;
|
|
105730
|
+
const [image, caption] = node.children;
|
|
105731
|
+
const { align, className, width } = image.data.hProperties;
|
|
105732
|
+
parent.children[index] = toImageJsx(toAttributes({ ...image, align, width, ...(className === 'border' && { border: true }), src: image.src || image.url }, IMAGE_ATTRS),
|
|
105733
|
+
// The caption stays a child rather than a pre-serialized `caption` attribute, so readme nodes
|
|
105734
|
+
// inside it (emoji, variables, glossary) reach their own handlers instead of the bare
|
|
105735
|
+
// `toMarkdown` in `compatibility.figureToImageBlock`, which throws on them.
|
|
105736
|
+
caption.children);
|
|
105737
|
+
});
|
|
105738
|
+
visit(tree, 'image', (n, index, parent) => {
|
|
105739
|
+
const node = n;
|
|
105740
|
+
if (!parent || index === undefined)
|
|
105741
|
+
return undefined;
|
|
105742
|
+
const hProperties = node.data?.hProperties;
|
|
105743
|
+
// A `:joy:`-style shortcode round-trips as a gemoji rather than the image it parsed into.
|
|
105744
|
+
if (hProperties?.className === 'emoji' && node.title) {
|
|
105745
|
+
const emoji = {
|
|
105746
|
+
type: NodeTypes.emoji,
|
|
105747
|
+
name: node.title.replace(EMOJI_COLONS, '$1'),
|
|
105748
|
+
value: node.title,
|
|
105749
|
+
};
|
|
105750
|
+
parent.children[index] = emoji;
|
|
105751
|
+
return undefined;
|
|
105752
|
+
}
|
|
105753
|
+
if (hProperties) {
|
|
105754
|
+
const attributes = toAttributes({ ...node, ...hProperties, src: node.url }, IMAGE_ATTRS);
|
|
105755
|
+
if (hasExtra(attributes)) {
|
|
105756
|
+
parent.children[index] = toImageJsx(attributes);
|
|
105757
|
+
return undefined;
|
|
105758
|
+
}
|
|
105759
|
+
}
|
|
105760
|
+
// An attribute-less `[block:image]` parses straight to an `image` in a flow slot, so it needs
|
|
105761
|
+
// the same wrap. Editor images always arrive inside a paragraph and are left alone.
|
|
105762
|
+
if (INLINE_ONLY_PARENT_TYPES.has(parent.type))
|
|
105763
|
+
return undefined;
|
|
105764
|
+
placeImage(parent, index, node);
|
|
105765
|
+
// Step over the paragraph just created, or the visitor walks back into the same image.
|
|
105766
|
+
return [(/* inlined export .SKIP */"skip"), index + 1];
|
|
105767
|
+
});
|
|
105768
|
+
visit(tree, NodeTypes.imageBlock, (node, index, parent) => {
|
|
105769
|
+
if (!parent || index === undefined)
|
|
105770
|
+
return;
|
|
105771
|
+
// An image-block keeps its caption as children, so it has to be re-serialized back into the
|
|
105772
|
+
// `caption` attribute before the node is replaced.
|
|
105773
|
+
const captionChildren = node.children ?? [];
|
|
105774
|
+
const caption = captionChildren.length ? toMarkdown({ type: 'root', children: captionChildren }).trim() : '';
|
|
105775
|
+
const attributes = toAttributes({ ...node, ...node.data.hProperties, ...(caption && { caption }) }, IMAGE_ATTRS);
|
|
105776
|
+
if (hasExtra(attributes)) {
|
|
105777
|
+
parent.children[index] = toImageJsx(attributes);
|
|
105778
|
+
return;
|
|
105779
|
+
}
|
|
105780
|
+
placeImage(parent, index, {
|
|
105781
|
+
type: 'image',
|
|
105782
|
+
url: node.src,
|
|
105783
|
+
...(node.title && { title: node.title }),
|
|
105784
|
+
...(node.alt && { alt: node.alt }),
|
|
105785
|
+
});
|
|
105786
|
+
});
|
|
105787
|
+
return tree;
|
|
105788
|
+
};
|
|
105789
|
+
/* harmony default export */ const images_to_jsx = (imagesToJsx);
|
|
105790
|
+
|
|
105691
105791
|
// EXTERNAL MODULE: external "@readme/variable"
|
|
105692
105792
|
var variable_ = __webpack_require__(8167);
|
|
105693
105793
|
var variable_default = /*#__PURE__*/__webpack_require__.n(variable_);
|
|
@@ -107724,6 +107824,24 @@ function normalizeTableSeparator(content) {
|
|
|
107724
107824
|
}
|
|
107725
107825
|
/* harmony default export */ const normalize_table_separator = ((/* unused pure expression or super */ null && (normalizeTableSeparator)));
|
|
107726
107826
|
|
|
107827
|
+
;// ./processor/transform/mdxish/unwrap-pins.ts
|
|
107828
|
+
|
|
107829
|
+
/**
|
|
107830
|
+
* A `sidebar: true` magic block (e.g. `[block:code]`) parses into an `rdme-pin` wrapper via
|
|
107831
|
+
* `wrapPinnedBlocks`, and remark-stringify throws on any node type without a handler. The mdxish
|
|
107832
|
+
* dialect has no spelling for a pin, so the wrapper serializes as its content instead — the same
|
|
107833
|
+
* (lossy) unwrap `readmeToMdx` has always done, trading the `sidebar` flag for not crashing.
|
|
107834
|
+
*/
|
|
107835
|
+
const unwrapPins = () => tree => {
|
|
107836
|
+
visit(tree, 'rdme-pin', (node, index, parent) => {
|
|
107837
|
+
if (!parent || index === undefined)
|
|
107838
|
+
return;
|
|
107839
|
+
parent.children.splice(index, 1, ...node.children);
|
|
107840
|
+
});
|
|
107841
|
+
return tree;
|
|
107842
|
+
};
|
|
107843
|
+
/* harmony default export */ const unwrap_pins = (unwrapPins);
|
|
107844
|
+
|
|
107727
107845
|
;// ./processor/transform/mdxish/variables-code.ts
|
|
107728
107846
|
|
|
107729
107847
|
|
|
@@ -107870,6 +107988,10 @@ function loadComponents() {
|
|
|
107870
107988
|
|
|
107871
107989
|
|
|
107872
107990
|
|
|
107991
|
+
|
|
107992
|
+
|
|
107993
|
+
|
|
107994
|
+
|
|
107873
107995
|
|
|
107874
107996
|
|
|
107875
107997
|
|
|
@@ -107953,35 +108075,43 @@ function mdxishAstProcessor(mdContent, opts = {}) {
|
|
|
107953
108075
|
};
|
|
107954
108076
|
}
|
|
107955
108077
|
/**
|
|
107956
|
-
* Registers
|
|
107957
|
-
*
|
|
108078
|
+
* Registers serialization for the node types remark-stringify can't write on its own:
|
|
108079
|
+
* JSX elements (e.g. `<Table>`), MDX expressions, and ESM exports.
|
|
107958
108080
|
*/
|
|
107959
|
-
function
|
|
108081
|
+
function mdxStringifyExtensions() {
|
|
107960
108082
|
const data = this.data();
|
|
107961
108083
|
const extensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
107962
|
-
extensions.push({ extensions: [mdxJsxToMarkdown()] });
|
|
108084
|
+
extensions.push({ extensions: [mdxJsxToMarkdown(), mdxExpressionToMarkdown(), mdxjsEsmToMarkdown()] });
|
|
107963
108085
|
}
|
|
108086
|
+
const stringifyOptions = {
|
|
108087
|
+
bullet: (/* inlined export .DEFAULT_BULLET */"-"),
|
|
108088
|
+
emphasis: '_',
|
|
108089
|
+
// Escape literal braces in text so they don't parse as (often
|
|
108090
|
+
// unterminated) MDX expressions on the next round trip.
|
|
108091
|
+
unsafe: [
|
|
108092
|
+
{ character: '{', inConstruct: 'phrasing' },
|
|
108093
|
+
{ character: '}', inConstruct: 'phrasing' },
|
|
108094
|
+
],
|
|
108095
|
+
};
|
|
107964
108096
|
/**
|
|
107965
108097
|
* Serializes an Mdast back into a markdown string.
|
|
107966
108098
|
*/
|
|
107967
108099
|
function mdxishMdastToMd(mdast) {
|
|
107968
108100
|
const processor = unified()
|
|
107969
108101
|
.use(remarkGfm)
|
|
108102
|
+
// Readme nodes with no markdown spelling go out as JSX, the same tags mdxish re-parses.
|
|
107970
108103
|
.use(callout_to_jsx)
|
|
107971
108104
|
.use(mdxish_tables_to_jsx)
|
|
107972
108105
|
.use(anchor_to_jsx)
|
|
108106
|
+
// The rest only a PARSER tree carries.
|
|
108107
|
+
// A `sidebar: true` block parses into an `rdme-pin` wrapper the dialect can't spell.
|
|
108108
|
+
.use(unwrap_pins)
|
|
108109
|
+
// Figures, image blocks, and images that picked up readme attributes while parsing.
|
|
108110
|
+
.use(images_to_jsx)
|
|
108111
|
+
// Handlers for the readme nodes that stay themselves (variables, emoji, html-blocks, lists).
|
|
107973
108112
|
.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
|
-
});
|
|
108113
|
+
.use(mdxStringifyExtensions)
|
|
108114
|
+
.use(remarkStringify, stringifyOptions);
|
|
107985
108115
|
return processor.stringify(processor.runSync(mdast));
|
|
107986
108116
|
}
|
|
107987
108117
|
/**
|
|
@@ -108991,7 +109121,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"*":["about","acceptCharset","accessK
|
|
|
108991
109121
|
/******/ // startup
|
|
108992
109122
|
/******/ // Load entry module and return exports
|
|
108993
109123
|
/******/ // This entry module used 'module' so it can't be inlined
|
|
108994
|
-
/******/ let __webpack_exports__ = __webpack_require__(
|
|
109124
|
+
/******/ let __webpack_exports__ = __webpack_require__(7070);
|
|
108995
109125
|
/******/
|
|
108996
109126
|
/******/ return __webpack_exports__;
|
|
108997
109127
|
/******/ })()
|
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";
|
|
@@ -125871,6 +125871,106 @@ const generateSlugForHeadings = () => (tree) => {
|
|
|
125871
125871
|
};
|
|
125872
125872
|
/* harmony default export */ const heading_slugs = (generateSlugForHeadings);
|
|
125873
125873
|
|
|
125874
|
+
;// ./processor/transform/mdxish/images-to-jsx.ts
|
|
125875
|
+
|
|
125876
|
+
|
|
125877
|
+
|
|
125878
|
+
|
|
125879
|
+
|
|
125880
|
+
const IMAGE_ATTRS = ['align', 'alt', 'border', 'caption', 'className', 'height', 'lazy', 'src', 'title', 'width'];
|
|
125881
|
+
/** The three attributes markdown's `` can carry. Anything else forces JSX. */
|
|
125882
|
+
const PLAIN_IMAGE_ATTRS = ['alt', 'src', 'title'];
|
|
125883
|
+
const EMOJI_COLONS = /^:(.*):$/;
|
|
125884
|
+
const hasExtra = (attributes) => attributes.some(attr => !PLAIN_IMAGE_ATTRS.includes(attr.name));
|
|
125885
|
+
const toImageJsx = (attributes, children = []) => ({
|
|
125886
|
+
type: 'mdxJsxFlowElement',
|
|
125887
|
+
name: 'Image',
|
|
125888
|
+
attributes,
|
|
125889
|
+
children,
|
|
125890
|
+
});
|
|
125891
|
+
/**
|
|
125892
|
+
* An `image` is phrasing content, but the nodes it replaces here (`image-block`, and a plain
|
|
125893
|
+
* `[block:image]`) sit where flow content belongs. `mdast-util-to-markdown` picks a block separator
|
|
125894
|
+
* from the two node types around it and has no rule for phrasing-next-to-flow, so it emits none and
|
|
125895
|
+
* glues the image to whatever follows (`# Heading`), which then cascades through the rest
|
|
125896
|
+
* of the document. Wrapping restores a block for it to join against.
|
|
125897
|
+
*/
|
|
125898
|
+
const placeImage = (parent, index, image) => {
|
|
125899
|
+
const wrapped = { type: 'paragraph', children: [image] };
|
|
125900
|
+
parent.children[index] = INLINE_ONLY_PARENT_TYPES.has(parent.type) ? image : wrapped;
|
|
125901
|
+
};
|
|
125902
|
+
/**
|
|
125903
|
+
* Serializes the three image shapes a parsed document carries. An image that picked up readme
|
|
125904
|
+
* attributes has no markdown spelling left and goes out as `<Image>`, a plain one stays
|
|
125905
|
+
* ``.
|
|
125906
|
+
*
|
|
125907
|
+
* Order matters: `figure` unwraps into the `image` its caption belongs to, so it runs first.
|
|
125908
|
+
*/
|
|
125909
|
+
const imagesToJsx = () => tree => {
|
|
125910
|
+
visit(tree, NodeTypes.figure, (node, index, parent) => {
|
|
125911
|
+
if (!parent || index === undefined)
|
|
125912
|
+
return;
|
|
125913
|
+
const [image, caption] = node.children;
|
|
125914
|
+
const { align, className, width } = image.data.hProperties;
|
|
125915
|
+
parent.children[index] = toImageJsx(toAttributes({ ...image, align, width, ...(className === 'border' && { border: true }), src: image.src || image.url }, IMAGE_ATTRS),
|
|
125916
|
+
// The caption stays a child rather than a pre-serialized `caption` attribute, so readme nodes
|
|
125917
|
+
// inside it (emoji, variables, glossary) reach their own handlers instead of the bare
|
|
125918
|
+
// `toMarkdown` in `compatibility.figureToImageBlock`, which throws on them.
|
|
125919
|
+
caption.children);
|
|
125920
|
+
});
|
|
125921
|
+
visit(tree, 'image', (n, index, parent) => {
|
|
125922
|
+
const node = n;
|
|
125923
|
+
if (!parent || index === undefined)
|
|
125924
|
+
return undefined;
|
|
125925
|
+
const hProperties = node.data?.hProperties;
|
|
125926
|
+
// A `:joy:`-style shortcode round-trips as a gemoji rather than the image it parsed into.
|
|
125927
|
+
if (hProperties?.className === 'emoji' && node.title) {
|
|
125928
|
+
const emoji = {
|
|
125929
|
+
type: NodeTypes.emoji,
|
|
125930
|
+
name: node.title.replace(EMOJI_COLONS, '$1'),
|
|
125931
|
+
value: node.title,
|
|
125932
|
+
};
|
|
125933
|
+
parent.children[index] = emoji;
|
|
125934
|
+
return undefined;
|
|
125935
|
+
}
|
|
125936
|
+
if (hProperties) {
|
|
125937
|
+
const attributes = toAttributes({ ...node, ...hProperties, src: node.url }, IMAGE_ATTRS);
|
|
125938
|
+
if (hasExtra(attributes)) {
|
|
125939
|
+
parent.children[index] = toImageJsx(attributes);
|
|
125940
|
+
return undefined;
|
|
125941
|
+
}
|
|
125942
|
+
}
|
|
125943
|
+
// An attribute-less `[block:image]` parses straight to an `image` in a flow slot, so it needs
|
|
125944
|
+
// the same wrap. Editor images always arrive inside a paragraph and are left alone.
|
|
125945
|
+
if (INLINE_ONLY_PARENT_TYPES.has(parent.type))
|
|
125946
|
+
return undefined;
|
|
125947
|
+
placeImage(parent, index, node);
|
|
125948
|
+
// Step over the paragraph just created, or the visitor walks back into the same image.
|
|
125949
|
+
return [(/* inlined export .SKIP */"skip"), index + 1];
|
|
125950
|
+
});
|
|
125951
|
+
visit(tree, NodeTypes.imageBlock, (node, index, parent) => {
|
|
125952
|
+
if (!parent || index === undefined)
|
|
125953
|
+
return;
|
|
125954
|
+
// An image-block keeps its caption as children, so it has to be re-serialized back into the
|
|
125955
|
+
// `caption` attribute before the node is replaced.
|
|
125956
|
+
const captionChildren = node.children ?? [];
|
|
125957
|
+
const caption = captionChildren.length ? toMarkdown({ type: 'root', children: captionChildren }).trim() : '';
|
|
125958
|
+
const attributes = toAttributes({ ...node, ...node.data.hProperties, ...(caption && { caption }) }, IMAGE_ATTRS);
|
|
125959
|
+
if (hasExtra(attributes)) {
|
|
125960
|
+
parent.children[index] = toImageJsx(attributes);
|
|
125961
|
+
return;
|
|
125962
|
+
}
|
|
125963
|
+
placeImage(parent, index, {
|
|
125964
|
+
type: 'image',
|
|
125965
|
+
url: node.src,
|
|
125966
|
+
...(node.title && { title: node.title }),
|
|
125967
|
+
...(node.alt && { alt: node.alt }),
|
|
125968
|
+
});
|
|
125969
|
+
});
|
|
125970
|
+
return tree;
|
|
125971
|
+
};
|
|
125972
|
+
/* harmony default export */ const images_to_jsx = (imagesToJsx);
|
|
125973
|
+
|
|
125874
125974
|
// EXTERNAL MODULE: ./node_modules/@readme/variable/dist/index.js
|
|
125875
125975
|
var variable_dist = __webpack_require__(4355);
|
|
125876
125976
|
var variable_dist_default = /*#__PURE__*/__webpack_require__.n(variable_dist);
|
|
@@ -127907,6 +128007,24 @@ function normalizeTableSeparator(content) {
|
|
|
127907
128007
|
}
|
|
127908
128008
|
/* harmony default export */ const normalize_table_separator = ((/* unused pure expression or super */ null && (normalizeTableSeparator)));
|
|
127909
128009
|
|
|
128010
|
+
;// ./processor/transform/mdxish/unwrap-pins.ts
|
|
128011
|
+
|
|
128012
|
+
/**
|
|
128013
|
+
* A `sidebar: true` magic block (e.g. `[block:code]`) parses into an `rdme-pin` wrapper via
|
|
128014
|
+
* `wrapPinnedBlocks`, and remark-stringify throws on any node type without a handler. The mdxish
|
|
128015
|
+
* dialect has no spelling for a pin, so the wrapper serializes as its content instead — the same
|
|
128016
|
+
* (lossy) unwrap `readmeToMdx` has always done, trading the `sidebar` flag for not crashing.
|
|
128017
|
+
*/
|
|
128018
|
+
const unwrapPins = () => tree => {
|
|
128019
|
+
visit(tree, 'rdme-pin', (node, index, parent) => {
|
|
128020
|
+
if (!parent || index === undefined)
|
|
128021
|
+
return;
|
|
128022
|
+
parent.children.splice(index, 1, ...node.children);
|
|
128023
|
+
});
|
|
128024
|
+
return tree;
|
|
128025
|
+
};
|
|
128026
|
+
/* harmony default export */ const unwrap_pins = (unwrapPins);
|
|
128027
|
+
|
|
127910
128028
|
;// ./processor/transform/mdxish/variables-code.ts
|
|
127911
128029
|
|
|
127912
128030
|
|
|
@@ -128053,6 +128171,10 @@ function loadComponents() {
|
|
|
128053
128171
|
|
|
128054
128172
|
|
|
128055
128173
|
|
|
128174
|
+
|
|
128175
|
+
|
|
128176
|
+
|
|
128177
|
+
|
|
128056
128178
|
|
|
128057
128179
|
|
|
128058
128180
|
|
|
@@ -128136,35 +128258,43 @@ function mdxishAstProcessor(mdContent, opts = {}) {
|
|
|
128136
128258
|
};
|
|
128137
128259
|
}
|
|
128138
128260
|
/**
|
|
128139
|
-
* Registers
|
|
128140
|
-
*
|
|
128261
|
+
* Registers serialization for the node types remark-stringify can't write on its own:
|
|
128262
|
+
* JSX elements (e.g. `<Table>`), MDX expressions, and ESM exports.
|
|
128141
128263
|
*/
|
|
128142
|
-
function
|
|
128264
|
+
function mdxStringifyExtensions() {
|
|
128143
128265
|
const data = this.data();
|
|
128144
128266
|
const extensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
128145
|
-
extensions.push({ extensions: [mdxJsxToMarkdown()] });
|
|
128267
|
+
extensions.push({ extensions: [mdxJsxToMarkdown(), mdxExpressionToMarkdown(), mdxjsEsmToMarkdown()] });
|
|
128146
128268
|
}
|
|
128269
|
+
const stringifyOptions = {
|
|
128270
|
+
bullet: (/* inlined export .DEFAULT_BULLET */"-"),
|
|
128271
|
+
emphasis: '_',
|
|
128272
|
+
// Escape literal braces in text so they don't parse as (often
|
|
128273
|
+
// unterminated) MDX expressions on the next round trip.
|
|
128274
|
+
unsafe: [
|
|
128275
|
+
{ character: '{', inConstruct: 'phrasing' },
|
|
128276
|
+
{ character: '}', inConstruct: 'phrasing' },
|
|
128277
|
+
],
|
|
128278
|
+
};
|
|
128147
128279
|
/**
|
|
128148
128280
|
* Serializes an Mdast back into a markdown string.
|
|
128149
128281
|
*/
|
|
128150
128282
|
function mdxishMdastToMd(mdast) {
|
|
128151
128283
|
const processor = unified()
|
|
128152
128284
|
.use(remarkGfm)
|
|
128285
|
+
// Readme nodes with no markdown spelling go out as JSX, the same tags mdxish re-parses.
|
|
128153
128286
|
.use(callout_to_jsx)
|
|
128154
128287
|
.use(mdxish_tables_to_jsx)
|
|
128155
128288
|
.use(anchor_to_jsx)
|
|
128289
|
+
// The rest only a PARSER tree carries.
|
|
128290
|
+
// A `sidebar: true` block parses into an `rdme-pin` wrapper the dialect can't spell.
|
|
128291
|
+
.use(unwrap_pins)
|
|
128292
|
+
// Figures, image blocks, and images that picked up readme attributes while parsing.
|
|
128293
|
+
.use(images_to_jsx)
|
|
128294
|
+
// Handlers for the readme nodes that stay themselves (variables, emoji, html-blocks, lists).
|
|
128156
128295
|
.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
|
-
});
|
|
128296
|
+
.use(mdxStringifyExtensions)
|
|
128297
|
+
.use(remarkStringify, stringifyOptions);
|
|
128168
128298
|
return processor.stringify(processor.runSync(mdast));
|
|
128169
128299
|
}
|
|
128170
128300
|
/**
|
|
@@ -129233,7 +129363,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"*":["about","acceptCharset","accessK
|
|
|
129233
129363
|
/******/ // startup
|
|
129234
129364
|
/******/ // Load entry module and return exports
|
|
129235
129365
|
/******/ // This entry module used 'module' so it can't be inlined
|
|
129236
|
-
/******/ let __webpack_exports__ = __webpack_require__(
|
|
129366
|
+
/******/ let __webpack_exports__ = __webpack_require__(6817);
|
|
129237
129367
|
/******/ module.exports = __webpack_exports__;
|
|
129238
129368
|
/******/
|
|
129239
129369
|
/******/ })()
|