@readme/markdown 11.7.2 → 11.7.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/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
|
|
@@ -88129,6 +88092,21 @@ const migrateCallouts = () => (tree) => {
|
|
|
88129
88092
|
};
|
|
88130
88093
|
/* harmony default export */ const migrate_callouts = (migrateCallouts);
|
|
88131
88094
|
|
|
88095
|
+
;// ./processor/transform/migrate-html-blocks.ts
|
|
88096
|
+
|
|
88097
|
+
const MigrateHtmlBlocks = () => tree => {
|
|
88098
|
+
visit(tree, 'html-block', (node) => {
|
|
88099
|
+
const { html, runScripts } = node.data?.hProperties || {};
|
|
88100
|
+
const escaped = html.replaceAll(/\\/g, '\\\\');
|
|
88101
|
+
node.data.hProperties = {
|
|
88102
|
+
...(runScripts && { runScripts }),
|
|
88103
|
+
html: escaped,
|
|
88104
|
+
};
|
|
88105
|
+
});
|
|
88106
|
+
return tree;
|
|
88107
|
+
};
|
|
88108
|
+
/* harmony default export */ const migrate_html_blocks = (MigrateHtmlBlocks);
|
|
88109
|
+
|
|
88132
88110
|
;// ./processor/transform/migrate-html-tags.ts
|
|
88133
88111
|
|
|
88134
88112
|
// Add more visits to migrate other HTML tags here
|
|
@@ -88194,14 +88172,18 @@ const migrateComments = (doc, migrateDoc, opts) => {
|
|
|
88194
88172
|
|
|
88195
88173
|
|
|
88196
88174
|
|
|
88175
|
+
|
|
88197
88176
|
const migrateDoc = (doc, { rdmd }) => {
|
|
88198
88177
|
const ast = lib_mdastV6(doc, { rdmd });
|
|
88199
|
-
return lib_mdx(ast, {
|
|
88178
|
+
return (lib_mdx(ast, {
|
|
88179
|
+
remarkTransformers: [migrate_callouts, [migrate_link_references, { rdmd }], migrate_html_tags, migrate_html_blocks],
|
|
88180
|
+
file: doc,
|
|
88181
|
+
})
|
|
88200
88182
|
.replaceAll(/ /g, ' ')
|
|
88201
88183
|
// @note: I'm not sure what's happening, but I think mdx is converting an
|
|
88202
88184
|
// 'a' to 'a' as a means of escaping it. I think this helps with
|
|
88203
88185
|
// parsing weird cases.
|
|
88204
|
-
.replaceAll(/a/g, 'a');
|
|
88186
|
+
.replaceAll(/a/g, 'a'));
|
|
88205
88187
|
};
|
|
88206
88188
|
const migrate = (doc, opts) => {
|
|
88207
88189
|
const migratedDoc = migrateDoc(doc, opts);
|
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
|
|
@@ -108333,6 +108296,21 @@ const migrateCallouts = () => (tree) => {
|
|
|
108333
108296
|
};
|
|
108334
108297
|
/* harmony default export */ const migrate_callouts = (migrateCallouts);
|
|
108335
108298
|
|
|
108299
|
+
;// ./processor/transform/migrate-html-blocks.ts
|
|
108300
|
+
|
|
108301
|
+
const MigrateHtmlBlocks = () => tree => {
|
|
108302
|
+
visit(tree, 'html-block', (node) => {
|
|
108303
|
+
const { html, runScripts } = node.data?.hProperties || {};
|
|
108304
|
+
const escaped = html.replaceAll(/\\/g, '\\\\');
|
|
108305
|
+
node.data.hProperties = {
|
|
108306
|
+
...(runScripts && { runScripts }),
|
|
108307
|
+
html: escaped,
|
|
108308
|
+
};
|
|
108309
|
+
});
|
|
108310
|
+
return tree;
|
|
108311
|
+
};
|
|
108312
|
+
/* harmony default export */ const migrate_html_blocks = (MigrateHtmlBlocks);
|
|
108313
|
+
|
|
108336
108314
|
;// ./processor/transform/migrate-html-tags.ts
|
|
108337
108315
|
|
|
108338
108316
|
// Add more visits to migrate other HTML tags here
|
|
@@ -108398,14 +108376,18 @@ const migrateComments = (doc, migrateDoc, opts) => {
|
|
|
108398
108376
|
|
|
108399
108377
|
|
|
108400
108378
|
|
|
108379
|
+
|
|
108401
108380
|
const migrateDoc = (doc, { rdmd }) => {
|
|
108402
108381
|
const ast = lib_mdastV6(doc, { rdmd });
|
|
108403
|
-
return lib_mdx(ast, {
|
|
108382
|
+
return (lib_mdx(ast, {
|
|
108383
|
+
remarkTransformers: [migrate_callouts, [migrate_link_references, { rdmd }], migrate_html_tags, migrate_html_blocks],
|
|
108384
|
+
file: doc,
|
|
108385
|
+
})
|
|
108404
108386
|
.replaceAll(/ /g, ' ')
|
|
108405
108387
|
// @note: I'm not sure what's happening, but I think mdx is converting an
|
|
108406
108388
|
// 'a' to 'a' as a means of escaping it. I think this helps with
|
|
108407
108389
|
// parsing weird cases.
|
|
108408
|
-
.replaceAll(/a/g, 'a');
|
|
108390
|
+
.replaceAll(/a/g, 'a'));
|
|
108409
108391
|
};
|
|
108410
108392
|
const migrate = (doc, opts) => {
|
|
108411
108393
|
const migratedDoc = migrateDoc(doc, opts);
|