@readme/markdown 10.2.7 → 10.2.9

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.
@@ -5,7 +5,7 @@ interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLQuoteEl
5
5
  attributes?: Record<string, unknown>;
6
6
  empty?: boolean;
7
7
  icon?: string;
8
- theme: string;
8
+ theme?: string;
9
9
  }
10
10
 
11
11
  export const themes: Record<string, string> = {
@@ -36,12 +36,13 @@ export const defaultIcons = {
36
36
  };
37
37
 
38
38
  const Callout = (props: Props) => {
39
- const { attributes, theme = 'default', empty } = props;
39
+ const { attributes, empty } = props;
40
40
  const children = React.Children.toArray(props.children);
41
41
 
42
42
  const icon = props.icon;
43
43
  const isEmoji = icon && emojiRegex().test(icon);
44
44
  const heading = empty ? <p className={'callout-heading empty'}></p> : children[0];
45
+ const theme = props.theme || (icon && themes[icon]) || 'default';
45
46
 
46
47
  return (
47
48
  // @ts-expect-error -- theme is not a valid attribute
@@ -3,7 +3,7 @@ interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLQuoteEl
3
3
  attributes?: Record<string, unknown>;
4
4
  empty?: boolean;
5
5
  icon?: string;
6
- theme: string;
6
+ theme?: string;
7
7
  }
8
8
  export declare const themes: Record<string, string>;
9
9
  export declare const defaultIcons: {
package/dist/enums.d.ts CHANGED
@@ -10,8 +10,10 @@ export declare enum NodeTypes {
10
10
  i = "i",
11
11
  imageBlock = "image-block",
12
12
  plain = "plain",
13
+ recipe = "recipe",
13
14
  reusableContent = "reusable-content",
14
15
  tableau = "tableau",
16
+ /** @deprecated Deprecated in favor of `recipe`. */
15
17
  tutorialTile = "tutorial-tile",
16
18
  variable = "readme-variable"
17
19
  }
package/dist/main.js CHANGED
@@ -10640,11 +10640,12 @@ const defaultIcons = {
10640
10640
  error: '\u2757\uFE0F',
10641
10641
  };
10642
10642
  const Callout = (props) => {
10643
- const { attributes, theme = 'default', empty } = props;
10643
+ const { attributes, empty } = props;
10644
10644
  const children = external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.Children.toArray(props.children);
10645
10645
  const icon = props.icon;
10646
10646
  const isEmoji = icon && emoji_regex().test(icon);
10647
10647
  const heading = empty ? external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("p", { className: 'callout-heading empty' }) : children[0];
10648
+ const theme = props.theme || (icon && themes[icon]) || 'default';
10648
10649
  return (
10649
10650
  // @ts-expect-error -- theme is not a valid attribute
10650
10651
  // eslint-disable-next-line react/jsx-props-no-spreading, react/no-unknown-property
@@ -39644,8 +39645,10 @@ var NodeTypes;
39644
39645
  NodeTypes["i"] = "i";
39645
39646
  NodeTypes["imageBlock"] = "image-block";
39646
39647
  NodeTypes["plain"] = "plain";
39648
+ NodeTypes["recipe"] = "recipe";
39647
39649
  NodeTypes["reusableContent"] = "reusable-content";
39648
39650
  NodeTypes["tableau"] = "tableau";
39651
+ /** @deprecated Deprecated in favor of `recipe`. */
39649
39652
  NodeTypes["tutorialTile"] = "tutorial-tile";
39650
39653
  NodeTypes["variable"] = "readme-variable";
39651
39654
  })(NodeTypes || (NodeTypes = {}));
@@ -51525,13 +51528,6 @@ const findFirst = (node) => {
51525
51528
  return node;
51526
51529
  return null;
51527
51530
  };
51528
- const findLast = (node) => {
51529
- if ('children' in node && Array.isArray(node.children))
51530
- return findFirst(node.children[node.children.length - 1]);
51531
- if (node.type === 'text')
51532
- return node;
51533
- return null;
51534
- };
51535
51531
  const wrapHeading = (node) => {
51536
51532
  const firstChild = node.children[0];
51537
51533
  return {
@@ -51539,8 +51535,8 @@ const wrapHeading = (node) => {
51539
51535
  depth: 3,
51540
51536
  children: ('children' in firstChild ? firstChild.children : []),
51541
51537
  position: {
51542
- start: findFirst(firstChild)?.position.start,
51543
- end: findLast(firstChild)?.position.end,
51538
+ start: firstChild.position.start,
51539
+ end: firstChild.position.end,
51544
51540
  },
51545
51541
  };
51546
51542
  };
@@ -51562,6 +51558,11 @@ const calloutTransformer = () => {
51562
51558
  }
51563
51559
  if (heading) {
51564
51560
  node.children[0] = wrapHeading(node);
51561
+ // @note: We add to the offset/column the length of the unicode
51562
+ // character that was stripped off, so that the start position of the
51563
+ // heading/text matches where it actually starts.
51564
+ node.children[0].position.start.offset += match.length;
51565
+ node.children[0].position.start.column += match.length;
51565
51566
  }
51566
51567
  Object.assign(node, {
51567
51568
  type: NodeTypes.callout,
@@ -51658,7 +51659,7 @@ const compatibilityTransfomer = () => tree => {
51658
51659
  ;// ./processor/transform/div.ts
51659
51660
 
51660
51661
 
51661
- // This transformer has been necessary for migrating legacy markdown files
51662
+ // This transformer has been necessary for migrating legacy markdown files
51662
51663
  // where tutorial tiles were wrapped in a div. It also provides a fallback for legacy magic blocks that were never fully supported:
51663
51664
  // [block:custom-block]
51664
51665
  // { ... }
@@ -51676,7 +51677,7 @@ const divTransformer = () => tree => {
51676
51677
  const { hName, hProperties, ...rest } = node.data;
51677
51678
  const tile = {
51678
51679
  ...rest,
51679
- type: NodeTypes.tutorialTile,
51680
+ type: NodeTypes.recipe,
51680
51681
  };
51681
51682
  parent.children.splice(index, 1, tile);
51682
51683
  }
@@ -69173,7 +69174,8 @@ const types = {
69173
69174
  HTMLBlock: NodeTypes.htmlBlock,
69174
69175
  Table: 'table',
69175
69176
  Variable: NodeTypes.variable,
69176
- TutorialTile: NodeTypes.tutorialTile,
69177
+ Recipe: NodeTypes.recipe,
69178
+ TutorialTile: NodeTypes.recipe, // coerce to recipe for backwards compatibility
69177
69179
  };
69178
69180
  var TableNames;
69179
69181
  (function (TableNames) {
@@ -69557,7 +69559,7 @@ const visitor = (table, index, parent) => {
69557
69559
  visit(cell, 'break', (_, breakIndex, breakParent) => {
69558
69560
  breakParent.children.splice(breakIndex, 1, { type: 'text', value: '\n' });
69559
69561
  });
69560
- if (!phrasing(content) && content.type !== 'escape') {
69562
+ if (!(phrasing(content) || content.type === 'plain') && content.type !== 'escape') {
69561
69563
  hasFlowContent = true;
69562
69564
  return EXIT;
69563
69565
  }
@@ -89598,8 +89600,8 @@ const makeUseMDXComponents = (more = {}) => {
89598
89600
  'html-block': components_HTMLBlock,
89599
89601
  'image-block': components_Image,
89600
89602
  'table-of-contents': components_TableOfContents,
89601
- // Ensures backwards compatibility with historical TutoirialTile component
89602
- 'TutorialTile': components_Recipe,
89603
+ // Ensures backwards compatibility with historical TutorialTile component
89604
+ TutorialTile: components_Recipe,
89603
89605
  ...headings,
89604
89606
  ...more,
89605
89607
  };
package/dist/main.node.js CHANGED
@@ -16196,11 +16196,12 @@ const defaultIcons = {
16196
16196
  error: '\u2757\uFE0F',
16197
16197
  };
16198
16198
  const Callout = (props) => {
16199
- const { attributes, theme = 'default', empty } = props;
16199
+ const { attributes, empty } = props;
16200
16200
  const children = external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.Children.toArray(props.children);
16201
16201
  const icon = props.icon;
16202
16202
  const isEmoji = icon && emoji_regex().test(icon);
16203
16203
  const heading = empty ? external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("p", { className: 'callout-heading empty' }) : children[0];
16204
+ const theme = props.theme || (icon && themes[icon]) || 'default';
16204
16205
  return (
16205
16206
  // @ts-expect-error -- theme is not a valid attribute
16206
16207
  // eslint-disable-next-line react/jsx-props-no-spreading, react/no-unknown-property
@@ -57727,8 +57728,10 @@ var NodeTypes;
57727
57728
  NodeTypes["i"] = "i";
57728
57729
  NodeTypes["imageBlock"] = "image-block";
57729
57730
  NodeTypes["plain"] = "plain";
57731
+ NodeTypes["recipe"] = "recipe";
57730
57732
  NodeTypes["reusableContent"] = "reusable-content";
57731
57733
  NodeTypes["tableau"] = "tableau";
57734
+ /** @deprecated Deprecated in favor of `recipe`. */
57732
57735
  NodeTypes["tutorialTile"] = "tutorial-tile";
57733
57736
  NodeTypes["variable"] = "readme-variable";
57734
57737
  })(NodeTypes || (NodeTypes = {}));
@@ -69608,13 +69611,6 @@ const findFirst = (node) => {
69608
69611
  return node;
69609
69612
  return null;
69610
69613
  };
69611
- const findLast = (node) => {
69612
- if ('children' in node && Array.isArray(node.children))
69613
- return findFirst(node.children[node.children.length - 1]);
69614
- if (node.type === 'text')
69615
- return node;
69616
- return null;
69617
- };
69618
69614
  const wrapHeading = (node) => {
69619
69615
  const firstChild = node.children[0];
69620
69616
  return {
@@ -69622,8 +69618,8 @@ const wrapHeading = (node) => {
69622
69618
  depth: 3,
69623
69619
  children: ('children' in firstChild ? firstChild.children : []),
69624
69620
  position: {
69625
- start: findFirst(firstChild)?.position.start,
69626
- end: findLast(firstChild)?.position.end,
69621
+ start: firstChild.position.start,
69622
+ end: firstChild.position.end,
69627
69623
  },
69628
69624
  };
69629
69625
  };
@@ -69645,6 +69641,11 @@ const calloutTransformer = () => {
69645
69641
  }
69646
69642
  if (heading) {
69647
69643
  node.children[0] = wrapHeading(node);
69644
+ // @note: We add to the offset/column the length of the unicode
69645
+ // character that was stripped off, so that the start position of the
69646
+ // heading/text matches where it actually starts.
69647
+ node.children[0].position.start.offset += match.length;
69648
+ node.children[0].position.start.column += match.length;
69648
69649
  }
69649
69650
  Object.assign(node, {
69650
69651
  type: NodeTypes.callout,
@@ -69741,7 +69742,7 @@ const compatibilityTransfomer = () => tree => {
69741
69742
  ;// ./processor/transform/div.ts
69742
69743
 
69743
69744
 
69744
- // This transformer has been necessary for migrating legacy markdown files
69745
+ // This transformer has been necessary for migrating legacy markdown files
69745
69746
  // where tutorial tiles were wrapped in a div. It also provides a fallback for legacy magic blocks that were never fully supported:
69746
69747
  // [block:custom-block]
69747
69748
  // { ... }
@@ -69759,7 +69760,7 @@ const divTransformer = () => tree => {
69759
69760
  const { hName, hProperties, ...rest } = node.data;
69760
69761
  const tile = {
69761
69762
  ...rest,
69762
- type: NodeTypes.tutorialTile,
69763
+ type: NodeTypes.recipe,
69763
69764
  };
69764
69765
  parent.children.splice(index, 1, tile);
69765
69766
  }
@@ -87256,7 +87257,8 @@ const readme_components_types = {
87256
87257
  HTMLBlock: NodeTypes.htmlBlock,
87257
87258
  Table: 'table',
87258
87259
  Variable: NodeTypes.variable,
87259
- TutorialTile: NodeTypes.tutorialTile,
87260
+ Recipe: NodeTypes.recipe,
87261
+ TutorialTile: NodeTypes.recipe, // coerce to recipe for backwards compatibility
87260
87262
  };
87261
87263
  var TableNames;
87262
87264
  (function (TableNames) {
@@ -87640,7 +87642,7 @@ const visitor = (table, index, parent) => {
87640
87642
  visit(cell, 'break', (_, breakIndex, breakParent) => {
87641
87643
  breakParent.children.splice(breakIndex, 1, { type: 'text', value: '\n' });
87642
87644
  });
87643
- if (!phrasing(content) && content.type !== 'escape') {
87645
+ if (!(phrasing(content) || content.type === 'plain') && content.type !== 'escape') {
87644
87646
  hasFlowContent = true;
87645
87647
  return EXIT;
87646
87648
  }
@@ -107681,8 +107683,8 @@ const makeUseMDXComponents = (more = {}) => {
107681
107683
  'html-block': components_HTMLBlock,
107682
107684
  'image-block': components_Image,
107683
107685
  'table-of-contents': components_TableOfContents,
107684
- // Ensures backwards compatibility with historical TutoirialTile component
107685
- 'TutorialTile': components_Recipe,
107686
+ // Ensures backwards compatibility with historical TutorialTile component
107687
+ TutorialTile: components_Recipe,
107686
107688
  ...headings,
107687
107689
  ...more,
107688
107690
  };