@readme/markdown 7.1.0 → 7.2.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.
@@ -0,0 +1,17 @@
1
+ import React, { useState } from 'react';
2
+
3
+ import './style.scss';
4
+
5
+ const Accordion = ({ children, icon, iconColor, title }) => {
6
+ return (
7
+ <details className="Accordion">
8
+ <summary className="Accordion-title">
9
+ {icon && <i className={`Accordion-icon fa ${icon}`} style={{ color: `${iconColor}` }}></i>}
10
+ {title}
11
+ </summary>
12
+ <div className="Accordion-content">{children}</div>
13
+ </details>
14
+ );
15
+ };
16
+
17
+ export default Accordion;
@@ -0,0 +1,40 @@
1
+ .Accordion {
2
+ background: rgba(var(--color-bg-page-rgb, white), 1);
3
+ border: 1px solid var(--color-border-default, rgba(black, 0.1));
4
+ border-radius: 5px;
5
+
6
+ &-title {
7
+ align-items: center;
8
+ background: white;
9
+ border: 0;
10
+ border-radius: 5px;
11
+ color: var(--color-text-default, #384248);
12
+ cursor: pointer;
13
+ display: flex;
14
+ font-size: 16px;
15
+ padding: 15px;
16
+ position: relative;
17
+ text-align: left;
18
+ width: 100%;
19
+
20
+ &:hover {
21
+ background: var(--color-bg-hover, #{rgba(black, 0.05)});
22
+ }
23
+
24
+ .Accordion[open] & {
25
+ border-bottom-left-radius: 0;
26
+ border-bottom-right-radius: 0;
27
+ }
28
+ }
29
+
30
+ &-icon {
31
+ color: var(--project-color-primary, inherit);
32
+ margin-left: 5px;
33
+ margin-right: 5px;
34
+ }
35
+
36
+ &-content {
37
+ color: var(--color-text-muted, #4f5a66);
38
+ padding: 10px 15px 0 15px;
39
+ }
40
+ }
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+
3
+ import './style.scss';
4
+
5
+ export const Card = ({ children, href, icon, iconColor, target, title }) => {
6
+ const Tag = href ? 'a' : 'div';
7
+ return (
8
+ <Tag className="Card" href={href} target={target}>
9
+ {icon && <i className={`Card-icon fa ${icon}`} style={{ color: `${iconColor}` }}></i>}
10
+ {title && <h3 className='Card-title'>{title}</h3>}
11
+ <div className="Card-content">{children}</div>
12
+ </Tag>
13
+ )
14
+ }
15
+
16
+ const CardsGrid = ({ columns = 2, children }) => {
17
+ columns = columns >= 2 ? columns : 2;
18
+ return (
19
+ <div className="CardsGrid" style={{ gridTemplateColumns: `repeat(${columns}, 1fr)` }}>
20
+ {children}
21
+ </div>
22
+ );
23
+ };
24
+
25
+ export default CardsGrid;
@@ -0,0 +1,47 @@
1
+ .CardsGrid {
2
+ display: grid;
3
+ gap: 20px;
4
+
5
+ .Card {
6
+ padding: 15px;
7
+ padding-bottom: 0;
8
+ backdrop-filter: blur(20px);
9
+ background: rgba(var(--color-bg-page-rgb, white), 1);
10
+ border: 1px solid var(--color-border-default, rgba(black, 0.1));
11
+ border-radius: 5px;
12
+ box-shadow: 0 1px 2px #{rgba(black, 0.05)}, 0 2px 5px #{rgba(black, 0.02)};
13
+
14
+ &-top {
15
+ display: inline-flex;
16
+ flex-direction: row;
17
+ }
18
+
19
+ &-icon {
20
+ color: var(--project-color-primary, inherit);
21
+ font-size: 20px;
22
+ }
23
+
24
+ &-title {
25
+ color: var(--color-text-default, #384248);
26
+
27
+ &:first-child {
28
+ margin-top: 0;
29
+ }
30
+ }
31
+
32
+ &-content {
33
+ color: var(--color-text-muted, #4f5a66);
34
+ }
35
+ }
36
+
37
+ a.Card:not([href=""]) {
38
+ text-decoration: none;
39
+ color: inherit;
40
+
41
+ &:hover {
42
+ background: var(--color-bg-hover, #{rgba(black, 0.05)});
43
+ }
44
+ }
45
+
46
+
47
+ }
@@ -19,6 +19,7 @@
19
19
  color: var(--blue, #118cfd);
20
20
  font-weight: 600;
21
21
  padding: 10px;
22
+ margin-bottom: -2px;
22
23
  }
23
24
 
24
25
  &:hover {
@@ -1,6 +1,7 @@
1
+ export { default as Accordion } from './Accordion';
1
2
  export { default as Anchor } from './Anchor';
2
3
  export { default as Callout } from './Callout';
3
- export { default as Cards } from './CardsGrid';
4
+ export { default as Cards, Card } from './Cards';
4
5
  export { default as Code } from './Code';
5
6
  export { default as CodeTabs } from './CodeTabs';
6
7
  export { default as Embed } from './Embed';
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import './style.scss';
3
+ declare const Accordion: ({ children, icon, iconColor, title }: {
4
+ children: any;
5
+ icon: any;
6
+ iconColor: any;
7
+ title: any;
8
+ }) => React.JSX.Element;
9
+ export default Accordion;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import './style.scss';
3
+ export declare const Card: ({ children, href, icon, iconColor, target, title }: {
4
+ children: any;
5
+ href: any;
6
+ icon: any;
7
+ iconColor: any;
8
+ target: any;
9
+ title: any;
10
+ }) => React.JSX.Element;
11
+ declare const CardsGrid: ({ columns, children }: {
12
+ columns?: number;
13
+ children: any;
14
+ }) => React.JSX.Element;
15
+ export default CardsGrid;
@@ -1,6 +1,7 @@
1
+ export { default as Accordion } from './Accordion';
1
2
  export { default as Anchor } from './Anchor';
2
3
  export { default as Callout } from './Callout';
3
- export { default as Cards } from './CardsGrid';
4
+ export { default as Cards, Card } from './Cards';
4
5
  export { default as Code } from './Code';
5
6
  export { default as CodeTabs } from './CodeTabs';
6
7
  export { default as Embed } from './Embed';
package/dist/enums.d.ts CHANGED
@@ -3,6 +3,8 @@ export declare enum NodeTypes {
3
3
  codeTabs = "code-tabs",
4
4
  embedBlock = "embed-block",
5
5
  emoji = "gemoji",
6
+ figcaption = "figcaption",
7
+ figure = "figure",
6
8
  glossary = "readme-glossary-item",
7
9
  htmlBlock = "html-block",
8
10
  i = "i",
@@ -18,6 +18,6 @@ declare class RenderError extends React.Component<PropsWithChildren<Props>, Stat
18
18
  componentDidCatch(error: any, info: {
19
19
  componentStack: any;
20
20
  }): void;
21
- render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element;
21
+ render(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode>;
22
22
  }
23
23
  export default RenderError;
package/dist/main.css CHANGED
@@ -1,5 +1,6 @@
1
- .CardsGrid{display:grid;gap:20px}.CardsGrid .Card{padding:10px;backdrop-filter:blur(20px);border:1px solid rgba(0,0,0,.1);border-radius:5px;box-shadow:0 1px 2px rgba(0, 0, 0, 0.05),0 2px 5px rgba(0, 0, 0, 0.02)}
2
- .TabGroup-nav{border-bottom:solid var(--color-border-default, rgba(0, 0, 0, 0.1));margin-bottom:15px}.TabGroup-tab{background:none;border:0;color:var(--color-text-minimum, #637288);cursor:pointer;font-weight:600;padding:10px}.TabGroup-tab_active{background:none;border:0;border-bottom:solid var(--blue, #118cfd);color:var(--blue, #118cfd);font-weight:600;padding:10px}.TabGroup-tab:hover{color:var(--color-text-muted, #4f5a66)}
1
+ .Accordion{background:rgba(var(--color-bg-page-rgb, white), 1);border:1px solid var(--color-border-default, rgba(0, 0, 0, 0.1));border-radius:5px}.Accordion-title{align-items:center;background:#fff;border:0;border-radius:5px;color:var(--color-text-default, #384248);cursor:pointer;display:flex;font-size:16px;padding:15px;position:relative;text-align:left;width:100%}.Accordion-title:hover{background:var(--color-bg-hover, rgba(0, 0, 0, 0.05))}.Accordion[open] .Accordion-title{border-bottom-left-radius:0;border-bottom-right-radius:0}.Accordion-icon{color:var(--project-color-primary, inherit);margin-left:5px;margin-right:5px}.Accordion-content{color:var(--color-text-muted, #4f5a66);padding:10px 15px 0 15px}
2
+ .CardsGrid{display:grid;gap:20px}.CardsGrid .Card{padding:15px;padding-bottom:0;backdrop-filter:blur(20px);background:rgba(var(--color-bg-page-rgb, white), 1);border:1px solid var(--color-border-default, rgba(0, 0, 0, 0.1));border-radius:5px;box-shadow:0 1px 2px rgba(0, 0, 0, 0.05),0 2px 5px rgba(0, 0, 0, 0.02)}.CardsGrid .Card-top{display:inline-flex;flex-direction:row}.CardsGrid .Card-icon{color:var(--project-color-primary, inherit);font-size:20px}.CardsGrid .Card-title{color:var(--color-text-default, #384248)}.CardsGrid .Card-title:first-child{margin-top:0}.CardsGrid .Card-content{color:var(--color-text-muted, #4f5a66)}.CardsGrid a.Card:not([href=""]){text-decoration:none;color:inherit}.CardsGrid a.Card:not([href=""]):hover{background:var(--color-bg-hover, rgba(0, 0, 0, 0.05))}
3
+ .TabGroup-nav{border-bottom:solid var(--color-border-default, rgba(0, 0, 0, 0.1));margin-bottom:15px}.TabGroup-tab{background:none;border:0;color:var(--color-text-minimum, #637288);cursor:pointer;font-weight:600;padding:10px}.TabGroup-tab_active{background:none;border:0;border-bottom:solid var(--blue, #118cfd);color:var(--blue, #118cfd);font-weight:600;padding:10px;margin-bottom:-2px}.TabGroup-tab:hover{color:var(--color-text-muted, #4f5a66)}
3
4
  /* BASICS */
4
5
 
5
6
  .CodeMirror {
package/dist/main.js CHANGED
@@ -13254,9 +13254,11 @@ __webpack_require__.d(__webpack_exports__, {
13254
13254
  var components_namespaceObject = {};
13255
13255
  __webpack_require__.r(components_namespaceObject);
13256
13256
  __webpack_require__.d(components_namespaceObject, {
13257
+ Accordion: () => (components_Accordion),
13257
13258
  Anchor: () => (components_Anchor),
13258
13259
  Callout: () => (components_Callout),
13259
- Cards: () => (components_CardsGrid),
13260
+ Card: () => (Card),
13261
+ Cards: () => (Cards),
13260
13262
  Code: () => (components_Code),
13261
13263
  CodeTabs: () => (components_CodeTabs),
13262
13264
  Embed: () => (components_Embed),
@@ -13298,6 +13300,21 @@ __webpack_require__.d(util_types_namespaceObject, {
13298
13300
  spaceSeparated: () => (spaceSeparated)
13299
13301
  });
13300
13302
 
13303
+ // EXTERNAL MODULE: external {"amd":"react","commonjs":"react","commonjs2":"react","root":"React","umd":"react"}
13304
+ var external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_ = __webpack_require__(1307);
13305
+ var external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default = /*#__PURE__*/__webpack_require__.n(external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_);
13306
+ ;// CONCATENATED MODULE: ./components/Accordion/index.tsx
13307
+
13308
+
13309
+ const Accordion = ({ children, icon, iconColor, title }) => {
13310
+ return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("details", { className: "Accordion" },
13311
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("summary", { className: "Accordion-title" },
13312
+ icon && external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("i", { className: `Accordion-icon fa ${icon}`, style: { color: `${iconColor}` } }),
13313
+ title),
13314
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "Accordion-content" }, children)));
13315
+ };
13316
+ /* harmony default export */ const components_Accordion = (Accordion);
13317
+
13301
13318
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.symbol.js
13302
13319
  var es_symbol = __webpack_require__(3534);
13303
13320
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.symbol.description.js
@@ -13340,9 +13357,6 @@ var es_regexp_exec = __webpack_require__(7136);
13340
13357
  var es_string_match = __webpack_require__(8636);
13341
13358
  // EXTERNAL MODULE: ./node_modules/prop-types/index.js
13342
13359
  var prop_types = __webpack_require__(5556);
13343
- // EXTERNAL MODULE: external {"amd":"react","commonjs":"react","commonjs2":"react","root":"React","umd":"react"}
13344
- var external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_ = __webpack_require__(1307);
13345
- var external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default = /*#__PURE__*/__webpack_require__.n(external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_);
13346
13360
  ;// CONCATENATED MODULE: ./contexts/BaseUrl.js
13347
13361
 
13348
13362
  var BaseUrlContext = /*#__PURE__*/external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createContext('/');
@@ -13483,15 +13497,21 @@ const Callout = (props) => {
13483
13497
  };
13484
13498
  /* harmony default export */ const components_Callout = (Callout);
13485
13499
 
13486
- ;// CONCATENATED MODULE: ./components/CardsGrid/index.tsx
13500
+ ;// CONCATENATED MODULE: ./components/Cards/index.tsx
13487
13501
 
13488
13502
 
13489
- const Card = ({ children }) => external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "Card" }, children);
13503
+ const Card = ({ children, href, icon, iconColor, target, title }) => {
13504
+ const Tag = href ? 'a' : 'div';
13505
+ return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Tag, { className: "Card", href: href, target: target },
13506
+ icon && external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("i", { className: `Card-icon fa ${icon}`, style: { color: `${iconColor}` } }),
13507
+ title && external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("h3", { className: 'Card-title' }, title),
13508
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "Card-content" }, children)));
13509
+ };
13490
13510
  const CardsGrid = ({ columns = 2, children }) => {
13491
13511
  columns = columns >= 2 ? columns : 2;
13492
- return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "CardsGrid", style: { gridTemplateColumns: `repeat(${columns}, 1fr)` } }, external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().Children.map(children, e => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Card, null, e)))));
13512
+ return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "CardsGrid", style: { gridTemplateColumns: `repeat(${columns}, 1fr)` } }, children));
13493
13513
  };
13494
- /* harmony default export */ const components_CardsGrid = (CardsGrid);
13514
+ /* harmony default export */ const Cards = (CardsGrid);
13495
13515
 
13496
13516
  // EXTERNAL MODULE: ./node_modules/copy-to-clipboard/index.js
13497
13517
  var copy_to_clipboard = __webpack_require__(7965);
@@ -13808,6 +13828,7 @@ function TableOfContents({ children }) {
13808
13828
 
13809
13829
 
13810
13830
 
13831
+
13811
13832
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.symbol.to-primitive.js
13812
13833
  var es_symbol_to_primitive = __webpack_require__(6611);
13813
13834
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.filter.js
@@ -47716,6 +47737,8 @@ var NodeTypes;
47716
47737
  NodeTypes["codeTabs"] = "code-tabs";
47717
47738
  NodeTypes["embedBlock"] = "embed-block";
47718
47739
  NodeTypes["emoji"] = "gemoji";
47740
+ NodeTypes["figcaption"] = "figcaption";
47741
+ NodeTypes["figure"] = "figure";
47719
47742
  NodeTypes["glossary"] = "readme-glossary-item";
47720
47743
  NodeTypes["htmlBlock"] = "html-block";
47721
47744
  NodeTypes["i"] = "i";
@@ -47962,6 +47985,19 @@ const reformatHTML = (html, indent = 2) => {
47962
47985
  // const indented = cleaned.split('\n').map((line: string) => `${tab}${line}`).join('\n');
47963
47986
  return cleaned;
47964
47987
  };
47988
+ const toAttributes = (object, keys = []) => {
47989
+ let attributes = [];
47990
+ Object.entries(object).forEach(([name, value]) => {
47991
+ if (keys.length > 0 && !keys.includes(name))
47992
+ return;
47993
+ attributes.push({
47994
+ type: 'mdxJsxAttribute',
47995
+ name,
47996
+ value: value,
47997
+ });
47998
+ });
47999
+ return attributes;
48000
+ };
47965
48001
 
47966
48002
  ;// CONCATENATED MODULE: ./processor/transform/images.ts
47967
48003
 
@@ -47971,10 +48007,8 @@ const reformatHTML = (html, indent = 2) => {
47971
48007
  const imageTransformer = () => (tree) => {
47972
48008
  visit(tree, 'paragraph', (node, i, parent) => {
47973
48009
  var _a;
47974
- // check if inline
47975
- if (parent.type !== 'root' ||
47976
- ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 ||
47977
- node.children[0].type !== 'image')
48010
+ // check if inline
48011
+ if (parent.type !== 'root' || ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 || node.children[0].type !== 'image')
47978
48012
  return;
47979
48013
  const [{ alt, url, title }] = node.children;
47980
48014
  const newNode = {
@@ -65198,6 +65232,8 @@ const readmeComponents = (opts) => () => tree => {
65198
65232
  ;// CONCATENATED MODULE: ./processor/transform/readme-to-mdx.ts
65199
65233
 
65200
65234
 
65235
+
65236
+ const imageAttrs = ['align', 'alt', 'caption', 'border', 'src', 'title', 'width', 'lazy', 'className'];
65201
65237
  const readmeToMdx = () => tree => {
65202
65238
  // Unwrap pinned nodes, replace rdme-pin with its child node
65203
65239
  visit(tree, 'rdme-pin', (node, i, parent) => {
@@ -65205,22 +65241,56 @@ const readmeToMdx = () => tree => {
65205
65241
  parent.children.splice(i, 1, newNode);
65206
65242
  });
65207
65243
  visit(tree, NodeTypes.tutorialTile, (tile, index, parent) => {
65208
- const attributes = ['backgroundColor', 'emoji', 'id', 'link', 'slug', 'title'].map(name => {
65209
- const value = tile[name];
65210
- delete tile[name];
65211
- return {
65212
- type: 'mdxJsxAttribute',
65213
- name,
65214
- value,
65215
- };
65216
- });
65217
65244
  parent.children.splice(index, 1, {
65218
65245
  type: 'mdxJsxFlowElement',
65219
65246
  name: 'TutorialTile',
65220
- attributes,
65247
+ attributes: toAttributes(tile, ['backgroundColor', 'emoji', 'id', 'link', 'slug', 'title']),
65221
65248
  children: [],
65222
65249
  });
65223
65250
  });
65251
+ visit(tree, 'figure', (figure, index, parent) => {
65252
+ const [image, caption] = figure.children;
65253
+ parent.children.splice(index, 1, {
65254
+ type: 'mdxJsxFlowElement',
65255
+ name: 'Image',
65256
+ attributes: toAttributes(image, imageAttrs),
65257
+ children: caption.children,
65258
+ });
65259
+ });
65260
+ const hasExtra = (attributes) => !!attributes.find(attr => !['alt', 'src', 'title'].includes(attr.name));
65261
+ visit(tree, 'image', (image, index, parent) => {
65262
+ if (!('data' in image))
65263
+ return;
65264
+ const attributes = toAttributes(image.data.hProperties, imageAttrs);
65265
+ if (hasExtra(attributes)) {
65266
+ parent.children.splice(index, 1, {
65267
+ type: 'mdxJsxFlowElement',
65268
+ name: 'Image',
65269
+ attributes,
65270
+ children: [],
65271
+ });
65272
+ }
65273
+ });
65274
+ visit(tree, NodeTypes.imageBlock, (image, index, parent) => {
65275
+ const attributes = toAttributes(image.data.hProperties, imageAttrs);
65276
+ if (hasExtra(attributes)) {
65277
+ parent.children.splice(index, 1, {
65278
+ type: 'mdxJsxFlowElement',
65279
+ name: 'Image',
65280
+ attributes,
65281
+ children: [],
65282
+ });
65283
+ }
65284
+ else {
65285
+ parent.children.splice(index, 1, {
65286
+ type: 'image',
65287
+ children: [],
65288
+ url: image.url,
65289
+ title: image.title,
65290
+ alt: image.alt,
65291
+ });
65292
+ }
65293
+ });
65224
65294
  return tree;
65225
65295
  };
65226
65296
  /* harmony default export */ const readme_to_mdx = (readmeToMdx);
@@ -82636,24 +82706,6 @@ ${reformatHTML(html)}
82636
82706
  };
82637
82707
  /* harmony default export */ const html_block = (htmlBlock);
82638
82708
 
82639
- ;// CONCATENATED MODULE: ./processor/compile/image.ts
82640
-
82641
- const compile_image_image = (node) => {
82642
- var _a;
82643
- const attributes = formatHProps(node);
82644
- const hProps = getHProps(node);
82645
- const hPropKeys = getHPropKeys(node);
82646
- const ImageBlock = `<Image ${attributes} />`;
82647
- const MDImage = `![${(_a = node.alt) !== null && _a !== void 0 ? _a : ''}](${hProps.src ? hProps.src : node.url}${node.title ? ` "${node.title}")` : ')'}`;
82648
- if (Boolean(attributes)) {
82649
- if (hPropKeys.includes('src') && (hPropKeys.includes('width') || hPropKeys.includes('border') || hPropKeys.includes('align'))) {
82650
- return ImageBlock;
82651
- }
82652
- }
82653
- return MDImage;
82654
- };
82655
- /* harmony default export */ const compile_image = (compile_image_image);
82656
-
82657
82709
  ;// CONCATENATED MODULE: ./node_modules/hast-util-from-parse5/node_modules/hastscript/lib/create-h.js
82658
82710
  /**
82659
82711
  * @typedef {import('hast').Element} Element
@@ -93850,7 +93902,12 @@ const compatibility = (node) => {
93850
93902
  /* harmony default export */ const compile_compatibility = (compatibility);
93851
93903
 
93852
93904
  ;// CONCATENATED MODULE: ./processor/compile/variable.ts
93853
- const variable = (node) => `{user.${node.data.hProperties.name}}`;
93905
+ const variable = (node) => {
93906
+ // @note: coming from RDMD, it's set as `variable`. But when mdx is parsed,
93907
+ // it's set as `name`
93908
+ const name = node.data.hProperties.variable || node.data.hProperties.name;
93909
+ return `{user.${name}}`;
93910
+ };
93854
93911
  /* harmony default export */ const compile_variable = (variable);
93855
93912
 
93856
93913
  ;// CONCATENATED MODULE: ./processor/compile/index.ts
@@ -93862,7 +93919,6 @@ const variable = (node) => `{user.${node.data.hProperties.name}}`;
93862
93919
 
93863
93920
 
93864
93921
 
93865
-
93866
93922
  function compilers() {
93867
93923
  const data = this.data();
93868
93924
  const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
@@ -93873,7 +93929,6 @@ function compilers() {
93873
93929
  [NodeTypes.emoji]: compile_gemoji,
93874
93930
  [NodeTypes.glossary]: compile_compatibility,
93875
93931
  [NodeTypes.htmlBlock]: html_block,
93876
- [NodeTypes.imageBlock]: compile_image,
93877
93932
  [NodeTypes.reusableContent]: compile_compatibility,
93878
93933
  [NodeTypes.variable]: compile_variable,
93879
93934
  embed: compile_compatibility,
@@ -93903,8 +93958,8 @@ const mdx_mdx = (tree, { hast = false } = {}) => {
93903
93958
  .use(div)
93904
93959
  .use(readme_to_mdx)
93905
93960
  .use(tables_to_jsx)
93906
- .use(remarkStringify)
93907
- .use(processor_compile);
93961
+ .use(processor_compile)
93962
+ .use(remarkStringify);
93908
93963
  return processor.stringify(processor.runSync(tree));
93909
93964
  };
93910
93965
  /* harmony default export */ const lib_mdx = (mdx_mdx);
package/dist/main.node.js CHANGED
@@ -7801,9 +7801,11 @@ __webpack_require__.d(__webpack_exports__, {
7801
7801
  var components_namespaceObject = {};
7802
7802
  __webpack_require__.r(components_namespaceObject);
7803
7803
  __webpack_require__.d(components_namespaceObject, {
7804
+ Accordion: () => (components_Accordion),
7804
7805
  Anchor: () => (components_Anchor),
7805
7806
  Callout: () => (components_Callout),
7806
- Cards: () => (components_CardsGrid),
7807
+ Card: () => (Card),
7808
+ Cards: () => (Cards),
7807
7809
  Code: () => (components_Code),
7808
7810
  CodeTabs: () => (components_CodeTabs),
7809
7811
  Embed: () => (components_Embed),
@@ -7845,11 +7847,23 @@ __webpack_require__.d(util_types_namespaceObject, {
7845
7847
  spaceSeparated: () => (spaceSeparated)
7846
7848
  });
7847
7849
 
7848
- // EXTERNAL MODULE: ./node_modules/prop-types/index.js
7849
- var prop_types = __webpack_require__(556);
7850
7850
  // EXTERNAL MODULE: external {"amd":"react","commonjs":"react","commonjs2":"react","root":"React","umd":"react"}
7851
7851
  var external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_ = __webpack_require__(137);
7852
7852
  var external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default = /*#__PURE__*/__webpack_require__.n(external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_);
7853
+ ;// CONCATENATED MODULE: ./components/Accordion/index.tsx
7854
+
7855
+
7856
+ const Accordion = ({ children, icon, iconColor, title }) => {
7857
+ return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("details", { className: "Accordion" },
7858
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("summary", { className: "Accordion-title" },
7859
+ icon && external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("i", { className: `Accordion-icon fa ${icon}`, style: { color: `${iconColor}` } }),
7860
+ title),
7861
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "Accordion-content" }, children)));
7862
+ };
7863
+ /* harmony default export */ const components_Accordion = (Accordion);
7864
+
7865
+ // EXTERNAL MODULE: ./node_modules/prop-types/index.js
7866
+ var prop_types = __webpack_require__(556);
7853
7867
  ;// CONCATENATED MODULE: ./contexts/BaseUrl.js
7854
7868
 
7855
7869
  const BaseUrlContext = /*#__PURE__*/external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createContext('/');
@@ -7963,15 +7977,21 @@ const Callout = (props) => {
7963
7977
  };
7964
7978
  /* harmony default export */ const components_Callout = (Callout);
7965
7979
 
7966
- ;// CONCATENATED MODULE: ./components/CardsGrid/index.tsx
7980
+ ;// CONCATENATED MODULE: ./components/Cards/index.tsx
7967
7981
 
7968
7982
 
7969
- const Card = ({ children }) => external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "Card" }, children);
7983
+ const Card = ({ children, href, icon, iconColor, target, title }) => {
7984
+ const Tag = href ? 'a' : 'div';
7985
+ return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Tag, { className: "Card", href: href, target: target },
7986
+ icon && external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("i", { className: `Card-icon fa ${icon}`, style: { color: `${iconColor}` } }),
7987
+ title && external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("h3", { className: 'Card-title' }, title),
7988
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "Card-content" }, children)));
7989
+ };
7970
7990
  const CardsGrid = ({ columns = 2, children }) => {
7971
7991
  columns = columns >= 2 ? columns : 2;
7972
- return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "CardsGrid", style: { gridTemplateColumns: `repeat(${columns}, 1fr)` } }, external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().Children.map(children, e => (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Card, null, e)))));
7992
+ return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "CardsGrid", style: { gridTemplateColumns: `repeat(${columns}, 1fr)` } }, children));
7973
7993
  };
