@readme/markdown 8.3.0 → 8.4.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/components/TailwindRoot/index.tsx +3 -1
- package/dist/example/components.d.ts +1 -0
- package/dist/lib/compile.d.ts +2 -1
- package/dist/main.js +18 -10
- package/dist/main.node.js +18 -10
- package/dist/main.node.js.map +1 -1
- package/dist/processor/plugin/toc.d.ts +2 -2
- package/dist/processor/transform/tailwind.d.ts +1 -0
- package/dist/utils/consts.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
+
import { tailwindPrefix } from '../../utils/consts';
|
|
4
|
+
|
|
3
5
|
interface Props extends React.PropsWithChildren<{ flow: boolean }> {}
|
|
4
6
|
|
|
5
7
|
const TailwindRoot = ({ children, flow }: Props) => {
|
|
6
8
|
const Tag = flow ? 'div' : 'span';
|
|
7
9
|
|
|
8
|
-
return <Tag className=
|
|
10
|
+
return <Tag className={tailwindPrefix}>{children}</Tag>;
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
export default TailwindRoot;
|
package/dist/lib/compile.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type CompileOpts = CompileOptions & {
|
|
|
3
3
|
components?: Record<string, string>;
|
|
4
4
|
copyButtons?: boolean;
|
|
5
5
|
useTailwind?: boolean;
|
|
6
|
+
useTailwindRoot?: boolean;
|
|
6
7
|
};
|
|
7
|
-
declare const compile: (text: string, { components, copyButtons, useTailwind, ...opts }?: CompileOpts) => Promise<string>;
|
|
8
|
+
declare const compile: (text: string, { components, copyButtons, useTailwind, useTailwindRoot, ...opts }?: CompileOpts) => Promise<string>;
|
|
8
9
|
export default compile;
|
package/dist/main.js
CHANGED
|
@@ -18590,11 +18590,15 @@ function TableOfContents({ children }) {
|
|
|
18590
18590
|
}
|
|
18591
18591
|
/* harmony default export */ const components_TableOfContents = (TableOfContents);
|
|
18592
18592
|
|
|
18593
|
+
;// ./utils/consts.ts
|
|
18594
|
+
const tailwindPrefix = 'readme-tailwind';
|
|
18595
|
+
|
|
18593
18596
|
;// ./components/TailwindRoot/index.tsx
|
|
18594
18597
|
|
|
18598
|
+
|
|
18595
18599
|
const TailwindRoot = ({ children, flow }) => {
|
|
18596
18600
|
const Tag = flow ? 'div' : 'span';
|
|
18597
|
-
return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Tag, { className:
|
|
18601
|
+
return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Tag, { className: tailwindPrefix }, children);
|
|
18598
18602
|
};
|
|
18599
18603
|
/* harmony default export */ const components_TailwindRoot = (TailwindRoot);
|
|
18600
18604
|
|
|
@@ -71623,10 +71627,12 @@ async function tailwindBundle(string, { prefix }) {
|
|
|
71623
71627
|
|
|
71624
71628
|
|
|
71625
71629
|
|
|
71626
|
-
|
|
71630
|
+
|
|
71631
|
+
const exportTailwindStylesheet = async (tree, vfile, { components, parseRoot }) => {
|
|
71627
71632
|
if (hasNamedExport(tree, 'stylesheet'))
|
|
71628
71633
|
return;
|
|
71629
|
-
const
|
|
71634
|
+
const stringToParse = [...Object.values(components), parseRoot ? String(vfile) : ''].join('\n\n');
|
|
71635
|
+
const stylesheet = (await tailwind_bundle(stringToParse, { prefix: `.${tailwindPrefix}` })).css;
|
|
71630
71636
|
const exportNode = {
|
|
71631
71637
|
type: 'mdxjsEsm',
|
|
71632
71638
|
value: '',
|
|
@@ -71677,13 +71683,13 @@ const injectTailwindRoot = ({ components = {} }) => (node, index, parent) => {
|
|
|
71677
71683
|
// eslint-disable-next-line consistent-return
|
|
71678
71684
|
return SKIP;
|
|
71679
71685
|
};
|
|
71680
|
-
const tailwind = ({ components }) => async (tree, vfile) => {
|
|
71686
|
+
const tailwind = ({ components, parseRoot }) => async (tree, vfile) => {
|
|
71681
71687
|
const localComponents = getExports(tree).reduce((acc, name) => {
|
|
71682
71688
|
acc[name] = String(vfile);
|
|
71683
71689
|
return acc;
|
|
71684
71690
|
}, {});
|
|
71685
71691
|
visit(tree, isMDXElement, injectTailwindRoot({ components: { ...components, ...localComponents } }));
|
|
71686
|
-
await exportTailwindStylesheet(tree, { ...components, ...localComponents });
|
|
71692
|
+
await exportTailwindStylesheet(tree, vfile, { components: { ...components, ...localComponents }, parseRoot });
|
|
71687
71693
|
return tree;
|
|
71688
71694
|
};
|
|
71689
71695
|
/* harmony default export */ const transform_tailwind = (tailwind);
|
|
@@ -83687,10 +83693,10 @@ const tocToHast = (headings = []) => {
|
|
|
83687
83693
|
});
|
|
83688
83694
|
return ast;
|
|
83689
83695
|
};
|
|
83690
|
-
const
|
|
83696
|
+
const tocHastToMdx = (toc, components) => {
|
|
83691
83697
|
const tree = { type: 'root', children: toc };
|
|
83692
83698
|
visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {
|
|
83693
|
-
const subToc = components[node.name]
|
|
83699
|
+
const subToc = components[node.name] || [];
|
|
83694
83700
|
parent.children.splice(index, 1, ...subToc);
|
|
83695
83701
|
});
|
|
83696
83702
|
const tocHast = tocToHast(tree.children);
|
|
@@ -83709,7 +83715,7 @@ const tocToMdx = (toc, components) => {
|
|
|
83709
83715
|
|
|
83710
83716
|
|
|
83711
83717
|
const { codeTabsTransformer: compile_codeTabsTransformer, ...transforms } = defaultTransforms;
|
|
83712
|
-
const compile_compile = async (text, { components = {}, copyButtons, useTailwind, ...opts } = {}) => {
|
|
83718
|
+
const compile_compile = async (text, { components = {}, copyButtons, useTailwind, useTailwindRoot, ...opts } = {}) => {
|
|
83713
83719
|
const remarkPlugins = [
|
|
83714
83720
|
remarkFrontmatter,
|
|
83715
83721
|
remarkGfm,
|
|
@@ -83717,7 +83723,7 @@ const compile_compile = async (text, { components = {}, copyButtons, useTailwind
|
|
|
83717
83723
|
[compile_codeTabsTransformer, { copyButtons }],
|
|
83718
83724
|
];
|
|
83719
83725
|
if (useTailwind) {
|
|
83720
|
-
remarkPlugins.push([transform_tailwind, { components }]);
|
|
83726
|
+
remarkPlugins.push([transform_tailwind, { components, parseRoot: useTailwindRoot }]);
|
|
83721
83727
|
}
|
|
83722
83728
|
try {
|
|
83723
83729
|
const vfile = await compile(text, {
|
|
@@ -88856,10 +88862,12 @@ const makeUseMDXComponents = (more = {}) => {
|
|
|
88856
88862
|
const run_run = async (string, _opts = {}) => {
|
|
88857
88863
|
const { Fragment } = jsx_runtime_namespaceObject;
|
|
88858
88864
|
const { components = {}, terms, variables, baseUrl, imports = {}, ...opts } = _opts;
|
|
88865
|
+
const tocsByTag = {};
|
|
88859
88866
|
const exportedComponents = Object.entries(components).reduce((memo, [tag, mod]) => {
|
|
88860
88867
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
88861
88868
|
const { default: Content, toc, Toc, stylesheets, ...rest } = mod;
|
|
88862
88869
|
memo[tag] = Content;
|
|
88870
|
+
tocsByTag[tag] = toc;
|
|
88863
88871
|
if (rest) {
|
|
88864
88872
|
Object.entries(rest).forEach(([subTag, component]) => {
|
|
88865
88873
|
memo[subTag] = component;
|
|
@@ -88880,7 +88888,7 @@ const run_run = async (string, _opts = {}) => {
|
|
|
88880
88888
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
88881
88889
|
const { Toc: _Toc, toc, default: Content, stylesheet, ...exports } = await exec(string);
|
|
88882
88890
|
let Toc;
|
|
88883
|
-
const tocMdx =
|
|
88891
|
+
const tocMdx = tocHastToMdx(toc, tocsByTag);
|
|
88884
88892
|
if (tocMdx) {
|
|
88885
88893
|
const compiledToc = await lib_compile(tocMdx);
|
|
88886
88894
|
const tocModule = await exec(compiledToc, { useMDXComponents: () => ({ p: Fragment }) });
|
package/dist/main.node.js
CHANGED
|
@@ -21609,11 +21609,15 @@ function TableOfContents({ children }) {
|
|
|
21609
21609
|
}
|
|
21610
21610
|
/* harmony default export */ const components_TableOfContents = (TableOfContents);
|
|
21611
21611
|
|
|
21612
|
+
;// ./utils/consts.ts
|
|
21613
|
+
const tailwindPrefix = 'readme-tailwind';
|
|
21614
|
+
|
|
21612
21615
|
;// ./components/TailwindRoot/index.tsx
|
|
21613
21616
|
|
|
21617
|
+
|
|
21614
21618
|
const TailwindRoot = ({ children, flow }) => {
|
|
21615
21619
|
const Tag = flow ? 'div' : 'span';
|
|
21616
|
-
return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Tag, { className:
|
|
21620
|
+
return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Tag, { className: tailwindPrefix }, children);
|
|
21617
21621
|
};
|
|
21618
21622
|
/* harmony default export */ const components_TailwindRoot = (TailwindRoot);
|
|
21619
21623
|
|
|
@@ -76205,10 +76209,12 @@ async function tailwindBundle(string, { prefix }) {
|
|
|
76205
76209
|
|
|
76206
76210
|
|
|
76207
76211
|
|
|
76208
|
-
|
|
76212
|
+
|
|
76213
|
+
const exportTailwindStylesheet = async (tree, vfile, { components, parseRoot }) => {
|
|
76209
76214
|
if (hasNamedExport(tree, 'stylesheet'))
|
|
76210
76215
|
return;
|
|
76211
|
-
const
|
|
76216
|
+
const stringToParse = [...Object.values(components), parseRoot ? String(vfile) : ''].join('\n\n');
|
|
76217
|
+
const stylesheet = (await tailwind_bundle(stringToParse, { prefix: `.${tailwindPrefix}` })).css;
|
|
76212
76218
|
const exportNode = {
|
|
76213
76219
|
type: 'mdxjsEsm',
|
|
76214
76220
|
value: '',
|
|
@@ -76259,13 +76265,13 @@ const injectTailwindRoot = ({ components = {} }) => (node, index, parent) => {
|
|
|
76259
76265
|
// eslint-disable-next-line consistent-return
|
|
76260
76266
|
return SKIP;
|
|
76261
76267
|
};
|
|
76262
|
-
const tailwind = ({ components }) => async (tree, vfile) => {
|
|
76268
|
+
const tailwind = ({ components, parseRoot }) => async (tree, vfile) => {
|
|
76263
76269
|
const localComponents = getExports(tree).reduce((acc, name) => {
|
|
76264
76270
|
acc[name] = String(vfile);
|
|
76265
76271
|
return acc;
|
|
76266
76272
|
}, {});
|
|
76267
76273
|
visit(tree, isMDXElement, injectTailwindRoot({ components: { ...components, ...localComponents } }));
|
|
76268
|
-
await exportTailwindStylesheet(tree, { ...components, ...localComponents });
|
|
76274
|
+
await exportTailwindStylesheet(tree, vfile, { components: { ...components, ...localComponents }, parseRoot });
|
|
76269
76275
|
return tree;
|
|
76270
76276
|
};
|
|
76271
76277
|
/* harmony default export */ const transform_tailwind = (tailwind);
|
|
@@ -88269,10 +88275,10 @@ const tocToHast = (headings = []) => {
|
|
|
88269
88275
|
});
|
|
88270
88276
|
return ast;
|
|
88271
88277
|
};
|
|
88272
|
-
const
|
|
88278
|
+
const tocHastToMdx = (toc, components) => {
|
|
88273
88279
|
const tree = { type: 'root', children: toc };
|
|
88274
88280
|
visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {
|
|
88275
|
-
const subToc = components[node.name]
|
|
88281
|
+
const subToc = components[node.name] || [];
|
|
88276
88282
|
parent.children.splice(index, 1, ...subToc);
|
|
88277
88283
|
});
|
|
88278
88284
|
const tocHast = tocToHast(tree.children);
|
|
@@ -88291,7 +88297,7 @@ const tocToMdx = (toc, components) => {
|
|
|
88291
88297
|
|
|
88292
88298
|
|
|
88293
88299
|
const { codeTabsTransformer: compile_codeTabsTransformer, ...transforms } = defaultTransforms;
|
|
88294
|
-
const compile_compile = async (text, { components = {}, copyButtons, useTailwind, ...opts } = {}) => {
|
|
88300
|
+
const compile_compile = async (text, { components = {}, copyButtons, useTailwind, useTailwindRoot, ...opts } = {}) => {
|
|
88295
88301
|
const remarkPlugins = [
|
|
88296
88302
|
remarkFrontmatter,
|
|
88297
88303
|
remarkGfm,
|
|
@@ -88299,7 +88305,7 @@ const compile_compile = async (text, { components = {}, copyButtons, useTailwind
|
|
|
88299
88305
|
[compile_codeTabsTransformer, { copyButtons }],
|
|
88300
88306
|
];
|
|
88301
88307
|
if (useTailwind) {
|
|
88302
|
-
remarkPlugins.push([transform_tailwind, { components }]);
|
|
88308
|
+
remarkPlugins.push([transform_tailwind, { components, parseRoot: useTailwindRoot }]);
|
|
88303
88309
|
}
|
|
88304
88310
|
try {
|
|
88305
88311
|
const vfile = await compile(text, {
|
|
@@ -93438,10 +93444,12 @@ const makeUseMDXComponents = (more = {}) => {
|
|
|
93438
93444
|
const run_run = async (string, _opts = {}) => {
|
|
93439
93445
|
const { Fragment } = jsx_runtime_namespaceObject;
|
|
93440
93446
|
const { components = {}, terms, variables, baseUrl, imports = {}, ...opts } = _opts;
|
|
93447
|
+
const tocsByTag = {};
|
|
93441
93448
|
const exportedComponents = Object.entries(components).reduce((memo, [tag, mod]) => {
|
|
93442
93449
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
93443
93450
|
const { default: Content, toc, Toc, stylesheets, ...rest } = mod;
|
|
93444
93451
|
memo[tag] = Content;
|
|
93452
|
+
tocsByTag[tag] = toc;
|
|
93445
93453
|
if (rest) {
|
|
93446
93454
|
Object.entries(rest).forEach(([subTag, component]) => {
|
|
93447
93455
|
memo[subTag] = component;
|
|
@@ -93462,7 +93470,7 @@ const run_run = async (string, _opts = {}) => {
|
|
|
93462
93470
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
93463
93471
|
const { Toc: _Toc, toc, default: Content, stylesheet, ...exports } = await exec(string);
|
|
93464
93472
|
let Toc;
|
|
93465
|
-
const tocMdx =
|
|
93473
|
+
const tocMdx = tocHastToMdx(toc, tocsByTag);
|
|
93466
93474
|
if (tocMdx) {
|
|
93467
93475
|
const compiledToc = await lib_compile(tocMdx);
|
|
93468
93476
|
const tocModule = await exec(compiledToc, { useMDXComponents: () => ({ p: Fragment }) });
|