@readme/markdown 6.75.0-beta.52 → 6.75.0-beta.53

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.
@@ -13,24 +13,42 @@ interface EmbedProps {
13
13
  lazy?: boolean;
14
14
  url: string;
15
15
  title: string;
16
- provider?: string;
16
+ providerName?: string;
17
+ providerUrl?: string;
17
18
  html?: string;
18
19
  iframe?: boolean;
19
20
  image?: string;
20
21
  favicon?: string;
22
+ typeOfEmbed?: string;
21
23
  }
22
24
 
23
- const Embed = ({ lazy = true, url, provider, title, html, iframe, image, favicon, ...attrs }: EmbedProps) => {
25
+ const Embed = ({
26
+ lazy = true,
27
+ url,
28
+ html,
29
+ providerName,
30
+ providerUrl,
31
+ title,
32
+ iframe,
33
+ image,
34
+ favicon,
35
+ ...attrs
36
+ }: EmbedProps) => {
37
+ if (typeof iframe !== 'boolean') iframe = iframe === 'true';
38
+ if (html === 'false') html = undefined;
39
+
24
40
  if (iframe) {
25
41
  return <iframe {...attrs} src={url} style={{ border: 'none', display: 'flex', margin: 'auto' }} />;
26
42
  }
27
43
 
28
- if (!provider)
29
- provider = new URL(url).hostname
44
+ if (!providerUrl && url)
45
+ providerUrl = new URL(url).hostname
30
46
  .split(/(?:www)?\./)
31
47
  .filter(i => i)
32
48
  .join('.');
33
49
 
50
+ if (!providerName) providerName = providerUrl;
51
+
34
52
  const classes = ['embed', image ? 'embed_hasImg' : ''];
35
53
 
36
54
  return (
@@ -40,13 +58,13 @@ const Embed = ({ lazy = true, url, provider, title, html, iframe, image, favicon
40
58
  ) : (
41
59
  <a className="embed-link" href={url} rel="noopener noreferrer" target="_blank">
42
60
  {!image || <img alt={title} className="embed-img" loading={lazy ? 'lazy' : undefined} src={image} />}
43
- {title ? (
61
+ {title && title !== '@embed' ? (
44
62
  <div className="embed-body">
45
- {!favicon || <Favicon alt={provider} src={favicon} />}
46
- {provider && (
63
+ {!favicon || <Favicon alt={providerName} src={favicon} />}
64
+ {providerUrl && (
47
65
  <small className="embed-provider">
48
- {provider.search(/^@{1}/) < 0 ? (
49
- provider
66
+ {providerUrl.search(/^@{1}/) < 0 ? (
67
+ providerName
50
68
  ) : (
51
69
  <code style={{ fontFamily: 'var(--md-code-font, monospace)' }}>{url}</code>
52
70
  )}
@@ -57,16 +57,16 @@ const Image = (Props: ImageProps) => {
57
57
 
58
58
  if (caption) {
59
59
  return (
60
- <figure>
61
- <span
62
- aria-label={alt}
63
- className={`img lightbox ${lightbox ? 'open' : 'closed'}`}
64
- onClick={toggle}
65
- onKeyDown={handleKeyDown}
66
- role={'button'}
67
- tabIndex={0}
68
- >
69
- <span className="lightbox-inner">
60
+ <span
61
+ aria-label={alt}
62
+ className={`img lightbox ${lightbox ? 'open' : 'closed'}`}
63
+ onClick={toggle}
64
+ onKeyDown={handleKeyDown}
65
+ role={'button'}
66
+ tabIndex={0}
67
+ >
68
+ <span className="lightbox-inner">
69
+ <figure>
70
70
  <img
71
71
  src={src}
72
72
  width={width}
@@ -76,34 +76,36 @@ const Image = (Props: ImageProps) => {
76
76
  alt={alt}
77
77
  loading={lazy ? 'lazy' : 'eager'}
78
78
  />
79
- </span>
79
+ <figcaption>{caption}</figcaption>
80
+ </figure>
80
81
  </span>
81
- <figcaption>{caption}</figcaption>
82
- </figure>
82
+ </span>
83
83
  );
84
84
  }
85
85
 
86
86
  return (
87
- <span
88
- aria-label={alt}
89
- className={`img lightbox ${lightbox ? 'open' : 'closed'}`}
90
- onClick={toggle}
91
- onKeyDown={handleKeyDown}
92
- role={'button'}
93
- tabIndex={0}
94
- >
95
- <span className="lightbox-inner">
96
- <img
97
- src={src}
98
- width={width}
99
- height={height}
100
- title={title}
101
- className={`img img-align-${align} ${border ? 'border' : ''}`}
102
- alt={alt}
103
- loading={lazy ? 'lazy' : 'eager'}
104
- />
87
+ <p>
88
+ <span
89
+ aria-label={alt}
90
+ className={`img lightbox ${lightbox ? 'open' : 'closed'}`}
91
+ onClick={toggle}
92
+ onKeyDown={handleKeyDown}
93
+ role={'button'}
94
+ tabIndex={0}
95
+ >
96
+ <span className="lightbox-inner">
97
+ <img
98
+ src={src}
99
+ width={width}
100
+ height={height}
101
+ title={title}
102
+ className={`img img-align-${align} ${border ? 'border' : ''}`}
103
+ alt={alt}
104
+ loading={lazy ? 'lazy' : 'eager'}
105
+ />
106
+ </span>
105
107
  </span>
106
- </span>
108
+ </p>
107
109
  );
108
110
  };
109
111
 
@@ -3,11 +3,13 @@ interface EmbedProps {
3
3
  lazy?: boolean;
4
4
  url: string;
5
5
  title: string;
6
- provider?: string;
6
+ providerName?: string;
7
+ providerUrl?: string;
7
8
  html?: string;
8
9
  iframe?: boolean;
9
10
  image?: string;
10
11
  favicon?: string;
12
+ typeOfEmbed?: string;
11
13
  }
12
- declare const Embed: ({ lazy, url, provider, title, html, iframe, image, favicon, ...attrs }: EmbedProps) => React.JSX.Element;
14
+ declare const Embed: ({ lazy, url, html, providerName, providerUrl, title, iframe, image, favicon, ...attrs }: EmbedProps) => React.JSX.Element;
13
15
  export default Embed;
package/dist/enums.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export declare enum NodeTypes {
2
2
  callout = "rdme-callout",
3
3
  codeTabs = "code-tabs",
4
- embed = "embed",
4
+ embedBlock = "embed-block",
5
5
  emoji = "gemoji",
6
6
  glossary = "readme-glossary-item",
7
7
  htmlBlock = "html-block",
8
8
  i = "i",
9
- image = "image",
9
+ imageBlock = "image-block",
10
10
  reusableContent = "reusable-content",
11
11
  tutorialTile = "tutorial-tile",
12
12
  variable = "readme-variable"
package/dist/main.js CHANGED
@@ -50851,21 +50851,27 @@ const Favicon = (_a) => {
50851
50851
  return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("img", Object.assign({}, attr, { alt: alt, height: "14", src: src, width: "14" })));
50852
50852
  };
50853
50853
  const Embed = (_a) => {
50854
- var { lazy = true, url, provider, title, html, iframe, image, favicon } = _a, attrs = __rest(_a, ["lazy", "url", "provider", "title", "html", "iframe", "image", "favicon"]);
50854
+ var { lazy = true, url, html, providerName, providerUrl, title, iframe, image, favicon } = _a, attrs = __rest(_a, ["lazy", "url", "html", "providerName", "providerUrl", "title", "iframe", "image", "favicon"]);
50855
+ if (typeof iframe !== 'boolean')
50856
+ iframe = iframe === 'true';
50857
+ if (html === 'false')
50858
+ html = undefined;
50855
50859
  if (iframe) {
50856
50860
  return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("iframe", Object.assign({}, attrs, { src: url, style: { border: 'none', display: 'flex', margin: 'auto' } }));
50857
50861
  }
50858
- if (!provider)
50859
- provider = new URL(url).hostname
50862
+ if (!providerUrl && url)
50863
+ providerUrl = new URL(url).hostname
50860
50864
  .split(/(?:www)?\./)
50861
50865
  .filter(i => i)
50862
50866
  .join('.');
50867
+ if (!providerName)
50868
+ providerName = providerUrl;
50863
50869
  const classes = ['embed', image ? 'embed_hasImg' : ''];
50864
50870
  return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: classes.join(' ') }, html ? (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "embed-media", dangerouslySetInnerHTML: { __html: html } })) : (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("a", { className: "embed-link", href: url, rel: "noopener noreferrer", target: "_blank" },
50865
50871
  !image || external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("img", { alt: title, className: "embed-img", loading: lazy ? 'lazy' : undefined, src: image }),
50866
- title ? (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "embed-body" },
50867
- !favicon || external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Favicon, { alt: provider, src: favicon }),
50868
- provider && (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("small", { className: "embed-provider" }, provider.search(/^@{1}/) < 0 ? (provider) : (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("code", { style: { fontFamily: 'var(--md-code-font, monospace)' } }, url)))),
50872
+ title && title !== '@embed' ? (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "embed-body" },
50873
+ !favicon || external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Favicon, { alt: providerName, src: favicon }),
50874
+ providerUrl && (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("small", { className: "embed-provider" }, providerUrl.search(/^@{1}/) < 0 ? (providerName) : (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("code", { style: { fontFamily: 'var(--md-code-font, monospace)' } }, url)))),
50869
50875
  external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "embed-title" }, title))) : (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "embed-body" },
50870
50876
  external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("b", null, "View"),
50871
50877
  ": ",
@@ -50990,15 +50996,16 @@ const Image = (Props) => {
50990
50996
  setLightbox(!lightbox);
50991
50997
  };
50992
50998
  if (caption) {
50993
- return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figure", null,
50994
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": alt, className: `img lightbox ${lightbox ? 'open' : 'closed'}`, onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
50995
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "lightbox-inner" },
50996
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("img", { src: src, width: width, height: height, title: title, className: `img img-align-center ${border ? 'border' : ''}`, alt: alt, loading: lazy ? 'lazy' : 'eager' }))),
50997
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figcaption", null, caption)));
50999
+ return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": alt, className: `img lightbox ${lightbox ? 'open' : 'closed'}`, onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
51000
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "lightbox-inner" },
51001
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figure", null,
51002
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("img", { src: src, width: width, height: height, title: title, className: `img img-align-center ${border ? 'border' : ''}`, alt: alt, loading: lazy ? 'lazy' : 'eager' }),
51003
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figcaption", null, caption)))));
50998
51004
  }
50999
- return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": alt, className: `img lightbox ${lightbox ? 'open' : 'closed'}`, onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
51000
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "lightbox-inner" },
51001
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("img", { src: src, width: width, height: height, title: title, className: `img img-align-${align} ${border ? 'border' : ''}`, alt: alt, loading: lazy ? 'lazy' : 'eager' }))));
51005
+ return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("p", null,
51006
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": alt, className: `img lightbox ${lightbox ? 'open' : 'closed'}`, onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
51007
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "lightbox-inner" },
51008
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("img", { src: src, width: width, height: height, title: title, className: `img img-align-${align} ${border ? 'border' : ''}`, alt: alt, loading: lazy ? 'lazy' : 'eager' })))));
51002
51009
  };