7974
- /* harmony default export */ const components_CardsGrid = (CardsGrid);
7994
+ /* harmony default export */ const Cards = (CardsGrid);
7975
7995
 
7976
7996
  // EXTERNAL MODULE: ./node_modules/copy-to-clipboard/index.js
7977
7997
  var copy_to_clipboard = __webpack_require__(965);
@@ -13232,6 +13252,7 @@ function TableOfContents({ children }) {
13232
13252
 
13233
13253
 
13234
13254
 
13255
+
13235
13256
  ;// CONCATENATED MODULE: ./options.js
13236
13257
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13237
13258
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -48703,6 +48724,8 @@ var NodeTypes;
48703
48724
  NodeTypes["codeTabs"] = "code-tabs";
48704
48725
  NodeTypes["embedBlock"] = "embed-block";
48705
48726
  NodeTypes["emoji"] = "gemoji";
48727
+ NodeTypes["figcaption"] = "figcaption";
48728
+ NodeTypes["figure"] = "figure";
48706
48729
  NodeTypes["glossary"] = "readme-glossary-item";
48707
48730
  NodeTypes["htmlBlock"] = "html-block";
48708
48731
  NodeTypes["i"] = "i";
@@ -48949,6 +48972,19 @@ const reformatHTML = (html, indent = 2) => {
48949
48972
  // const indented = cleaned.split('\n').map((line: string) => `${tab}${line}`).join('\n');
48950
48973
  return cleaned;
48951
48974
  };
48975
+ const toAttributes = (object, keys = []) => {
48976
+ let attributes = [];
48977
+ Object.entries(object).forEach(([name, value]) => {
48978
+ if (keys.length > 0 && !keys.includes(name))
48979
+ return;
48980
+ attributes.push({
48981
+ type: 'mdxJsxAttribute',
48982
+ name,
48983
+ value: value,
48984
+ });
48985
+ });
48986
+ return attributes;
48987
+ };
48952
48988
 
48953
48989
  ;// CONCATENATED MODULE: ./processor/transform/images.ts
48954
48990
 
@@ -48958,10 +48994,8 @@ const reformatHTML = (html, indent = 2) => {
48958
48994
  const imageTransformer = () => (tree) => {
48959
48995
  visit(tree, 'paragraph', (node, i, parent) => {
48960
48996
  var _a;
48961
- // check if inline
48962
- if (parent.type !== 'root' ||
48963
- ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 ||
48964
- node.children[0].type !== 'image')
48997
+ // check if inline
48998
+ if (parent.type !== 'root' || ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 || node.children[0].type !== 'image')
48965
48999
  return;
48966
49000
  const [{ alt, url, title }] = node.children;
48967
49001
  const newNode = {
@@ -66185,6 +66219,8 @@ const readmeComponents = (opts) => () => tree => {
66185
66219
  ;// CONCATENATED MODULE: ./processor/transform/readme-to-mdx.ts
66186
66220
 
66187
66221
 
66222
+
66223
+ const imageAttrs = ['align', 'alt', 'caption', 'border', 'src', 'title', 'width', 'lazy', 'className'];
66188
66224
  const readmeToMdx = () => tree => {
66189
66225
  // Unwrap pinned nodes, replace rdme-pin with its child node
66190
66226
  visit(tree, 'rdme-pin', (node, i, parent) => {
@@ -66192,22 +66228,56 @@ const readmeToMdx = () => tree => {
66192
66228
  parent.children.splice(i, 1, newNode);
66193
66229
  });
66194
66230
  visit(tree, NodeTypes.tutorialTile, (tile, index, parent) => {
66195
- const attributes = ['backgroundColor', 'emoji', 'id', 'link', 'slug', 'title'].map(name => {
66196
- const value = tile[name];
66197
- delete tile[name];
66198
- return {
66199
- type: 'mdxJsxAttribute',
66200
- name,
66201
- value,
66202
- };
66203
- });
66204
66231
  parent.children.splice(index, 1, {
66205
66232
  type: 'mdxJsxFlowElement',
66206
66233
  name: 'TutorialTile',
66207
- attributes,
66234
+ attributes: toAttributes(tile, ['backgroundColor', 'emoji', 'id', 'link', 'slug', 'title']),
66208
66235
  children: [],
66209
66236
  });
66210
66237
  });
66238
+ visit(tree, 'figure', (figure, index, parent) => {
66239
+ const [image, caption] = figure.children;
66240
+ parent.children.splice(index, 1, {
66241
+ type: 'mdxJsxFlowElement',
66242
+ name: 'Image',
66243
+ attributes: toAttributes(image, imageAttrs),
66244
+ children: caption.children,
66245
+ });
66246
+ });
66247
+ const hasExtra = (attributes) => !!attributes.find(attr => !['alt', 'src', 'title'].includes(attr.name));
66248
+ visit(tree, 'image', (image, index, parent) => {
66249
+ if (!('data' in image))
66250
+ return;
66251
+ const attributes = toAttributes(image.data.hProperties, imageAttrs);
66252
+ if (hasExtra(attributes)) {
66253
+ parent.children.splice(index, 1, {
66254
+ type: 'mdxJsxFlowElement',
66255
+ name: 'Image',
66256
+ attributes,
66257
+ children: [],
66258
+ });
66259
+ }
66260
+ });
66261
+ visit(tree, NodeTypes.imageBlock, (image, index, parent) => {
66262
+ const attributes = toAttributes(image.data.hProperties, imageAttrs);
66263
+ if (hasExtra(attributes)) {
66264
+ parent.children.splice(index, 1, {
66265
+ type: 'mdxJsxFlowElement',
66266
+ name: 'Image',
66267
+ attributes,
66268
+ children: [],
66269
+ });
66270
+ }
66271
+ else {
66272
+ parent.children.splice(index, 1, {
66273
+ type: 'image',
66274
+ children: [],
66275
+ url: image.url,
66276
+ title: image.title,
66277
+ alt: image.alt,
66278
+ });
66279
+ }
66280
+ });
66211
66281
  return tree;
66212
66282
  };
66213
66283
  /* harmony default export */ const readme_to_mdx = (readmeToMdx);
@@ -83623,24 +83693,6 @@ ${reformatHTML(html)}
83623
83693
  };
83624
83694
  /* harmony default export */ const html_block = (htmlBlock);
83625
83695
 
83626
- ;// CONCATENATED MODULE: ./processor/compile/image.ts
83627
-
83628
- const compile_image_image = (node) => {
83629
- var _a;
83630
- const attributes = formatHProps(node);
83631
- const hProps = getHProps(node);
83632
- const hPropKeys = getHPropKeys(node);
83633
- const ImageBlock = `<Image ${attributes} />`;
83634
- const MDImage = `![${(_a = node.alt) !== null && _a !== void 0 ? _a : ''}](${hProps.src ? hProps.src : node.url}${node.title ? ` "${node.title}")` : ')'}`;
83635
- if (Boolean(attributes)) {
83636
- if (hPropKeys.includes('src') && (hPropKeys.includes('width') || hPropKeys.includes('border') || hPropKeys.includes('align'))) {
83637
- return ImageBlock;
83638
- }
83639
- }
83640
- return MDImage;
83641
- };
83642
- /* harmony default export */ const compile_image = (compile_image_image);
83643
-
83644
83696
  ;// CONCATENATED MODULE: ./node_modules/hast-util-from-parse5/node_modules/hastscript/lib/create-h.js
83645
83697
  /**
83646
83698
  * @typedef {import('hast').Element} Element
@@ -94837,7 +94889,12 @@ const compatibility = (node) => {
94837
94889
  /* harmony default export */ const compile_compatibility = (compatibility);
94838
94890
 
94839
94891
  ;// CONCATENATED MODULE: ./processor/compile/variable.ts
94840
- const variable = (node) => `{user.${node.data.hProperties.name}}`;
94892
+ const variable = (node) => {
94893
+ // @note: coming from RDMD, it's set as `variable`. But when mdx is parsed,
94894
+ // it's set as `name`
94895
+ const name = node.data.hProperties.variable || node.data.hProperties.name;
94896
+ return `{user.${name}}`;
94897
+ };
94841
94898
  /* harmony default export */ const compile_variable = (variable);
94842
94899
 
94843
94900
  ;// CONCATENATED MODULE: ./processor/compile/index.ts
@@ -94849,7 +94906,6 @@ const variable = (node) => `{user.${node.data.hProperties.name}}`;
94849
94906
 
94850
94907
 
94851
94908
 
94852
-
94853
94909
  function compilers() {
94854
94910
  const data = this.data();
94855
94911
  const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
@@ -94860,7 +94916,6 @@ function compilers() {
94860
94916
  [NodeTypes.emoji]: compile_gemoji,
94861
94917
  [NodeTypes.glossary]: compile_compatibility,
94862
94918
  [NodeTypes.htmlBlock]: html_block,
94863
- [NodeTypes.imageBlock]: compile_image,
94864
94919
  [NodeTypes.reusableContent]: compile_compatibility,
94865
94920
  [NodeTypes.variable]: compile_variable,
94866
94921
  embed: compile_compatibility,
@@ -94890,8 +94945,8 @@ const mdx_mdx = (tree, { hast = false } = {}) => {
94890
94945
  .use(transform_div)
94891
94946
  .use(readme_to_mdx)
94892
94947
  .use(tables_to_jsx)
94893
- .use(remarkStringify)
94894
- .use(processor_compile);
94948
+ .use(processor_compile)
94949
+ .use(remarkStringify);
94895
94950
  return processor.stringify(processor.runSync(tree));
94896
94951
  };
94897
94952
  /* harmony default export */ const lib_mdx = (mdx_mdx);
@@ -1,5 +1,6 @@
1
1
  import { Node } from 'mdast';
2
2
  import { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx';
3
+ import { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
3
4
  /**
4
5
  * Formats the hProperties of a node as a string, so they can be compiled back into JSX/MDX.
5
6
  * This currently sets all the values to a string since we process/compile the MDX on the fly
@@ -75,3 +76,4 @@ export declare const formatHTML: (html: string) => string;
75
76
  * @returns {string} re-formatted HTML
76
77
  */
77
78
  export declare const reformatHTML: (html: string, indent?: number) => string;
79
+ export declare const toAttributes: (object: Record<string, any>, keys?: string[]) => MdxJsxAttribute[];
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.1.0",
5
+ "version": "7.2.1",
6
6
  "main": "dist/main.node.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "browser": "dist/main.js",
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
-
3
- import './style.scss';
4
-
5
- const Card = ({ children }) => <div className="Card">{children}</div>;
6
-
7
- const CardsGrid = ({ columns = 2, children }) => {
8
- columns = columns >= 2 ? columns : 2;
9
- return (
10
- <div className="CardsGrid" style={{ gridTemplateColumns: `repeat(${columns}, 1fr)` }}>
11
- {React.Children.map(children, e => (
12
- <Card>{e}</Card>
13
- ))}
14
- </div>
15
- );
16
- };
17
-
18
- export default CardsGrid;
@@ -1,12 +0,0 @@
1
- .CardsGrid {
2
- display: grid;
3
- gap: 20px;
4
-
5
- .Card {
6
- padding: 10px;
7
- backdrop-filter: blur(20px);
8
- border: 1px solid rgba(black, 0.1);
9
- border-radius: 5px;
10
- box-shadow: 0 1px 2px #{rgba(black, 0.05)}, 0 2px 5px #{rgba(black, 0.02)};
11
- }
12
- }
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import './style.scss';
3
- declare const CardsGrid: ({ columns, children }: {
4
- columns?: number;
5
- children: any;
6
- }) => React.JSX.Element;
7
- export default CardsGrid;
@@ -1,3 +0,0 @@
1
- import type { ImageBlock } from 'types';
2
- declare const image: (node: ImageBlock) => string;
3
- export default image;