@readme/markdown 7.11.0 → 7.12.1
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/lib/exports.d.ts +2 -0
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/run.d.ts +1 -7
- package/dist/main.js +133 -79
- package/dist/main.node.js +133 -79
- package/dist/processor/utils.d.ts +9 -2
- package/dist/utils/user.d.ts +10 -0
- package/package.json +1 -1
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export type { MdastOpts } from './ast-processor';
|
|
2
2
|
export { default as astProcessor, remarkPlugins } from './ast-processor';
|
|
3
3
|
export { default as compile } from './compile';
|
|
4
|
+
export { default as exports } from './exports';
|
|
4
5
|
export { default as hast } from './hast';
|
|
5
6
|
export { default as mdast } from './mdast';
|
|
6
7
|
export { default as mdastV6 } from './mdastV6';
|
|
7
8
|
export { default as mdx } from './mdx';
|
|
9
|
+
export { default as migrate } from './migrate';
|
|
8
10
|
export { default as plain } from './plain';
|
|
9
11
|
export { default as run } from './run';
|
|
10
12
|
export { default as tags } from './tags';
|
|
11
|
-
export { default as migrate } from './migrate';
|
package/dist/lib/run.d.ts
CHANGED
|
@@ -2,13 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { RunOptions } from '@mdx-js/mdx';
|
|
3
3
|
import { GlossaryTerm } from '../contexts/GlossaryTerms';
|
|
4
4
|
import { CustomComponents } from '../types';
|
|
5
|
-
|
|
6
|
-
user: Record<string, string>;
|
|
7
|
-
defaults: {
|
|
8
|
-
name: string;
|
|
9
|
-
default: string;
|
|
10
|
-
}[];
|
|
11
|
-
}
|
|
5
|
+
import { Variables } from '../utils/user';
|
|
12
6
|
export type RunOpts = Omit<RunOptions, 'Fragment'> & {
|
|
13
7
|
components?: CustomComponents;
|
|
14
8
|
imports?: Record<string, unknown>;
|
package/dist/main.js
CHANGED
|
@@ -26117,7 +26117,7 @@ function toResult(value) {
|
|
|
26117
26117
|
* @template {Test} Check
|
|
26118
26118
|
* `unist-util-is`-compatible test.
|
|
26119
26119
|
*/
|
|
26120
|
-
function
|
|
26120
|
+
function lib_visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
|
|
26121
26121
|
/** @type {boolean | null | undefined} */
|
|
26122
26122
|
let reverse
|
|
26123
26123
|
/** @type {Test} */
|
|
@@ -26172,7 +26172,7 @@ function formatHeadingAsSetext(node, state) {
|
|
|
26172
26172
|
|
|
26173
26173
|
// Look for literals with a line break.
|
|
26174
26174
|
// Note that this also
|
|
26175
|
-
|
|
26175
|
+
lib_visit(node, function (node) {
|
|
26176
26176
|
if (
|
|
26177
26177
|
('value' in node && /\r?\n|\r/.test(node.value)) ||
|
|
26178
26178
|
node.type === 'break'
|
|
@@ -39512,7 +39512,7 @@ const lib_SKIP = Symbol('skip')
|
|
|
39512
39512
|
* @returns {undefined}
|
|
39513
39513
|
* Nothing.
|
|
39514
39514
|
*/
|
|
39515
|
-
function
|
|
39515
|
+
function estree_util_visit_lib_visit(tree, visitor) {
|
|
39516
39516
|
/** @type {Visitor | undefined} */
|
|
39517
39517
|
let enter
|
|
39518
39518
|
/** @type {Visitor | undefined} */
|
|
@@ -39815,7 +39815,7 @@ function eventsToAcorn(events, options) {
|
|
|
39815
39815
|
estree.comments = comments;
|
|
39816
39816
|
|
|
39817
39817
|
// @ts-expect-error: acorn looks enough like estree.
|
|
39818
|
-
|
|
39818
|
+
estree_util_visit_lib_visit(estree, function (esnode, field, index, parents) {
|
|
39819
39819
|
let context = /** @type {AcornNode | Array<AcornNode>} */
|
|
39820
39820
|
parents[parents.length - 1];
|
|
39821
39821
|
/** @type {number | string | undefined} */
|
|
@@ -47941,7 +47941,7 @@ var NodeTypes;
|
|
|
47941
47941
|
const regex = `^(${emoji_regex().source}|⚠)(\\s+|$)`;
|
|
47942
47942
|
const calloutTransformer = () => {
|
|
47943
47943
|
return (tree) => {
|
|
47944
|
-
|
|
47944
|
+
lib_visit(tree, 'blockquote', (node) => {
|
|
47945
47945
|
if (!(node.children[0].type === 'paragraph' && node.children[0].children[0].type === 'text'))
|
|
47946
47946
|
return;
|
|
47947
47947
|
const startText = node.children[0].children[0].value;
|
|
@@ -47971,13 +47971,13 @@ const calloutTransformer = () => {
|
|
|
47971
47971
|
|
|
47972
47972
|
const isCode = (node) => (node === null || node === void 0 ? void 0 : node.type) === 'code';
|
|
47973
47973
|
const codeTabsTransformer = ({ copyButtons } = {}) => (tree) => {
|
|
47974
|
-
|
|
47974
|
+
lib_visit(tree, 'code', (node) => {
|
|
47975
47975
|
const { lang, meta, value } = node;
|
|
47976
47976
|
node.data = {
|
|
47977
47977
|
hProperties: { lang, meta, value, copyButtons },
|
|
47978
47978
|
};
|
|
47979
47979
|
});
|
|
47980
|
-
|
|
47980
|
+
lib_visit(tree, 'code', (node, index, parent) => {
|
|
47981
47981
|
if (parent.type === 'code-tabs' || !('children' in parent))
|
|
47982
47982
|
return;
|
|
47983
47983
|
const length = parent.children.length;
|
|
@@ -48020,7 +48020,7 @@ const codeTabsTransformer = ({ copyButtons } = {}) => (tree) => {
|
|
|
48020
48020
|
|
|
48021
48021
|
const embedTransformer = () => {
|
|
48022
48022
|
return (tree) => {
|
|
48023
|
-
|
|
48023
|
+
lib_visit(tree, 'paragraph', (node, i, parent) => {
|
|
48024
48024
|
var _a, _b, _c;
|
|
48025
48025
|
const [{ url, title, children = [] }] = node.children;
|
|
48026
48026
|
if (title !== '@embed')
|
|
@@ -48047,12 +48047,12 @@ const embedTransformer = () => {
|
|
|
48047
48047
|
|
|
48048
48048
|
;// ./lib/mdast.ts
|
|
48049
48049
|
|
|
48050
|
-
const
|
|
48050
|
+
const mdast_mdast = (text, opts = {}) => {
|
|
48051
48051
|
const processor = ast_processor(opts);
|
|
48052
48052
|
const tree = processor.parse(text);
|
|
48053
48053
|
return processor.runSync(tree);
|
|
48054
48054
|
};
|
|
48055
|
-
/* harmony default export */ const lib_mdast = (
|
|
48055
|
+
/* harmony default export */ const lib_mdast = (mdast_mdast);
|
|
48056
48056
|
|
|
48057
48057
|
;// ./processor/utils.ts
|
|
48058
48058
|
|
|
@@ -48144,11 +48144,20 @@ const getChildren = (jsx) => jsx.children.reduce((memo, child, i) => {
|
|
|
48144
48144
|
* TODO: Make this more extensible to all types of nodes. isElement(node, 'type' or ['type1', 'type2']), say
|
|
48145
48145
|
*
|
|
48146
48146
|
* @param {Node} node
|
|
48147
|
-
* @returns {(node is MdxJsxFlowElement | MdxJsxTextElement)}
|
|
48147
|
+
* @returns {(node is MdxJsxFlowElement | MdxJsxTextElement | MdxjsEsm)}
|
|
48148
48148
|
*/
|
|
48149
48149
|
const isMDXElement = (node) => {
|
|
48150
48150
|
return ['mdxJsxFlowElement', 'mdxJsxTextElement'].includes(node.type);
|
|
48151
48151
|
};
|
|
48152
|
+
/**
|
|
48153
|
+
* Tests if a node is an MDX ESM element (i.e. import or export).
|
|
48154
|
+
*
|
|
48155
|
+
* @param {Node} node
|
|
48156
|
+
* @returns {boolean}
|
|
48157
|
+
*/
|
|
48158
|
+
const utils_isMDXEsm = (node) => {
|
|
48159
|
+
return node.type === 'mdxjsEsm';
|
|
48160
|
+
};
|
|
48152
48161
|
/**
|
|
48153
48162
|
* Takes an HTML string and formats it for display in the editor. Removes leading/trailing newlines
|
|
48154
48163
|
* and unindents the HTML.
|
|
@@ -48181,7 +48190,7 @@ const formatHTML = (html) => {
|
|
|
48181
48190
|
*/
|
|
48182
48191
|
const reformatHTML = (html, indent = 2) => {
|
|
48183
48192
|
// Remove leading/trailing newlines
|
|
48184
|
-
const cleaned = html.replace(/^\s*\n|\n\s*$/g, '');
|
|
48193
|
+
const cleaned = html.replace(/^\s*\n|\n\s*$/g, '').replaceAll(/(?<!\\(\\\\)*)`/g, '\\`');
|
|
48185
48194
|
// // Create a tab/indent with the specified number of spaces
|
|
48186
48195
|
// const tab = ' '.repeat(indent);
|
|
48187
48196
|
// // Indent each line of the HTML (converts to an array, indents each line, then joins back)
|
|
@@ -48235,7 +48244,7 @@ const toAttributes = (object, keys = []) => {
|
|
|
48235
48244
|
|
|
48236
48245
|
|
|
48237
48246
|
const imageTransformer = () => (tree) => {
|
|
48238
|
-
|
|
48247
|
+
lib_visit(tree, 'paragraph', (node, i, parent) => {
|
|
48239
48248
|
var _a;
|
|
48240
48249
|
// check if inline
|
|
48241
48250
|
if (parent.type !== 'root' || ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 || node.children[0].type !== 'image')
|
|
@@ -48259,7 +48268,7 @@ const imageTransformer = () => (tree) => {
|
|
|
48259
48268
|
parent.children.splice(i, 1, newNode);
|
|
48260
48269
|
});
|
|
48261
48270
|
const isImage = (node) => node.name === 'Image';
|
|
48262
|
-
|
|
48271
|
+
lib_visit(tree, isImage, (node) => {
|
|
48263
48272
|
const attrs = getAttrs(node);
|
|
48264
48273
|
if (attrs.caption) {
|
|
48265
48274
|
node.children = lib_mdast(attrs.caption).children;
|
|
@@ -65259,17 +65268,17 @@ const gemojiTransformer = () => (tree) => {
|
|
|
65259
65268
|
const strongTest = (node) => ['emphasis', 'strong'].includes(node.type);
|
|
65260
65269
|
const compatibilityTransfomer = () => tree => {
|
|
65261
65270
|
const trimEmphasis = (node) => {
|
|
65262
|
-
|
|
65271
|
+
lib_visit(node, 'text', child => {
|
|
65263
65272
|
child.value = child.value.trim();
|
|
65264
65273
|
return EXIT;
|
|
65265
65274
|
});
|
|
65266
65275
|
return node;
|
|
65267
65276
|
};
|
|
65268
|
-
|
|
65277
|
+
lib_visit(tree, strongTest, node => {
|
|
65269
65278
|
trimEmphasis(node);
|
|
65270
65279
|
return SKIP;
|
|
65271
65280
|
});
|
|
65272
|
-
|
|
65281
|
+
lib_visit(tree, 'image', (node, index, parent) => {
|
|
65273
65282
|
if (phrasing(parent) || !parent.children.every(child => child.type === 'image' || !phrasing(child)))
|
|
65274
65283
|
return;
|
|
65275
65284
|
parent.children.splice(index, 1, { type: 'paragraph', children: [node] });
|
|
@@ -65293,7 +65302,7 @@ var div_rest = (undefined && undefined.__rest) || function (s, e) {
|
|
|
65293
65302
|
|
|
65294
65303
|
|
|
65295
65304
|
const divTransformer = () => tree => {
|
|
65296
|
-
|
|
65305
|
+
lib_visit(tree, 'div', (node, index, parent) => {
|
|
65297
65306
|
var _a;
|
|
65298
65307
|
const type = (_a = node.data) === null || _a === void 0 ? void 0 : _a.hName;
|
|
65299
65308
|
switch (type) {
|
|
@@ -65321,7 +65330,7 @@ const inject = ({ components } = {}) => (node, index, parent) => {
|
|
|
65321
65330
|
parent.children.splice(index, children.length, ...children);
|
|
65322
65331
|
};
|
|
65323
65332
|
const injectComponents = (opts) => () => tree => {
|
|
65324
|
-
|
|
65333
|
+
lib_visit(tree, isMDXElement, inject(opts));
|
|
65325
65334
|
return tree;
|
|
65326
65335
|
};
|
|
65327
65336
|
/* harmony default export */ const inject_components = (injectComponents);
|
|
@@ -65341,7 +65350,7 @@ const setData = (node, index, parent) => {
|
|
|
65341
65350
|
} });
|
|
65342
65351
|
};
|
|
65343
65352
|
const mdxToHast = () => tree => {
|
|
65344
|
-
|
|
65353
|
+
lib_visit(tree, isMDXElement, setData);
|
|
65345
65354
|
return tree;
|
|
65346
65355
|
};
|
|
65347
65356
|
/* harmony default export */ const mdx_to_hast = (mdxToHast);
|
|
@@ -65349,7 +65358,7 @@ const mdxToHast = () => tree => {
|
|
|
65349
65358
|
;// ./processor/transform/mermaid.ts
|
|
65350
65359
|
|
|
65351
65360
|
const mermaidTransformer = () => (tree) => {
|
|
65352
|
-
|
|
65361
|
+
lib_visit(tree, 'element', (node) => {
|
|
65353
65362
|
if (node.tagName !== 'pre' || node.children.length !== 1)
|
|
65354
65363
|
return;
|
|
65355
65364
|
const [child] = node.children;
|
|
@@ -65438,9 +65447,9 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
|
|
|
65438
65447
|
const { position } = node;
|
|
65439
65448
|
const { align = [...new Array(node.children.length)].map(() => null) } = getAttrs(node);
|
|
65440
65449
|
let children = [];
|
|
65441
|
-
|
|
65450
|
+
lib_visit(node, { name: 'tr' }, row => {
|
|
65442
65451
|
let rowChildren = [];
|
|
65443
|
-
|
|
65452
|
+
lib_visit(row, isTableCell, ({ name, children, position }) => {
|
|
65444
65453
|
rowChildren.push({
|
|
65445
65454
|
type: tableTypes[name],
|
|
65446
65455
|
children,
|
|
@@ -65459,7 +65468,7 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
|
|
|
65459
65468
|
position,
|
|
65460
65469
|
children,
|
|
65461
65470
|
};
|
|
65462
|
-
|
|
65471
|
+
lib_visit(mdNode, isMDXElement, coerceJsxToMd({ components, html }));
|
|
65463
65472
|
parent.children[index] = mdNode;
|
|
65464
65473
|
return SKIP;
|
|
65465
65474
|
}
|
|
@@ -65502,8 +65511,8 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
|
|
|
65502
65511
|
}
|
|
65503
65512
|
};
|
|
65504
65513
|
const readmeComponents = (opts) => () => tree => {
|
|
65505
|
-
|
|
65506
|
-
|
|
65514
|
+
lib_visit(tree, isMDXElement, coerceJsxToMd(opts));
|
|
65515
|
+
lib_visit(tree, 'paragraph', (node, index, parent) => {
|
|
65507
65516
|
// @ts-ignore
|
|
65508
65517
|
if (parent.type !== 'tableRow')
|
|
65509
65518
|
return;
|
|
@@ -65521,11 +65530,11 @@ const readmeComponents = (opts) => () => tree => {
|
|
|
65521
65530
|
const imageAttrs = ['align', 'alt', 'caption', 'border', 'height', 'src', 'title', 'width', 'lazy', 'className'];
|
|
65522
65531
|
const readmeToMdx = () => tree => {
|
|
65523
65532
|
// Unwrap pinned nodes, replace rdme-pin with its child node
|
|
65524
|
-
|
|
65533
|
+
lib_visit(tree, 'rdme-pin', (node, i, parent) => {
|
|
65525
65534
|
const newNode = node.children[0];
|
|
65526
65535
|
parent.children.splice(i, 1, newNode);
|
|
65527
65536
|
});
|
|
65528
|
-
|
|
65537
|
+
lib_visit(tree, NodeTypes.tutorialTile, (tile, index, parent) => {
|
|
65529
65538
|
parent.children.splice(index, 1, {
|
|
65530
65539
|
type: 'mdxJsxFlowElement',
|
|
65531
65540
|
name: 'TutorialTile',
|
|
@@ -65533,7 +65542,7 @@ const readmeToMdx = () => tree => {
|
|
|
65533
65542
|
children: [],
|
|
65534
65543
|
});
|
|
65535
65544
|
});
|
|
65536
|
-
|
|
65545
|
+
lib_visit(tree, 'figure', (figure, index, parent) => {
|
|
65537
65546
|
const [image, caption] = figure.children;
|
|
65538
65547
|
const { align, width } = image.data.hProperties;
|
|
65539
65548
|
const border = image.data.hProperties.className === 'border';
|
|
@@ -65545,7 +65554,7 @@ const readmeToMdx = () => tree => {
|
|
|
65545
65554
|
});
|
|
65546
65555
|
});
|
|
65547
65556
|
const hasExtra = (attributes) => !!attributes.find(attr => !['alt', 'src', 'title'].includes(attr.name));
|
|
65548
|
-
|
|
65557
|
+
lib_visit(tree, 'image', (image, index, parent) => {
|
|
65549
65558
|
if (!('data' in image))
|
|
65550
65559
|
return;
|
|
65551
65560
|
if ('url' in image)
|
|
@@ -65567,7 +65576,7 @@ const readmeToMdx = () => tree => {
|
|
|
65567
65576
|
});
|
|
65568
65577
|
}
|
|
65569
65578
|
});
|
|
65570
|
-
|
|
65579
|
+
lib_visit(tree, NodeTypes.imageBlock, (image, index, parent) => {
|
|
65571
65580
|
const attributes = toAttributes(image.data.hProperties, imageAttrs);
|
|
65572
65581
|
if (hasExtra(attributes)) {
|
|
65573
65582
|
parent.children.splice(index, 1, {
|
|
@@ -65581,7 +65590,7 @@ const readmeToMdx = () => tree => {
|
|
|
65581
65590
|
parent.children.splice(index, 1, Object.assign(Object.assign(Object.assign({ type: 'image', children: [] }, (image.src && { url: image.src })), (image.title && { title: image.title })), (image.alt && { alt: image.alt })));
|
|
65582
65591
|
}
|
|
65583
65592
|
});
|
|
65584
|
-
|
|
65593
|
+
lib_visit(tree, 'html', (node, index, parent) => {
|
|
65585
65594
|
const html = node.value;
|
|
65586
65595
|
const isScriptOrStyleTag = [!!html.match(/^<(?:style|script)/i), !!html.match(/<\/(?:style|script)>$/i)];
|
|
65587
65596
|
if (!isScriptOrStyleTag.includes(true))
|
|
@@ -65624,21 +65633,21 @@ const visitor = (table, index, parent) => {
|
|
|
65624
65633
|
: cell.children[0];
|
|
65625
65634
|
// @note: Compatibility with RDMD. Ideally, I'd put this in a separate
|
|
65626
65635
|
// transformer, but then there'd be some duplication.
|
|
65627
|
-
|
|
65636
|
+
lib_visit(cell, 'break', (_, index, parent) => {
|
|
65628
65637
|
parent.children.splice(index, 1, { type: 'text', value: '\n' });
|
|
65629
65638
|
});
|
|
65630
65639
|
if (!phrasing(content) && content.type !== 'escape') {
|
|
65631
65640
|
hasFlowContent = true;
|
|
65632
65641
|
return EXIT;
|
|
65633
65642
|
}
|
|
65634
|
-
|
|
65643
|
+
lib_visit(cell, isLiteral, (node) => {
|
|
65635
65644
|
if (node.value.match(/\n/)) {
|
|
65636
65645
|
hasFlowContent = true;
|
|
65637
65646
|
return EXIT;
|
|
65638
65647
|
}
|
|
65639
65648
|
});
|
|
65640
65649
|
};
|
|
65641
|
-
|
|
65650
|
+
lib_visit(table, tables_to_jsx_isTableCell, tableCellVisitor);
|
|
65642
65651
|
if (!hasFlowContent) {
|
|
65643
65652
|
table.type = 'table';
|
|
65644
65653
|
return;
|
|
@@ -65686,7 +65695,7 @@ const visitor = (table, index, parent) => {
|
|
|
65686
65695
|
};
|
|
65687
65696
|
const isTable = (node) => ['table', 'tableau'].includes(node.type);
|
|
65688
65697
|
const tablesToJsx = () => tree => {
|
|
65689
|
-
|
|
65698
|
+
lib_visit(tree, isTable, visitor);
|
|
65690
65699
|
return tree;
|
|
65691
65700
|
};
|
|
65692
65701
|
/* harmony default export */ const tables_to_jsx = (tablesToJsx);
|
|
@@ -65695,7 +65704,7 @@ const tablesToJsx = () => tree => {
|
|
|
65695
65704
|
|
|
65696
65705
|
|
|
65697
65706
|
const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
65698
|
-
|
|
65707
|
+
lib_visit(tree, (node, index, parent) => {
|
|
65699
65708
|
var _a, _b;
|
|
65700
65709
|
if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
|
|
65701
65710
|
return;
|
|
@@ -65975,7 +65984,7 @@ function rehypeSlug(options) {
|
|
|
65975
65984
|
return function (tree) {
|
|
65976
65985
|
slugs.reset()
|
|
65977
65986
|
|
|
65978
|
-
|
|
65987
|
+
lib_visit(tree, 'element', function (node) {
|
|
65979
65988
|
if (headingRank(node) && !node.properties.id) {
|
|
65980
65989
|
node.properties.id = prefix + slugs.slug(hast_util_to_string_lib_toString(node))
|
|
65981
65990
|
}
|
|
@@ -74098,7 +74107,7 @@ function state_createState(tree, options) {
|
|
|
74098
74107
|
wrap: state_wrap
|
|
74099
74108
|
}
|
|
74100
74109
|
|
|
74101
|
-
|
|
74110
|
+
lib_visit(tree, function (node) {
|
|
74102
74111
|
if (node.type === 'definition' || node.type === 'footnoteDefinition') {
|
|
74103
74112
|
const map = node.type === 'definition' ? definitionById : footnoteById
|
|
74104
74113
|
const id = String(node.identifier).toUpperCase()
|
|
@@ -76759,7 +76768,7 @@ function rehypeRemoveRaw() {
|
|
|
76759
76768
|
* Nothing.
|
|
76760
76769
|
*/
|
|
76761
76770
|
return function (tree) {
|
|
76762
|
-
|
|
76771
|
+
lib_visit(tree, 'raw', function (_, index, parent) {
|
|
76763
76772
|
if (parent && typeof index === 'number') {
|
|
76764
76773
|
parent.children.splice(index, 1)
|
|
76765
76774
|
return index
|
|
@@ -76883,7 +76892,7 @@ function remarkMarkAndUnravel() {
|
|
|
76883
76892
|
* Nothing.
|
|
76884
76893
|
*/
|
|
76885
76894
|
return function (tree) {
|
|
76886
|
-
|
|
76895
|
+
lib_visit(tree, function (node, index, parent) {
|
|
76887
76896
|
let offset = -1
|
|
76888
76897
|
let all = true
|
|
76889
76898
|
let oneOrMore = false
|
|
@@ -78502,7 +78511,7 @@ const tocToHast = (headings = []) => {
|
|
|
78502
78511
|
};
|
|
78503
78512
|
const tocToMdx = (toc, components) => {
|
|
78504
78513
|
const tree = { type: 'root', children: toc };
|
|
78505
|
-
|
|
78514
|
+
lib_visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {
|
|
78506
78515
|
const toc = components[node.name].toc || [];
|
|
78507
78516
|
parent.children.splice(index, 1, ...toc);
|
|
78508
78517
|
});
|
|
@@ -78558,9 +78567,10 @@ const compile_compile = (text, _a = {}) => {
|
|
|
78558
78567
|
remarkGfm,
|
|
78559
78568
|
...Object.values(transforms),
|
|
78560
78569
|
[compile_codeTabsTransformer, { copyButtons }],
|
|
78561
|
-
transform_variables,
|
|
78562
78570
|
], rehypePlugins: [...rehypePlugins, [rehypeToc, { components }]] }, opts));
|
|
78563
|
-
return String(vfile)
|
|
78571
|
+
return String(vfile)
|
|
78572
|
+
.replace(/await import\(_resolveDynamicMdxSpecifier\(('react'|"react")\)\)/, 'arguments[0].imports.React')
|
|
78573
|
+
.replace('"use strict";', '"use strict";\nconst { user } = arguments[0].imports;');
|
|
78564
78574
|
}
|
|
78565
78575
|
catch (error) {
|
|
78566
78576
|
throw error.line ? new MdxSyntaxError(error, text) : error;
|
|
@@ -78568,6 +78578,24 @@ const compile_compile = (text, _a = {}) => {
|
|
|
78568
78578
|
};
|
|
78569
78579
|
/* harmony default export */ const lib_compile = (compile_compile);
|
|
78570
78580
|
|
|
78581
|
+
;// ./lib/exports.ts
|
|
78582
|
+
|
|
78583
|
+
|
|
78584
|
+
|
|
78585
|
+
const EXPORT_NAME_REGEX = /export\s+(?:const|let|var|function)\s+(\w+)/;
|
|
78586
|
+
const exports_exports = (doc) => {
|
|
78587
|
+
const set = new Set();
|
|
78588
|
+
visit(mdast(doc), isMDXEsm, (node) => {
|
|
78589
|
+
var _a;
|
|
78590
|
+
if ((_a = node.value) === null || _a === void 0 ? void 0 : _a.match(EXPORT_NAME_REGEX)) {
|
|
78591
|
+
const [, name] = node.value.match(EXPORT_NAME_REGEX);
|
|
78592
|
+
set.add(name);
|
|
78593
|
+
}
|
|
78594
|
+
});
|
|
78595
|
+
return Array.from(set);
|
|
78596
|
+
};
|
|
78597
|
+
/* harmony default export */ const lib_exports = ((/* unused pure expression or super */ null && (exports_exports)));
|
|
78598
|
+
|
|
78571
78599
|
;// ./lib/hast.ts
|
|
78572
78600
|
|
|
78573
78601
|
|
|
@@ -78609,7 +78637,7 @@ const addSpaceAfter = (index, parent) => {
|
|
|
78609
78637
|
};
|
|
78610
78638
|
const trimEmphasis = (node, index, parent) => {
|
|
78611
78639
|
let trimmed = false;
|
|
78612
|
-
|
|
78640
|
+
lib_visit(node, 'text', (child) => {
|
|
78613
78641
|
const newValue = child.value.trimStart();
|
|
78614
78642
|
if (newValue !== child.value) {
|
|
78615
78643
|
trimmed = true;
|
|
@@ -78617,7 +78645,7 @@ const trimEmphasis = (node, index, parent) => {
|
|
|
78617
78645
|
}
|
|
78618
78646
|
return EXIT;
|
|
78619
78647
|
});
|
|
78620
|
-
|
|
78648
|
+
lib_visit(node, 'text', (child) => {
|
|
78621
78649
|
const newValue = child.value.trimEnd();
|
|
78622
78650
|
if (newValue !== child.value) {
|
|
78623
78651
|
trimmed = true;
|
|
@@ -78631,7 +78659,7 @@ const trimEmphasis = (node, index, parent) => {
|
|
|
78631
78659
|
}
|
|
78632
78660
|
};
|
|
78633
78661
|
const emphasisTransfomer = () => (tree) => {
|
|
78634
|
-
|
|
78662
|
+
lib_visit(tree, emphasis_strongTest, trimEmphasis);
|
|
78635
78663
|
return tree;
|
|
78636
78664
|
};
|
|
78637
78665
|
/* harmony default export */ const migration_emphasis = (emphasisTransfomer);
|
|
@@ -78639,7 +78667,7 @@ const emphasisTransfomer = () => (tree) => {
|
|
|
78639
78667
|
;// ./processor/migration/images.ts
|
|
78640
78668
|
|
|
78641
78669
|
const images_imageTransformer = () => tree => {
|
|
78642
|
-
|
|
78670
|
+
lib_visit(tree, 'image', (image) => {
|
|
78643
78671
|
var _a, _b;
|
|
78644
78672
|
if (((_b = (_a = image.data) === null || _a === void 0 ? void 0 : _a.hProperties) === null || _b === void 0 ? void 0 : _b.className) === 'border') {
|
|
78645
78673
|
image.data.hProperties.border = true;
|
|
@@ -78651,9 +78679,9 @@ const images_imageTransformer = () => tree => {
|
|
|
78651
78679
|
;// ./processor/migration/linkReference.ts
|
|
78652
78680
|
|
|
78653
78681
|
const linkReferenceTransformer = () => (tree) => {
|
|
78654
|
-
|
|
78682
|
+
lib_visit(tree, 'linkReference', (node, index, parent) => {
|
|
78655
78683
|
const definitions = {};
|
|
78656
|
-
|
|
78684
|
+
lib_visit(tree, 'definition', (def) => {
|
|
78657
78685
|
definitions[def.identifier] = def;
|
|
78658
78686
|
});
|
|
78659
78687
|
if (node.label === node.identifier && parent) {
|
|
@@ -78716,8 +78744,8 @@ const migrateTableCells = (vfile, rdmd) => (table) => {
|
|
|
78716
78744
|
*/
|
|
78717
78745
|
// console.error(err);
|
|
78718
78746
|
}
|
|
78719
|
-
|
|
78720
|
-
|
|
78747
|
+
lib_visit(table, 'tableRow', (row, i) => {
|
|
78748
|
+
lib_visit(row, 'tableCell', (cell, j) => {
|
|
78721
78749
|
let children = cell.children;
|
|
78722
78750
|
if (json && json.data[magicIndex(i, j)]) {
|
|
78723
78751
|
const string = json.data[magicIndex(i, j)].replace(psuedoListRegex, '$<ws>- $<item>');
|
|
@@ -78731,7 +78759,7 @@ const migrateTableCells = (vfile, rdmd) => (table) => {
|
|
|
78731
78759
|
});
|
|
78732
78760
|
return SKIP;
|
|
78733
78761
|
});
|
|
78734
|
-
|
|
78762
|
+
lib_visit(table, 'inlineCode', (code) => {
|
|
78735
78763
|
if (code.value.includes('\n')) {
|
|
78736
78764
|
// eslint-disable-next-line no-param-reassign
|
|
78737
78765
|
code.type = 'code';
|
|
@@ -78741,7 +78769,7 @@ const migrateTableCells = (vfile, rdmd) => (table) => {
|
|
|
78741
78769
|
function tableCellTransformer() {
|
|
78742
78770
|
const rdmd = this.data('rdmd');
|
|
78743
78771
|
return (tree, vfile) => {
|
|
78744
|
-
|
|
78772
|
+
lib_visit(tree, 'table', migrateTableCells(vfile, rdmd));
|
|
78745
78773
|
return tree;
|
|
78746
78774
|
};
|
|
78747
78775
|
}
|
|
@@ -81836,7 +81864,7 @@ function media(state, node) {
|
|
|
81836
81864
|
/** @type {Root} */
|
|
81837
81865
|
const fragment = {type: 'root', children: nodes}
|
|
81838
81866
|
|
|
81839
|
-
|
|
81867
|
+
lib_visit(fragment, function (node) {
|
|
81840
81868
|
if (node.type === 'link') {
|
|
81841
81869
|
linkInFallbackContent = true
|
|
81842
81870
|
return EXIT
|
|
@@ -82307,7 +82335,7 @@ function inspect(node) {
|
|
|
82307
82335
|
let rowIndex = 0
|
|
82308
82336
|
let cellIndex = 0
|
|
82309
82337
|
|
|
82310
|
-
|
|
82338
|
+
lib_visit(node, function (child) {
|
|
82311
82339
|
if (child.type === 'element') {
|
|
82312
82340
|
// Don’t enter nested tables.
|
|
82313
82341
|
if (child.tagName === 'table' && node !== child) {
|
|
@@ -83129,7 +83157,7 @@ function toMdast(tree, options) {
|
|
|
83129
83157
|
// @ts-expect-error: fine to pass an arbitrary node.
|
|
83130
83158
|
transformWhitespace(cleanTree)
|
|
83131
83159
|
|
|
83132
|
-
|
|
83160
|
+
lib_visit(cleanTree, function (node) {
|
|
83133
83161
|
if (node && node.type === 'element' && node.properties) {
|
|
83134
83162
|
const id = String(node.properties.id || '') || undefined
|
|
83135
83163
|
|
|
@@ -83157,7 +83185,7 @@ function toMdast(tree, options) {
|
|
|
83157
83185
|
// we’re generating some whitespace too, and some nodes are in the end
|
|
83158
83186
|
// ignored.
|
|
83159
83187
|
// So clean up.
|
|
83160
|
-
|
|
83188
|
+
lib_visit(mdast, function (node, index, parent) {
|
|
83161
83189
|
if (node.type === 'text' && index !== undefined && parent) {
|
|
83162
83190
|
const previous = parent.children[index - 1]
|
|
83163
83191
|
|
|
@@ -83497,6 +83525,14 @@ const mdx_mdx = (tree, _a = {}) => {
|
|
|
83497
83525
|
};
|
|
83498
83526
|
/* harmony default export */ const lib_mdx = (mdx_mdx);
|
|
83499
83527
|
|
|
83528
|
+
;// ./lib/migrate.ts
|
|
83529
|
+
|
|
83530
|
+
|
|
83531
|
+
const migrate = (doc, { rdmd }) => {
|
|
83532
|
+
return lib_mdx(lib_mdastV6(doc, { rdmd })).replaceAll(/ /g, ' ');
|
|
83533
|
+
};
|
|
83534
|
+
/* harmony default export */ const lib_migrate = (migrate);
|
|
83535
|
+
|
|
83500
83536
|
;// ./lib/plain.ts
|
|
83501
83537
|
|
|
83502
83538
|
const STRIP_TAGS = ['script', 'style'];
|
|
@@ -83629,6 +83665,24 @@ const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }
|
|
|
83629
83665
|
};
|
|
83630
83666
|
/* harmony default export */ const contexts = (Contexts);
|
|
83631
83667
|
|
|
83668
|
+
;// ./utils/user.ts
|
|
83669
|
+
const User = (variables) => {
|
|
83670
|
+
const { user = {}, defaults = [] } = variables || {};
|
|
83671
|
+
return new Proxy(user, {
|
|
83672
|
+
get(target, attribute) {
|
|
83673
|
+
if (typeof attribute === 'symbol') {
|
|
83674
|
+
return '';
|
|
83675
|
+
}
|
|
83676
|
+
if (attribute in target) {
|
|
83677
|
+
return target[attribute];
|
|
83678
|
+
}
|
|
83679
|
+
const def = defaults.find((d) => d.name === attribute);
|
|
83680
|
+
return def ? def.default : attribute.toUpperCase();
|
|
83681
|
+
},
|
|
83682
|
+
});
|
|
83683
|
+
};
|
|
83684
|
+
/* harmony default export */ const user = (User);
|
|
83685
|
+
|
|
83632
83686
|
;// ./lib/run.tsx
|
|
83633
83687
|
var run_rest = (undefined && undefined.__rest) || function (s, e) {
|
|
83634
83688
|
var t = {};
|
|
@@ -83649,6 +83703,7 @@ var run_rest = (undefined && undefined.__rest) || function (s, e) {
|
|
|
83649
83703
|
|
|
83650
83704
|
|
|
83651
83705
|
|
|
83706
|
+
|
|
83652
83707
|
const makeUseMDXComponents = (more = {}) => {
|
|
83653
83708
|
const headings = Array.from({ length: 6 }).reduce((map, _, index) => {
|
|
83654
83709
|
map[`h${index + 1}`] = components_Heading((index + 1));
|
|
@@ -83660,21 +83715,26 @@ const makeUseMDXComponents = (more = {}) => {
|
|
|
83660
83715
|
const run_run = async (string, _opts = {}) => {
|
|
83661
83716
|
const { Fragment } = jsx_runtime_namespaceObject;
|
|
83662
83717
|
const { components = {}, terms, variables, baseUrl } = _opts, opts = run_rest(_opts, ["components", "terms", "variables", "baseUrl"]);
|
|
83663
|
-
const
|
|
83664
|
-
|
|
83665
|
-
|
|
83718
|
+
const executedComponents = Object.entries(components).reduce((memo, [tag, mod]) => {
|
|
83719
|
+
const { default: Content, toc, Toc } = mod, rest = run_rest(mod, ["default", "toc", "Toc"]);
|
|
83720
|
+
memo[tag] = Content;
|
|
83721
|
+
if (rest) {
|
|
83722
|
+
Object.entries(rest).forEach(([subTag, component]) => {
|
|
83723
|
+
memo[subTag] = component;
|
|
83724
|
+
});
|
|
83725
|
+
}
|
|
83726
|
+
return memo;
|
|
83727
|
+
}, {});
|
|
83728
|
+
const exec = (text, { useMDXComponents = makeUseMDXComponents(executedComponents) } = {}) => {
|
|
83729
|
+
return run(text, Object.assign(Object.assign(Object.assign({}, jsx_runtime_namespaceObject), { Fragment, baseUrl: "file:///home/runner/work/markdown/markdown/lib/run.tsx", imports: { React: (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default()), user: user(variables) }, useMDXComponents }), opts));
|
|
83666
83730
|
};
|
|
83667
|
-
const { toc, default: Content } =
|
|
83731
|
+
const _a = await exec(string), { Toc: _Toc, toc, default: Content } = _a, exports = run_rest(_a, ["Toc", "toc", "default"]);
|
|
83668
83732
|
const tocMdx = tocToMdx(toc, components);
|
|
83669
83733
|
const { default: Toc } = await exec(lib_compile(tocMdx), { useMDXComponents: () => ({ p: Fragment }) });
|
|
83670
|
-
return {
|
|
83671
|
-
|
|
83672
|
-
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Content, null))),
|
|
83673
|
-
toc,
|
|
83674
|
-
Toc: () => tocMdx &&
|
|
83734
|
+
return Object.assign({ default: () => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(contexts, { terms: terms, baseUrl: baseUrl, variables: variables },
|
|
83735
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Content, null))), toc, Toc: () => tocMdx &&
|
|
83675
83736
|
Toc && (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(components_TableOfContents, null,
|
|
83676
|
-
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Toc, null))),
|
|
83677
|
-
};
|
|
83737
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Toc, null))) }, exports);
|
|
83678
83738
|
};
|
|
83679
83739
|
/* harmony default export */ const lib_run = (run_run);
|
|
83680
83740
|
|
|
@@ -83684,8 +83744,9 @@ const run_run = async (string, _opts = {}) => {
|
|
|
83684
83744
|
|
|
83685
83745
|
const tags = (doc) => {
|
|
83686
83746
|
const set = new Set();
|
|
83687
|
-
|
|
83688
|
-
|
|
83747
|
+
lib_visit(lib_mdast(doc), isMDXElement, (node) => {
|
|
83748
|
+
var _a;
|
|
83749
|
+
if ((_a = node.name) === null || _a === void 0 ? void 0 : _a.match(/^[A-Z]/)) {
|
|
83689
83750
|
set.add(node.name);
|
|
83690
83751
|
}
|
|
83691
83752
|
});
|
|
@@ -83693,14 +83754,6 @@ const tags = (doc) => {
|
|
|
83693
83754
|
};
|
|
83694
83755
|
/* harmony default export */ const lib_tags = (tags);
|
|
83695
83756
|
|
|
83696
|
-
;// ./lib/migrate.ts
|
|
83697
|
-
|
|
83698
|
-
|
|
83699
|
-
const migrate = (doc, { rdmd }) => {
|
|
83700
|
-
return lib_mdx(lib_mdastV6(doc, { rdmd })).replaceAll(/ /g, ' ');
|
|
83701
|
-
};
|
|
83702
|
-
/* harmony default export */ const lib_migrate = (migrate);
|
|
83703
|
-
|
|
83704
83757
|
;// ./lib/index.ts
|
|
83705
83758
|
|
|
83706
83759
|
|
|
@@ -83713,6 +83766,7 @@ const migrate = (doc, { rdmd }) => {
|
|
|
83713
83766
|
|
|
83714
83767
|
|
|
83715
83768
|
|
|
83769
|
+
|
|
83716
83770
|
;// ./index.tsx
|
|
83717
83771
|
|
|
83718
83772
|
|
package/dist/main.node.js
CHANGED
|
@@ -27700,7 +27700,7 @@ function toResult(value) {
|
|
|
27700
27700
|
* @template {Test} Check
|
|
27701
27701
|
* `unist-util-is`-compatible test.
|
|
27702
27702
|
*/
|
|
27703
|
-
function
|
|
27703
|
+
function lib_visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
|
|
27704
27704
|
/** @type {boolean | null | undefined} */
|
|
27705
27705
|
let reverse
|
|
27706
27706
|
/** @type {Test} */
|
|
@@ -27755,7 +27755,7 @@ function formatHeadingAsSetext(node, state) {
|
|
|
27755
27755
|
|
|
27756
27756
|
// Look for literals with a line break.
|
|
27757
27757
|
// Note that this also
|
|
27758
|
-
|
|
27758
|
+
lib_visit(node, function (node) {
|
|
27759
27759
|
if (
|
|
27760
27760
|
('value' in node && /\r?\n|\r/.test(node.value)) ||
|
|
27761
27761
|
node.type === 'break'
|
|
@@ -40591,7 +40591,7 @@ const lib_SKIP = Symbol('skip')
|
|
|
40591
40591
|
* @returns {undefined}
|
|
40592
40592
|
* Nothing.
|
|
40593
40593
|
*/
|
|
40594
|
-
function
|
|
40594
|
+
function estree_util_visit_lib_visit(tree, visitor) {
|
|
40595
40595
|
/** @type {Visitor | undefined} */
|
|
40596
40596
|
let enter
|
|
40597
40597
|
/** @type {Visitor | undefined} */
|
|
@@ -40894,7 +40894,7 @@ function eventsToAcorn(events, options) {
|
|
|
40894
40894
|
estree.comments = comments;
|
|
40895
40895
|
|
|
40896
40896
|
// @ts-expect-error: acorn looks enough like estree.
|
|
40897
|
-
|
|
40897
|
+
estree_util_visit_lib_visit(estree, function (esnode, field, index, parents) {
|
|
40898
40898
|
let context = /** @type {AcornNode | Array<AcornNode>} */
|
|
40899
40899
|
parents[parents.length - 1];
|
|
40900
40900
|
/** @type {number | string | undefined} */
|
|
@@ -49020,7 +49020,7 @@ var NodeTypes;
|
|
|
49020
49020
|
const regex = `^(${emoji_regex().source}|⚠)(\\s+|$)`;
|
|
49021
49021
|
const calloutTransformer = () => {
|
|
49022
49022
|
return (tree) => {
|
|
49023
|
-
|
|
49023
|
+
lib_visit(tree, 'blockquote', (node) => {
|
|
49024
49024
|
if (!(node.children[0].type === 'paragraph' && node.children[0].children[0].type === 'text'))
|
|
49025
49025
|
return;
|
|
49026
49026
|
const startText = node.children[0].children[0].value;
|
|
@@ -49050,13 +49050,13 @@ const calloutTransformer = () => {
|
|
|
49050
49050
|
|
|
49051
49051
|
const isCode = (node) => (node === null || node === void 0 ? void 0 : node.type) === 'code';
|
|
49052
49052
|
const codeTabsTransformer = ({ copyButtons } = {}) => (tree) => {
|
|
49053
|
-
|
|
49053
|
+
lib_visit(tree, 'code', (node) => {
|
|
49054
49054
|
const { lang, meta, value } = node;
|
|
49055
49055
|
node.data = {
|
|
49056
49056
|
hProperties: { lang, meta, value, copyButtons },
|
|
49057
49057
|
};
|
|
49058
49058
|
});
|
|
49059
|
-
|
|
49059
|
+
lib_visit(tree, 'code', (node, index, parent) => {
|
|
49060
49060
|
if (parent.type === 'code-tabs' || !('children' in parent))
|
|
49061
49061
|
return;
|
|
49062
49062
|
const length = parent.children.length;
|
|
@@ -49099,7 +49099,7 @@ const codeTabsTransformer = ({ copyButtons } = {}) => (tree) => {
|
|
|
49099
49099
|
|
|
49100
49100
|
const embedTransformer = () => {
|
|
49101
49101
|
return (tree) => {
|
|
49102
|
-
|
|
49102
|
+
lib_visit(tree, 'paragraph', (node, i, parent) => {
|
|
49103
49103
|
var _a, _b, _c;
|
|
49104
49104
|
const [{ url, title, children = [] }] = node.children;
|
|
49105
49105
|
if (title !== '@embed')
|
|
@@ -49126,12 +49126,12 @@ const embedTransformer = () => {
|
|
|
49126
49126
|
|
|
49127
49127
|
;// ./lib/mdast.ts
|
|
49128
49128
|
|
|
49129
|
-
const
|
|
49129
|
+
const mdast_mdast = (text, opts = {}) => {
|
|
49130
49130
|
const processor = ast_processor(opts);
|
|
49131
49131
|
const tree = processor.parse(text);
|
|
49132
49132
|
return processor.runSync(tree);
|
|
49133
49133
|
};
|
|
49134
|
-
/* harmony default export */ const lib_mdast = (
|
|
49134
|
+
/* harmony default export */ const lib_mdast = (mdast_mdast);
|
|
49135
49135
|
|
|
49136
49136
|
;// ./processor/utils.ts
|
|
49137
49137
|
|
|
@@ -49223,11 +49223,20 @@ const utils_getChildren = (jsx) => jsx.children.reduce((memo, child, i) => {
|
|
|
49223
49223
|
* TODO: Make this more extensible to all types of nodes. isElement(node, 'type' or ['type1', 'type2']), say
|
|
49224
49224
|
*
|
|
49225
49225
|
* @param {Node} node
|
|
49226
|
-
* @returns {(node is MdxJsxFlowElement | MdxJsxTextElement)}
|
|
49226
|
+
* @returns {(node is MdxJsxFlowElement | MdxJsxTextElement | MdxjsEsm)}
|
|
49227
49227
|
*/
|
|
49228
49228
|
const isMDXElement = (node) => {
|
|
49229
49229
|
return ['mdxJsxFlowElement', 'mdxJsxTextElement'].includes(node.type);
|
|
49230
49230
|
};
|
|
49231
|
+
/**
|
|
49232
|
+
* Tests if a node is an MDX ESM element (i.e. import or export).
|
|
49233
|
+
*
|
|
49234
|
+
* @param {Node} node
|
|
49235
|
+
* @returns {boolean}
|
|
49236
|
+
*/
|
|
49237
|
+
const utils_isMDXEsm = (node) => {
|
|
49238
|
+
return node.type === 'mdxjsEsm';
|
|
49239
|
+
};
|
|
49231
49240
|
/**
|
|
49232
49241
|
* Takes an HTML string and formats it for display in the editor. Removes leading/trailing newlines
|
|
49233
49242
|
* and unindents the HTML.
|
|
@@ -49260,7 +49269,7 @@ const formatHTML = (html) => {
|
|
|
49260
49269
|
*/
|
|
49261
49270
|
const reformatHTML = (html, indent = 2) => {
|
|
49262
49271
|
// Remove leading/trailing newlines
|
|
49263
|
-
const cleaned = html.replace(/^\s*\n|\n\s*$/g, '');
|
|
49272
|
+
const cleaned = html.replace(/^\s*\n|\n\s*$/g, '').replaceAll(/(?<!\\(\\\\)*)`/g, '\\`');
|
|
49264
49273
|
// // Create a tab/indent with the specified number of spaces
|
|
49265
49274
|
// const tab = ' '.repeat(indent);
|
|
49266
49275
|
// // Indent each line of the HTML (converts to an array, indents each line, then joins back)
|
|
@@ -49314,7 +49323,7 @@ const toAttributes = (object, keys = []) => {
|
|
|
49314
49323
|
|
|
49315
49324
|
|
|
49316
49325
|
const imageTransformer = () => (tree) => {
|
|
49317
|
-
|
|
49326
|
+
lib_visit(tree, 'paragraph', (node, i, parent) => {
|
|
49318
49327
|
var _a;
|
|
49319
49328
|
// check if inline
|
|
49320
49329
|
if (parent.type !== 'root' || ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 || node.children[0].type !== 'image')
|
|
@@ -49338,7 +49347,7 @@ const imageTransformer = () => (tree) => {
|
|
|
49338
49347
|
parent.children.splice(i, 1, newNode);
|
|
49339
49348
|
});
|
|
49340
49349
|
const isImage = (node) => node.name === 'Image';
|
|
49341
|
-
|
|
49350
|
+
lib_visit(tree, isImage, (node) => {
|
|
49342
49351
|
const attrs = getAttrs(node);
|
|
49343
49352
|
if (attrs.caption) {
|
|
49344
49353
|
node.children = lib_mdast(attrs.caption).children;
|
|
@@ -66338,17 +66347,17 @@ const gemojiTransformer = () => (tree) => {
|
|
|
66338
66347
|
const strongTest = (node) => ['emphasis', 'strong'].includes(node.type);
|
|
66339
66348
|
const compatibilityTransfomer = () => tree => {
|
|
66340
66349
|
const trimEmphasis = (node) => {
|
|
66341
|
-
|
|
66350
|
+
lib_visit(node, 'text', child => {
|
|
66342
66351
|
child.value = child.value.trim();
|
|
66343
66352
|
return EXIT;
|
|
66344
66353
|
});
|
|
66345
66354
|
return node;
|
|
66346
66355
|
};
|
|
66347
|
-
|
|
66356
|
+
lib_visit(tree, strongTest, node => {
|
|
66348
66357
|
trimEmphasis(node);
|
|
66349
66358
|
return SKIP;
|
|
66350
66359
|
});
|
|
66351
|
-
|
|
66360
|
+
lib_visit(tree, 'image', (node, index, parent) => {
|
|
66352
66361
|
if (phrasing(parent) || !parent.children.every(child => child.type === 'image' || !phrasing(child)))
|
|
66353
66362
|
return;
|
|
66354
66363
|
parent.children.splice(index, 1, { type: 'paragraph', children: [node] });
|
|
@@ -66372,7 +66381,7 @@ var div_rest = (undefined && undefined.__rest) || function (s, e) {
|
|
|
66372
66381
|
|
|
66373
66382
|
|
|
66374
66383
|
const divTransformer = () => tree => {
|
|
66375
|
-
|
|
66384
|
+
lib_visit(tree, 'div', (node, index, parent) => {
|
|
66376
66385
|
var _a;
|
|
66377
66386
|
const type = (_a = node.data) === null || _a === void 0 ? void 0 : _a.hName;
|
|
66378
66387
|
switch (type) {
|
|
@@ -66400,7 +66409,7 @@ const inject = ({ components } = {}) => (node, index, parent) => {
|
|
|
66400
66409
|
parent.children.splice(index, children.length, ...children);
|
|
66401
66410
|
};
|
|
66402
66411
|
const injectComponents = (opts) => () => tree => {
|
|
66403
|
-
|
|
66412
|
+
lib_visit(tree, isMDXElement, inject(opts));
|
|
66404
66413
|
return tree;
|
|
66405
66414
|
};
|
|
66406
66415
|
/* harmony default export */ const inject_components = (injectComponents);
|
|
@@ -66420,7 +66429,7 @@ const setData = (node, index, parent) => {
|
|
|
66420
66429
|
} });
|
|
66421
66430
|
};
|
|
66422
66431
|
const mdxToHast = () => tree => {
|
|
66423
|
-
|
|
66432
|
+
lib_visit(tree, isMDXElement, setData);
|
|
66424
66433
|
return tree;
|
|
66425
66434
|
};
|
|
66426
66435
|
/* harmony default export */ const mdx_to_hast = (mdxToHast);
|
|
@@ -66428,7 +66437,7 @@ const mdxToHast = () => tree => {
|
|
|
66428
66437
|
;// ./processor/transform/mermaid.ts
|
|
66429
66438
|
|
|
66430
66439
|
const mermaidTransformer = () => (tree) => {
|
|
66431
|
-
|
|
66440
|
+
lib_visit(tree, 'element', (node) => {
|
|
66432
66441
|
if (node.tagName !== 'pre' || node.children.length !== 1)
|
|
66433
66442
|
return;
|
|
66434
66443
|
const [child] = node.children;
|
|
@@ -66517,9 +66526,9 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
|
|
|
66517
66526
|
const { position } = node;
|
|
66518
66527
|
const { align = [...new Array(node.children.length)].map(() => null) } = getAttrs(node);
|
|
66519
66528
|
let children = [];
|
|
66520
|
-
|
|
66529
|
+
lib_visit(node, { name: 'tr' }, row => {
|
|
66521
66530
|
let rowChildren = [];
|
|
66522
|
-
|
|
66531
|
+
lib_visit(row, isTableCell, ({ name, children, position }) => {
|
|
66523
66532
|
rowChildren.push({
|
|
66524
66533
|
type: tableTypes[name],
|
|
66525
66534
|
children,
|
|
@@ -66538,7 +66547,7 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
|
|
|
66538
66547
|
position,
|
|
66539
66548
|
children,
|
|
66540
66549
|
};
|
|
66541
|
-
|
|
66550
|
+
lib_visit(mdNode, isMDXElement, coerceJsxToMd({ components, html }));
|
|
66542
66551
|
parent.children[index] = mdNode;
|
|
66543
66552
|
return SKIP;
|
|
66544
66553
|
}
|
|
@@ -66581,8 +66590,8 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
|
|
|
66581
66590
|
}
|
|
66582
66591
|
};
|
|
66583
66592
|
const readmeComponents = (opts) => () => tree => {
|
|
66584
|
-
|
|
66585
|
-
|
|
66593
|
+
lib_visit(tree, isMDXElement, coerceJsxToMd(opts));
|
|
66594
|
+
lib_visit(tree, 'paragraph', (node, index, parent) => {
|
|
66586
66595
|
// @ts-ignore
|
|
66587
66596
|
if (parent.type !== 'tableRow')
|
|
66588
66597
|
return;
|
|
@@ -66600,11 +66609,11 @@ const readmeComponents = (opts) => () => tree => {
|
|
|
66600
66609
|
const imageAttrs = ['align', 'alt', 'caption', 'border', 'height', 'src', 'title', 'width', 'lazy', 'className'];
|
|
66601
66610
|
const readmeToMdx = () => tree => {
|
|
66602
66611
|
// Unwrap pinned nodes, replace rdme-pin with its child node
|
|
66603
|
-
|
|
66612
|
+
lib_visit(tree, 'rdme-pin', (node, i, parent) => {
|
|
66604
66613
|
const newNode = node.children[0];
|
|
66605
66614
|
parent.children.splice(i, 1, newNode);
|
|
66606
66615
|
});
|
|
66607
|
-
|
|
66616
|
+
lib_visit(tree, NodeTypes.tutorialTile, (tile, index, parent) => {
|
|
66608
66617
|
parent.children.splice(index, 1, {
|
|
66609
66618
|
type: 'mdxJsxFlowElement',
|
|
66610
66619
|
name: 'TutorialTile',
|
|
@@ -66612,7 +66621,7 @@ const readmeToMdx = () => tree => {
|
|
|
66612
66621
|
children: [],
|
|
66613
66622
|
});
|
|
66614
66623
|
});
|
|
66615
|
-
|
|
66624
|
+
lib_visit(tree, 'figure', (figure, index, parent) => {
|
|
66616
66625
|
const [image, caption] = figure.children;
|
|
66617
66626
|
const { align, width } = image.data.hProperties;
|
|
66618
66627
|
const border = image.data.hProperties.className === 'border';
|
|
@@ -66624,7 +66633,7 @@ const readmeToMdx = () => tree => {
|
|
|
66624
66633
|
});
|
|
66625
66634
|
});
|
|
66626
66635
|
const hasExtra = (attributes) => !!attributes.find(attr => !['alt', 'src', 'title'].includes(attr.name));
|
|
66627
|
-
|
|
66636
|
+
lib_visit(tree, 'image', (image, index, parent) => {
|
|
66628
66637
|
if (!('data' in image))
|
|
66629
66638
|
return;
|
|
66630
66639
|
if ('url' in image)
|
|
@@ -66646,7 +66655,7 @@ const readmeToMdx = () => tree => {
|
|
|
66646
66655
|
});
|
|
66647
66656
|
}
|
|
66648
66657
|
});
|
|
66649
|
-
|
|
66658
|
+
lib_visit(tree, NodeTypes.imageBlock, (image, index, parent) => {
|
|
66650
66659
|
const attributes = toAttributes(image.data.hProperties, imageAttrs);
|
|
66651
66660
|
if (hasExtra(attributes)) {
|
|
66652
66661
|
parent.children.splice(index, 1, {
|
|
@@ -66660,7 +66669,7 @@ const readmeToMdx = () => tree => {
|
|
|
66660
66669
|
parent.children.splice(index, 1, Object.assign(Object.assign(Object.assign({ type: 'image', children: [] }, (image.src && { url: image.src })), (image.title && { title: image.title })), (image.alt && { alt: image.alt })));
|
|
66661
66670
|
}
|
|
66662
66671
|
});
|
|
66663
|
-
|
|
66672
|
+
lib_visit(tree, 'html', (node, index, parent) => {
|
|
66664
66673
|
const html = node.value;
|
|
66665
66674
|
const isScriptOrStyleTag = [!!html.match(/^<(?:style|script)/i), !!html.match(/<\/(?:style|script)>$/i)];
|
|
66666
66675
|
if (!isScriptOrStyleTag.includes(true))
|
|
@@ -66703,21 +66712,21 @@ const visitor = (table, index, parent) => {
|
|
|
66703
66712
|
: cell.children[0];
|
|
66704
66713
|
// @note: Compatibility with RDMD. Ideally, I'd put this in a separate
|
|
66705
66714
|
// transformer, but then there'd be some duplication.
|
|
66706
|
-
|
|
66715
|
+
lib_visit(cell, 'break', (_, index, parent) => {
|
|
66707
66716
|
parent.children.splice(index, 1, { type: 'text', value: '\n' });
|
|
66708
66717
|
});
|
|
66709
66718
|
if (!phrasing(content) && content.type !== 'escape') {
|
|
66710
66719
|
hasFlowContent = true;
|
|
66711
66720
|
return EXIT;
|
|
66712
66721
|
}
|
|
66713
|
-
|
|
66722
|
+
lib_visit(cell, isLiteral, (node) => {
|
|
66714
66723
|
if (node.value.match(/\n/)) {
|
|
66715
66724
|
hasFlowContent = true;
|
|
66716
66725
|
return EXIT;
|
|
66717
66726
|
}
|
|
66718
66727
|
});
|
|
66719
66728
|
};
|
|
66720
|
-
|
|
66729
|
+
lib_visit(table, tables_to_jsx_isTableCell, tableCellVisitor);
|
|
66721
66730
|
if (!hasFlowContent) {
|
|
66722
66731
|
table.type = 'table';
|
|
66723
66732
|
return;
|
|
@@ -66765,7 +66774,7 @@ const visitor = (table, index, parent) => {
|
|
|
66765
66774
|
};
|
|
66766
66775
|
const isTable = (node) => ['table', 'tableau'].includes(node.type);
|
|
66767
66776
|
const tablesToJsx = () => tree => {
|
|
66768
|
-
|
|
66777
|
+
lib_visit(tree, isTable, visitor);
|
|
66769
66778
|
return tree;
|
|
66770
66779
|
};
|
|
66771
66780
|
/* harmony default export */ const tables_to_jsx = (tablesToJsx);
|
|
@@ -66774,7 +66783,7 @@ const tablesToJsx = () => tree => {
|
|
|
66774
66783
|
|
|
66775
66784
|
|
|
66776
66785
|
const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
66777
|
-
|
|
66786
|
+
lib_visit(tree, (node, index, parent) => {
|
|
66778
66787
|
var _a, _b;
|
|
66779
66788
|
if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
|
|
66780
66789
|
return;
|
|
@@ -67054,7 +67063,7 @@ function rehypeSlug(options) {
|
|
|
67054
67063
|
return function (tree) {
|
|
67055
67064
|
slugs.reset()
|
|
67056
67065
|
|
|
67057
|
-
|
|
67066
|
+
lib_visit(tree, 'element', function (node) {
|
|
67058
67067
|
if (headingRank(node) && !node.properties.id) {
|
|
67059
67068
|
node.properties.id = prefix + slugs.slug(hast_util_to_string_lib_toString(node))
|
|
67060
67069
|
}
|
|
@@ -75177,7 +75186,7 @@ function state_createState(tree, options) {
|
|
|
75177
75186
|
wrap: state_wrap
|
|
75178
75187
|
}
|
|
75179
75188
|
|
|
75180
|
-
|
|
75189
|
+
lib_visit(tree, function (node) {
|
|
75181
75190
|
if (node.type === 'definition' || node.type === 'footnoteDefinition') {
|
|
75182
75191
|
const map = node.type === 'definition' ? definitionById : footnoteById
|
|
75183
75192
|
const id = String(node.identifier).toUpperCase()
|
|
@@ -77838,7 +77847,7 @@ function rehypeRemoveRaw() {
|
|
|
77838
77847
|
* Nothing.
|
|
77839
77848
|
*/
|
|
77840
77849
|
return function (tree) {
|
|
77841
|
-
|
|
77850
|
+
lib_visit(tree, 'raw', function (_, index, parent) {
|
|
77842
77851
|
if (parent && typeof index === 'number') {
|
|
77843
77852
|
parent.children.splice(index, 1)
|
|
77844
77853
|
return index
|
|
@@ -77962,7 +77971,7 @@ function remarkMarkAndUnravel() {
|
|
|
77962
77971
|
* Nothing.
|
|
77963
77972
|
*/
|
|
77964
77973
|
return function (tree) {
|
|
77965
|
-
|
|
77974
|
+
lib_visit(tree, function (node, index, parent) {
|
|
77966
77975
|
let offset = -1
|
|
77967
77976
|
let all = true
|
|
77968
77977
|
let oneOrMore = false
|
|
@@ -79581,7 +79590,7 @@ const tocToHast = (headings = []) => {
|
|
|
79581
79590
|
};
|
|
79582
79591
|
const tocToMdx = (toc, components) => {
|
|
79583
79592
|
const tree = { type: 'root', children: toc };
|
|
79584
|
-
|
|
79593
|
+
lib_visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {
|
|
79585
79594
|
const toc = components[node.name].toc || [];
|
|
79586
79595
|
parent.children.splice(index, 1, ...toc);
|
|
79587
79596
|
});
|
|
@@ -79637,9 +79646,10 @@ const compile_compile = (text, _a = {}) => {
|
|
|
79637
79646
|
remarkGfm,
|
|
79638
79647
|
...Object.values(transforms),
|
|
79639
79648
|
[compile_codeTabsTransformer, { copyButtons }],
|
|
79640
|
-
transform_variables,
|
|
79641
79649
|
], rehypePlugins: [...rehypePlugins, [rehypeToc, { components }]] }, opts));
|
|
79642
|
-
return String(vfile)
|
|
79650
|
+
return String(vfile)
|
|
79651
|
+
.replace(/await import\(_resolveDynamicMdxSpecifier\(('react'|"react")\)\)/, 'arguments[0].imports.React')
|
|
79652
|
+
.replace('"use strict";', '"use strict";\nconst { user } = arguments[0].imports;');
|
|
79643
79653
|
}
|
|
79644
79654
|
catch (error) {
|
|
79645
79655
|
throw error.line ? new MdxSyntaxError(error, text) : error;
|
|
@@ -79647,6 +79657,24 @@ const compile_compile = (text, _a = {}) => {
|
|
|
79647
79657
|
};
|
|
79648
79658
|
/* harmony default export */ const lib_compile = (compile_compile);
|
|
79649
79659
|
|
|
79660
|
+
;// ./lib/exports.ts
|
|
79661
|
+
|
|
79662
|
+
|
|
79663
|
+
|
|
79664
|
+
const EXPORT_NAME_REGEX = /export\s+(?:const|let|var|function)\s+(\w+)/;
|
|
79665
|
+
const exports_exports = (doc) => {
|
|
79666
|
+
const set = new Set();
|
|
79667
|
+
visit(mdast(doc), isMDXEsm, (node) => {
|
|
79668
|
+
var _a;
|
|
79669
|
+
if ((_a = node.value) === null || _a === void 0 ? void 0 : _a.match(EXPORT_NAME_REGEX)) {
|
|
79670
|
+
const [, name] = node.value.match(EXPORT_NAME_REGEX);
|
|
79671
|
+
set.add(name);
|
|
79672
|
+
}
|
|
79673
|
+
});
|
|
79674
|
+
return Array.from(set);
|
|
79675
|
+
};
|
|
79676
|
+
/* harmony default export */ const lib_exports = ((/* unused pure expression or super */ null && (exports_exports)));
|
|
79677
|
+
|
|
79650
79678
|
;// ./lib/hast.ts
|
|
79651
79679
|
|
|
79652
79680
|
|
|
@@ -79688,7 +79716,7 @@ const addSpaceAfter = (index, parent) => {
|
|
|
79688
79716
|
};
|
|
79689
79717
|
const trimEmphasis = (node, index, parent) => {
|
|
79690
79718
|
let trimmed = false;
|
|
79691
|
-
|
|
79719
|
+
lib_visit(node, 'text', (child) => {
|
|
79692
79720
|
const newValue = child.value.trimStart();
|
|
79693
79721
|
if (newValue !== child.value) {
|
|
79694
79722
|
trimmed = true;
|
|
@@ -79696,7 +79724,7 @@ const trimEmphasis = (node, index, parent) => {
|
|
|
79696
79724
|
}
|
|
79697
79725
|
return EXIT;
|
|
79698
79726
|
});
|
|
79699
|
-
|
|
79727
|
+
lib_visit(node, 'text', (child) => {
|
|
79700
79728
|
const newValue = child.value.trimEnd();
|
|
79701
79729
|
if (newValue !== child.value) {
|
|
79702
79730
|
trimmed = true;
|
|
@@ -79710,7 +79738,7 @@ const trimEmphasis = (node, index, parent) => {
|
|
|
79710
79738
|
}
|
|
79711
79739
|
};
|
|
79712
79740
|
const emphasisTransfomer = () => (tree) => {
|
|
79713
|
-
|
|
79741
|
+
lib_visit(tree, emphasis_strongTest, trimEmphasis);
|
|
79714
79742
|
return tree;
|
|
79715
79743
|
};
|
|
79716
79744
|
/* harmony default export */ const migration_emphasis = (emphasisTransfomer);
|
|
@@ -79718,7 +79746,7 @@ const emphasisTransfomer = () => (tree) => {
|
|
|
79718
79746
|
;// ./processor/migration/images.ts
|
|
79719
79747
|
|
|
79720
79748
|
const images_imageTransformer = () => tree => {
|
|
79721
|
-
|
|
79749
|
+
lib_visit(tree, 'image', (image) => {
|
|
79722
79750
|
var _a, _b;
|
|
79723
79751
|
if (((_b = (_a = image.data) === null || _a === void 0 ? void 0 : _a.hProperties) === null || _b === void 0 ? void 0 : _b.className) === 'border') {
|
|
79724
79752
|
image.data.hProperties.border = true;
|
|
@@ -79730,9 +79758,9 @@ const images_imageTransformer = () => tree => {
|
|
|
79730
79758
|
;// ./processor/migration/linkReference.ts
|
|
79731
79759
|
|
|
79732
79760
|
const linkReferenceTransformer = () => (tree) => {
|
|
79733
|
-
|
|
79761
|
+
lib_visit(tree, 'linkReference', (node, index, parent) => {
|
|
79734
79762
|
const definitions = {};
|
|
79735
|
-
|
|
79763
|
+
lib_visit(tree, 'definition', (def) => {
|
|
79736
79764
|
definitions[def.identifier] = def;
|
|
79737
79765
|
});
|
|
79738
79766
|
if (node.label === node.identifier && parent) {
|
|
@@ -79795,8 +79823,8 @@ const migrateTableCells = (vfile, rdmd) => (table) => {
|
|
|
79795
79823
|
*/
|
|
79796
79824
|
// console.error(err);
|
|
79797
79825
|
}
|
|
79798
|
-
|
|
79799
|
-
|
|
79826
|
+
lib_visit(table, 'tableRow', (row, i) => {
|
|
79827
|
+
lib_visit(row, 'tableCell', (cell, j) => {
|
|
79800
79828
|
let children = cell.children;
|
|
79801
79829
|
if (json && json.data[magicIndex(i, j)]) {
|
|
79802
79830
|
const string = json.data[magicIndex(i, j)].replace(psuedoListRegex, '$<ws>- $<item>');
|
|
@@ -79810,7 +79838,7 @@ const migrateTableCells = (vfile, rdmd) => (table) => {
|
|
|
79810
79838
|
});
|
|
79811
79839
|
return SKIP;
|
|
79812
79840
|
});
|
|
79813
|
-
|
|
79841
|
+
lib_visit(table, 'inlineCode', (code) => {
|
|
79814
79842
|
if (code.value.includes('\n')) {
|
|
79815
79843
|
// eslint-disable-next-line no-param-reassign
|
|
79816
79844
|
code.type = 'code';
|
|
@@ -79820,7 +79848,7 @@ const migrateTableCells = (vfile, rdmd) => (table) => {
|
|
|
79820
79848
|
function tableCellTransformer() {
|
|
79821
79849
|
const rdmd = this.data('rdmd');
|
|
79822
79850
|
return (tree, vfile) => {
|
|
79823
|
-
|
|
79851
|
+
lib_visit(tree, 'table', migrateTableCells(vfile, rdmd));
|
|
79824
79852
|
return tree;
|
|
79825
79853
|
};
|
|
79826
79854
|
}
|
|
@@ -82915,7 +82943,7 @@ function media(state, node) {
|
|
|
82915
82943
|
/** @type {Root} */
|
|
82916
82944
|
const fragment = {type: 'root', children: nodes}
|
|
82917
82945
|
|
|
82918
|
-
|
|
82946
|
+
lib_visit(fragment, function (node) {
|
|
82919
82947
|
if (node.type === 'link') {
|
|
82920
82948
|
linkInFallbackContent = true
|
|
82921
82949
|
return EXIT
|
|
@@ -83386,7 +83414,7 @@ function inspect(node) {
|
|
|
83386
83414
|
let rowIndex = 0
|
|
83387
83415
|
let cellIndex = 0
|
|
83388
83416
|
|
|
83389
|
-
|
|
83417
|
+
lib_visit(node, function (child) {
|
|
83390
83418
|
if (child.type === 'element') {
|
|
83391
83419
|
// Don’t enter nested tables.
|
|
83392
83420
|
if (child.tagName === 'table' && node !== child) {
|
|
@@ -84208,7 +84236,7 @@ function toMdast(tree, options) {
|
|
|
84208
84236
|
// @ts-expect-error: fine to pass an arbitrary node.
|
|
84209
84237
|
transformWhitespace(cleanTree)
|
|
84210
84238
|
|
|
84211
|
-
|
|
84239
|
+
lib_visit(cleanTree, function (node) {
|
|
84212
84240
|
if (node && node.type === 'element' && node.properties) {
|
|
84213
84241
|
const id = String(node.properties.id || '') || undefined
|
|
84214
84242
|
|
|
@@ -84236,7 +84264,7 @@ function toMdast(tree, options) {
|
|
|
84236
84264
|
// we’re generating some whitespace too, and some nodes are in the end
|
|
84237
84265
|
// ignored.
|
|
84238
84266
|
// So clean up.
|
|
84239
|
-
|
|
84267
|
+
lib_visit(mdast, function (node, index, parent) {
|
|
84240
84268
|
if (node.type === 'text' && index !== undefined && parent) {
|
|
84241
84269
|
const previous = parent.children[index - 1]
|
|
84242
84270
|
|
|
@@ -84576,6 +84604,14 @@ const mdx_mdx = (tree, _a = {}) => {
|
|
|
84576
84604
|
};
|
|
84577
84605
|
/* harmony default export */ const lib_mdx = (mdx_mdx);
|
|
84578
84606
|
|
|
84607
|
+
;// ./lib/migrate.ts
|
|
84608
|
+
|
|
84609
|
+
|
|
84610
|
+
const migrate = (doc, { rdmd }) => {
|
|
84611
|
+
return lib_mdx(lib_mdastV6(doc, { rdmd })).replaceAll(/ /g, ' ');
|
|
84612
|
+
};
|
|
84613
|
+
/* harmony default export */ const lib_migrate = (migrate);
|
|
84614
|
+
|
|
84579
84615
|
;// ./lib/plain.ts
|
|
84580
84616
|
|
|
84581
84617
|
const STRIP_TAGS = ['script', 'style'];
|
|
@@ -84708,6 +84744,24 @@ const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }
|
|
|
84708
84744
|
};
|
|
84709
84745
|
/* harmony default export */ const contexts = (Contexts);
|
|
84710
84746
|
|
|
84747
|
+
;// ./utils/user.ts
|
|
84748
|
+
const User = (variables) => {
|
|
84749
|
+
const { user = {}, defaults = [] } = variables || {};
|
|
84750
|
+
return new Proxy(user, {
|
|
84751
|
+
get(target, attribute) {
|
|
84752
|
+
if (typeof attribute === 'symbol') {
|
|
84753
|
+
return '';
|
|
84754
|
+
}
|
|
84755
|
+
if (attribute in target) {
|
|
84756
|
+
return target[attribute];
|
|
84757
|
+
}
|
|
84758
|
+
const def = defaults.find((d) => d.name === attribute);
|
|
84759
|
+
return def ? def.default : attribute.toUpperCase();
|
|
84760
|
+
},
|
|
84761
|
+
});
|
|
84762
|
+
};
|
|
84763
|
+
/* harmony default export */ const user = (User);
|
|
84764
|
+
|
|
84711
84765
|
;// ./lib/run.tsx
|
|
84712
84766
|
var run_rest = (undefined && undefined.__rest) || function (s, e) {
|
|
84713
84767
|
var t = {};
|
|
@@ -84728,6 +84782,7 @@ var run_rest = (undefined && undefined.__rest) || function (s, e) {
|
|
|
84728
84782
|
|
|
84729
84783
|
|
|
84730
84784
|
|
|
84785
|
+
|
|
84731
84786
|
const makeUseMDXComponents = (more = {}) => {
|
|
84732
84787
|
const headings = Array.from({ length: 6 }).reduce((map, _, index) => {
|
|
84733
84788
|
map[`h${index + 1}`] = components_Heading((index + 1));
|
|
@@ -84739,21 +84794,26 @@ const makeUseMDXComponents = (more = {}) => {
|
|
|
84739
84794
|
const run_run = async (string, _opts = {}) => {
|
|
84740
84795
|
const { Fragment } = jsx_runtime_namespaceObject;
|
|
84741
84796
|
const { components = {}, terms, variables, baseUrl } = _opts, opts = run_rest(_opts, ["components", "terms", "variables", "baseUrl"]);
|
|
84742
|
-
const
|
|
84743
|
-
|
|
84744
|
-
|
|
84797
|
+
const executedComponents = Object.entries(components).reduce((memo, [tag, mod]) => {
|
|
84798
|
+
const { default: Content, toc, Toc } = mod, rest = run_rest(mod, ["default", "toc", "Toc"]);
|
|
84799
|
+
memo[tag] = Content;
|
|
84800
|
+
if (rest) {
|
|
84801
|
+
Object.entries(rest).forEach(([subTag, component]) => {
|
|
84802
|
+
memo[subTag] = component;
|
|
84803
|
+
});
|
|
84804
|
+
}
|
|
84805
|
+
return memo;
|
|
84806
|
+
}, {});
|
|
84807
|
+
const exec = (text, { useMDXComponents = makeUseMDXComponents(executedComponents) } = {}) => {
|
|
84808
|
+
return run(text, Object.assign(Object.assign(Object.assign({}, jsx_runtime_namespaceObject), { Fragment, baseUrl: "file:///home/runner/work/markdown/markdown/lib/run.tsx", imports: { React: (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default()), user: user(variables) }, useMDXComponents }), opts));
|
|
84745
84809
|
};
|
|
84746
|
-
const { toc, default: Content } =
|
|
84810
|
+
const _a = await exec(string), { Toc: _Toc, toc, default: Content } = _a, exports = run_rest(_a, ["Toc", "toc", "default"]);
|
|
84747
84811
|
const tocMdx = tocToMdx(toc, components);
|
|
84748
84812
|
const { default: Toc } = await exec(lib_compile(tocMdx), { useMDXComponents: () => ({ p: Fragment }) });
|
|
84749
|
-
return {
|
|
84750
|
-
|
|
84751
|
-
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Content, null))),
|
|
84752
|
-
toc,
|
|
84753
|
-
Toc: () => tocMdx &&
|
|
84813
|
+
return Object.assign({ default: () => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(contexts, { terms: terms, baseUrl: baseUrl, variables: variables },
|
|
84814
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Content, null))), toc, Toc: () => tocMdx &&
|
|
84754
84815
|
Toc && (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(components_TableOfContents, null,
|
|
84755
|
-
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Toc, null))),
|
|
84756
|
-
};
|
|
84816
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Toc, null))) }, exports);
|
|
84757
84817
|
};
|
|
84758
84818
|
/* harmony default export */ const lib_run = (run_run);
|
|
84759
84819
|
|
|
@@ -84763,8 +84823,9 @@ const run_run = async (string, _opts = {}) => {
|
|
|
84763
84823
|
|
|
84764
84824
|
const tags = (doc) => {
|
|
84765
84825
|
const set = new Set();
|
|
84766
|
-
|
|
84767
|
-
|
|
84826
|
+
lib_visit(lib_mdast(doc), isMDXElement, (node) => {
|
|
84827
|
+
var _a;
|
|
84828
|
+
if ((_a = node.name) === null || _a === void 0 ? void 0 : _a.match(/^[A-Z]/)) {
|
|
84768
84829
|
set.add(node.name);
|
|
84769
84830
|
}
|
|
84770
84831
|
});
|
|
@@ -84772,14 +84833,6 @@ const tags = (doc) => {
|
|
|
84772
84833
|
};
|
|
84773
84834
|
/* harmony default export */ const lib_tags = (tags);
|
|
84774
84835
|
|
|
84775
|
-
;// ./lib/migrate.ts
|
|
84776
|
-
|
|
84777
|
-
|
|
84778
|
-
const migrate = (doc, { rdmd }) => {
|
|
84779
|
-
return lib_mdx(lib_mdastV6(doc, { rdmd })).replaceAll(/ /g, ' ');
|
|
84780
|
-
};
|
|
84781
|
-
/* harmony default export */ const lib_migrate = (migrate);
|
|
84782
|
-
|
|
84783
84836
|
;// ./lib/index.ts
|
|
84784
84837
|
|
|
84785
84838
|
|
|
@@ -84792,6 +84845,7 @@ const migrate = (doc, { rdmd }) => {
|
|
|
84792
84845
|
|
|
84793
84846
|
|
|
84794
84847
|
|
|
84848
|
+
|
|
84795
84849
|
;// ./index.tsx
|
|
84796
84850
|
|
|
84797
84851
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Node } from 'mdast';
|
|
2
|
-
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx';
|
|
2
|
+
import type { MdxJsxFlowElement, MdxJsxTextElement, MdxjsEsm } from 'mdast-util-mdx';
|
|
3
3
|
import type { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
|
|
4
4
|
/**
|
|
5
5
|
* Formats the hProperties of a node as a string, so they can be compiled back into JSX/MDX.
|
|
@@ -56,9 +56,16 @@ export declare const getChildren: <T>(jsx: MdxJsxFlowElement | MdxJsxTextElement
|
|
|
56
56
|
* TODO: Make this more extensible to all types of nodes. isElement(node, 'type' or ['type1', 'type2']), say
|
|
57
57
|
*
|
|
58
58
|
* @param {Node} node
|
|
59
|
-
* @returns {(node is MdxJsxFlowElement | MdxJsxTextElement)}
|
|
59
|
+
* @returns {(node is MdxJsxFlowElement | MdxJsxTextElement | MdxjsEsm)}
|
|
60
60
|
*/
|
|
61
61
|
export declare const isMDXElement: (node: Node) => node is MdxJsxFlowElement | MdxJsxTextElement;
|
|
62
|
+
/**
|
|
63
|
+
* Tests if a node is an MDX ESM element (i.e. import or export).
|
|
64
|
+
*
|
|
65
|
+
* @param {Node} node
|
|
66
|
+
* @returns {boolean}
|
|
67
|
+
*/
|
|
68
|
+
export declare const isMDXEsm: (node: Node) => node is MdxjsEsm;
|
|
62
69
|
/**
|
|
63
70
|
* Takes an HTML string and formats it for display in the editor. Removes leading/trailing newlines
|
|
64
71
|
* and unindents the HTML.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@readme/markdown",
|
|
3
3
|
"description": "ReadMe's React-based Markdown parser",
|
|
4
4
|
"author": "Rafe Goldberg <rafe@readme.io>",
|
|
5
|
-
"version": "7.
|
|
5
|
+
"version": "7.12.1",
|
|
6
6
|
"main": "dist/main.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/main.js",
|