@redocly/theme 0.69.0 → 0.70.0-next.0

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.
Files changed (181) hide show
  1. package/lib/components/Buttons/DownloadButton.js +13 -3
  2. package/lib/components/Catalog/Catalog.d.ts +2 -2
  3. package/lib/components/Catalog/CatalogActionsRow.d.ts +3 -2
  4. package/lib/components/Catalog/CatalogCardView/CatalogCard.d.ts +2 -2
  5. package/lib/components/Catalog/CatalogEntities.d.ts +2 -2
  6. package/lib/components/Catalog/CatalogEntitiesEmptyState.d.ts +1 -1
  7. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.d.ts +2 -2
  8. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.js +1 -2
  9. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton.d.ts +3 -1
  10. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton.js +45 -23
  11. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.js +67 -33
  12. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem.d.ts +3 -1
  13. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem.js +15 -3
  14. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.d.ts +3 -1
  15. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.js +48 -57
  16. package/lib/components/Catalog/CatalogEntity/CatalogEntityInfoBar.d.ts +1 -1
  17. package/lib/components/Catalog/CatalogEntity/CatalogEntityLinks.d.ts +1 -1
  18. package/lib/components/Catalog/CatalogEntity/CatalogEntityMetadata.d.ts +1 -1
  19. package/lib/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.d.ts +1 -1
  20. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.d.ts +2 -2
  21. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.d.ts +1 -1
  22. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.d.ts +2 -2
  23. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/DomainsProperty.d.ts +2 -2
  24. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/EntityTypeProperty.d.ts +2 -2
  25. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/FormatProperty.d.ts +2 -2
  26. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/GitProperty.d.ts +2 -2
  27. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/OwnersProperty.d.ts +2 -2
  28. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/OwnersProperty.js +1 -2
  29. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/TagsProperty.d.ts +2 -2
  30. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/UserEmailProperty.d.ts +2 -2
  31. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.d.ts +1 -1
  32. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.d.ts +2 -3
  33. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.d.ts +1 -1
  34. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.d.ts +3 -4
  35. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.d.ts +3 -4
  36. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.d.ts +1 -1
  37. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.js +1 -2
  38. package/lib/components/Catalog/CatalogEntityIcon.d.ts +1 -1
  39. package/lib/components/Catalog/CatalogEntityTypeTag.d.ts +2 -2
  40. package/lib/components/Catalog/CatalogFilter/CatalogFilterContent.d.ts +1 -1
  41. package/lib/components/Catalog/CatalogFilter/CatalogFilterContent.js +1 -2
  42. package/lib/components/Catalog/CatalogHighlight.d.ts +2 -1
  43. package/lib/components/Catalog/CatalogMobileFiltersPanel/CatalogMobileFiltersPanel.d.ts +2 -1
  44. package/lib/components/Catalog/CatalogMobileFiltersPanel/CatalogMobileFiltersPanelHeader.d.ts +1 -1
  45. package/lib/components/Catalog/CatalogMobileFiltersPanel/CatalogMobileFiltersPanelOverlay.d.ts +2 -1
  46. package/lib/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBar.d.ts +2 -2
  47. package/lib/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBarControls.d.ts +2 -2
  48. package/lib/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBarFiltersButton.d.ts +1 -1
  49. package/lib/components/Catalog/CatalogSelector.d.ts +3 -2
  50. package/lib/components/Catalog/CatalogTableView/CatalogEntityCell.d.ts +1 -1
  51. package/lib/components/Catalog/CatalogTableView/CatalogTableHeaderCell.d.ts +1 -1
  52. package/lib/components/Catalog/CatalogTableView/CatalogTableView.d.ts +2 -1
  53. package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.d.ts +2 -1
  54. package/lib/components/Catalog/CatalogTableView/CatalogTagsCell.d.ts +1 -1
  55. package/lib/components/Catalog/CatalogTags.d.ts +2 -2
  56. package/lib/components/Catalog/CatalogViewModeToggle.d.ts +1 -1
  57. package/lib/components/Catalog/variables.js +24 -33
  58. package/lib/components/CatalogClassic/CatalogClassicInfoBlock.d.ts +1 -1
  59. package/lib/components/CatalogClassic/CatalogClassicInfoBlock.js +1 -2
  60. package/lib/components/CatalogClassic/CatalogClassicVirtualizedGroups.d.ts +1 -1
  61. package/lib/components/CodeBlock/CodeBlockControls.d.ts +1 -1
  62. package/lib/components/Dropdown/Dropdown.js +7 -1
  63. package/lib/components/Filter/FilterOptionLabel.d.ts +1 -1
  64. package/lib/components/LoadMore/LoadMore.d.ts +1 -1
  65. package/lib/components/MCP/McpConnectionTabs.js +2 -2
  66. package/lib/components/PageActions/PageActions.d.ts +1 -1
  67. package/lib/components/Search/SearchAiDialog.d.ts +1 -1
  68. package/lib/components/Search/SearchAiMessage.d.ts +1 -2
  69. package/lib/components/Search/SearchAiMessage.js +8 -10
  70. package/lib/components/Search/SearchAiResponse.d.ts +1 -1
  71. package/lib/components/Search/SearchGroups.d.ts +1 -1
  72. package/lib/core/constants/markdown.d.ts +2 -0
  73. package/lib/core/constants/markdown.js +3 -1
  74. package/lib/core/hooks/catalog/use-catalog-entity-schema.d.ts +1 -1
  75. package/lib/core/hooks/catalog/use-catalog-table-header-cell-actions.d.ts +1 -1
  76. package/lib/core/hooks/catalog/use-graph.d.ts +3 -3
  77. package/lib/core/hooks/use-active-section-id.js +6 -0
  78. package/lib/core/hooks/use-element-size.d.ts +1 -1
  79. package/lib/core/types/catalog.d.ts +2 -3
  80. package/lib/core/types/common.d.ts +1 -1
  81. package/lib/core/types/hooks.d.ts +4 -7
  82. package/lib/core/utils/mcp.d.ts +0 -1
  83. package/lib/core/utils/mcp.js +0 -13
  84. package/lib/core/utils/menu.d.ts +2 -2
  85. package/lib/core/utils/urls.js +1 -3
  86. package/lib/ext/use-configure-replay.d.ts +1 -1
  87. package/lib/layouts/OIDCForbidden.js +1 -1
  88. package/lib/markdoc/components/CodeWalkthrough/CodePanelPreview.d.ts +1 -2
  89. package/lib/markdoc/components/Diagram/Diagram.d.ts +1 -1
  90. package/lib/markdoc/components/Diagram/Diagram.js +1 -2
  91. package/lib/markdoc/components/Tabs/Tab.d.ts +1 -1
  92. package/lib/markdoc/components/Tabs/TabList.d.ts +1 -1
  93. package/lib/markdoc/tags/code-walkthrough.d.ts +1 -1
  94. package/lib/markdoc/tags/markdoc-example.js +34 -22
  95. package/package.json +2 -2
  96. package/src/components/Buttons/DownloadButton.tsx +16 -8
  97. package/src/components/Catalog/Catalog.tsx +4 -4
  98. package/src/components/Catalog/CatalogActionsRow.tsx +3 -2
  99. package/src/components/Catalog/CatalogCardView/CatalogCard.tsx +3 -2
  100. package/src/components/Catalog/CatalogEntities.tsx +3 -2
  101. package/src/components/Catalog/CatalogEntitiesEmptyState.tsx +2 -1
  102. package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +6 -2
  103. package/src/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.tsx +4 -5
  104. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton.tsx +56 -35
  105. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.tsx +80 -42
  106. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem.tsx +18 -2
  107. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.tsx +61 -75
  108. package/src/components/Catalog/CatalogEntity/CatalogEntityInfoBar.tsx +2 -1
  109. package/src/components/Catalog/CatalogEntity/CatalogEntityLinks.tsx +1 -1
  110. package/src/components/Catalog/CatalogEntity/CatalogEntityMetadata.tsx +1 -1
  111. package/src/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.tsx +1 -1
  112. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.tsx +3 -2
  113. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.tsx +2 -1
  114. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.tsx +3 -2
  115. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/DomainsProperty.tsx +3 -2
  116. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/EntityTypeProperty.tsx +3 -2
  117. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/FormatProperty.tsx +3 -2
  118. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/GitProperty.tsx +3 -2
  119. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/OwnersProperty.tsx +3 -4
  120. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/TagsProperty.tsx +3 -2
  121. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/UserEmailProperty.tsx +3 -2
  122. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +2 -1
  123. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.tsx +7 -4
  124. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +2 -1
  125. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.tsx +7 -4
  126. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.tsx +3 -4
  127. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +3 -2
  128. package/src/components/Catalog/CatalogEntity/CatalogEntitySchema.tsx +1 -2
  129. package/src/components/Catalog/CatalogEntityIcon.tsx +3 -2
  130. package/src/components/Catalog/CatalogEntityTypeTag.tsx +3 -2
  131. package/src/components/Catalog/CatalogFilter/CatalogFilterContent.tsx +2 -4
  132. package/src/components/Catalog/CatalogHighlight.tsx +2 -1
  133. package/src/components/Catalog/CatalogMobileFiltersPanel/CatalogMobileFiltersPanel.tsx +2 -1
  134. package/src/components/Catalog/CatalogMobileFiltersPanel/CatalogMobileFiltersPanelHeader.tsx +2 -1
  135. package/src/components/Catalog/CatalogMobileFiltersPanel/CatalogMobileFiltersPanelOverlay.tsx +2 -1
  136. package/src/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBar.tsx +3 -2
  137. package/src/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBarControls.tsx +3 -2
  138. package/src/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBarFiltersButton.tsx +2 -1
  139. package/src/components/Catalog/CatalogSelector.tsx +3 -2
  140. package/src/components/Catalog/CatalogTableView/CatalogEntityCell.tsx +1 -1
  141. package/src/components/Catalog/CatalogTableView/CatalogTableHeaderCell.tsx +1 -1
  142. package/src/components/Catalog/CatalogTableView/CatalogTableView.tsx +2 -1
  143. package/src/components/Catalog/CatalogTableView/CatalogTableViewRow.tsx +2 -1
  144. package/src/components/Catalog/CatalogTableView/CatalogTagsCell.tsx +1 -1
  145. package/src/components/Catalog/CatalogTags.tsx +4 -2
  146. package/src/components/Catalog/CatalogViewModeToggle.tsx +1 -1
  147. package/src/components/Catalog/variables.ts +24 -33
  148. package/src/components/CatalogClassic/CatalogClassicInfoBlock.tsx +2 -5
  149. package/src/components/CatalogClassic/CatalogClassicVirtualizedGroups.tsx +1 -1
  150. package/src/components/CodeBlock/CodeBlockControls.tsx +2 -1
  151. package/src/components/Dropdown/Dropdown.tsx +5 -1
  152. package/src/components/Filter/FilterOptionLabel.tsx +1 -1
  153. package/src/components/LoadMore/LoadMore.tsx +2 -1
  154. package/src/components/MCP/McpConnectionTabs.tsx +3 -4
  155. package/src/components/PageActions/PageActions.tsx +2 -1
  156. package/src/components/Search/SearchAiDialog.tsx +1 -1
  157. package/src/components/Search/SearchAiMessage.tsx +3 -6
  158. package/src/components/Search/SearchAiResponse.tsx +2 -4
  159. package/src/components/Search/SearchGroups.tsx +1 -5
  160. package/src/core/constants/markdown.ts +4 -0
  161. package/src/core/hooks/catalog/use-catalog-entity-schema.ts +1 -1
  162. package/src/core/hooks/catalog/use-catalog-table-header-cell-actions.ts +1 -1
  163. package/src/core/hooks/catalog/use-graph.ts +4 -4
  164. package/src/core/hooks/menu/__mocks__/use-mobile-menu-items.ts +1 -1
  165. package/src/core/hooks/use-active-section-id.ts +8 -0
  166. package/src/core/hooks/use-element-size.ts +2 -1
  167. package/src/core/types/catalog.ts +7 -3
  168. package/src/core/types/common.ts +1 -1
  169. package/src/core/types/hooks.ts +15 -13
  170. package/src/core/utils/mcp.ts +0 -17
  171. package/src/core/utils/menu.ts +2 -2
  172. package/src/core/utils/urls.ts +1 -3
  173. package/src/ext/use-configure-replay.ts +3 -3
  174. package/src/layouts/OIDCForbidden.tsx +1 -1
  175. package/src/markdoc/components/CodeWalkthrough/CodePanelPreview.tsx +2 -2
  176. package/src/markdoc/components/CodeWalkthrough/CodeWalkthrough.tsx +2 -4
  177. package/src/markdoc/components/Diagram/Diagram.tsx +2 -5
  178. package/src/markdoc/components/Tabs/Tab.tsx +1 -1
  179. package/src/markdoc/components/Tabs/TabList.tsx +1 -1
  180. package/src/markdoc/tags/code-walkthrough.ts +2 -1
  181. package/src/markdoc/tags/markdoc-example.ts +45 -28