51003
51010
  /* harmony default export */ const components_Image = (Image);
51004
51011
 
@@ -59518,12 +59525,12 @@ var NodeTypes;
59518
59525
  (function (NodeTypes) {
59519
59526
  NodeTypes["callout"] = "rdme-callout";
59520
59527
  NodeTypes["codeTabs"] = "code-tabs";
59521
- NodeTypes["embed"] = "embed";
59528
+ NodeTypes["embedBlock"] = "embed-block";
59522
59529
  NodeTypes["emoji"] = "gemoji";
59523
59530
  NodeTypes["glossary"] = "readme-glossary-item";
59524
59531
  NodeTypes["htmlBlock"] = "html-block";
59525
59532
  NodeTypes["i"] = "i";
59526
- NodeTypes["image"] = "image";
59533
+ NodeTypes["imageBlock"] = "image-block";
59527
59534
  NodeTypes["reusableContent"] = "reusable-content";
59528
59535
  NodeTypes["tutorialTile"] = "tutorial-tile";
59529
59536
  NodeTypes["variable"] = "readme-variable";
@@ -59614,25 +59621,59 @@ const codeTabsTransformer = () => tree => {
59614
59621
 
59615
59622
  const embedTransformer = () => {
59616
59623
  return (tree) => {
59617
- lib_visit(tree, 'link', (node, _, parent) => {
59618
- var _a, _b;
59619
- if (parent.type !== 'paragraph' || parent.children.length > 1 || node.title !== '@embed')
59624
+ lib_visit(tree, 'paragraph', (node, i, parent) => {
59625
+ var _a, _b, _c;
59626
+ const [{ url, title, children = [] }] = node.children;
59627
+ if (title !== '@embed')
59620
59628
  return;
59621
59629
  const newNode = {
59622
- type: NodeTypes.embed,
59630
+ type: NodeTypes.embedBlock,
59631
+ label: (_a = children[0]) === null || _a === void 0 ? void 0 : _a.value,
59632
+ title,
59633
+ url,
59623
59634
  data: {
59624
- hProperties: { title: (_b = (_a = node.children[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : node.url, url: node.url, provider: node.url },
59625
- hName: 'Embed',
59635
+ hProperties: {
59636
+ url,
59637
+ title: (_c = (_b = children[0]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : title,
59638
+ },
59639
+ hName: 'embed',
59626
59640
  },
59627
59641
  position: node.position,
59628
- children: [],
59629
59642
  };
59630
- parent = newNode;
59643
+ parent.children.splice(i, 1, newNode);
59631
59644
  });
59632
59645
  };
59633
59646
  };
59634
59647
  /* harmony default export */ const transform_embeds = (embedTransformer);
59635
59648
 
59649
+ ;// CONCATENATED MODULE: ./processor/transform/images.ts
59650
+
59651
+
59652
+ const imageTransformer = () => {
59653
+ return (tree) => {
59654
+ lib_visit(tree, 'paragraph', (node, i, parent) => {
59655
+ var _a;
59656
+ // check if inline or already transformed
59657
+ if (parent.type !== 'root' || ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 || node.children[0].type !== 'image')
59658
+ return;
59659
+ const [{ alt, url, title }] = node.children;
59660
+ const newNode = {
59661
+ type: NodeTypes.imageBlock,
59662
+ alt,
59663
+ title,
59664
+ url,
59665
+ data: {
59666
+ hName: 'img',
59667
+ hProperties: Object.assign(Object.assign(Object.assign({}, (alt && { alt })), { src: url }), (title && { title })),
59668
+ },
59669
+ position: node.position,
59670
+ };
59671
+ parent.children.splice(i, 1, newNode);
59672
+ });
59673
+ };
59674
+ };
59675
+ /* harmony default export */ const transform_images = (imageTransformer);
59676
+
59636
59677
  ;// CONCATENATED MODULE: ./node_modules/gemoji/index.js
59637
59678
  /**
59638
59679
  * @typedef Gemoji
@@ -76632,33 +76673,54 @@ const injectComponents = (opts) => () => tree => {
76632
76673
  };
76633
76674
  /* harmony default export */ const inject_components = (injectComponents);
76634
76675
 
76676
+ ;// CONCATENATED MODULE: ./processor/utils.ts
76677
+ const formatHProps = (node) => {
76678
+ const hProps = getHProps(node);
76679
+ const hPropKeys = getHPropKeys(node);
76680
+ return hPropKeys.map(key => `${key}="${hProps[key]}"`).join(' ');
76681
+ };
76682
+ const getHProps = (node) => {
76683
+ var _a;
76684
+ const hProps = ((_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties) || {};
76685
+ return hProps;
76686
+ };
76687
+ const getHPropKeys = (node) => {
76688
+ const hProps = getHProps(node);
76689
+ return Object.keys(hProps) || [];
76690
+ };
76691
+ const getAttrs = (jsx) => jsx.attributes.reduce((memo, attr) => {
76692
+ if ('name' in attr) {
76693
+ memo[attr.name] = attr.value;
76694
+ }
76695
+ return memo;
76696
+ }, {});
76697
+ const isMDXElement = (node) => {
76698
+ return ['mdxJsxFlowElement', 'mdxJsxTextElement'].includes(node.type);
76699
+ };
76700
+
76635
76701
  ;// CONCATENATED MODULE: ./processor/transform/readme-components.ts
76636
76702
 
76637
76703
 
76704
+
76638
76705
  const readme_components_types = {
76639
76706
  Callout: NodeTypes['callout'],
76640
76707
  Code: 'code',
76641
76708
  CodeTabs: NodeTypes['codeTabs'],
76709
+ EmbedBlock: NodeTypes['embed-block'],
76642
76710
  Glossary: NodeTypes['glossary'],
76643
- Image: 'image',
76711
+ ImageBlock: NodeTypes['image-block'],
76644
76712
  Table: 'table',
76645
76713
  Variable: NodeTypes['variable'],
76646
76714
  td: 'tableCell',
76647
76715
  tr: 'tableRow',
76648
76716
  TutorialTile: NodeTypes.tutorialTile,
76649
76717
  };
76650
- const attributes = (jsx) => jsx.attributes.reduce((memo, attr) => {
76651
- if ('name' in attr) {
76652
- memo[attr.name] = attr.value;
76653
- }
76654
- return memo;
76655
- }, {});
76656
76718
  const coerceJsxToMd = ({ components = {} } = {}) => (node, index, parent) => {
76657
76719
  if (node.name in components)
76658
76720
  return;
76659
76721
  if (node.name === 'Code') {
76660
76722
  const { position } = node;
76661
- const { value, lang = null, meta = null } = attributes(node);
76723
+ const { value, lang = null, meta = null } = getAttrs(node);
76662
76724
  const mdNode = {
76663
76725
  lang,
76664
76726
  meta,
@@ -76673,19 +76735,24 @@ const coerceJsxToMd = ({ components = {} } = {}) => (node, index, parent) => {
76673
76735
  }
76674
76736
  else if (node.name === 'Image') {
76675
76737
  const { position } = node;
76676
- const { alt = '', url, title = null } = attributes(node);
76738
+ const { alt = '', url, title = null } = getAttrs(node);
76739
+ const attrs = getAttrs(node);
76677
76740
  const mdNode = {
76678
76741
  alt,
76679
76742
  position,
76680
76743
  title,
76681
- type: 'image',
76682
- url,
76744
+ type: NodeTypes.imageBlock,
76745
+ url: url || attrs.src,
76746
+ data: {
76747
+ hName: 'img',
76748
+ hProperties: attrs,
76749
+ },
76683
76750
  };
76684
76751
  parent.children[index] = mdNode;
76685
76752
  }
76686
76753
  else if (node.name === 'Table') {
76687
76754
  const { children, position } = node;
76688
- const { align = [...new Array(node.children.length)].map(() => null) } = attributes(node);
76755
+ const { align = [...new Array(node.children.length)].map(() => null) } = getAttrs(node);
76689
76756
  const mdNode = {
76690
76757
  align,
76691
76758
  type: 'table',
@@ -76696,7 +76763,7 @@ const coerceJsxToMd = ({ components = {} } = {}) => (node, index, parent) => {
76696
76763
  parent.children[index] = mdNode;
76697
76764
  }
76698
76765
  else if (node.name === 'Callout') {
76699
- const { icon, empty = false } = attributes(node);
76766
+ const { icon, empty = false } = getAttrs(node);
76700
76767
  // @ts-ignore
76701
76768
  const mdNode = {
76702
76769
  children: node.children,
@@ -76709,23 +76776,31 @@ const coerceJsxToMd = ({ components = {} } = {}) => (node, index, parent) => {
76709
76776
  };
76710
76777
  parent.children[index] = mdNode;
76711
76778
  }
76779
+ else if (node.name === 'Embed') {
76780
+ const hProperties = getAttrs(node);
76781
+ const mdNode = {
76782
+ type: NodeTypes.embedBlock,
76783
+ title: hProperties.title,
76784
+ data: {
76785
+ hName: 'embed',
76786
+ hProperties,
76787
+ },
76788
+ position: node.position,
76789
+ };
76790
+ parent.children[index] = mdNode;
76791
+ }
76712
76792
  else if (node.name in readme_components_types) {
76713
- const hProperties = attributes(node);
76714
- // @ts-ignore
76793
+ const hProperties = getAttrs(node);
76715
76794
  const mdNode = Object.assign(Object.assign({ children: node.children, type: readme_components_types[node.name] }, (['tr', 'td'].includes(node.name)
76716
76795
  ? {}
76717
76796
  : {
76718
- data: Object.assign({ hName: node.name }, (Object.keys(hProperties).length ? { hProperties } : {})),
76797
+ data: Object.assign({ hName: node.name }, (hProperties !== null && hProperties !== void 0 ? hProperties : hProperties)),
76719
76798
  })), { position: node.position });
76720
76799
  parent.children[index] = mdNode;
76721
76800
  }
76722
76801
  };
76723
76802
  const readmeComponents = (opts) => () => tree => {
76724
- // @TODO: unist-util-visit does a really good job with types, **but** it
76725
- // can't seem to infer allowing multiple types passed to the visitor
76726
- // function. Otherwise, I would have these two function calls be one?
76727
- lib_visit(tree, 'mdxJsxFlowElement', coerceJsxToMd(opts));
76728
- lib_visit(tree, 'mdxJsxTextElement', coerceJsxToMd(opts));
76803
+ lib_visit(tree, isMDXElement, coerceJsxToMd(opts));
76729
76804
  lib_visit(tree, 'paragraph', (node, index, parent) => {
76730
76805
  // @ts-ignore
76731
76806
  if (parent.type !== 'tableRow')
@@ -76771,7 +76846,8 @@ const readmeToMdx = () => tree => {
76771
76846
 
76772
76847
 
76773
76848
 
76774
- /* harmony default export */ const transform = ([callouts, code_tabs, transform_embeds, gemoji_]);
76849
+
76850
+ /* harmony default export */ const transform = ([callouts, code_tabs, transform_embeds, transform_images, gemoji_]);
76775
76851
 
76776
76852
  ;// CONCATENATED MODULE: ./lib/ast-processor.ts
76777
76853
 
@@ -82888,16 +82964,15 @@ const codeTabs = (node, _, state, info) => {
82888
82964
  /* harmony default export */ const compile_code_tabs = (codeTabs);
82889
82965
 
82890
82966
  ;// CONCATENATED MODULE: ./processor/compile/embed.ts
82967
+
82891
82968
  const embed_embed = (node) => {
82892
- var _a, _b;
82893
- const { image, favicon, iframe, title, url } = ((_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties) || {};
82894
- const complexEmbed = Boolean(image) || Boolean(favicon) || iframe;
82895
- if (complexEmbed) {
82896
- const attributes = Object.keys((_b = node.data) === null || _b === void 0 ? void 0 : _b.hProperties).map(key => { var _a; return `${key}="${(_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties[key]}"`; }).join(' ');
82897
- // TODO: make this a util
82969
+ const attributes = formatHProps(node);
82970
+ const props = getHProps(node);
82971
+ if (node.title !== '@embed') {
82898
82972
  return `<Embed ${attributes} />`;
82899
82973
  }
82900
- return `[${title}](${url} "@embed")'`;
82974
+ ;
82975
+ return `[${node.label || ''}](${props.url} "${node.title}")`;
82901
82976
  };
82902
82977
  /* harmony default export */ const compile_embed = (embed_embed);
82903
82978
 
@@ -82915,17 +82990,20 @@ const htmlBlock = (node) => {
82915
82990
  /* harmony default export */ const html_block = (htmlBlock);
82916
82991
 
82917
82992
  ;// CONCATENATED MODULE: ./processor/compile/image.ts
82993
+
82918
82994
  const compile_image_image = (node) => {
82919
- var _a, _b;
82920
- const { align, className, width } = ((_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties) || {};
82921
- const complexImage = Boolean(width) || Boolean(className) || Boolean(align);
82922
- if (complexImage) {
82923
- const attributes = Object.keys((_b = node.data) === null || _b === void 0 ? void 0 : _b.hProperties)
82924
- .map(key => { var _a; return `${key}="${(_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties[key]}"`; })
82925
- .join(' ');
82926
- return `<Image ${attributes} />`;
82995
+ var _a;
82996
+ const attributes = formatHProps(node);
82997
+ const hProps = getHProps(node);
82998
+ const hPropKeys = getHPropKeys(node);
82999
+ const ImageBlock = `<Image ${attributes} />`;
83000
+ const MDImage = `![${(_a = node.alt) !== null && _a !== void 0 ? _a : ''}](${hProps.src ? hProps.src : node.url}${node.title ? ` "${node.title}")` : ')'}`;
83001
+ if (Boolean(attributes)) {
83002
+ if (hPropKeys.includes('src') && (hPropKeys.includes('width') || hPropKeys.includes('border') || hPropKeys.includes('align'))) {
83003
+ return ImageBlock;
83004
+ }
82927
83005
  }
82928
- return `![${node.alt}](${node.url}${node.title ? ` "${node.title}")` : ')'}`;
83006
+ return MDImage;
82929
83007
  };
82930
83008
  /* harmony default export */ const compile_image = (compile_image_image);
82931
83009
 
@@ -94101,9 +94179,9 @@ function compilers() {
94101
94179
  [NodeTypes.callout]: compile_callout,
94102
94180
  [NodeTypes.emoji]: compile_gemoji,
94103
94181
  [NodeTypes.codeTabs]: compile_code_tabs,
94104
- [NodeTypes.embed]: compile_embed,
94182
+ [NodeTypes.embedBlock]: compile_embed,
94105
94183
  [NodeTypes.htmlBlock]: html_block,
94106
- [NodeTypes.image]: compile_image,
94184
+ [NodeTypes.imageBlock]: compile_image,
94107
94185
  [NodeTypes.variable]: compile_compatibility,
94108
94186
  [NodeTypes.glossary]: compile_compatibility,
94109
94187
  [NodeTypes.reusableContent]: compile_compatibility,
@@ -94257,7 +94335,7 @@ const makeUseMDXComponents = (more = {}) => {
94257
94335
  map[`h${index + 1}`] = components_Heading((index + 1));
94258
94336
  return map;
94259
94337
  }, {});
94260
- const components = Object.assign(Object.assign(Object.assign(Object.assign({}, components_namespaceObject), { Variable: (variable_default()), code: components_Code, 'code-tabs': components_CodeTabs, 'html-block': components_HTMLBlock, embed: components_Embed, img: components_Image, table: components_Table }), headings), more);
94338
+ const components = Object.assign(Object.assign(Object.assign(Object.assign({}, components_namespaceObject), { Variable: (variable_default()), code: components_Code, embed: components_Embed, img: components_Image, table: components_Table }), headings), more);
94261
94339
  return () => components;
94262
94340
  };
94263
94341
  const run_run = async (string, _opts = {}) => {
package/dist/main.node.js CHANGED
@@ -47412,21 +47412,27 @@ const Favicon = (_a) => {
47412
47412
  return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("img", Object.assign({}, attr, { alt: alt, height: "14", src: src, width: "14" })));
47413
47413
  };
47414
47414
  const Embed = (_a) => {
47415
- var { lazy = true, url, provider, title, html, iframe, image, favicon } = _a, attrs = __rest(_a, ["lazy", "url", "provider", "title", "html", "iframe", "image", "favicon"]);
47415
+ var { lazy = true, url, html, providerName, providerUrl, title, iframe, image, favicon } = _a, attrs = __rest(_a, ["lazy", "url", "html", "providerName", "providerUrl", "title", "iframe", "image", "favicon"]);
47416
+ if (typeof iframe !== 'boolean')
47417
+ iframe = iframe === 'true';
47418
+ if (html === 'false')
47419
+ html = undefined;
47416
47420
  if (iframe) {
47417
47421
  return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("iframe", Object.assign({}, attrs, { src: url, style: { border: 'none', display: 'flex', margin: 'auto' } }));
47418
47422
  }
47419
- if (!provider)
47420
- provider = new URL(url).hostname
47423
+ if (!providerUrl && url)
47424
+ providerUrl = new URL(url).hostname
47421
47425
  .split(/(?:www)?\./)
47422
47426
  .filter(i => i)
47423
47427
  .join('.');
47428
+ if (!providerName)
47429
+ providerName = providerUrl;
47424
47430
  const classes = ['embed', image ? 'embed_hasImg' : ''];
47425
47431
  return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: classes.join(' ') }, html ? (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "embed-media", dangerouslySetInnerHTML: { __html: html } })) : (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("a", { className: "embed-link", href: url, rel: "noopener noreferrer", target: "_blank" },
47426
47432
  !image || external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("img", { alt: title, className: "embed-img", loading: lazy ? 'lazy' : undefined, src: image }),
47427
- title ? (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "embed-body" },
47428
- !favicon || external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Favicon, { alt: provider, src: favicon }),
47429
- provider && (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("small", { className: "embed-provider" }, provider.search(/^@{1}/) < 0 ? (provider) : (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("code", { style: { fontFamily: 'var(--md-code-font, monospace)' } }, url)))),
47433
+ title && title !== '@embed' ? (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "embed-body" },
47434
+ !favicon || external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(Favicon, { alt: providerName, src: favicon }),
47435
+ providerUrl && (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("small", { className: "embed-provider" }, providerUrl.search(/^@{1}/) < 0 ? (providerName) : (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("code", { style: { fontFamily: 'var(--md-code-font, monospace)' } }, url)))),
47430
47436
  external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "embed-title" }, title))) : (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "embed-body" },
47431
47437
  external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("b", null, "View"),
47432
47438
  ": ",
@@ -52495,15 +52501,16 @@ const Image = (Props) => {
52495
52501
  setLightbox(!lightbox);
52496
52502
  };
52497
52503
  if (caption) {
52498
- return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figure", null,
52499
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": alt, className: `img lightbox ${lightbox ? 'open' : 'closed'}`, onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
52500
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "lightbox-inner" },
52501
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("img", { src: src, width: width, height: height, title: title, className: `img img-align-center ${border ? 'border' : ''}`, alt: alt, loading: lazy ? 'lazy' : 'eager' }))),
52502
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figcaption", null, caption)));
52503
- }
52504
- return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": alt, className: `img lightbox ${lightbox ? 'open' : 'closed'}`, onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
52505
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "lightbox-inner" },
52506
- external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("img", { src: src, width: width, height: height, title: title, className: `img img-align-${align} ${border ? 'border' : ''}`, alt: alt, loading: lazy ? 'lazy' : 'eager' }))));
52504
+ return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": alt, className: `img lightbox ${lightbox ? 'open' : 'closed'}`, onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
52505
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "lightbox-inner" },
52506
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figure", null,
52507
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("img", { src: src, width: width, height: height, title: title, className: `img img-align-center ${border ? 'border' : ''}`, alt: alt, loading: lazy ? 'lazy' : 'eager' }),
52508
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figcaption", null, caption)))));
52509
+ }
52510
+ return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("p", null,
52511
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": alt, className: `img lightbox ${lightbox ? 'open' : 'closed'}`, onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
52512
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "lightbox-inner" },
52513
+ external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("img", { src: src, width: width, height: height, title: title, className: `img img-align-${align} ${border ? 'border' : ''}`, alt: alt, loading: lazy ? 'lazy' : 'eager' })))));
52507
52514
  };
52508
52515
  /* harmony default export */ const components_Image = (Image);
52509
52516
 
@@ -60971,12 +60978,12 @@ var NodeTypes;
60971
60978
  (function (NodeTypes) {
60972
60979
  NodeTypes["callout"] = "rdme-callout";
60973
60980
  NodeTypes["codeTabs"] = "code-tabs";
60974
- NodeTypes["embed"] = "embed";
60981
+ NodeTypes["embedBlock"] = "embed-block";
60975
60982
  NodeTypes["emoji"] = "gemoji";
60976
60983
  NodeTypes["glossary"] = "readme-glossary-item";
60977
60984
  NodeTypes["htmlBlock"] = "html-block";
60978
60985
  NodeTypes["i"] = "i";
60979
- NodeTypes["image"] = "image";
60986
+ NodeTypes["imageBlock"] = "image-block";
60980
60987
  NodeTypes["reusableContent"] = "reusable-content";
60981
60988
  NodeTypes["tutorialTile"] = "tutorial-tile";
60982
60989
  NodeTypes["variable"] = "readme-variable";
@@ -61067,25 +61074,59 @@ const codeTabsTransformer = () => tree => {
61067
61074
 
61068
61075
  const embedTransformer = () => {
61069
61076
  return (tree) => {
61070
- lib_visit(tree, 'link', (node, _, parent) => {
61071
- var _a, _b;
61072
- if (parent.type !== 'paragraph' || parent.children.length > 1 || node.title !== '@embed')
61077
+ lib_visit(tree, 'paragraph', (node, i, parent) => {
61078
+ var _a, _b, _c;
61079
+ const [{ url, title, children = [] }] = node.children;
61080
+ if (title !== '@embed')
61073
61081
  return;
61074
61082
  const newNode = {
61075
- type: NodeTypes.embed,
61083
+ type: NodeTypes.embedBlock,
61084
+ label: (_a = children[0]) === null || _a === void 0 ? void 0 : _a.value,
61085
+ title,
61086
+ url,
61076
61087
  data: {
61077
- hProperties: { title: (_b = (_a = node.children[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : node.url, url: node.url, provider: node.url },
61078
- hName: 'Embed',
61088
+ hProperties: {
61089
+ url,
61090
+ title: (_c = (_b = children[0]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : title,
61091
+ },
61092
+ hName: 'embed',
61079
61093
  },
61080
61094
  position: node.position,
61081
- children: [],
61082
61095
  };
61083
- parent = newNode;
61096
+ parent.children.splice(i, 1, newNode);
61084
61097
  });
61085
61098
  };
61086
61099
  };
61087
61100
  /* harmony default export */ const transform_embeds = (embedTransformer);
61088
61101
 
61102
+ ;// CONCATENATED MODULE: ./processor/transform/images.ts
61103
+
61104
+
61105
+ const imageTransformer = () => {
61106
+ return (tree) => {
61107
+ lib_visit(tree, 'paragraph', (node, i, parent) => {
61108
+ var _a;
61109
+ // check if inline or already transformed
61110
+ if (parent.type !== 'root' || ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 || node.children[0].type !== 'image')
61111
+ return;
61112
+ const [{ alt, url, title }] = node.children;
61113
+ const newNode = {
61114
+ type: NodeTypes.imageBlock,
61115
+ alt,
61116
+ title,
61117
+ url,
61118
+ data: {
61119
+ hName: 'img',
61120
+ hProperties: Object.assign(Object.assign(Object.assign({}, (alt && { alt })), { src: url }), (title && { title })),
61121
+ },
61122
+ position: node.position,
61123
+ };
61124
+ parent.children.splice(i, 1, newNode);
61125
+ });
61126
+ };
61127
+ };
61128
+ /* harmony default export */ const transform_images = (imageTransformer);
61129
+
61089
61130
  ;// CONCATENATED MODULE: ./node_modules/gemoji/index.js
61090
61131
  /**
61091
61132
  * @typedef Gemoji
@@ -78085,33 +78126,54 @@ const injectComponents = (opts) => () => tree => {
78085
78126
  };
78086
78127
  /* harmony default export */ const inject_components = (injectComponents);
78087
78128
 
78129
+ ;// CONCATENATED MODULE: ./processor/utils.ts
78130
+ const formatHProps = (node) => {
78131
+ const hProps = getHProps(node);
78132
+ const hPropKeys = getHPropKeys(node);
78133
+ return hPropKeys.map(key => `${key}="${hProps[key]}"`).join(' ');
78134
+ };
78135
+ const getHProps = (node) => {
78136
+ var _a;
78137
+ const hProps = ((_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties) || {};
78138
+ return hProps;
78139
+ };
78140
+ const getHPropKeys = (node) => {
78141
+ const hProps = getHProps(node);
78142
+ return Object.keys(hProps) || [];
78143
+ };
78144
+ const getAttrs = (jsx) => jsx.attributes.reduce((memo, attr) => {
78145
+ if ('name' in attr) {
78146
+ memo[attr.name] = attr.value;
78147
+ }
78148
+ return memo;
78149
+ }, {});
78150
+ const isMDXElement = (node) => {
78151
+ return ['mdxJsxFlowElement', 'mdxJsxTextElement'].includes(node.type);
78152
+ };
78153
+
78088
78154
  ;// CONCATENATED MODULE: ./processor/transform/readme-components.ts
78089
78155
 
78090
78156
 
78157
+
78091
78158
  const readme_components_types = {
78092
78159
  Callout: NodeTypes['callout'],
78093
78160
  Code: 'code',
78094
78161
  CodeTabs: NodeTypes['codeTabs'],
78162
+ EmbedBlock: NodeTypes['embed-block'],
78095
78163
  Glossary: NodeTypes['glossary'],
78096
- Image: 'image',
78164
+ ImageBlock: NodeTypes['image-block'],
78097
78165
  Table: 'table',
78098
78166
  Variable: NodeTypes['variable'],
78099
78167
  td: 'tableCell',
78100
78168
  tr: 'tableRow',
78101
78169
  TutorialTile: NodeTypes.tutorialTile,
78102
78170
  };
78103
- const attributes = (jsx) => jsx.attributes.reduce((memo, attr) => {
78104
- if ('name' in attr) {
78105
- memo[attr.name] = attr.value;
78106
- }
78107
- return memo;
78108
- }, {});
78109
78171
  const coerceJsxToMd = ({ components = {} } = {}) => (node, index, parent) => {
78110
78172
  if (node.name in components)
78111
78173
  return;
78112
78174
  if (node.name === 'Code') {
78113
78175
  const { position } = node;
78114
- const { value, lang = null, meta = null } = attributes(node);
78176
+ const { value, lang = null, meta = null } = getAttrs(node);
78115
78177
  const mdNode = {
78116
78178
  lang,
78117
78179
  meta,
@@ -78126,19 +78188,24 @@ const coerceJsxToMd = ({ components = {} } = {}) => (node, index, parent) => {
78126
78188
  }
78127
78189
  else if (node.name === 'Image') {
78128
78190
  const { position } = node;
78129
- const { alt = '', url, title = null } = attributes(node);
78191
+ const { alt = '', url, title = null } = getAttrs(node);
78192
+ const attrs = getAttrs(node);
78130
78193
  const mdNode = {
78131
78194
  alt,
78132
78195
  position,
78133
78196
  title,
78134
- type: 'image',
78135
- url,
78197
+ type: NodeTypes.imageBlock,
78198
+ url: url || attrs.src,
78199
+ data: {
78200
+ hName: 'img',
78201
+ hProperties: attrs,
78202
+ },
78136
78203
  };
78137
78204
  parent.children[index] = mdNode;
78138
78205
  }
78139
78206
  else if (node.name === 'Table') {
78140
78207
  const { children, position } = node;
78141
- const { align = [...new Array(node.children.length)].map(() => null) } = attributes(node);
78208
+ const { align = [...new Array(node.children.length)].map(() => null) } = getAttrs(node);
78142
78209
  const mdNode = {
78143
78210
  align,
78144
78211
  type: 'table',
@@ -78149,7 +78216,7 @@ const coerceJsxToMd = ({ components = {} } = {}) => (node, index, parent) => {
78149
78216
  parent.children[index] = mdNode;
78150
78217
  }
78151
78218
  else if (node.name === 'Callout') {
78152
- const { icon, empty = false } = attributes(node);
78219
+ const { icon, empty = false } = getAttrs(node);
78153
78220
  // @ts-ignore
78154
78221
  const mdNode = {
78155
78222
  children: node.children,
@@ -78162,23 +78229,31 @@ const coerceJsxToMd = ({ components = {} } = {}) => (node, index, parent) => {
78162
78229
  };
78163
78230
  parent.children[index] = mdNode;
78164
78231
  }
78232
+ else if (node.name === 'Embed') {
78233
+ const hProperties = getAttrs(node);
78234
+ const mdNode = {
78235
+ type: NodeTypes.embedBlock,
78236
+ title: hProperties.title,
78237
+ data: {
78238
+ hName: 'embed',
78239
+ hProperties,
78240
+ },
78241
+ position: node.position,
78242
+ };
78243
+ parent.children[index] = mdNode;
78244
+ }
78165
78245
  else if (node.name in readme_components_types) {
78166
- const hProperties = attributes(node);
78167
- // @ts-ignore
78246
+ const hProperties = getAttrs(node);
78168
78247
  const mdNode = Object.assign(Object.assign({ children: node.children, type: readme_components_types[node.name] }, (['tr', 'td'].includes(node.name)
78169
78248
  ? {}
78170
78249
  : {
78171
- data: Object.assign({ hName: node.name }, (Object.keys(hProperties).length ? { hProperties } : {})),
78250
+ data: Object.assign({ hName: node.name }, (hProperties !== null && hProperties !== void 0 ? hProperties : hProperties)),
78172
78251
  })), { position: node.position });
78173
78252
  parent.children[index] = mdNode;
78174
78253
  }
78175
78254
  };
78176
78255
  const readmeComponents = (opts) => () => tree => {
78177
- // @TODO: unist-util-visit does a really good job with types, **but** it
78178
- // can't seem to infer allowing multiple types passed to the visitor
78179
- // function. Otherwise, I would have these two function calls be one?
78180
- lib_visit(tree, 'mdxJsxFlowElement', coerceJsxToMd(opts));
78181
- lib_visit(tree, 'mdxJsxTextElement', coerceJsxToMd(opts));
78256
+ lib_visit(tree, isMDXElement, coerceJsxToMd(opts));
78182
78257
  lib_visit(tree, 'paragraph', (node, index, parent) => {
78183
78258
  // @ts-ignore
78184
78259
  if (parent.type !== 'tableRow')
@@ -78224,7 +78299,8 @@ const readmeToMdx = () => tree => {
78224
78299
 
78225
78300
 
78226
78301
 
78227
- /* harmony default export */ const transform = ([callouts, code_tabs, transform_embeds, gemoji_]);
78302
+
78303
+ /* harmony default export */ const transform = ([callouts, code_tabs, transform_embeds, transform_images, gemoji_]);
78228
78304
 
78229
78305
  ;// CONCATENATED MODULE: ./lib/ast-processor.ts
78230
78306
 
@@ -84341,16 +84417,15 @@ const codeTabs = (node, _, state, info) => {
84341
84417
  /* harmony default export */ const compile_code_tabs = (codeTabs);
84342
84418
 
84343
84419
  ;// CONCATENATED MODULE: ./processor/compile/embed.ts
84420
+
84344
84421
  const embed_embed = (node) => {
84345
- var _a, _b;
84346
- const { image, favicon, iframe, title, url } = ((_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties) || {};
84347
- const complexEmbed = Boolean(image) || Boolean(favicon) || iframe;
84348
- if (complexEmbed) {
84349
- const attributes = Object.keys((_b = node.data) === null || _b === void 0 ? void 0 : _b.hProperties).map(key => { var _a; return `${key}="${(_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties[key]}"`; }).join(' ');
84350
- // TODO: make this a util
84422
+ const attributes = formatHProps(node);
84423
+ const props = getHProps(node);
84424
+ if (node.title !== '@embed') {
84351
84425
  return `<Embed ${attributes} />`;
84352
84426
  }
84353
- return `[${title}](${url} "@embed")'`;
84427
+ ;
84428
+ return `[${node.label || ''}](${props.url} "${node.title}")`;
84354
84429
  };
84355
84430
  /* harmony default export */ const compile_embed = (embed_embed);
84356
84431
 
@@ -84368,17 +84443,20 @@ const htmlBlock = (node) => {
84368
84443
  /* harmony default export */ const html_block = (htmlBlock);
84369
84444
 
84370
84445
  ;// CONCATENATED MODULE: ./processor/compile/image.ts
84446
+
84371
84447
  const compile_image_image = (node) => {
84372
- var _a, _b;
84373
- const { align, className, width } = ((_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties) || {};
84374
- const complexImage = Boolean(width) || Boolean(className) || Boolean(align);
84375
- if (complexImage) {
84376
- const attributes = Object.keys((_b = node.data) === null || _b === void 0 ? void 0 : _b.hProperties)
84377
- .map(key => { var _a; return `${key}="${(_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties[key]}"`; })
84378
- .join(' ');
84379
- return `<Image ${attributes} />`;
84380
- }
84381
- return `![${node.alt}](${node.url}${node.title ? ` "${node.title}")` : ')'}`;
84448
+ var _a;
84449
+ const attributes = formatHProps(node);
84450
+ const hProps = getHProps(node);
84451
+ const hPropKeys = getHPropKeys(node);
84452
+ const ImageBlock = `<Image ${attributes} />`;
84453
+ const MDImage = `![${(_a = node.alt) !== null && _a !== void 0 ? _a : ''}](${hProps.src ? hProps.src : node.url}${node.title ? ` "${node.title}")` : ')'}`;
84454
+ if (Boolean(attributes)) {
84455
+ if (hPropKeys.includes('src') && (hPropKeys.includes('width') || hPropKeys.includes('border') || hPropKeys.includes('align'))) {
84456
+ return ImageBlock;
84457
+ }
84458
+ }
84459
+ return MDImage;
84382
84460
  };
84383
84461
  /* harmony default export */ const compile_image = (compile_image_image);
84384
84462
 
@@ -95554,9 +95632,9 @@ function compilers() {
95554
95632
  [NodeTypes.callout]: compile_callout,
95555
95633
  [NodeTypes.emoji]: compile_gemoji,
95556
95634
  [NodeTypes.codeTabs]: compile_code_tabs,
95557
- [NodeTypes.embed]: compile_embed,
95635
+ [NodeTypes.embedBlock]: compile_embed,
95558
95636
  [NodeTypes.htmlBlock]: html_block,
95559
- [NodeTypes.image]: compile_image,
95637
+ [NodeTypes.imageBlock]: compile_image,
95560
95638
  [NodeTypes.variable]: compile_compatibility,
95561
95639
  [NodeTypes.glossary]: compile_compatibility,
95562
95640
  [NodeTypes.reusableContent]: compile_compatibility,
@@ -95710,7 +95788,7 @@ const makeUseMDXComponents = (more = {}) => {
95710
95788
  map[`h${index + 1}`] = components_Heading((index + 1));
95711
95789
  return map;
95712
95790
  }, {});
95713
- const components = Object.assign(Object.assign(Object.assign(Object.assign({}, components_namespaceObject), { Variable: (dist_default()), code: components_Code, 'code-tabs': components_CodeTabs, 'html-block': components_HTMLBlock, embed: components_Embed, img: components_Image, table: components_Table }), headings), more);
95791
+ const components = Object.assign(Object.assign(Object.assign(Object.assign({}, components_namespaceObject), { Variable: (dist_default()), code: components_Code, embed: components_Embed, img: components_Image, table: components_Table }), headings), more);
95714
95792
  return () => components;
95715
95793
  };
95716
95794
  const run_run = async (string, _opts = {}) => {
@@ -1,3 +1,3 @@
1
- import type { Embed } from "types";
2
- declare const embed: (node: Embed) => string;
1
+ import type { EmbedBlock } from "types";
2
+ declare const embed: (node: EmbedBlock) => string;
3
3
  export default embed;
@@ -1,3 +1,3 @@
1
- import type { Image } from 'mdast';
2
- declare const image: (node: Image) => string;
1
+ import type { ImageBlock } from 'types';
2
+ declare const image: (node: ImageBlock) => string;
3
3
  export default image;
@@ -1,2 +1,3 @@
1
- declare const embedTransformer: () => (tree: any) => void;
1
+ import { Node } from 'mdast';
2
+ declare const embedTransformer: () => (tree: Node) => void;
2
3
  export default embedTransformer;
@@ -0,0 +1,3 @@
1
+ import { Node } from 'mdast';
2
+ declare const imageTransformer: () => (tree: Node) => void;
3
+ export default imageTransformer;
@@ -0,0 +1,7 @@
1
+ import { Node } from 'mdast';
2
+ import { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx';
3
+ export declare const formatHProps: <T>(node: Node) => T;
4
+ export declare const getHProps: <T>(node: Node) => T;
5
+ export declare const getHPropKeys: <T>(node: Node) => string[] | T;
6
+ export declare const getAttrs: <T>(jsx: MdxJsxFlowElement | MdxJsxTextElement) => T;
7
+ export declare const isMDXElement: (node: Node) => node is MdxJsxFlowElement | MdxJsxTextElement;
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": "6.75.0-beta.52",
5
+ "version": "6.75.0-beta.53",
6
6
  "main": "dist/main.node.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "browser": "dist/main.js",