@readme/markdown 6.75.0-beta.64 → 6.75.0-beta.65

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/dist/main.js CHANGED
@@ -48562,8 +48562,17 @@ const embedTransformer = () => {
48562
48562
  */
48563
48563
  const formatHProps = (node) => {
48564
48564
  const hProps = getHProps(node);
48565
- const hPropKeys = getHPropKeys(node);
48566
- return hPropKeys.map(key => `${key}="${hProps[key]}"`).join(' ');
48565
+ return formatProps(hProps);
48566
+ };
48567
+ /**
48568
+ * Formats an object of props as a string.
48569
+ *
48570
+ * @param {Object} props
48571
+ * @returns {string}
48572
+ */
48573
+ const formatProps = (props) => {
48574
+ const keys = Object.keys(props);
48575
+ return keys.map(key => `${key}="${props[key]}"`).join(' ');
48567
48576
  };
48568
48577
  /**
48569
48578
  * Returns the hProperties of a node.
@@ -94389,6 +94398,19 @@ function toXml(tree, options) {
94389
94398
  }
94390
94399
 
94391
94400
  ;// CONCATENATED MODULE: ./processor/compile/compatibility.ts
94401
+ var compatibility_rest = (undefined && undefined.__rest) || function (s, e) {
94402
+ var t = {};
94403
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
94404
+ t[p] = s[p];
94405
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
94406
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
94407
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
94408
+ t[p[i]] = s[p[i]];
94409
+ }
94410
+ return t;
94411
+ };
94412
+
94413
+
94392
94414
 
94393
94415
 
94394
94416
 
@@ -94407,6 +94429,17 @@ const compatibility_html = (node) => {
94407
94429
  const xml = toXml(xast, { closeEmptyElements: true });
94408
94430
  return xml.replace(/<html.*<body>(.*)<\/body><\/html>/ms, '$1');
94409
94431
  };
94432
+ const figureToImageBlock = (node) => {
94433
+ const _a = node.children.find((child) => child.type === 'image'), { align, width, src, alt, title } = _a, image = compatibility_rest(_a, ["align", "width", "src", "alt", "title"]);
94434
+ const { className } = image.data.hProperties;
94435
+ const figcaption = node.children.find((child) => child.type === 'figcaption');
94436
+ const caption = figcaption ? toMarkdown({
94437
+ type: 'paragraph',
94438
+ children: figcaption.children,
94439
+ }).trim() : null;
94440
+ const attributes = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (align && { align })), (alt && { alt })), (className && { border: className === 'border' })), (caption && { caption })), (title && { title })), (width && { width })), { src });
94441
+ return `<Image ${formatProps(attributes)} />`;
94442
+ };
94410
94443
  const compatibility = (node) => {
94411
94444
  var _a, _b;
94412
94445
  switch (node.type) {
@@ -94420,6 +94453,11 @@ const compatibility = (node) => {
94420
94453
  return compatibility_html(node);
94421
94454
  case 'escape':
94422
94455
  return `\\${node.value}`;
94456
+ case 'figure':
94457
+ return figureToImageBlock(node);
94458
+ case 'embed':
94459
+ const attributes = formatHProps(node);
94460
+ return `<Embed ${attributes} />`;
94423
94461
  default:
94424
94462
  throw new Error('Unhandled node type!');
94425
94463
  }
@@ -94453,7 +94491,9 @@ function compilers() {
94453
94491
  [NodeTypes.imageBlock]: compile_image,
94454
94492
  [NodeTypes.reusableContent]: compile_compatibility,
94455
94493
  [NodeTypes.variable]: compile_variable,
94494
+ embed: compile_compatibility,
94456
94495
  escape: compile_compatibility,
94496
+ figure: compile_compatibility,
94457
94497
  html: compile_compatibility,
94458
94498
  };
94459
94499
  toMarkdownExtensions.push({ extensions: [{ handlers }] });
package/dist/main.node.js CHANGED
@@ -50015,8 +50015,17 @@ const embedTransformer = () => {
50015
50015
  */
50016
50016
  const formatHProps = (node) => {
50017
50017
  const hProps = getHProps(node);
50018
- const hPropKeys = getHPropKeys(node);
50019
- return hPropKeys.map(key => `${key}="${hProps[key]}"`).join(' ');
50018
+ return formatProps(hProps);
50019
+ };
50020
+ /**
50021
+ * Formats an object of props as a string.
50022
+ *
50023
+ * @param {Object} props
50024
+ * @returns {string}
50025
+ */
50026
+ const formatProps = (props) => {
50027
+ const keys = Object.keys(props);
50028
+ return keys.map(key => `${key}="${props[key]}"`).join(' ');
50020
50029
  };
50021
50030
  /**
50022
50031
  * Returns the hProperties of a node.
@@ -95842,6 +95851,19 @@ function toXml(tree, options) {
95842
95851
  }
95843
95852
 
95844
95853
  ;// CONCATENATED MODULE: ./processor/compile/compatibility.ts
95854
+ var compatibility_rest = (undefined && undefined.__rest) || function (s, e) {
95855
+ var t = {};
95856
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
95857
+ t[p] = s[p];
95858
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
95859
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
95860
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
95861
+ t[p[i]] = s[p[i]];
95862
+ }
95863
+ return t;
95864
+ };
95865
+
95866
+
95845
95867
 
95846
95868
 
95847
95869
 
@@ -95860,6 +95882,17 @@ const compatibility_html = (node) => {
95860
95882
  const xml = toXml(xast, { closeEmptyElements: true });
95861
95883
  return xml.replace(/<html.*<body>(.*)<\/body><\/html>/ms, '$1');
95862
95884
  };
95885
+ const figureToImageBlock = (node) => {
95886
+ const _a = node.children.find((child) => child.type === 'image'), { align, width, src, alt, title } = _a, image = compatibility_rest(_a, ["align", "width", "src", "alt", "title"]);
95887
+ const { className } = image.data.hProperties;
95888
+ const figcaption = node.children.find((child) => child.type === 'figcaption');
95889
+ const caption = figcaption ? toMarkdown({
95890
+ type: 'paragraph',
95891
+ children: figcaption.children,
95892
+ }).trim() : null;
95893
+ const attributes = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (align && { align })), (alt && { alt })), (className && { border: className === 'border' })), (caption && { caption })), (title && { title })), (width && { width })), { src });
95894
+ return `<Image ${formatProps(attributes)} />`;
95895
+ };
95863
95896
  const compatibility = (node) => {
95864
95897
  var _a, _b;
95865
95898
  switch (node.type) {
@@ -95873,6 +95906,11 @@ const compatibility = (node) => {
95873
95906
  return compatibility_html(node);
95874
95907
  case 'escape':
95875
95908
  return `\\${node.value}`;
95909
+ case 'figure':
95910
+ return figureToImageBlock(node);
95911
+ case 'embed':
95912
+ const attributes = formatHProps(node);
95913
+ return `<Embed ${attributes} />`;
95876
95914
  default:
95877
95915
  throw new Error('Unhandled node type!');
95878
95916
  }
@@ -95906,7 +95944,9 @@ function compilers() {
95906
95944
  [NodeTypes.imageBlock]: compile_image,
95907
95945
  [NodeTypes.reusableContent]: compile_compatibility,
95908
95946
  [NodeTypes.variable]: compile_variable,
95947
+ embed: compile_compatibility,
95909
95948
  escape: compile_compatibility,
95949
+ figure: compile_compatibility,
95910
95950
  html: compile_compatibility,
95911
95951
  };
95912
95952
  toMarkdownExtensions.push({ extensions: [{ handlers }] });
@@ -1,4 +1,4 @@
1
- import { Html } from 'mdast';
1
+ import { Html, Image } from 'mdast';
2
2
  import { NodeTypes } from '../../enums';
3
3
  type CompatNodes = {
4
4
  type: NodeTypes.glossary;
@@ -19,9 +19,25 @@ type CompatNodes = {
19
19
  } | {
20
20
  type: NodeTypes.reusableContent;
21
21
  tag: string;
22
+ } | {
23
+ type: 'embed';
24
+ data: {
25
+ hProperties: {
26
+ [key: string]: string;
27
+ };
28
+ };
22
29
  } | {
23
30
  type: 'escape';
24
31
  value: string;
32
+ } | {
33
+ type: 'figure';
34
+ children: [Image, {
35
+ type: 'figcaption';
36
+ children: [{
37
+ type: 'text';
38
+ value: string;
39
+ }];
40
+ }];
25
41
  } | Html;
26
42
  declare const compatibility: (node: CompatNodes) => string;
27
43
  export default compatibility;
@@ -10,6 +10,13 @@ import { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx';
10
10
  * @returns {string} formatted hProperties as JSX attributes
11
11
  */
12
12
  export declare const formatHProps: <T>(node: Node) => string;
13
+ /**
14
+ * Formats an object of props as a string.
15
+ *
16
+ * @param {Object} props
17
+ * @returns {string}
18
+ */
19
+ export declare const formatProps: (props: Object) => string;
13
20
  /**
14
21
  * Returns the hProperties of a node.
15
22
  *
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.64",
5
+ "version": "6.75.0-beta.65",
6
6
  "main": "dist/main.node.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "browser": "dist/main.js",