@@ -14,7 +14,7 @@ export function OIDCForbidden(): JSX.Element {
14
14
 
15
15
  // use whatever you want here
16
16
  const URL_REGEX =
17
- /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/;
17
+ /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
18
18
 
19
19
  const renderText = (text: string) =>
20
20
  text.split(' ').map((part: string) =>
@@ -1,7 +1,7 @@
1
- import React, { PropsWithChildren, useState } from 'react';
1
+ import React, { useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
- import type { JSX } from 'react';
4
+ import type { JSX, PropsWithChildren } from 'react';
5
5
 
6
6
  import { useThemeHooks } from '@redocly/theme/core/hooks';
7
7
  import { ChevronUpIcon } from '@redocly/theme/icons/ChevronUpIcon/ChevronUpIcon';
@@ -9,10 +9,8 @@ import {
9
9
  } from '@redocly/theme/core/contexts';
10
10
  import { CodePanel } from '@redocly/theme/markdoc/components/CodeWalkthrough/CodePanel';
11
11
  import { useCodeWalkthrough } from '@redocly/theme/core/hooks';
12
- import {
13
- CodeFilters,
14
- GetFilterState,
15
- } from '@redocly/theme/markdoc/components/CodeWalkthrough/CodeFilters';
12
+ import type { GetFilterState } from '@redocly/theme/markdoc/components/CodeWalkthrough/CodeFilters';
13
+ import { CodeFilters } from '@redocly/theme/markdoc/components/CodeWalkthrough/CodeFilters';
16
14
 
17
15
  export type CodeWalkthroughProps = PropsWithChildren<CodeWalkthroughAttr>;
18
16
 
@@ -1,11 +1,8 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, type JSX } from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
- import type { JSX } from 'react';
5
-
6
4
  import { concatClassNames } from '@redocly/theme/core/utils';
7
- import { useColorSwitcher } from '@redocly/theme/core/hooks';
8
- import { useThemeHooks } from '@redocly/theme/core/hooks';
5
+ import { useColorSwitcher, useThemeHooks } from '@redocly/theme/core/hooks';
9
6
  import { SvgViewer } from '@redocly/theme/components/SvgViewer/SvgViewer';
10
7
 
11
8
  type DiagramProps = {
@@ -3,7 +3,7 @@ import styled from 'styled-components';
3
3
 
4
4
  import type { JSX } from 'react';
5
5
 
6
- import { TabsSize } from '@redocly/theme/markdoc/components/Tabs/Tabs';
6
+ import type { TabsSize } from '@redocly/theme/markdoc/components/Tabs/Tabs';
7
7
  import { TabButtonLink, TabItem } from '@redocly/theme/markdoc/components/Tabs/TabList';
8
8
  import { GenericIcon } from '@redocly/theme/icons/GenericIcon/GenericIcon';
9
9
 
@@ -5,7 +5,7 @@ import type { JSX } from 'react';
5
5
  import type { TabItemProps } from '@redocly/theme/markdoc/components/Tabs/TabItemFragment';
6
6
 
7
7
  import { Tab } from '@redocly/theme/markdoc/components/Tabs/Tab';
8
- import { TabsSize } from '@redocly/theme/markdoc/components/Tabs/Tabs';
8
+ import type { TabsSize } from '@redocly/theme/markdoc/components/Tabs/Tabs';
9
9
  import { Dropdown } from '@redocly/theme/components/Dropdown/Dropdown';
10
10
  import { DropdownMenu } from '@redocly/theme/components/Dropdown/DropdownMenu';
11
11
  import { DropdownMenuItem } from '@redocly/theme/components/Dropdown/DropdownMenuItem';
@@ -1,4 +1,5 @@
1
- import markdoc, { Node, RenderableTreeNode, ValidationError } from '@markdoc/markdoc';
1
+ import type { Node, RenderableTreeNode, ValidationError } from '@markdoc/markdoc';
2
+ import markdoc from '@markdoc/markdoc';
2
3
 
3
4
  import type { MarkdocSchemaWrapper } from '@redocly/theme/markdoc/tags/types';
4
5
  import type {
@@ -3,27 +3,7 @@ import markdoc from '@markdoc/markdoc';
3
3
  import type { Config, Node, RenderableTreeNode } from '@markdoc/markdoc';
4
4
  import type { MarkdocSchemaWrapper } from '@redocly/theme/markdoc/tags/types';
5
5
 
6
- // Walk through AST and look for raw markdown to parse
7
- function parseInlineMarkdown(
8
- ast: RenderableTreeNode | RenderableTreeNode[],
9
- config: Config,
10
- ): RenderableTreeNode | RenderableTreeNode[] {
11
- if (Array.isArray(ast)) {
12
- return ast.flatMap((child) => parseInlineMarkdown(child, config));
13
- }
14
-
15
- if (typeof ast === 'string') {
16
- const parsed = markdoc.parse(ast);
17
- return markdoc.transform(parsed, config);
18
- }
19
-
20
- if (ast && typeof ast === 'object' && ast.$$mdtype === 'Tag') {
21
- const children = parseInlineMarkdown(ast.children, config);
22
- return { ...ast, children } as RenderableTreeNode;
23
- }
24
-
25
- return ast;
26
- }
6
+ import { EXAMPLE_CONTENT_ATTRIBUTE, MARKDOC_EXAMPLE_TAG } from '@redocly/theme/core/constants';
27
7
 
28
8
  // This custom tag prevents evaluating any children markdoc tags (no children) so we can
29
9
  // have markdoc examples in code fences
@@ -39,33 +19,70 @@ export const markdocExample: MarkdocSchemaWrapper = {
39
19
  children: ['fence'],
40
20
  transform(node: Node, config: Config) {
41
21
  const attributes = node.transformAttributes(config);
42
- const { content } = node.children[0]?.attributes || {};
22
+ const fenceNode = node.children[0];
23
+ const { content } = fenceNode?.attributes || {};
43
24
  if (!content) return null;
44
25
 
45
26
  const language = 'markdoc';
46
27
 
47
- const annotations = node.children[0].annotations;
28
+ const annotations = fenceNode.annotations;
48
29
  let title = null;
49
30
  if (annotations.length > 0) {
50
31
  const fenceWithTitle = annotations.find((annotation) => annotation.name === 'title');
51
32
  title = fenceWithTitle?.value;
52
33
  }
53
34
 
54
- const demoContent = node.children[0].transformChildren(config);
55
- const parsedDemoContent = parseInlineMarkdown(demoContent, config);
56
-
57
35
  return new markdoc.Tag(
58
36
  'MarkdocExample',
59
37
  {
60
38
  ...attributes,
61
39
  title,
62
40
  language,
63
- demoContent: parsedDemoContent,
41
+ demoContent: transformDemoContent(fenceNode, content, config),
64
42
  rawContent: content,
65
43
  },
66
44
  [],
67
45
  );
68
46
  },
69
47
  },
70
- tagName: 'markdoc-example',
48
+ tagName: MARKDOC_EXAMPLE_TAG,
71
49
  };
50
+
51
+ // Walk through AST and look for raw markdown to parse
52
+ function parseRawMarkdown(
53
+ ast: RenderableTreeNode | RenderableTreeNode[],
54
+ config: Config,
55
+ ): RenderableTreeNode | RenderableTreeNode[] {
56
+ if (Array.isArray(ast)) {
57
+ return ast.flatMap((child) => parseRawMarkdown(child, config));
58
+ }
59
+
60
+ if (typeof ast === 'string') {
61
+ const parsed = markdoc.parse(ast);
62
+ return markdoc.transform(parsed, config);
63
+ }
64
+
65
+ if (ast && typeof ast === 'object' && ast.$$mdtype === 'Tag') {
66
+ const children = parseRawMarkdown(ast.children, config);
67
+ return { ...ast, children } as RenderableTreeNode;
68
+ }
69
+
70
+ return ast;
71
+ }
72
+
73
+ function toRenderableArray(node: RenderableTreeNode | RenderableTreeNode[]): RenderableTreeNode[] {
74
+ return Array.isArray(node) ? node : [node];
75
+ }
76
+
77
+ function transformDemoContent(fenceNode: Node, content: string, config: Config) {
78
+ const parsedBody = fenceNode.attributes[EXAMPLE_CONTENT_ATTRIBUTE] as Node | undefined;
79
+ if (parsedBody) {
80
+ return toRenderableArray(markdoc.transform(parsedBody.children, config));
81
+ }
82
+
83
+ if (!fenceNode.children.length) {
84
+ return toRenderableArray(markdoc.transform(markdoc.parse(content).children, config));
85
+ }
86
+
87
+ return toRenderableArray(parseRawMarkdown(fenceNode.transformChildren(config), config));
88
+ }