@readme/markdown 9.0.6 → 9.1.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/Callout/index.tsx +12 -5
- package/components/Cards/index.tsx +1 -1
- package/components/Cards/style.scss +23 -9
- package/components/Code/index.tsx +5 -2
- package/components/CodeTabs/index.tsx +6 -3
- package/dist/components/Callout/index.d.ts +9 -2
- package/dist/components/CodeTabs/index.d.ts +0 -1
- package/dist/contexts/Theme.d.ts +2 -0
- package/dist/contexts/index.d.ts +3 -3
- package/dist/lib/ast-processor.d.ts +1 -0
- package/dist/lib/compile.d.ts +2 -1
- package/dist/lib/run.d.ts +4 -0
- package/dist/lib/utils/makeUseMdxComponents.d.ts +3 -0
- package/dist/main.css +1 -1
- package/dist/main.css.map +1 -1
- package/dist/main.js +129 -41
- package/dist/main.node.js +129 -41
- package/dist/main.node.js.map +1 -1
- package/dist/processor/transform/handle-missing-components.d.ts +6 -0
- package/dist/processor/transform/index.d.ts +2 -1
- package/package.json +1 -1
- package/styles/mixins/dark-mode.scss +47 -0
- package/dist/processor/compile/variable.d.ts +0 -3
package/dist/main.js
CHANGED
|
@@ -18217,9 +18217,15 @@ const themes = {
|
|
|
18217
18217
|
'\u2139\uFE0F': 'info',
|
|
18218
18218
|
'\u26A0': 'warn',
|
|
18219
18219
|
};
|
|
18220
|
+
const defaultIcons = {
|
|
18221
|
+
info: '\uD83D\uDCD8',
|
|
18222
|
+
warn: '\uD83D\uDEA7',
|
|
18223
|
+
okay: '\uD83D\uDC4D',
|
|
18224
|
+
error: '\u2757\uFE0F',
|
|
18225
|
+
};
|
|
18220
18226
|
const Callout = (props) => {
|
|
18221
|
-
const { attributes, children,
|
|
18222
|
-
const
|
|
18227
|
+
const { attributes, children, theme, empty } = props;
|
|
18228
|
+
const icon = props.icon || defaultIcons[theme] || '❗';
|
|
18223
18229
|
return (
|
|
18224
18230
|
// @ts-expect-error -- theme is not a valid attribute
|
|
18225
18231
|
// eslint-disable-next-line react/jsx-props-no-spreading, react/no-unknown-property
|
|
@@ -18237,7 +18243,7 @@ const Callout = (props) => {
|
|
|
18237
18243
|
const Card = ({ children, href, icon, iconColor, target, title }) => {
|
|
18238
18244
|
const Tag = href ? 'a' : 'div';
|
|
18239
18245
|
return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Tag, { className: "Card", href: href, target: target },
|
|
18240
|
-
icon && external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("i", { className: `Card-icon fa-duotone fa-solid ${icon}`, style: { color:
|
|
18246
|
+
icon && external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("i", { className: `Card-icon fa-duotone fa-solid ${icon}`, style: { '--Card-icon-color': iconColor } }),
|
|
18241
18247
|
title && external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("p", { className: "Card-title" }, title),
|
|
18242
18248
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "Card-content" }, children)));
|
|
18243
18249
|
};
|
|
@@ -18251,9 +18257,15 @@ const CardsGrid = ({ columns = 2, children }) => {
|
|
|
18251
18257
|
// EXTERNAL MODULE: ./node_modules/copy-to-clipboard/index.js
|
|
18252
18258
|
var copy_to_clipboard = __webpack_require__(7965);
|
|
18253
18259
|
var copy_to_clipboard_default = /*#__PURE__*/__webpack_require__.n(copy_to_clipboard);
|
|
18260
|
+
;// ./contexts/Theme.ts
|
|
18261
|
+
|
|
18262
|
+
const ThemeContext = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createContext)('light');
|
|
18263
|
+
/* harmony default export */ const Theme = (ThemeContext);
|
|
18264
|
+
|
|
18254
18265
|
;// ./components/Code/index.tsx
|
|
18255
18266
|
|
|
18256
18267
|
|
|
18268
|
+
|
|
18257
18269
|
// Only load CodeMirror in the browser, for SSR
|
|
18258
18270
|
// apps. Necessary because of people like this:
|
|
18259
18271
|
// https://github.com/codemirror/CodeMirror/issues/3701#issuecomment-164904534
|
|
@@ -18280,7 +18292,8 @@ function CopyCode({ codeRef, rootClass = 'rdmd-code-copy', className = '', }) {
|
|
|
18280
18292
|
return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("button", { ref: buttonRef, "aria-label": "Copy Code", className: `${rootClass} ${className}`, onClick: copier });
|
|
18281
18293
|
}
|
|
18282
18294
|
const Code = (props) => {
|
|
18283
|
-
const { children, copyButtons, lang,
|
|
18295
|
+
const { children, copyButtons, lang, value } = props;
|
|
18296
|
+
const theme = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useContext)(Theme);
|
|
18284
18297
|
const language = canonicalLanguage(lang);
|
|
18285
18298
|
const codeRef = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createRef)();
|
|
18286
18299
|
const codeOpts = {
|
|
@@ -18304,9 +18317,11 @@ var dist = __webpack_require__(4668);
|
|
|
18304
18317
|
;// ./components/CodeTabs/index.tsx
|
|
18305
18318
|
|
|
18306
18319
|
|
|
18320
|
+
|
|
18307
18321
|
let mermaid;
|
|
18308
18322
|
const CodeTabs = (props) => {
|
|
18309
|
-
const { children
|
|
18323
|
+
const { children } = props;
|
|
18324
|
+
const theme = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useContext)(Theme);
|
|
18310
18325
|
// render Mermaid diagram
|
|
18311
18326
|
(0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useEffect)(() => {
|
|
18312
18327
|
if (typeof window !== 'undefined') {
|
|
@@ -53166,6 +53181,7 @@ var NodeTypes;
|
|
|
53166
53181
|
|
|
53167
53182
|
|
|
53168
53183
|
|
|
53184
|
+
|
|
53169
53185
|
const callouts_regex = `^(${emoji_regex().source}|⚠)(\\s+|$)`;
|
|
53170
53186
|
const calloutTransformer = () => {
|
|
53171
53187
|
return (tree) => {
|
|
@@ -53177,6 +53193,7 @@ const calloutTransformer = () => {
|
|
|
53177
53193
|
if (icon && match) {
|
|
53178
53194
|
const heading = startText.slice(match.length);
|
|
53179
53195
|
const empty = !heading.length && node.children[0].children.length === 1;
|
|
53196
|
+
const theme = themes[icon] || 'default';
|
|
53180
53197
|
node.children[0].children[0].value = heading;
|
|
53181
53198
|
Object.assign(node, {
|
|
53182
53199
|
type: NodeTypes.callout,
|
|
@@ -53185,6 +53202,7 @@ const calloutTransformer = () => {
|
|
|
53185
53202
|
hProperties: {
|
|
53186
53203
|
icon,
|
|
53187
53204
|
empty,
|
|
53205
|
+
theme,
|
|
53188
53206
|
},
|
|
53189
53207
|
},
|
|
53190
53208
|
});
|
|
@@ -70596,6 +70614,28 @@ const getExports = (tree) => {
|
|
|
70596
70614
|
return Array.from(set);
|
|
70597
70615
|
};
|
|
70598
70616
|
|
|
70617
|
+
;// ./processor/transform/handle-missing-components.ts
|
|
70618
|
+
|
|
70619
|
+
|
|
70620
|
+
|
|
70621
|
+
const handleMissingComponents = ({ components, missingComponents }) => tree => {
|
|
70622
|
+
const allComponents = new Set([
|
|
70623
|
+
...getExports(tree),
|
|
70624
|
+
...Object.keys(components_namespaceObject),
|
|
70625
|
+
...Object.keys(components),
|
|
70626
|
+
'Variable',
|
|
70627
|
+
]);
|
|
70628
|
+
visit(tree, isMDXElement, (node, index, parent) => {
|
|
70629
|
+
if (allComponents.has(node.name) || node.name.match(/^[a-z]/))
|
|
70630
|
+
return;
|
|
70631
|
+
if (missingComponents === 'throw') {
|
|
70632
|
+
throw new Error(`Expected component \`${node.name}\` to be defined: you likely forgot to import, pass, or provide it.`);
|
|
70633
|
+
}
|
|
70634
|
+
parent.children.splice(index, 1);
|
|
70635
|
+
}, true);
|
|
70636
|
+
};
|
|
70637
|
+
/* harmony default export */ const handle_missing_components = (handleMissingComponents);
|
|
70638
|
+
|
|
70599
70639
|
;// ./processor/transform/images.ts
|
|
70600
70640
|
|
|
70601
70641
|
|
|
@@ -70706,6 +70746,7 @@ const mermaidTransformer = () => (tree) => {
|
|
|
70706
70746
|
|
|
70707
70747
|
|
|
70708
70748
|
|
|
70749
|
+
|
|
70709
70750
|
const readme_components_types = {
|
|
70710
70751
|
Callout: NodeTypes.callout,
|
|
70711
70752
|
Code: 'code',
|
|
@@ -70822,13 +70863,15 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
|
|
|
70822
70863
|
return SKIP;
|
|
70823
70864
|
}
|
|
70824
70865
|
else if (node.name === 'Callout') {
|
|
70866
|
+
const attrs = getAttrs(node);
|
|
70825
70867
|
const { icon, empty = false } = getAttrs(node);
|
|
70868
|
+
const theme = attrs.theme || themes[icon] || 'default';
|
|
70826
70869
|
const mdNode = {
|
|
70827
70870
|
children: node.children,
|
|
70828
70871
|
type: NodeTypes.callout,
|
|
70829
70872
|
data: {
|
|
70830
70873
|
hName: node.name,
|
|
70831
|
-
hProperties: { icon, empty },
|
|
70874
|
+
hProperties: { icon, empty, theme },
|
|
70832
70875
|
},
|
|
70833
70876
|
position: node.position,
|
|
70834
70877
|
};
|
|
@@ -70962,6 +71005,42 @@ const readmeToMdx = () => tree => {
|
|
|
70962
71005
|
},
|
|
70963
71006
|
});
|
|
70964
71007
|
});
|
|
71008
|
+
const isVariable = (node) => 'type' in node && node.type === NodeTypes.variable;
|
|
71009
|
+
visit(tree, isVariable, (node, index, parent) => {
|
|
71010
|
+
const identifier = (node.data.hProperties.variable || node.data.hProperties.name).toString();
|
|
71011
|
+
const validIdentifier = identifier.match(/^(\p{Letter}|[$_])(\p{Letter}|[$_0-9])*$/u);
|
|
71012
|
+
const value = validIdentifier ? `user.${identifier}` : `user[${JSON.stringify(identifier)}]`;
|
|
71013
|
+
const mdxFlowExpression = {
|
|
71014
|
+
type: 'mdxFlowExpression',
|
|
71015
|
+
value,
|
|
71016
|
+
data: {
|
|
71017
|
+
estree: {
|
|
71018
|
+
type: 'Program',
|
|
71019
|
+
body: [
|
|
71020
|
+
{
|
|
71021
|
+
type: 'ExpressionStatement',
|
|
71022
|
+
expression: {
|
|
71023
|
+
type: 'MemberExpression',
|
|
71024
|
+
object: {
|
|
71025
|
+
type: 'Identifier',
|
|
71026
|
+
name: 'user',
|
|
71027
|
+
},
|
|
71028
|
+
property: {
|
|
71029
|
+
type: 'Identifier',
|
|
71030
|
+
name: identifier,
|
|
71031
|
+
},
|
|
71032
|
+
computed: false,
|
|
71033
|
+
optional: false,
|
|
71034
|
+
},
|
|
71035
|
+
},
|
|
71036
|
+
],
|
|
71037
|
+
sourceType: 'module',
|
|
71038
|
+
comments: [],
|
|
71039
|
+
},
|
|
71040
|
+
},
|
|
71041
|
+
};
|
|
71042
|
+
parent.children.splice(index, 1, mdxFlowExpression);
|
|
71043
|
+
});
|
|
70965
71044
|
return tree;
|
|
70966
71045
|
};
|
|
70967
71046
|
/* harmony default export */ const readme_to_mdx = (readmeToMdx);
|
|
@@ -71178,6 +71257,7 @@ const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
|
71178
71257
|
|
|
71179
71258
|
|
|
71180
71259
|
|
|
71260
|
+
|
|
71181
71261
|
const defaultTransforms = {
|
|
71182
71262
|
calloutTransformer: callouts,
|
|
71183
71263
|
codeTabsTransformer: code_tabs,
|
|
@@ -71196,12 +71276,22 @@ const defaultTransforms = {
|
|
|
71196
71276
|
|
|
71197
71277
|
const remarkPlugins = [remarkFrontmatter, remarkGfm, ...transform];
|
|
71198
71278
|
const rehypePlugins = [rehypeSlug, transform_mermaid];
|
|
71199
|
-
const astProcessor = (opts = {
|
|
71200
|
-
.
|
|
71201
|
-
|
|
71202
|
-
|
|
71203
|
-
|
|
71204
|
-
|
|
71279
|
+
const astProcessor = (opts = {}) => {
|
|
71280
|
+
const components = opts.components || {};
|
|
71281
|
+
let processor = remark()
|
|
71282
|
+
.use(remarkMdx)
|
|
71283
|
+
.use(remarkPlugins)
|
|
71284
|
+
.use(opts.remarkPlugins)
|
|
71285
|
+
.use(transform_variables, { asMdx: false })
|
|
71286
|
+
.use(readme_components({ components }));
|
|
71287
|
+
if (['ignore', 'throw'].includes(opts.missingComponents)) {
|
|
71288
|
+
processor = processor.use(handle_missing_components, {
|
|
71289
|
+
components,
|
|
71290
|
+
missingComponents: opts.missingComponents,
|
|
71291
|
+
});
|
|
71292
|
+
}
|
|
71293
|
+
return processor;
|
|
71294
|
+
};
|
|
71205
71295
|
/* harmony default export */ const ast_processor = (astProcessor);
|
|
71206
71296
|
|
|
71207
71297
|
;// ./node_modules/markdown-extensions/index.js
|
|
@@ -83752,12 +83842,16 @@ const tocHastToMdx = (toc, components) => {
|
|
|
83752
83842
|
|
|
83753
83843
|
|
|
83754
83844
|
const { codeTabsTransformer: compile_codeTabsTransformer, ...transforms } = defaultTransforms;
|
|
83755
|
-
const compile_compile = async (text, { components = {}, copyButtons, useTailwind, ...opts } = {}) => {
|
|
83845
|
+
const compile_compile = async (text, { components = {}, missingComponents, copyButtons, useTailwind, ...opts } = {}) => {
|
|
83756
83846
|
const remarkPlugins = [
|
|
83757
83847
|
remarkFrontmatter,
|
|
83758
83848
|
remarkGfm,
|
|
83759
83849
|
...Object.values(transforms),
|
|
83760
83850
|
[compile_codeTabsTransformer, { copyButtons }],
|
|
83851
|
+
[
|
|
83852
|
+
handle_missing_components,
|
|
83853
|
+
{ components, missingComponents: ['ignore', 'throw'].includes(missingComponents) ? missingComponents : 'ignore' },
|
|
83854
|
+
],
|
|
83761
83855
|
];
|
|
83762
83856
|
if (useTailwind) {
|
|
83763
83857
|
remarkPlugins.push([transform_tailwind, { components }]);
|
|
@@ -88633,15 +88727,6 @@ ${reformatHTML(html)}
|
|
|
88633
88727
|
};
|
|
88634
88728
|
/* harmony default export */ const html_block = (htmlBlock);
|
|
88635
88729
|
|
|
88636
|
-
;// ./processor/compile/variable.ts
|
|
88637
|
-
const variable = (node) => {
|
|
88638
|
-
// @note: coming from RDMD, it's set as `variable`. But when mdx is parsed,
|
|
88639
|
-
// it's set as `name`
|
|
88640
|
-
const name = node.data.hProperties.variable || node.data.hProperties.name;
|
|
88641
|
-
return name.toString().match(/ /) ? `{user[${JSON.stringify(name)}]}` : `{user.${name}}`;
|
|
88642
|
-
};
|
|
88643
|
-
/* harmony default export */ const compile_variable = (variable);
|
|
88644
|
-
|
|
88645
88730
|
;// ./processor/compile/index.ts
|
|
88646
88731
|
|
|
88647
88732
|
|
|
@@ -88650,7 +88735,6 @@ const variable = (node) => {
|
|
|
88650
88735
|
|
|
88651
88736
|
|
|
88652
88737
|
|
|
88653
|
-
|
|
88654
88738
|
function compilers() {
|
|
88655
88739
|
const data = this.data();
|
|
88656
88740
|
const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
@@ -88662,7 +88746,6 @@ function compilers() {
|
|
|
88662
88746
|
[NodeTypes.glossary]: compile_compatibility,
|
|
88663
88747
|
[NodeTypes.htmlBlock]: html_block,
|
|
88664
88748
|
[NodeTypes.reusableContent]: compile_compatibility,
|
|
88665
|
-
[NodeTypes.variable]: compile_variable,
|
|
88666
88749
|
embed: compile_compatibility,
|
|
88667
88750
|
escape: compile_compatibility,
|
|
88668
88751
|
figure: compile_compatibility,
|
|
@@ -99121,24 +99204,25 @@ function runSync(code, options) {
|
|
|
99121
99204
|
return new Function(String(code))(options)
|
|
99122
99205
|
}
|
|
99123
99206
|
|
|
99124
|
-
// EXTERNAL MODULE: external "@readme/variable"
|
|
99125
|
-
var variable_ = __webpack_require__(8167);
|
|
99126
|
-
var variable_default = /*#__PURE__*/__webpack_require__.n(variable_);
|
|
99127
99207
|
// EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js
|
|
99128
99208
|
var jsx_runtime = __webpack_require__(4848);
|
|
99129
99209
|
var jsx_runtime_namespaceObject = /*#__PURE__*/__webpack_require__.t(jsx_runtime, 2);
|
|
99210
|
+
// EXTERNAL MODULE: external "@readme/variable"
|
|
99211
|
+
var variable_ = __webpack_require__(8167);
|
|
99212
|
+
var variable_default = /*#__PURE__*/__webpack_require__.n(variable_);
|
|
99130
99213
|
;// ./contexts/index.tsx
|
|
99131
99214
|
|
|
99132
99215
|
|
|
99133
99216
|
|
|
99134
99217
|
|
|
99218
|
+
|
|
99135
99219
|
const compose = (children, ...contexts) => {
|
|
99136
99220
|
return contexts.reduce((content, [Context, value]) => {
|
|
99137
99221
|
return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Context.Provider, { value: value }, content);
|
|
99138
99222
|
}, children);
|
|
99139
99223
|
};
|
|
99140
|
-
const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }, baseUrl = '/' }) => {
|
|
99141
|
-
return compose(children, [GlossaryTerms, terms], [variable_.VariablesContext, variables], [BaseUrl, baseUrl]);
|
|
99224
|
+
const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }, baseUrl = '/', theme }) => {
|
|
99225
|
+
return compose(children, [GlossaryTerms, terms], [variable_.VariablesContext, variables], [BaseUrl, baseUrl], [Theme, theme]);
|
|
99142
99226
|
};
|
|
99143
99227
|
/* harmony default export */ const contexts = (Contexts);
|
|
99144
99228
|
|
|
@@ -99160,14 +99244,7 @@ const User = (variables) => {
|
|
|
99160
99244
|
};
|
|
99161
99245
|
/* harmony default export */ const user = (User);
|
|
99162
99246
|
|
|
99163
|
-
;// ./lib/
|
|
99164
|
-
|
|
99165
|
-
|
|
99166
|
-
|
|
99167
|
-
|
|
99168
|
-
|
|
99169
|
-
|
|
99170
|
-
|
|
99247
|
+
;// ./lib/utils/makeUseMdxComponents.ts
|
|
99171
99248
|
|
|
99172
99249
|
|
|
99173
99250
|
const makeUseMDXComponents = (more = {}) => {
|
|
@@ -99190,9 +99267,20 @@ const makeUseMDXComponents = (more = {}) => {
|
|
|
99190
99267
|
...headings,
|
|
99191
99268
|
...more,
|
|
99192
99269
|
};
|
|
99193
|
-
|
|
99194
|
-
return () => components;
|
|
99270
|
+
return (() => components);
|
|
99195
99271
|
};
|
|
99272
|
+
/* harmony default export */ const makeUseMdxComponents = (makeUseMDXComponents);
|
|
99273
|
+
|
|
99274
|
+
;// ./lib/run.tsx
|
|
99275
|
+
|
|
99276
|
+
|
|
99277
|
+
|
|
99278
|
+
|
|
99279
|
+
|
|
99280
|
+
|
|
99281
|
+
|
|
99282
|
+
|
|
99283
|
+
|
|
99196
99284
|
const run_run = async (string, _opts = {}) => {
|
|
99197
99285
|
const { Fragment } = jsx_runtime_namespaceObject;
|
|
99198
99286
|
const { components = {}, terms, variables, baseUrl, imports = {}, ...opts } = _opts;
|
|
@@ -99209,7 +99297,7 @@ const run_run = async (string, _opts = {}) => {
|
|
|
99209
99297
|
}
|
|
99210
99298
|
return memo;
|
|
99211
99299
|
}, {});
|
|
99212
|
-
const exec = (text, { useMDXComponents =
|
|
99300
|
+
const exec = (text, { useMDXComponents = makeUseMdxComponents(exportedComponents) } = {}) => {
|
|
99213
99301
|
return run(text, {
|
|
99214
99302
|
...jsx_runtime_namespaceObject,
|
|
99215
99303
|
Fragment,
|
|
@@ -99229,7 +99317,7 @@ const run_run = async (string, _opts = {}) => {
|
|
|
99229
99317
|
Toc = tocModule.default;
|
|
99230
99318
|
}
|
|
99231
99319
|
return {
|
|
99232
|
-
default: props => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(contexts, { baseUrl: baseUrl, terms: terms, variables: variables },
|
|
99320
|
+
default: (props) => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(contexts, { baseUrl: baseUrl, terms: terms, theme: props.theme, variables: variables },
|
|
99233
99321
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Content, { ...props }))),
|
|
99234
99322
|
toc,
|
|
99235
99323
|
Toc: props => Toc ? (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(components_TableOfContents, null,
|