@readme/markdown 11.7.2 → 11.7.3
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 +21 -58
- package/dist/main.node.js +21 -58
- package/dist/main.node.js.map +1 -1
- package/dist/processor/plugin/toc.d.ts +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -82988,59 +82988,16 @@ const lib_s = create_h_createH(node_modules_property_information_svg, 'g', svg_c
|
|
|
82988
82988
|
|
|
82989
82989
|
|
|
82990
82990
|
|
|
82991
|
-
|
|
82992
|
-
|
|
82993
|
-
|
|
82994
|
-
|
|
82995
|
-
const { type, name, tagName, data, properties } = node;
|
|
82996
|
-
if (type === 'mdxJsxFlowElement' && name === 'Callout') {
|
|
82997
|
-
return true;
|
|
82998
|
-
}
|
|
82999
|
-
if (type !== 'element')
|
|
83000
|
-
return false;
|
|
83001
|
-
if (tagName === 'Callout')
|
|
83002
|
-
return true;
|
|
83003
|
-
if (typeof data === 'object' && data && 'hName' in data) {
|
|
83004
|
-
const { hName } = data;
|
|
83005
|
-
if (hName === 'Callout')
|
|
83006
|
-
return true;
|
|
83007
|
-
}
|
|
83008
|
-
if (tagName !== 'blockquote')
|
|
83009
|
-
return false;
|
|
83010
|
-
if (!properties || typeof properties !== 'object')
|
|
83011
|
-
return false;
|
|
83012
|
-
const { className } = properties;
|
|
83013
|
-
if (!className)
|
|
83014
|
-
return false;
|
|
83015
|
-
if (Array.isArray(className)) {
|
|
83016
|
-
return className.some(cls => typeof cls === 'string' && cls.startsWith('callout'));
|
|
83017
|
-
}
|
|
83018
|
-
if (typeof className === 'string') {
|
|
83019
|
-
return className.includes('callout');
|
|
83020
|
-
}
|
|
83021
|
-
return false;
|
|
83022
|
-
};
|
|
82991
|
+
/*
|
|
82992
|
+
* A rehype plugin to generate a flat list of top-level headings or jsx flow
|
|
82993
|
+
* elements.
|
|
82994
|
+
*/
|
|
83023
82995
|
const rehypeToc = ({ components = {} }) => {
|
|
83024
82996
|
return (tree) => {
|
|
83025
82997
|
if (hasNamedExport(tree, 'toc'))
|
|
83026
82998
|
return;
|
|
83027
|
-
const headings = []
|
|
83028
|
-
|
|
83029
|
-
if (isCalloutNode(node)) {
|
|
83030
|
-
return SKIP;
|
|
83031
|
-
}
|
|
83032
|
-
const insideCallout = parent ? isCalloutNode(parent) : false;
|
|
83033
|
-
if (insideCallout) {
|
|
83034
|
-
return undefined;
|
|
83035
|
-
}
|
|
83036
|
-
if (node.type === 'element' && ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(node.tagName)) {
|
|
83037
|
-
headings.push(node);
|
|
83038
|
-
}
|
|
83039
|
-
if (node.type === 'mdxJsxFlowElement' && node.name && node.name in components) {
|
|
83040
|
-
headings.push(node);
|
|
83041
|
-
}
|
|
83042
|
-
return undefined;
|
|
83043
|
-
});
|
|
82999
|
+
const headings = tree.children.filter(child => (child.type === 'element' && ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(child.tagName)) ||
|
|
83000
|
+
(child.type === 'mdxJsxFlowElement' && child.name in components));
|
|
83044
83001
|
tree.children.unshift({
|
|
83045
83002
|
type: 'mdxjsEsm',
|
|
83046
83003
|
data: {
|
|
@@ -83072,6 +83029,10 @@ const rehypeToc = ({ components = {} }) => {
|
|
|
83072
83029
|
};
|
|
83073
83030
|
const MAX_DEPTH = 2;
|
|
83074
83031
|
const getDepth = (el) => parseInt(el.tagName?.match(/^h(\d)/)[1], 10);
|
|
83032
|
+
/*
|
|
83033
|
+
* `tocToHast` consumes the list generated by `rehypeToc` and produces a hast
|
|
83034
|
+
* of nested lists to be rendered as a table of contents.
|
|
83035
|
+
*/
|
|
83075
83036
|
const tocToHast = (headings = []) => {
|
|
83076
83037
|
const min = Math.min(...headings.map(getDepth));
|
|
83077
83038
|
const ast = hastscript_lib_h('ul');
|
|
@@ -83095,17 +83056,19 @@ const tocToHast = (headings = []) => {
|
|
|
83095
83056
|
});
|
|
83096
83057
|
return ast;
|
|
83097
83058
|
};
|
|
83059
|
+
/*
|
|
83060
|
+
* `tocHastToMdx` is a utility for combining `TocList`s of a root document and
|
|
83061
|
+
* any child components it may have. Once combined it will generate a markdown
|
|
83062
|
+
* doc representing a table of contents.
|
|
83063
|
+
*/
|
|
83098
83064
|
const tocHastToMdx = (toc, components) => {
|
|
83099
|
-
|
|
83100
|
-
|
|
83101
|
-
|
|
83102
|
-
|
|
83065
|
+
if (typeof toc === 'undefined')
|
|
83066
|
+
return '';
|
|
83067
|
+
const injected = toc.flatMap(node => {
|
|
83068
|
+
return node.type === 'mdxJsxFlowElement' && node.name in components ? components[node.name] || [] : node;
|
|
83103
83069
|
});
|
|
83104
|
-
const tocHast = tocToHast(
|
|
83105
|
-
|
|
83106
|
-
// to cast it to Root. But I think there's something wrong with our
|
|
83107
|
-
// RootContentMap type.
|
|
83108
|
-
return lib_mdx(tocHast, { hast: true });
|
|
83070
|
+
const tocHast = tocToHast(injected);
|
|
83071
|
+
return lib_mdx({ type: 'root', children: [tocHast] }, { hast: true });
|
|
83109
83072
|
};
|
|
83110
83073
|
|
|
83111
83074
|
;// ./lib/compile.ts
|
package/dist/main.node.js
CHANGED
|
@@ -103192,59 +103192,16 @@ const lib_s = create_h_createH(node_modules_property_information_svg, 'g', svg_c
|
|
|
103192
103192
|
|
|
103193
103193
|
|
|
103194
103194
|
|
|
103195
|
-
|
|
103196
|
-
|
|
103197
|
-
|
|
103198
|
-
|
|
103199
|
-
const { type, name, tagName, data, properties } = node;
|
|
103200
|
-
if (type === 'mdxJsxFlowElement' && name === 'Callout') {
|
|
103201
|
-
return true;
|
|
103202
|
-
}
|
|
103203
|
-
if (type !== 'element')
|
|
103204
|
-
return false;
|
|
103205
|
-
if (tagName === 'Callout')
|
|
103206
|
-
return true;
|
|
103207
|
-
if (typeof data === 'object' && data && 'hName' in data) {
|
|
103208
|
-
const { hName } = data;
|
|
103209
|
-
if (hName === 'Callout')
|
|
103210
|
-
return true;
|
|
103211
|
-
}
|
|
103212
|
-
if (tagName !== 'blockquote')
|
|
103213
|
-
return false;
|
|
103214
|
-
if (!properties || typeof properties !== 'object')
|
|
103215
|
-
return false;
|
|
103216
|
-
const { className } = properties;
|
|
103217
|
-
if (!className)
|
|
103218
|
-
return false;
|
|
103219
|
-
if (Array.isArray(className)) {
|
|
103220
|
-
return className.some(cls => typeof cls === 'string' && cls.startsWith('callout'));
|
|
103221
|
-
}
|
|
103222
|
-
if (typeof className === 'string') {
|
|
103223
|
-
return className.includes('callout');
|
|
103224
|
-
}
|
|
103225
|
-
return false;
|
|
103226
|
-
};
|
|
103195
|
+
/*
|
|
103196
|
+
* A rehype plugin to generate a flat list of top-level headings or jsx flow
|
|
103197
|
+
* elements.
|
|
103198
|
+
*/
|
|
103227
103199
|
const rehypeToc = ({ components = {} }) => {
|
|
103228
103200
|
return (tree) => {
|
|
103229
103201
|
if (hasNamedExport(tree, 'toc'))
|
|
103230
103202
|
return;
|
|
103231
|
-
const headings = []
|
|
103232
|
-
|
|
103233
|
-
if (isCalloutNode(node)) {
|
|
103234
|
-
return SKIP;
|
|
103235
|
-
}
|
|
103236
|
-
const insideCallout = parent ? isCalloutNode(parent) : false;
|
|
103237
|
-
if (insideCallout) {
|
|
103238
|
-
return undefined;
|
|
103239
|
-
}
|
|
103240
|
-
if (node.type === 'element' && ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(node.tagName)) {
|
|
103241
|
-
headings.push(node);
|
|
103242
|
-
}
|
|
103243
|
-
if (node.type === 'mdxJsxFlowElement' && node.name && node.name in components) {
|
|
103244
|
-
headings.push(node);
|
|
103245
|
-
}
|
|
103246
|
-
return undefined;
|
|
103247
|
-
});
|
|
103203
|
+
const headings = tree.children.filter(child => (child.type === 'element' && ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(child.tagName)) ||
|
|
103204
|
+
(child.type === 'mdxJsxFlowElement' && child.name in components));
|
|
103248
103205
|
tree.children.unshift({
|
|
103249
103206
|
type: 'mdxjsEsm',
|
|
103250
103207
|
data: {
|
|
@@ -103276,6 +103233,10 @@ const rehypeToc = ({ components = {} }) => {
|
|
|
103276
103233
|
};
|
|
103277
103234
|
const MAX_DEPTH = 2;
|
|
103278
103235
|
const getDepth = (el) => parseInt(el.tagName?.match(/^h(\d)/)[1], 10);
|
|
103236
|
+
/*
|
|
103237
|
+
* `tocToHast` consumes the list generated by `rehypeToc` and produces a hast
|
|
103238
|
+
* of nested lists to be rendered as a table of contents.
|
|
103239
|
+
*/
|
|
103279
103240
|
const tocToHast = (headings = []) => {
|
|
103280
103241
|
const min = Math.min(...headings.map(getDepth));
|
|
103281
103242
|
const ast = hastscript_lib_h('ul');
|
|
@@ -103299,17 +103260,19 @@ const tocToHast = (headings = []) => {
|
|
|
103299
103260
|
});
|
|
103300
103261
|
return ast;
|
|
103301
103262
|
};
|
|
103263
|
+
/*
|
|
103264
|
+
* `tocHastToMdx` is a utility for combining `TocList`s of a root document and
|
|
103265
|
+
* any child components it may have. Once combined it will generate a markdown
|
|
103266
|
+
* doc representing a table of contents.
|
|
103267
|
+
*/
|
|
103302
103268
|
const tocHastToMdx = (toc, components) => {
|
|
103303
|
-
|
|
103304
|
-
|
|
103305
|
-
|
|
103306
|
-
|
|
103269
|
+
if (typeof toc === 'undefined')
|
|
103270
|
+
return '';
|
|
103271
|
+
const injected = toc.flatMap(node => {
|
|
103272
|
+
return node.type === 'mdxJsxFlowElement' && node.name in components ? components[node.name] || [] : node;
|
|
103307
103273
|
});
|
|
103308
|
-
const tocHast = tocToHast(
|
|
103309
|
-
|
|
103310
|
-
// to cast it to Root. But I think there's something wrong with our
|
|
103311
|
-
// RootContentMap type.
|
|
103312
|
-
return lib_mdx(tocHast, { hast: true });
|
|
103274
|
+
const tocHast = tocToHast(injected);
|
|
103275
|
+
return lib_mdx({ type: 'root', children: [tocHast] }, { hast: true });
|
|
103313
103276
|
};
|
|
103314
103277
|
|
|
103315
103278
|
;// ./lib/compile.ts
|