@readme/markdown 9.8.0 → 9.9.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 +35 -0
- package/dist/main.node.js +35 -0
- package/dist/main.node.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -58531,6 +58531,7 @@ const mermaidTransformer = () => (tree) => {
|
|
|
58531
58531
|
|
|
58532
58532
|
|
|
58533
58533
|
const types = {
|
|
58534
|
+
Anchor: 'link',
|
|
58534
58535
|
Callout: NodeTypes.callout,
|
|
58535
58536
|
Code: 'code',
|
|
58536
58537
|
CodeTabs: NodeTypes.codeTabs,
|
|
@@ -58673,6 +58674,21 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
|
|
|
58673
58674
|
};
|
|
58674
58675
|
parent.children[index] = mdNode;
|
|
58675
58676
|
}
|
|
58677
|
+
else if (node.name === 'Anchor') {
|
|
58678
|
+
const hProperties = getAttrs(node);
|
|
58679
|
+
if (hProperties.href) {
|
|
58680
|
+
hProperties.url = hProperties.href;
|
|
58681
|
+
delete hProperties.href;
|
|
58682
|
+
}
|
|
58683
|
+
// @ts-expect-error we don't have a mechanism to enforce the URL attribute type right now
|
|
58684
|
+
const mdNode = {
|
|
58685
|
+
...hProperties,
|
|
58686
|
+
children: node.children,
|
|
58687
|
+
type: types[node.name],
|
|
58688
|
+
position: node.position,
|
|
58689
|
+
};
|
|
58690
|
+
parent.children[index] = mdNode;
|
|
58691
|
+
}
|
|
58676
58692
|
else if (node.name in types) {
|
|
58677
58693
|
const hProperties = getAttrs(node);
|
|
58678
58694
|
const mdNode = {
|
|
@@ -58774,6 +58790,25 @@ const readmeToMdx = () => tree => {
|
|
|
58774
58790
|
});
|
|
58775
58791
|
}
|
|
58776
58792
|
});
|
|
58793
|
+
const hasExtraLinkAttrs = (attributes) => !!attributes.find(attr => !['href', 'label'].includes(attr.name));
|
|
58794
|
+
// converts links with extra attributes to Anchor elements
|
|
58795
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
58796
|
+
visit(tree, 'link', ({ type, children, position, ...attrs }, index, parent) => {
|
|
58797
|
+
if ('url' in attrs) {
|
|
58798
|
+
attrs.href = attrs.url;
|
|
58799
|
+
delete attrs.url;
|
|
58800
|
+
}
|
|
58801
|
+
const attributes = toAttributes(attrs);
|
|
58802
|
+
if (hasExtraLinkAttrs(attributes)) {
|
|
58803
|
+
parent.children.splice(index, 1, {
|
|
58804
|
+
type: 'mdxJsxTextElement',
|
|
58805
|
+
name: 'Anchor',
|
|
58806
|
+
attributes,
|
|
58807
|
+
children,
|
|
58808
|
+
position,
|
|
58809
|
+
});
|
|
58810
|
+
}
|
|
58811
|
+
});
|
|
58777
58812
|
visit(tree, 'html', (node, index, parent) => {
|
|
58778
58813
|
const html = node.value;
|
|
58779
58814
|
const isScriptOrStyleTag = [!!html.match(/^<(?:style|script)/i), !!html.match(/<\/(?:style|script)>$/i)];
|
package/dist/main.node.js
CHANGED
|
@@ -75441,6 +75441,7 @@ const mermaidTransformer = () => (tree) => {
|
|
|
75441
75441
|
|
|
75442
75442
|
|
|
75443
75443
|
const readme_components_types = {
|
|
75444
|
+
Anchor: 'link',
|
|
75444
75445
|
Callout: NodeTypes.callout,
|
|
75445
75446
|
Code: 'code',
|
|
75446
75447
|
CodeTabs: NodeTypes.codeTabs,
|
|
@@ -75583,6 +75584,21 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
|
|
|
75583
75584
|
};
|
|
75584
75585
|
parent.children[index] = mdNode;
|
|
75585
75586
|
}
|
|
75587
|
+
else if (node.name === 'Anchor') {
|
|
75588
|
+
const hProperties = getAttrs(node);
|
|
75589
|
+
if (hProperties.href) {
|
|
75590
|
+
hProperties.url = hProperties.href;
|
|
75591
|
+
delete hProperties.href;
|
|
75592
|
+
}
|
|
75593
|
+
// @ts-expect-error we don't have a mechanism to enforce the URL attribute type right now
|
|
75594
|
+
const mdNode = {
|
|
75595
|
+
...hProperties,
|
|
75596
|
+
children: node.children,
|
|
75597
|
+
type: readme_components_types[node.name],
|
|
75598
|
+
position: node.position,
|
|
75599
|
+
};
|
|
75600
|
+
parent.children[index] = mdNode;
|
|
75601
|
+
}
|
|
75586
75602
|
else if (node.name in readme_components_types) {
|
|
75587
75603
|
const hProperties = getAttrs(node);
|
|
75588
75604
|
const mdNode = {
|
|
@@ -75684,6 +75700,25 @@ const readmeToMdx = () => tree => {
|
|
|
75684
75700
|
});
|
|
75685
75701
|
}
|
|
75686
75702
|
});
|
|
75703
|
+
const hasExtraLinkAttrs = (attributes) => !!attributes.find(attr => !['href', 'label'].includes(attr.name));
|
|
75704
|
+
// converts links with extra attributes to Anchor elements
|
|
75705
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
75706
|
+
visit(tree, 'link', ({ type, children, position, ...attrs }, index, parent) => {
|
|
75707
|
+
if ('url' in attrs) {
|
|
75708
|
+
attrs.href = attrs.url;
|
|
75709
|
+
delete attrs.url;
|
|
75710
|
+
}
|
|
75711
|
+
const attributes = toAttributes(attrs);
|
|
75712
|
+
if (hasExtraLinkAttrs(attributes)) {
|
|
75713
|
+
parent.children.splice(index, 1, {
|
|
75714
|
+
type: 'mdxJsxTextElement',
|
|
75715
|
+
name: 'Anchor',
|
|
75716
|
+
attributes,
|
|
75717
|
+
children,
|
|
75718
|
+
position,
|
|
75719
|
+
});
|
|
75720
|
+
}
|
|
75721
|
+
});
|
|
75687
75722
|
visit(tree, 'html', (node, index, parent) => {
|
|
75688
75723
|
const html = node.value;
|
|
75689
75724
|
const isScriptOrStyleTag = [!!html.match(/^<(?:style|script)/i), !!html.match(/<\/(?:style|script)>$/i)];
|