@readme/markdown 9.11.0 → 9.12.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/components/Callout/index.tsx +16 -11
- package/components/Callout/style.scss +7 -1
- package/components/Heading/style.scss +10 -5
- package/dist/10.node.js +2 -2
- package/dist/354.node.js +1 -1
- package/dist/lib/mdx.d.ts +2 -1
- package/dist/main.css +1 -1
- package/dist/main.css.map +1 -1
- package/dist/main.js +64 -14
- package/dist/main.node.js +64 -14
- package/dist/main.node.js.map +1 -1
- package/dist/processor/transform/callouts.d.ts +3 -1
- package/dist/processor/transform/migrate-callouts.d.ts +3 -0
- package/package.json +2 -1
package/dist/main.js
CHANGED
|
@@ -11946,11 +11946,11 @@ Anchor.defaultProps = {
|
|
|
11946
11946
|
|
|
11947
11947
|
|
|
11948
11948
|
const themes = {
|
|
11949
|
-
|
|
11950
|
-
|
|
11951
|
-
|
|
11952
|
-
|
|
11953
|
-
|
|
11949
|
+
error: 'error',
|
|
11950
|
+
default: 'default',
|
|
11951
|
+
info: 'info',
|
|
11952
|
+
okay: 'okay',
|
|
11953
|
+
warn: 'warn',
|
|
11954
11954
|
'\uD83D\uDCD8': 'info',
|
|
11955
11955
|
'\uD83D\uDEA7': 'warn',
|
|
11956
11956
|
'\u26A0\uFE0F': 'warn',
|
|
@@ -11971,17 +11971,18 @@ const defaultIcons = {
|
|
|
11971
11971
|
error: '\u2757\uFE0F',
|
|
11972
11972
|
};
|
|
11973
11973
|
const Callout = (props) => {
|
|
11974
|
-
const { attributes,
|
|
11974
|
+
const { attributes, theme = 'default', empty } = props;
|
|
11975
|
+
const children = external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.Children.toArray(props.children);
|
|
11975
11976
|
const icon = props.icon || defaultIcons[theme] || '❗';
|
|
11976
11977
|
const isEmoji = emoji_regex().test(icon);
|
|
11978
|
+
const heading = empty ? external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("p", { className: 'callout-heading empty' }) : children[0];
|
|
11977
11979
|
return (
|
|
11978
11980
|
// @ts-expect-error -- theme is not a valid attribute
|
|
11979
11981
|
// eslint-disable-next-line react/jsx-props-no-spreading, react/no-unknown-property
|
|
11980
11982
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("blockquote", { ...attributes, className: `callout callout_${theme}`, theme: icon },
|
|
11981
|
-
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("
|
|
11982
|
-
|
|
11983
|
-
|
|
11984
|
-
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.Children.toArray(children).slice(1)));
|
|
11983
|
+
isEmoji ? (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "callout-icon" }, icon)) : (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: `callout-icon callout-icon_fa ${icon}` })),
|
|
11984
|
+
heading,
|
|
11985
|
+
children.slice(1)));
|
|
11985
11986
|
};
|
|
11986
11987
|
/* harmony default export */ const components_Callout = (Callout);
|
|
11987
11988
|
|
|
@@ -40932,6 +40933,32 @@ var NodeTypes;
|
|
|
40932
40933
|
|
|
40933
40934
|
|
|
40934
40935
|
const callouts_regex = `^(${emoji_regex().source}|⚠)(\\s+|$)`;
|
|
40936
|
+
const findFirst = (node) => {
|
|
40937
|
+
if ('children' in node)
|
|
40938
|
+
return findFirst(node.children[0]);
|
|
40939
|
+
if (node.type === 'text')
|
|
40940
|
+
return node;
|
|
40941
|
+
return null;
|
|
40942
|
+
};
|
|
40943
|
+
const findLast = (node) => {
|
|
40944
|
+
if ('children' in node && Array.isArray(node.children))
|
|
40945
|
+
return findFirst(node.children[node.children.length - 1]);
|
|
40946
|
+
if (node.type === 'text')
|
|
40947
|
+
return node;
|
|
40948
|
+
return null;
|
|
40949
|
+
};
|
|
40950
|
+
const wrapHeading = (node) => {
|
|
40951
|
+
const firstChild = node.children[0];
|
|
40952
|
+
return {
|
|
40953
|
+
type: 'heading',
|
|
40954
|
+
depth: 3,
|
|
40955
|
+
children: ('children' in firstChild ? firstChild.children : []),
|
|
40956
|
+
position: {
|
|
40957
|
+
start: findFirst(firstChild).position.start,
|
|
40958
|
+
end: findLast(firstChild).position.end,
|
|
40959
|
+
},
|
|
40960
|
+
};
|
|
40961
|
+
};
|
|
40935
40962
|
const calloutTransformer = () => {
|
|
40936
40963
|
return (tree) => {
|
|
40937
40964
|
visit(tree, 'blockquote', (node) => {
|
|
@@ -40944,6 +40971,9 @@ const calloutTransformer = () => {
|
|
|
40944
40971
|
const empty = !heading.length && node.children[0].children.length === 1;
|
|
40945
40972
|
const theme = themes[icon] || 'default';
|
|
40946
40973
|
node.children[0].children[0].value = heading;
|
|
40974
|
+
if (heading) {
|
|
40975
|
+
node.children[0] = wrapHeading(node);
|
|
40976
|
+
}
|
|
40947
40977
|
Object.assign(node, {
|
|
40948
40978
|
type: NodeTypes.callout,
|
|
40949
40979
|
data: {
|
|
@@ -58738,14 +58768,21 @@ const readmeToMdx = () => tree => {
|
|
|
58738
58768
|
visit(tree, 'rdme-callout', (node, index, parent) => {
|
|
58739
58769
|
const isEmoji = emoji_regex().test(node.data.hProperties.icon);
|
|
58740
58770
|
const isEmpty = node.data.hProperties?.empty;
|
|
58771
|
+
const isH3 = node.children[0].type === 'heading' && node.children[0].depth === 3;
|
|
58741
58772
|
// return the usual markdown if there is an emoji and the icon theme matches our default theme
|
|
58742
|
-
if (isEmoji && themes[node.data.hProperties.icon] === node.data.hProperties.theme) {
|
|
58773
|
+
if ((isEmpty || isH3) && isEmoji && themes[node.data.hProperties.icon] === node.data.hProperties.theme) {
|
|
58774
|
+
if (isH3) {
|
|
58775
|
+
node.children[0] = {
|
|
58776
|
+
type: 'paragraph',
|
|
58777
|
+
children: 'children' in node.children[0] ? node.children[0].children : [],
|
|
58778
|
+
};
|
|
58779
|
+
}
|
|
58743
58780
|
return;
|
|
58744
58781
|
}
|
|
58745
58782
|
parent.children.splice(index, 1, {
|
|
58746
58783
|
type: 'mdxJsxFlowElement',
|
|
58747
58784
|
name: 'Callout',
|
|
58748
|
-
attributes: toAttributes(node.data.hProperties, ['icon',
|
|
58785
|
+
attributes: toAttributes(node.data.hProperties, ['icon', isEmpty && 'empty', 'theme'].filter(Boolean)),
|
|
58749
58786
|
children: node.children,
|
|
58750
58787
|
});
|
|
58751
58788
|
});
|
|
@@ -90042,11 +90079,12 @@ function compilers() {
|
|
|
90042
90079
|
|
|
90043
90080
|
|
|
90044
90081
|
|
|
90045
|
-
const mdx_mdx = (tree, { hast = false, ...opts } = {}) => {
|
|
90082
|
+
const mdx_mdx = (tree, { hast = false, remarkTransformers = [], ...opts } = {}) => {
|
|
90046
90083
|
const processor = unified()
|
|
90047
90084
|
.use(hast ? rehypeRemark : undefined)
|
|
90048
90085
|
.use(remarkMdx)
|
|
90049
90086
|
.use(remarkGfm)
|
|
90087
|
+
.use(remarkTransformers)
|
|
90050
90088
|
.use(div)
|
|
90051
90089
|
.use(readme_to_mdx)
|
|
90052
90090
|
.use(tables_to_jsx)
|
|
@@ -90059,11 +90097,23 @@ const mdx_mdx = (tree, { hast = false, ...opts } = {}) => {
|
|
|
90059
90097
|
};
|
|
90060
90098
|
/* harmony default export */ const lib_mdx = (mdx_mdx);
|
|
90061
90099
|
|
|
90100
|
+
;// ./processor/transform/migrate-callouts.ts
|
|
90101
|
+
|
|
90102
|
+
|
|
90103
|
+
const migrateCallouts = () => (tree) => {
|
|
90104
|
+
visit(tree, 'rdme-callout', callout => {
|
|
90105
|
+
callout.children[0] = wrapHeading(callout);
|
|
90106
|
+
});
|
|
90107
|
+
return tree;
|
|
90108
|
+
};
|
|
90109
|
+
/* harmony default export */ const migrate_callouts = (migrateCallouts);
|
|
90110
|
+
|
|
90062
90111
|
;// ./lib/migrate.ts
|
|
90063
90112
|
|
|
90064
90113
|
|
|
90114
|
+
|
|
90065
90115
|
const migrate = (doc, { rdmd }) => {
|
|
90066
|
-
return (lib_mdx(lib_mdastV6(doc, { rdmd }))
|
|
90116
|
+
return (lib_mdx(lib_mdastV6(doc, { rdmd }), { remarkTransformers: [migrate_callouts] })
|
|
90067
90117
|
.replaceAll(/ /g, ' ')
|
|
90068
90118
|
// @note: I'm not sure what's happening, but I think mdx is converting an
|
|
90069
90119
|
// 'a' to 'a' as a means of escaping it. I think this helps with
|
package/dist/main.node.js
CHANGED
|
@@ -16315,11 +16315,11 @@ Anchor.defaultProps = {
|
|
|
16315
16315
|
|
|
16316
16316
|
|
|
16317
16317
|
const themes = {
|
|
16318
|
-
|
|
16319
|
-
|
|
16320
|
-
|
|
16321
|
-
|
|
16322
|
-
|
|
16318
|
+
error: 'error',
|
|
16319
|
+
default: 'default',
|
|
16320
|
+
info: 'info',
|
|
16321
|
+
okay: 'okay',
|
|
16322
|
+
warn: 'warn',
|
|
16323
16323
|
'\uD83D\uDCD8': 'info',
|
|
16324
16324
|
'\uD83D\uDEA7': 'warn',
|
|
16325
16325
|
'\u26A0\uFE0F': 'warn',
|
|
@@ -16340,17 +16340,18 @@ const defaultIcons = {
|
|
|
16340
16340
|
error: '\u2757\uFE0F',
|
|
16341
16341
|
};
|
|
16342
16342
|
const Callout = (props) => {
|
|
16343
|
-
const { attributes,
|
|
16343
|
+
const { attributes, theme = 'default', empty } = props;
|
|
16344
|
+
const children = external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.Children.toArray(props.children);
|
|
16344
16345
|
const icon = props.icon || defaultIcons[theme] || '❗';
|
|
16345
16346
|
const isEmoji = emoji_regex().test(icon);
|
|
16347
|
+
const heading = empty ? external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("p", { className: 'callout-heading empty' }) : children[0];
|
|
16346
16348
|
return (
|
|
16347
16349
|
// @ts-expect-error -- theme is not a valid attribute
|
|
16348
16350
|
// eslint-disable-next-line react/jsx-props-no-spreading, react/no-unknown-property
|
|
16349
16351
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("blockquote", { ...attributes, className: `callout callout_${theme}`, theme: icon },
|
|
16350
|
-
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("
|
|
16351
|
-
|
|
16352
|
-
|
|
16353
|
-
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.Children.toArray(children).slice(1)));
|
|
16352
|
+
isEmoji ? (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "callout-icon" }, icon)) : (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: `callout-icon callout-icon_fa ${icon}` })),
|
|
16353
|
+
heading,
|
|
16354
|
+
children.slice(1)));
|
|
16354
16355
|
};
|
|
16355
16356
|
/* harmony default export */ const components_Callout = (Callout);
|
|
16356
16357
|
|
|
@@ -57842,6 +57843,32 @@ var NodeTypes;
|
|
|
57842
57843
|
|
|
57843
57844
|
|
|
57844
57845
|
const callouts_regex = `^(${emoji_regex().source}|⚠)(\\s+|$)`;
|
|
57846
|
+
const findFirst = (node) => {
|
|
57847
|
+
if ('children' in node)
|
|
57848
|
+
return findFirst(node.children[0]);
|
|
57849
|
+
if (node.type === 'text')
|
|
57850
|
+
return node;
|
|
57851
|
+
return null;
|
|
57852
|
+
};
|
|
57853
|
+
const findLast = (node) => {
|
|
57854
|
+
if ('children' in node && Array.isArray(node.children))
|
|
57855
|
+
return findFirst(node.children[node.children.length - 1]);
|
|
57856
|
+
if (node.type === 'text')
|
|
57857
|
+
return node;
|
|
57858
|
+
return null;
|
|
57859
|
+
};
|
|
57860
|
+
const wrapHeading = (node) => {
|
|
57861
|
+
const firstChild = node.children[0];
|
|
57862
|
+
return {
|
|
57863
|
+
type: 'heading',
|
|
57864
|
+
depth: 3,
|
|
57865
|
+
children: ('children' in firstChild ? firstChild.children : []),
|
|
57866
|
+
position: {
|
|
57867
|
+
start: findFirst(firstChild).position.start,
|
|
57868
|
+
end: findLast(firstChild).position.end,
|
|
57869
|
+
},
|
|
57870
|
+
};
|
|
57871
|
+
};
|
|
57845
57872
|
const calloutTransformer = () => {
|
|
57846
57873
|
return (tree) => {
|
|
57847
57874
|
visit(tree, 'blockquote', (node) => {
|
|
@@ -57854,6 +57881,9 @@ const calloutTransformer = () => {
|
|
|
57854
57881
|
const empty = !heading.length && node.children[0].children.length === 1;
|
|
57855
57882
|
const theme = themes[icon] || 'default';
|
|
57856
57883
|
node.children[0].children[0].value = heading;
|
|
57884
|
+
if (heading) {
|
|
57885
|
+
node.children[0] = wrapHeading(node);
|
|
57886
|
+
}
|
|
57857
57887
|
Object.assign(node, {
|
|
57858
57888
|
type: NodeTypes.callout,
|
|
57859
57889
|
data: {
|
|
@@ -75648,14 +75678,21 @@ const readmeToMdx = () => tree => {
|
|
|
75648
75678
|
visit(tree, 'rdme-callout', (node, index, parent) => {
|
|
75649
75679
|
const isEmoji = emoji_regex().test(node.data.hProperties.icon);
|
|
75650
75680
|
const isEmpty = node.data.hProperties?.empty;
|
|
75681
|
+
const isH3 = node.children[0].type === 'heading' && node.children[0].depth === 3;
|
|
75651
75682
|
// return the usual markdown if there is an emoji and the icon theme matches our default theme
|
|
75652
|
-
if (isEmoji && themes[node.data.hProperties.icon] === node.data.hProperties.theme) {
|
|
75683
|
+
if ((isEmpty || isH3) && isEmoji && themes[node.data.hProperties.icon] === node.data.hProperties.theme) {
|
|
75684
|
+
if (isH3) {
|
|
75685
|
+
node.children[0] = {
|
|
75686
|
+
type: 'paragraph',
|
|
75687
|
+
children: 'children' in node.children[0] ? node.children[0].children : [],
|
|
75688
|
+
};
|
|
75689
|
+
}
|
|
75653
75690
|
return;
|
|
75654
75691
|
}
|
|
75655
75692
|
parent.children.splice(index, 1, {
|
|
75656
75693
|
type: 'mdxJsxFlowElement',
|
|
75657
75694
|
name: 'Callout',
|
|
75658
|
-
attributes: toAttributes(node.data.hProperties, ['icon',
|
|
75695
|
+
attributes: toAttributes(node.data.hProperties, ['icon', isEmpty && 'empty', 'theme'].filter(Boolean)),
|
|
75659
75696
|
children: node.children,
|
|
75660
75697
|
});
|
|
75661
75698
|
});
|
|
@@ -106952,11 +106989,12 @@ function compilers() {
|
|
|
106952
106989
|
|
|
106953
106990
|
|
|
106954
106991
|
|
|
106955
|
-
const mdx_mdx = (tree, { hast = false, ...opts } = {}) => {
|
|
106992
|
+
const mdx_mdx = (tree, { hast = false, remarkTransformers = [], ...opts } = {}) => {
|
|
106956
106993
|
const processor = unified()
|
|
106957
106994
|
.use(hast ? rehypeRemark : undefined)
|
|
106958
106995
|
.use(remarkMdx)
|
|
106959
106996
|
.use(remarkGfm)
|
|
106997
|
+
.use(remarkTransformers)
|
|
106960
106998
|
.use(transform_div)
|
|
106961
106999
|
.use(readme_to_mdx)
|
|
106962
107000
|
.use(tables_to_jsx)
|
|
@@ -106969,11 +107007,23 @@ const mdx_mdx = (tree, { hast = false, ...opts } = {}) => {
|
|
|
106969
107007
|
};
|
|
106970
107008
|
/* harmony default export */ const lib_mdx = (mdx_mdx);
|
|
106971
107009
|
|
|
107010
|
+
;// ./processor/transform/migrate-callouts.ts
|
|
107011
|
+
|
|
107012
|
+
|
|
107013
|
+
const migrateCallouts = () => (tree) => {
|
|
107014
|
+
visit(tree, 'rdme-callout', callout => {
|
|
107015
|
+
callout.children[0] = wrapHeading(callout);
|
|
107016
|
+
});
|
|
107017
|
+
return tree;
|
|
107018
|
+
};
|
|
107019
|
+
/* harmony default export */ const migrate_callouts = (migrateCallouts);
|
|
107020
|
+
|
|
106972
107021
|
;// ./lib/migrate.ts
|
|
106973
107022
|
|
|
106974
107023
|
|
|
107024
|
+
|
|
106975
107025
|
const migrate = (doc, { rdmd }) => {
|
|
106976
|
-
return (lib_mdx(lib_mdastV6(doc, { rdmd }))
|
|
107026
|
+
return (lib_mdx(lib_mdastV6(doc, { rdmd }), { remarkTransformers: [migrate_callouts] })
|
|
106977
107027
|
.replaceAll(/ /g, ' ')
|
|
106978
107028
|
// @note: I'm not sure what's happening, but I think mdx is converting an
|
|
106979
107029
|
// 'a' to 'a' as a means of escaping it. I think this helps with
|