@readme/markdown 7.10.4 → 7.11.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 +144 -114
- package/dist/main.node.js +144 -114
- package/dist/processor/transform/index.d.ts +5 -4
- package/dist/processor/transform/mdx-to-hast.d.ts +3 -0
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -65253,6 +65253,31 @@ const gemojiTransformer = () => (tree) => {
|
|
|
65253
65253
|
};
|
|
65254
65254
|
/* harmony default export */ const gemoji_ = (gemojiTransformer);
|
|
65255
65255
|
|
|
65256
|
+
;// ./processor/transform/compatability.ts
|
|
65257
|
+
|
|
65258
|
+
|
|
65259
|
+
const strongTest = (node) => ['emphasis', 'strong'].includes(node.type);
|
|
65260
|
+
const compatibilityTransfomer = () => tree => {
|
|
65261
|
+
const trimEmphasis = (node) => {
|
|
65262
|
+
visit(node, 'text', child => {
|
|
65263
|
+
child.value = child.value.trim();
|
|
65264
|
+
return EXIT;
|
|
65265
|
+
});
|
|
65266
|
+
return node;
|
|
65267
|
+
};
|
|
65268
|
+
visit(tree, strongTest, node => {
|
|
65269
|
+
trimEmphasis(node);
|
|
65270
|
+
return SKIP;
|
|
65271
|
+
});
|
|
65272
|
+
visit(tree, 'image', (node, index, parent) => {
|
|
65273
|
+
if (phrasing(parent) || !parent.children.every(child => child.type === 'image' || !phrasing(child)))
|
|
65274
|
+
return;
|
|
65275
|
+
parent.children.splice(index, 1, { type: 'paragraph', children: [node] });
|
|
65276
|
+
});
|
|
65277
|
+
return tree;
|
|
65278
|
+
};
|
|
65279
|
+
/* harmony default export */ const compatability = (compatibilityTransfomer);
|
|
65280
|
+
|
|
65256
65281
|
;// ./processor/transform/div.ts
|
|
65257
65282
|
var div_rest = (undefined && undefined.__rest) || function (s, e) {
|
|
65258
65283
|
var t = {};
|
|
@@ -65301,6 +65326,41 @@ const injectComponents = (opts) => () => tree => {
|
|
|
65301
65326
|
};
|
|
65302
65327
|
/* harmony default export */ const inject_components = (injectComponents);
|
|
65303
65328
|
|
|
65329
|
+
;// ./processor/transform/mdx-to-hast.ts
|
|
65330
|
+
|
|
65331
|
+
|
|
65332
|
+
|
|
65333
|
+
const setData = (node, index, parent) => {
|
|
65334
|
+
if (!node.name)
|
|
65335
|
+
return;
|
|
65336
|
+
if (!(node.name in components_namespaceObject))
|
|
65337
|
+
return;
|
|
65338
|
+
parent.children[index] = Object.assign(Object.assign({}, node), { data: {
|
|
65339
|
+
hName: node.name,
|
|
65340
|
+
hProperties: getAttrs(node),
|
|
65341
|
+
} });
|
|
65342
|
+
};
|
|
65343
|
+
const mdxToHast = () => tree => {
|
|
65344
|
+
visit(tree, isMDXElement, setData);
|
|
65345
|
+
return tree;
|
|
65346
|
+
};
|
|
65347
|
+
/* harmony default export */ const mdx_to_hast = (mdxToHast);
|
|
65348
|
+
|
|
65349
|
+
;// ./processor/transform/mermaid.ts
|
|
65350
|
+
|
|
65351
|
+
const mermaidTransformer = () => (tree) => {
|
|
65352
|
+
visit(tree, 'element', (node) => {
|
|
65353
|
+
if (node.tagName !== 'pre' || node.children.length !== 1)
|
|
65354
|
+
return;
|
|
65355
|
+
const [child] = node.children;
|
|
65356
|
+
if (child.type === 'element' && child.tagName === 'code' && child.properties.lang === 'mermaid') {
|
|
65357
|
+
node.properties = Object.assign(Object.assign({}, node.properties), { className: ['mermaid', ...(node.properties.className || [])] });
|
|
65358
|
+
}
|
|
65359
|
+
});
|
|
65360
|
+
return tree;
|
|
65361
|
+
};
|
|
65362
|
+
/* harmony default export */ const transform_mermaid = (mermaidTransformer);
|
|
65363
|
+
|
|
65304
65364
|
;// ./processor/transform/readme-components.ts
|
|
65305
65365
|
|
|
65306
65366
|
|
|
@@ -65539,58 +65599,6 @@ const readmeToMdx = () => tree => {
|
|
|
65539
65599
|
};
|
|
65540
65600
|
/* harmony default export */ const readme_to_mdx = (readmeToMdx);
|
|
65541
65601
|
|
|
65542
|
-
;// ./processor/transform/variables.ts
|
|
65543
|
-
|
|
65544
|
-
|
|
65545
|
-
const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
65546
|
-
visit(tree, (node, index, parent) => {
|
|
65547
|
-
var _a, _b;
|
|
65548
|
-
if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
|
|
65549
|
-
return;
|
|
65550
|
-
// @ts-expect-error - estree is not defined on our mdx types?!
|
|
65551
|
-
if (node.data.estree.type !== 'Program')
|
|
65552
|
-
return;
|
|
65553
|
-
// @ts-expect-error - estree is not defined on our mdx types?!
|
|
65554
|
-
const [expression] = node.data.estree.body;
|
|
65555
|
-
if (!expression ||
|
|
65556
|
-
expression.type !== 'ExpressionStatement' ||
|
|
65557
|
-
((_a = expression.expression.object) === null || _a === void 0 ? void 0 : _a.name) !== 'user' ||
|
|
65558
|
-
!['Literal', 'Identifier'].includes((_b = expression.expression.property) === null || _b === void 0 ? void 0 : _b.type))
|
|
65559
|
-
return;
|
|
65560
|
-
const name = expression.expression.property.type === 'Identifier'
|
|
65561
|
-
? expression.expression.property.name
|
|
65562
|
-
: expression.expression.property.value;
|
|
65563
|
-
let variable = asMdx
|
|
65564
|
-
? {
|
|
65565
|
-
type: 'mdxJsxTextElement',
|
|
65566
|
-
name: 'Variable',
|
|
65567
|
-
attributes: [
|
|
65568
|
-
{
|
|
65569
|
-
type: 'mdxJsxAttribute',
|
|
65570
|
-
name: 'name',
|
|
65571
|
-
value: name,
|
|
65572
|
-
},
|
|
65573
|
-
],
|
|
65574
|
-
children: [],
|
|
65575
|
-
position: node.position,
|
|
65576
|
-
}
|
|
65577
|
-
: {
|
|
65578
|
-
type: NodeTypes.variable,
|
|
65579
|
-
data: {
|
|
65580
|
-
hName: 'Variable',
|
|
65581
|
-
hProperties: {
|
|
65582
|
-
name,
|
|
65583
|
-
},
|
|
65584
|
-
},
|
|
65585
|
-
value: `{${node.value}}`,
|
|
65586
|
-
position: node.position,
|
|
65587
|
-
};
|
|
65588
|
-
parent.children.splice(index, 1, variable);
|
|
65589
|
-
});
|
|
65590
|
-
return tree;
|
|
65591
|
-
};
|
|
65592
|
-
/* harmony default export */ const transform_variables = (variables);
|
|
65593
|
-
|
|
65594
65602
|
;// ./processor/transform/tables-to-jsx.ts
|
|
65595
65603
|
|
|
65596
65604
|
|
|
@@ -65619,7 +65627,7 @@ const visitor = (table, index, parent) => {
|
|
|
65619
65627
|
visit(cell, 'break', (_, index, parent) => {
|
|
65620
65628
|
parent.children.splice(index, 1, { type: 'text', value: '\n' });
|
|
65621
65629
|
});
|
|
65622
|
-
if (!phrasing(content)) {
|
|
65630
|
+
if (!phrasing(content) && content.type !== 'escape') {
|
|
65623
65631
|
hasFlowContent = true;
|
|
65624
65632
|
return EXIT;
|
|
65625
65633
|
}
|
|
@@ -65683,45 +65691,57 @@ const tablesToJsx = () => tree => {
|
|
|
65683
65691
|
};
|
|
65684
65692
|
/* harmony default export */ const tables_to_jsx = (tablesToJsx);
|
|
65685
65693
|
|
|
65686
|
-
;// ./processor/transform/
|
|
65694
|
+
;// ./processor/transform/variables.ts
|
|
65687
65695
|
|
|
65688
65696
|
|
|
65689
|
-
const
|
|
65690
|
-
|
|
65691
|
-
|
|
65692
|
-
|
|
65693
|
-
child.value = child.value.trim();
|
|
65694
|
-
return EXIT;
|
|
65695
|
-
});
|
|
65696
|
-
return node;
|
|
65697
|
-
};
|
|
65698
|
-
visit(tree, strongTest, node => {
|
|
65699
|
-
trimEmphasis(node);
|
|
65700
|
-
return SKIP;
|
|
65701
|
-
});
|
|
65702
|
-
visit(tree, 'image', (node, index, parent) => {
|
|
65703
|
-
if (phrasing(parent) || !parent.children.every(child => child.type === 'image' || !phrasing(child)))
|
|
65697
|
+
const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
65698
|
+
visit(tree, (node, index, parent) => {
|
|
65699
|
+
var _a, _b;
|
|
65700
|
+
if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
|
|
65704
65701
|
return;
|
|
65705
|
-
|
|
65706
|
-
|
|
65707
|
-
return tree;
|
|
65708
|
-
};
|
|
65709
|
-
/* harmony default export */ const compatability = (compatibilityTransfomer);
|
|
65710
|
-
|
|
65711
|
-
;// ./processor/transform/mermaid.ts
|
|
65712
|
-
|
|
65713
|
-
const mermaidTransformer = () => (tree) => {
|
|
65714
|
-
visit(tree, 'element', (node) => {
|
|
65715
|
-
if (node.tagName !== 'pre' || node.children.length !== 1)
|
|
65702
|
+
// @ts-expect-error - estree is not defined on our mdx types?!
|
|
65703
|
+
if (node.data.estree.type !== 'Program')
|
|
65716
65704
|
return;
|
|
65717
|
-
|
|
65718
|
-
|
|
65719
|
-
|
|
65720
|
-
|
|
65705
|
+
// @ts-expect-error - estree is not defined on our mdx types?!
|
|
65706
|
+
const [expression] = node.data.estree.body;
|
|
65707
|
+
if (!expression ||
|
|
65708
|
+
expression.type !== 'ExpressionStatement' ||
|
|
65709
|
+
((_a = expression.expression.object) === null || _a === void 0 ? void 0 : _a.name) !== 'user' ||
|
|
65710
|
+
!['Literal', 'Identifier'].includes((_b = expression.expression.property) === null || _b === void 0 ? void 0 : _b.type))
|
|
65711
|
+
return;
|
|
65712
|
+
const name = expression.expression.property.type === 'Identifier'
|
|
65713
|
+
? expression.expression.property.name
|
|
65714
|
+
: expression.expression.property.value;
|
|
65715
|
+
let variable = asMdx
|
|
65716
|
+
? {
|
|
65717
|
+
type: 'mdxJsxTextElement',
|
|
65718
|
+
name: 'Variable',
|
|
65719
|
+
attributes: [
|
|
65720
|
+
{
|
|
65721
|
+
type: 'mdxJsxAttribute',
|
|
65722
|
+
name: 'name',
|
|
65723
|
+
value: name,
|
|
65724
|
+
},
|
|
65725
|
+
],
|
|
65726
|
+
children: [],
|
|
65727
|
+
position: node.position,
|
|
65728
|
+
}
|
|
65729
|
+
: {
|
|
65730
|
+
type: NodeTypes.variable,
|
|
65731
|
+
data: {
|
|
65732
|
+
hName: 'Variable',
|
|
65733
|
+
hProperties: {
|
|
65734
|
+
name,
|
|
65735
|
+
},
|
|
65736
|
+
},
|
|
65737
|
+
value: `{${node.value}}`,
|
|
65738
|
+
position: node.position,
|
|
65739
|
+
};
|
|
65740
|
+
parent.children.splice(index, 1, variable);
|
|
65721
65741
|
});
|
|
65722
65742
|
return tree;
|
|
65723
65743
|
};
|
|
65724
|
-
/* harmony default export */ const
|
|
65744
|
+
/* harmony default export */ const transform_variables = (variables);
|
|
65725
65745
|
|
|
65726
65746
|
;// ./processor/transform/index.ts
|
|
65727
65747
|
|
|
@@ -65738,6 +65758,7 @@ const mermaidTransformer = () => (tree) => {
|
|
|
65738
65758
|
|
|
65739
65759
|
|
|
65740
65760
|
|
|
65761
|
+
|
|
65741
65762
|
const defaultTransforms = {
|
|
65742
65763
|
calloutTransformer: callouts,
|
|
65743
65764
|
codeTabsTransformer: code_tabs,
|
|
@@ -78557,7 +78578,11 @@ const hast = (text, opts = {}) => {
|
|
|
78557
78578
|
memo[name] = lib_mdast(doc);
|
|
78558
78579
|
return memo;
|
|
78559
78580
|
}, {});
|
|
78560
|
-
const processor = ast_processor(opts)
|
|
78581
|
+
const processor = ast_processor(opts)
|
|
78582
|
+
.use(inject_components({ components }))
|
|
78583
|
+
.use(mdx_to_hast)
|
|
78584
|
+
.use(remarkRehype)
|
|
78585
|
+
.use(rehypePlugins);
|
|
78561
78586
|
return processor.runSync(processor.parse(text));
|
|
78562
78587
|
};
|
|
78563
78588
|
/* harmony default export */ const lib_hast = (hast);
|
|
@@ -78727,12 +78752,7 @@ function tableCellTransformer() {
|
|
|
78727
78752
|
|
|
78728
78753
|
|
|
78729
78754
|
|
|
78730
|
-
const transformers = [
|
|
78731
|
-
migration_emphasis,
|
|
78732
|
-
migration_images,
|
|
78733
|
-
migration_linkReference,
|
|
78734
|
-
table_cell,
|
|
78735
|
-
];
|
|
78755
|
+
const transformers = [migration_emphasis, migration_images, migration_linkReference, table_cell];
|
|
78736
78756
|
/* harmony default export */ const migration = (transformers);
|
|
78737
78757
|
|
|
78738
78758
|
;// ./lib/mdastV6.ts
|
|
@@ -83481,7 +83501,7 @@ const mdx_mdx = (tree, _a = {}) => {
|
|
|
83481
83501
|
|
|
83482
83502
|
const STRIP_TAGS = ['script', 'style'];
|
|
83483
83503
|
function plain_one(node, opts) {
|
|
83484
|
-
var _a, _b;
|
|
83504
|
+
var _a, _b, _c;
|
|
83485
83505
|
if (node.type === 'comment')
|
|
83486
83506
|
return '';
|
|
83487
83507
|
if ('type' in node && node.type === 'text') {
|
|
@@ -83490,27 +83510,37 @@ function plain_one(node, opts) {
|
|
|
83490
83510
|
if ('tagName' in node) {
|
|
83491
83511
|
if (STRIP_TAGS.includes(node.tagName))
|
|
83492
83512
|
return '';
|
|
83493
|
-
|
|
83494
|
-
|
|
83495
|
-
|
|
83496
|
-
|
|
83497
|
-
|
|
83498
|
-
|
|
83499
|
-
|
|
83500
|
-
|
|
83501
|
-
|
|
83502
|
-
|
|
83503
|
-
|
|
83504
|
-
|
|
83505
|
-
|
|
83506
|
-
|
|
83507
|
-
|
|
83508
|
-
|
|
83509
|
-
|
|
83510
|
-
|
|
83511
|
-
|
|
83512
|
-
|
|
83513
|
-
|
|
83513
|
+
switch (node.tagName) {
|
|
83514
|
+
case 'html-block': {
|
|
83515
|
+
if (!node.properties.html)
|
|
83516
|
+
return '';
|
|
83517
|
+
return plain_all(lib_hast(node.properties.html.toString()), opts);
|
|
83518
|
+
}
|
|
83519
|
+
case 'rdme-callout': {
|
|
83520
|
+
const { icon, title } = node.properties;
|
|
83521
|
+
const children = (_a = node === null || node === void 0 ? void 0 : node.children) === null || _a === void 0 ? void 0 : _a.slice(title ? 1 : 0);
|
|
83522
|
+
const body = children ? plain_all({ type: 'root', children }, opts) : '';
|
|
83523
|
+
return [icon, ' ', title, title && body && ': ', body].filter(Boolean).join('');
|
|
83524
|
+
}
|
|
83525
|
+
case 'readme-glossary-item': {
|
|
83526
|
+
return node.properties.term;
|
|
83527
|
+
}
|
|
83528
|
+
case 'readme-variable': {
|
|
83529
|
+
const key = node.properties.variable.toString();
|
|
83530
|
+
const val = opts.variables[key];
|
|
83531
|
+
return val || `<<${key}>>`;
|
|
83532
|
+
}
|
|
83533
|
+
case 'img': {
|
|
83534
|
+
return ((_b = node.properties) === null || _b === void 0 ? void 0 : _b.title) || '';
|
|
83535
|
+
}
|
|
83536
|
+
case 'Accordion':
|
|
83537
|
+
case 'Card':
|
|
83538
|
+
case 'Tab': {
|
|
83539
|
+
const title = ((_c = node.properties) === null || _c === void 0 ? void 0 : _c.title) || '';
|
|
83540
|
+
const children = node === null || node === void 0 ? void 0 : node.children;
|
|
83541
|
+
const body = children ? plain_all({ type: 'root', children }, opts) : '';
|
|
83542
|
+
return [title, body].filter(Boolean).join(' ');
|
|
83543
|
+
}
|
|
83514
83544
|
}
|
|
83515
83545
|
}
|
|
83516
83546
|
if ('value' in node) {
|
package/dist/main.node.js
CHANGED
|
@@ -66332,6 +66332,31 @@ const gemojiTransformer = () => (tree) => {
|
|
|
66332
66332
|
};
|
|
66333
66333
|
/* harmony default export */ const gemoji_ = (gemojiTransformer);
|
|
66334
66334
|
|
|
66335
|
+
;// ./processor/transform/compatability.ts
|
|
66336
|
+
|
|
66337
|
+
|
|
66338
|
+
const strongTest = (node) => ['emphasis', 'strong'].includes(node.type);
|
|
66339
|
+
const compatibilityTransfomer = () => tree => {
|
|
66340
|
+
const trimEmphasis = (node) => {
|
|
66341
|
+
visit(node, 'text', child => {
|
|
66342
|
+
child.value = child.value.trim();
|
|
66343
|
+
return EXIT;
|
|
66344
|
+
});
|
|
66345
|
+
return node;
|
|
66346
|
+
};
|
|
66347
|
+
visit(tree, strongTest, node => {
|
|
66348
|
+
trimEmphasis(node);
|
|
66349
|
+
return SKIP;
|
|
66350
|
+
});
|
|
66351
|
+
visit(tree, 'image', (node, index, parent) => {
|
|
66352
|
+
if (phrasing(parent) || !parent.children.every(child => child.type === 'image' || !phrasing(child)))
|
|
66353
|
+
return;
|
|
66354
|
+
parent.children.splice(index, 1, { type: 'paragraph', children: [node] });
|
|
66355
|
+
});
|
|
66356
|
+
return tree;
|
|
66357
|
+
};
|
|
66358
|
+
/* harmony default export */ const compatability = (compatibilityTransfomer);
|
|
66359
|
+
|
|
66335
66360
|
;// ./processor/transform/div.ts
|
|
66336
66361
|
var div_rest = (undefined && undefined.__rest) || function (s, e) {
|
|
66337
66362
|
var t = {};
|
|
@@ -66380,6 +66405,41 @@ const injectComponents = (opts) => () => tree => {
|
|
|
66380
66405
|
};
|
|
66381
66406
|
/* harmony default export */ const inject_components = (injectComponents);
|
|
66382
66407
|
|
|
66408
|
+
;// ./processor/transform/mdx-to-hast.ts
|
|
66409
|
+
|
|
66410
|
+
|
|
66411
|
+
|
|
66412
|
+
const setData = (node, index, parent) => {
|
|
66413
|
+
if (!node.name)
|
|
66414
|
+
return;
|
|
66415
|
+
if (!(node.name in components_namespaceObject))
|
|
66416
|
+
return;
|
|
66417
|
+
parent.children[index] = Object.assign(Object.assign({}, node), { data: {
|
|
66418
|
+
hName: node.name,
|
|
66419
|
+
hProperties: getAttrs(node),
|
|
66420
|
+
} });
|
|
66421
|
+
};
|
|
66422
|
+
const mdxToHast = () => tree => {
|
|
66423
|
+
visit(tree, isMDXElement, setData);
|
|
66424
|
+
return tree;
|
|
66425
|
+
};
|
|
66426
|
+
/* harmony default export */ const mdx_to_hast = (mdxToHast);
|
|
66427
|
+
|
|
66428
|
+
;// ./processor/transform/mermaid.ts
|
|
66429
|
+
|
|
66430
|
+
const mermaidTransformer = () => (tree) => {
|
|
66431
|
+
visit(tree, 'element', (node) => {
|
|
66432
|
+
if (node.tagName !== 'pre' || node.children.length !== 1)
|
|
66433
|
+
return;
|
|
66434
|
+
const [child] = node.children;
|
|
66435
|
+
if (child.type === 'element' && child.tagName === 'code' && child.properties.lang === 'mermaid') {
|
|
66436
|
+
node.properties = Object.assign(Object.assign({}, node.properties), { className: ['mermaid', ...(node.properties.className || [])] });
|
|
66437
|
+
}
|
|
66438
|
+
});
|
|
66439
|
+
return tree;
|
|
66440
|
+
};
|
|
66441
|
+
/* harmony default export */ const transform_mermaid = (mermaidTransformer);
|
|
66442
|
+
|
|
66383
66443
|
;// ./processor/transform/readme-components.ts
|
|
66384
66444
|
|
|
66385
66445
|
|
|
@@ -66618,58 +66678,6 @@ const readmeToMdx = () => tree => {
|
|
|
66618
66678
|
};
|
|
66619
66679
|
/* harmony default export */ const readme_to_mdx = (readmeToMdx);
|
|
66620
66680
|
|
|
66621
|
-
;// ./processor/transform/variables.ts
|
|
66622
|
-
|
|
66623
|
-
|
|
66624
|
-
const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
66625
|
-
visit(tree, (node, index, parent) => {
|
|
66626
|
-
var _a, _b;
|
|
66627
|
-
if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
|
|
66628
|
-
return;
|
|
66629
|
-
// @ts-expect-error - estree is not defined on our mdx types?!
|
|
66630
|
-
if (node.data.estree.type !== 'Program')
|
|
66631
|
-
return;
|
|
66632
|
-
// @ts-expect-error - estree is not defined on our mdx types?!
|
|
66633
|
-
const [expression] = node.data.estree.body;
|
|
66634
|
-
if (!expression ||
|
|
66635
|
-
expression.type !== 'ExpressionStatement' ||
|
|
66636
|
-
((_a = expression.expression.object) === null || _a === void 0 ? void 0 : _a.name) !== 'user' ||
|
|
66637
|
-
!['Literal', 'Identifier'].includes((_b = expression.expression.property) === null || _b === void 0 ? void 0 : _b.type))
|
|
66638
|
-
return;
|
|
66639
|
-
const name = expression.expression.property.type === 'Identifier'
|
|
66640
|
-
? expression.expression.property.name
|
|
66641
|
-
: expression.expression.property.value;
|
|
66642
|
-
let variable = asMdx
|
|
66643
|
-
? {
|
|
66644
|
-
type: 'mdxJsxTextElement',
|
|
66645
|
-
name: 'Variable',
|
|
66646
|
-
attributes: [
|
|
66647
|
-
{
|
|
66648
|
-
type: 'mdxJsxAttribute',
|
|
66649
|
-
name: 'name',
|
|
66650
|
-
value: name,
|
|
66651
|
-
},
|
|
66652
|
-
],
|
|
66653
|
-
children: [],
|
|
66654
|
-
position: node.position,
|
|
66655
|
-
}
|
|
66656
|
-
: {
|
|
66657
|
-
type: NodeTypes.variable,
|
|
66658
|
-
data: {
|
|
66659
|
-
hName: 'Variable',
|
|
66660
|
-
hProperties: {
|
|
66661
|
-
name,
|
|
66662
|
-
},
|
|
66663
|
-
},
|
|
66664
|
-
value: `{${node.value}}`,
|
|
66665
|
-
position: node.position,
|
|
66666
|
-
};
|
|
66667
|
-
parent.children.splice(index, 1, variable);
|
|
66668
|
-
});
|
|
66669
|
-
return tree;
|
|
66670
|
-
};
|
|
66671
|
-
/* harmony default export */ const transform_variables = (variables);
|
|
66672
|
-
|
|
66673
66681
|
;// ./processor/transform/tables-to-jsx.ts
|
|
66674
66682
|
|
|
66675
66683
|
|
|
@@ -66698,7 +66706,7 @@ const visitor = (table, index, parent) => {
|
|
|
66698
66706
|
visit(cell, 'break', (_, index, parent) => {
|
|
66699
66707
|
parent.children.splice(index, 1, { type: 'text', value: '\n' });
|
|
66700
66708
|
});
|
|
66701
|
-
if (!phrasing(content)) {
|
|
66709
|
+
if (!phrasing(content) && content.type !== 'escape') {
|
|
66702
66710
|
hasFlowContent = true;
|
|
66703
66711
|
return EXIT;
|
|
66704
66712
|
}
|
|
@@ -66762,45 +66770,57 @@ const tablesToJsx = () => tree => {
|
|
|
66762
66770
|
};
|
|
66763
66771
|
/* harmony default export */ const tables_to_jsx = (tablesToJsx);
|
|
66764
66772
|
|
|
66765
|
-
;// ./processor/transform/
|
|
66773
|
+
;// ./processor/transform/variables.ts
|
|
66766
66774
|
|
|
66767
66775
|
|
|
66768
|
-
const
|
|
66769
|
-
|
|
66770
|
-
|
|
66771
|
-
|
|
66772
|
-
child.value = child.value.trim();
|
|
66773
|
-
return EXIT;
|
|
66774
|
-
});
|
|
66775
|
-
return node;
|
|
66776
|
-
};
|
|
66777
|
-
visit(tree, strongTest, node => {
|
|
66778
|
-
trimEmphasis(node);
|
|
66779
|
-
return SKIP;
|
|
66780
|
-
});
|
|
66781
|
-
visit(tree, 'image', (node, index, parent) => {
|
|
66782
|
-
if (phrasing(parent) || !parent.children.every(child => child.type === 'image' || !phrasing(child)))
|
|
66776
|
+
const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
66777
|
+
visit(tree, (node, index, parent) => {
|
|
66778
|
+
var _a, _b;
|
|
66779
|
+
if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
|
|
66783
66780
|
return;
|
|
66784
|
-
|
|
66785
|
-
|
|
66786
|
-
return tree;
|
|
66787
|
-
};
|
|
66788
|
-
/* harmony default export */ const compatability = (compatibilityTransfomer);
|
|
66789
|
-
|
|
66790
|
-
;// ./processor/transform/mermaid.ts
|
|
66791
|
-
|
|
66792
|
-
const mermaidTransformer = () => (tree) => {
|
|
66793
|
-
visit(tree, 'element', (node) => {
|
|
66794
|
-
if (node.tagName !== 'pre' || node.children.length !== 1)
|
|
66781
|
+
// @ts-expect-error - estree is not defined on our mdx types?!
|
|
66782
|
+
if (node.data.estree.type !== 'Program')
|
|
66795
66783
|
return;
|
|
66796
|
-
|
|
66797
|
-
|
|
66798
|
-
|
|
66799
|
-
|
|
66784
|
+
// @ts-expect-error - estree is not defined on our mdx types?!
|
|
66785
|
+
const [expression] = node.data.estree.body;
|
|
66786
|
+
if (!expression ||
|
|
66787
|
+
expression.type !== 'ExpressionStatement' ||
|
|
66788
|
+
((_a = expression.expression.object) === null || _a === void 0 ? void 0 : _a.name) !== 'user' ||
|
|
66789
|
+
!['Literal', 'Identifier'].includes((_b = expression.expression.property) === null || _b === void 0 ? void 0 : _b.type))
|
|
66790
|
+
return;
|
|
66791
|
+
const name = expression.expression.property.type === 'Identifier'
|
|
66792
|
+
? expression.expression.property.name
|
|
66793
|
+
: expression.expression.property.value;
|
|
66794
|
+
let variable = asMdx
|
|
66795
|
+
? {
|
|
66796
|
+
type: 'mdxJsxTextElement',
|
|
66797
|
+
name: 'Variable',
|
|
66798
|
+
attributes: [
|
|
66799
|
+
{
|
|
66800
|
+
type: 'mdxJsxAttribute',
|
|
66801
|
+
name: 'name',
|
|
66802
|
+
value: name,
|
|
66803
|
+
},
|
|
66804
|
+
],
|
|
66805
|
+
children: [],
|
|
66806
|
+
position: node.position,
|
|
66807
|
+
}
|
|
66808
|
+
: {
|
|
66809
|
+
type: NodeTypes.variable,
|
|
66810
|
+
data: {
|
|
66811
|
+
hName: 'Variable',
|
|
66812
|
+
hProperties: {
|
|
66813
|
+
name,
|
|
66814
|
+
},
|
|
66815
|
+
},
|
|
66816
|
+
value: `{${node.value}}`,
|
|
66817
|
+
position: node.position,
|
|
66818
|
+
};
|
|
66819
|
+
parent.children.splice(index, 1, variable);
|
|
66800
66820
|
});
|
|
66801
66821
|
return tree;
|
|
66802
66822
|
};
|
|
66803
|
-
/* harmony default export */ const
|
|
66823
|
+
/* harmony default export */ const transform_variables = (variables);
|
|
66804
66824
|
|
|
66805
66825
|
;// ./processor/transform/index.ts
|
|
66806
66826
|
|
|
@@ -66817,6 +66837,7 @@ const mermaidTransformer = () => (tree) => {
|
|
|
66817
66837
|
|
|
66818
66838
|
|
|
66819
66839
|
|
|
66840
|
+
|
|
66820
66841
|
const defaultTransforms = {
|
|
66821
66842
|
calloutTransformer: callouts,
|
|
66822
66843
|
codeTabsTransformer: code_tabs,
|
|
@@ -79636,7 +79657,11 @@ const hast = (text, opts = {}) => {
|
|
|
79636
79657
|
memo[name] = lib_mdast(doc);
|
|
79637
79658
|
return memo;
|
|
79638
79659
|
}, {});
|
|
79639
|
-
const processor = ast_processor(opts)
|
|
79660
|
+
const processor = ast_processor(opts)
|
|
79661
|
+
.use(inject_components({ components }))
|
|
79662
|
+
.use(mdx_to_hast)
|
|
79663
|
+
.use(remarkRehype)
|
|
79664
|
+
.use(rehypePlugins);
|
|
79640
79665
|
return processor.runSync(processor.parse(text));
|
|
79641
79666
|
};
|
|
79642
79667
|
/* harmony default export */ const lib_hast = (hast);
|
|
@@ -79806,12 +79831,7 @@ function tableCellTransformer() {
|
|
|
79806
79831
|
|
|
79807
79832
|
|
|
79808
79833
|
|
|
79809
|
-
const transformers = [
|
|
79810
|
-
migration_emphasis,
|
|
79811
|
-
migration_images,
|
|
79812
|
-
migration_linkReference,
|
|
79813
|
-
table_cell,
|
|
79814
|
-
];
|
|
79834
|
+
const transformers = [migration_emphasis, migration_images, migration_linkReference, table_cell];
|
|
79815
79835
|
/* harmony default export */ const migration = (transformers);
|
|
79816
79836
|
|
|
79817
79837
|
;// ./lib/mdastV6.ts
|
|
@@ -84560,7 +84580,7 @@ const mdx_mdx = (tree, _a = {}) => {
|
|
|
84560
84580
|
|
|
84561
84581
|
const STRIP_TAGS = ['script', 'style'];
|
|
84562
84582
|
function plain_one(node, opts) {
|
|
84563
|
-
var _a, _b;
|
|
84583
|
+
var _a, _b, _c;
|
|
84564
84584
|
if (node.type === 'comment')
|
|
84565
84585
|
return '';
|
|
84566
84586
|
if ('type' in node && node.type === 'text') {
|
|
@@ -84569,27 +84589,37 @@ function plain_one(node, opts) {
|
|
|
84569
84589
|
if ('tagName' in node) {
|
|
84570
84590
|
if (STRIP_TAGS.includes(node.tagName))
|
|
84571
84591
|
return '';
|
|
84572
|
-
|
|
84573
|
-
|
|
84574
|
-
|
|
84575
|
-
|
|
84576
|
-
|
|
84577
|
-
|
|
84578
|
-
|
|
84579
|
-
|
|
84580
|
-
|
|
84581
|
-
|
|
84582
|
-
|
|
84583
|
-
|
|
84584
|
-
|
|
84585
|
-
|
|
84586
|
-
|
|
84587
|
-
|
|
84588
|
-
|
|
84589
|
-
|
|
84590
|
-
|
|
84591
|
-
|
|
84592
|
-
|
|
84592
|
+
switch (node.tagName) {
|
|
84593
|
+
case 'html-block': {
|
|
84594
|
+
if (!node.properties.html)
|
|
84595
|
+
return '';
|
|
84596
|
+
return plain_all(lib_hast(node.properties.html.toString()), opts);
|
|
84597
|
+
}
|
|
84598
|
+
case 'rdme-callout': {
|
|
84599
|
+
const { icon, title } = node.properties;
|
|
84600
|
+
const children = (_a = node === null || node === void 0 ? void 0 : node.children) === null || _a === void 0 ? void 0 : _a.slice(title ? 1 : 0);
|
|
84601
|
+
const body = children ? plain_all({ type: 'root', children }, opts) : '';
|
|
84602
|
+
return [icon, ' ', title, title && body && ': ', body].filter(Boolean).join('');
|
|
84603
|
+
}
|
|
84604
|
+
case 'readme-glossary-item': {
|
|
84605
|
+
return node.properties.term;
|
|
84606
|
+
}
|
|
84607
|
+
case 'readme-variable': {
|
|
84608
|
+
const key = node.properties.variable.toString();
|
|
84609
|
+
const val = opts.variables[key];
|
|
84610
|
+
return val || `<<${key}>>`;
|
|
84611
|
+
}
|
|
84612
|
+
case 'img': {
|
|
84613
|
+
return ((_b = node.properties) === null || _b === void 0 ? void 0 : _b.title) || '';
|
|
84614
|
+
}
|
|
84615
|
+
case 'Accordion':
|
|
84616
|
+
case 'Card':
|
|
84617
|
+
case 'Tab': {
|
|
84618
|
+
const title = ((_c = node.properties) === null || _c === void 0 ? void 0 : _c.title) || '';
|
|
84619
|
+
const children = node === null || node === void 0 ? void 0 : node.children;
|
|
84620
|
+
const body = children ? plain_all({ type: 'root', children }, opts) : '';
|
|
84621
|
+
return [title, body].filter(Boolean).join(' ');
|
|
84622
|
+
}
|
|
84593
84623
|
}
|
|
84594
84624
|
}
|
|
84595
84625
|
if ('value' in node) {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import compatabilityTransfomer from './compatability';
|
|
1
2
|
import divTransformer from './div';
|
|
2
3
|
import injectComponents from './inject-components';
|
|
4
|
+
import mdxToHast from './mdx-to-hast';
|
|
5
|
+
import mermaidTransformer from './mermaid';
|
|
3
6
|
import readmeComponentsTransformer from './readme-components';
|
|
4
7
|
import readmeToMdx from './readme-to-mdx';
|
|
5
|
-
import variablesTransformer from './variables';
|
|
6
8
|
import tablesToJsx from './tables-to-jsx';
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
export { compatabilityTransfomer, divTransformer, readmeComponentsTransformer, readmeToMdx, injectComponents, variablesTransformer, tablesToJsx, mermaidTransformer, };
|
|
9
|
+
import variablesTransformer from './variables';
|
|
10
|
+
export { compatabilityTransfomer, divTransformer, injectComponents, mdxToHast, mermaidTransformer, readmeComponentsTransformer, readmeToMdx, tablesToJsx, variablesTransformer, };
|
|
10
11
|
export declare const defaultTransforms: {
|
|
11
12
|
calloutTransformer: () => (tree: any) => void;
|
|
12
13
|
codeTabsTransformer: ({ copyButtons }?: {
|
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.11.0",
|
|
6
6
|
"main": "dist/main.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/main.js",
|