@multiplatform.one/markdown 6.0.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.
- package/LICENSE +201 -0
- package/dist/cjs/Aside/index.cjs +112 -0
- package/dist/cjs/Aside/index.native.js +119 -0
- package/dist/cjs/Aside/index.native.js.map +1 -0
- package/dist/cjs/ExternalIcon/ExternalIcon.spec.cjs +37 -0
- package/dist/cjs/ExternalIcon/ExternalIcon.spec.native.js +40 -0
- package/dist/cjs/ExternalIcon/ExternalIcon.spec.native.js.map +1 -0
- package/dist/cjs/ExternalIcon/index.cjs +46 -0
- package/dist/cjs/ExternalIcon/index.native.js +51 -0
- package/dist/cjs/ExternalIcon/index.native.js.map +1 -0
- package/dist/cjs/Hr/hr.spec.cjs +21 -0
- package/dist/cjs/Hr/hr.spec.native.js +24 -0
- package/dist/cjs/Hr/hr.spec.native.js.map +1 -0
- package/dist/cjs/Hr/index.cjs +41 -0
- package/dist/cjs/Hr/index.native.js +46 -0
- package/dist/cjs/Hr/index.native.js.map +1 -0
- package/dist/cjs/Li/index.cjs +38 -0
- package/dist/cjs/Li/index.native.js +41 -0
- package/dist/cjs/Li/index.native.js.map +1 -0
- package/dist/cjs/Li/li.spec.cjs +45 -0
- package/dist/cjs/Li/li.spec.native.js +50 -0
- package/dist/cjs/Li/li.spec.native.js.map +1 -0
- package/dist/cjs/Markdown.cjs +66 -0
- package/dist/cjs/Markdown.native.js +71 -0
- package/dist/cjs/Markdown.native.js.map +1 -0
- package/dist/cjs/Markdown.stories.cjs +153 -0
- package/dist/cjs/Markdown.stories.native.js +162 -0
- package/dist/cjs/Markdown.stories.native.js.map +1 -0
- package/dist/cjs/Mdx/index.cjs +58 -0
- package/dist/cjs/Mdx/index.native.js +62 -0
- package/dist/cjs/Mdx/index.native.js.map +1 -0
- package/dist/cjs/Mdx/mdx.spec.cjs +139 -0
- package/dist/cjs/Mdx/mdx.spec.native.js +158 -0
- package/dist/cjs/Mdx/mdx.spec.native.js.map +1 -0
- package/dist/cjs/MdxCodeBlock/index.cjs +185 -0
- package/dist/cjs/MdxCodeBlock/index.native.js +205 -0
- package/dist/cjs/MdxCodeBlock/index.native.js.map +1 -0
- package/dist/cjs/MdxCodeBlock/mdxCodeBlock.spec.cjs +90 -0
- package/dist/cjs/MdxCodeBlock/mdxCodeBlock.spec.native.js +122 -0
- package/dist/cjs/MdxCodeBlock/mdxCodeBlock.spec.native.js.map +1 -0
- package/dist/cjs/MdxCodeBlock/mdxCodeBlockContext.cjs +29 -0
- package/dist/cjs/MdxCodeBlock/mdxCodeBlockContext.native.js +32 -0
- package/dist/cjs/MdxCodeBlock/mdxCodeBlockContext.native.js.map +1 -0
- package/dist/cjs/Notice/index.cjs +94 -0
- package/dist/cjs/Notice/index.native.js +98 -0
- package/dist/cjs/Notice/index.native.js.map +1 -0
- package/dist/cjs/SimpleTable/index.cjs +132 -0
- package/dist/cjs/SimpleTable/index.native.js +162 -0
- package/dist/cjs/SimpleTable/index.native.js.map +1 -0
- package/dist/cjs/Table/index.cjs +121 -0
- package/dist/cjs/Table/index.native.js +130 -0
- package/dist/cjs/Table/index.native.js.map +1 -0
- package/dist/cjs/Tabs/index.cjs +93 -0
- package/dist/cjs/Tabs/index.native.js +103 -0
- package/dist/cjs/Tabs/index.native.js.map +1 -0
- package/dist/cjs/Ul/index.cjs +35 -0
- package/dist/cjs/Ul/index.native.js +38 -0
- package/dist/cjs/Ul/index.native.js.map +1 -0
- package/dist/cjs/Ul/ul.spec.cjs +150 -0
- package/dist/cjs/Ul/ul.spec.native.js +153 -0
- package/dist/cjs/Ul/ul.spec.native.js.map +1 -0
- package/dist/cjs/Video/index.cjs +84 -0
- package/dist/cjs/Video/index.native.js +89 -0
- package/dist/cjs/Video/index.native.js.map +1 -0
- package/dist/cjs/components/Blockquote.cjs +47 -0
- package/dist/cjs/components/Blockquote.native.js +51 -0
- package/dist/cjs/components/Blockquote.native.js.map +1 -0
- package/dist/cjs/components/Break.cjs +34 -0
- package/dist/cjs/components/Break.native.js +37 -0
- package/dist/cjs/components/Break.native.js.map +1 -0
- package/dist/cjs/components/CodeBlock.cjs +109 -0
- package/dist/cjs/components/CodeBlock.native.js +119 -0
- package/dist/cjs/components/CodeBlock.native.js.map +1 -0
- package/dist/cjs/components/Heading.cjs +48 -0
- package/dist/cjs/components/Heading.native.js +52 -0
- package/dist/cjs/components/Heading.native.js.map +1 -0
- package/dist/cjs/components/HorizontalRule.cjs +34 -0
- package/dist/cjs/components/HorizontalRule.native.js +37 -0
- package/dist/cjs/components/HorizontalRule.native.js.map +1 -0
- package/dist/cjs/components/Image.cjs +53 -0
- package/dist/cjs/components/Image.native.js +57 -0
- package/dist/cjs/components/Image.native.js.map +1 -0
- package/dist/cjs/components/InlineCode.cjs +48 -0
- package/dist/cjs/components/InlineCode.native.js +52 -0
- package/dist/cjs/components/InlineCode.native.js.map +1 -0
- package/dist/cjs/components/InlineStyles.cjs +55 -0
- package/dist/cjs/components/InlineStyles.native.js +61 -0
- package/dist/cjs/components/InlineStyles.native.js.map +1 -0
- package/dist/cjs/components/Link.cjs +54 -0
- package/dist/cjs/components/Link.native.js +58 -0
- package/dist/cjs/components/Link.native.js.map +1 -0
- package/dist/cjs/components/List.cjs +74 -0
- package/dist/cjs/components/List.native.js +79 -0
- package/dist/cjs/components/List.native.js.map +1 -0
- package/dist/cjs/components/Paragraph.cjs +38 -0
- package/dist/cjs/components/Paragraph.native.js +42 -0
- package/dist/cjs/components/Paragraph.native.js.map +1 -0
- package/dist/cjs/components/Table.cjs +86 -0
- package/dist/cjs/components/Table.native.js +92 -0
- package/dist/cjs/components/Table.native.js.map +1 -0
- package/dist/cjs/components/index.cjs +55 -0
- package/dist/cjs/components/index.native.js +58 -0
- package/dist/cjs/components/index.native.js.map +1 -0
- package/dist/cjs/hooks/index.cjs +22 -0
- package/dist/cjs/hooks/index.native.js +25 -0
- package/dist/cjs/hooks/index.native.js.map +1 -0
- package/dist/cjs/hooks/useCompileAndEvaluateMdx.cjs +42 -0
- package/dist/cjs/hooks/useCompileAndEvaluateMdx.native.js +45 -0
- package/dist/cjs/hooks/useCompileAndEvaluateMdx.native.js.map +1 -0
- package/dist/cjs/hooks/useCompileAndEvaluateMdx.spec.cjs +34 -0
- package/dist/cjs/hooks/useCompileAndEvaluateMdx.spec.native.js +49 -0
- package/dist/cjs/hooks/useCompileAndEvaluateMdx.spec.native.js.map +1 -0
- package/dist/cjs/hooks/useCompileMdx.cjs +80 -0
- package/dist/cjs/hooks/useCompileMdx.native.js +83 -0
- package/dist/cjs/hooks/useCompileMdx.native.js.map +1 -0
- package/dist/cjs/hooks/useEvaluateMdx.cjs +58 -0
- package/dist/cjs/hooks/useEvaluateMdx.native.js +63 -0
- package/dist/cjs/hooks/useEvaluateMdx.native.js.map +1 -0
- package/dist/cjs/icons/index.cjs +205 -0
- package/dist/cjs/icons/index.native.js +226 -0
- package/dist/cjs/icons/index.native.js.map +1 -0
- package/dist/cjs/index.cjs +51 -0
- package/dist/cjs/index.native.js +54 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/mdx.spec.cjs +400 -0
- package/dist/cjs/mdx.spec.native.js +465 -0
- package/dist/cjs/mdx.spec.native.js.map +1 -0
- package/dist/cjs/mdxComponents.cjs +317 -0
- package/dist/cjs/mdxComponents.native.js +376 -0
- package/dist/cjs/mdxComponents.native.js.map +1 -0
- package/dist/cjs/parser.cjs +49 -0
- package/dist/cjs/parser.native.js +52 -0
- package/dist/cjs/parser.native.js.map +1 -0
- package/dist/cjs/parser.spec.cjs +109 -0
- package/dist/cjs/parser.spec.native.js +114 -0
- package/dist/cjs/parser.spec.native.js.map +1 -0
- package/dist/cjs/renderer.cjs +326 -0
- package/dist/cjs/renderer.native.js +348 -0
- package/dist/cjs/renderer.native.js.map +1 -0
- package/dist/cjs/shared/colorRamps.cjs +74 -0
- package/dist/cjs/shared/colorRamps.native.js +77 -0
- package/dist/cjs/shared/colorRamps.native.js.map +1 -0
- package/dist/cjs/shared/index.cjs +20 -0
- package/dist/cjs/shared/index.native.js +23 -0
- package/dist/cjs/shared/index.native.js.map +1 -0
- package/dist/cjs/shiki/highlighter.cjs +89 -0
- package/dist/cjs/shiki/highlighter.native.js +94 -0
- package/dist/cjs/shiki/highlighter.native.js.map +1 -0
- package/dist/cjs/shiki/index.cjs +33 -0
- package/dist/cjs/shiki/index.native.js +36 -0
- package/dist/cjs/shiki/index.native.js.map +1 -0
- package/dist/cjs/types.cjs +18 -0
- package/dist/cjs/types.native.js +21 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/cjs/util/rehypeMetaAttributes.cjs +45 -0
- package/dist/cjs/util/rehypeMetaAttributes.native.js +49 -0
- package/dist/cjs/util/rehypeMetaAttributes.native.js.map +1 -0
- package/dist/cjs/util/util.spec.cjs +81 -0
- package/dist/cjs/util/util.spec.native.js +84 -0
- package/dist/cjs/util/util.spec.native.js.map +1 -0
- package/dist/esm/Aside/index.mjs +86 -0
- package/dist/esm/Aside/index.mjs.map +1 -0
- package/dist/esm/Aside/index.native.js +90 -0
- package/dist/esm/Aside/index.native.js.map +1 -0
- package/dist/esm/ExternalIcon/ExternalIcon.spec.mjs +38 -0
- package/dist/esm/ExternalIcon/ExternalIcon.spec.mjs.map +1 -0
- package/dist/esm/ExternalIcon/ExternalIcon.spec.native.js +38 -0
- package/dist/esm/ExternalIcon/ExternalIcon.spec.native.js.map +1 -0
- package/dist/esm/ExternalIcon/index.mjs +21 -0
- package/dist/esm/ExternalIcon/index.mjs.map +1 -0
- package/dist/esm/ExternalIcon/index.native.js +23 -0
- package/dist/esm/ExternalIcon/index.native.js.map +1 -0
- package/dist/esm/Hr/hr.spec.mjs +22 -0
- package/dist/esm/Hr/hr.spec.mjs.map +1 -0
- package/dist/esm/Hr/hr.spec.native.js +22 -0
- package/dist/esm/Hr/hr.spec.native.js.map +1 -0
- package/dist/esm/Hr/index.mjs +16 -0
- package/dist/esm/Hr/index.mjs.map +1 -0
- package/dist/esm/Hr/index.native.js +18 -0
- package/dist/esm/Hr/index.native.js.map +1 -0
- package/dist/esm/Li/index.mjs +13 -0
- package/dist/esm/Li/index.mjs.map +1 -0
- package/dist/esm/Li/index.native.js +13 -0
- package/dist/esm/Li/index.native.js.map +1 -0
- package/dist/esm/Li/li.spec.mjs +46 -0
- package/dist/esm/Li/li.spec.mjs.map +1 -0
- package/dist/esm/Li/li.spec.native.js +48 -0
- package/dist/esm/Li/li.spec.native.js.map +1 -0
- package/dist/esm/Markdown.mjs +41 -0
- package/dist/esm/Markdown.mjs.map +1 -0
- package/dist/esm/Markdown.native.js +43 -0
- package/dist/esm/Markdown.native.js.map +1 -0
- package/dist/esm/Markdown.stories.mjs +125 -0
- package/dist/esm/Markdown.stories.mjs.map +1 -0
- package/dist/esm/Markdown.stories.native.js +131 -0
- package/dist/esm/Markdown.stories.native.js.map +1 -0
- package/dist/esm/Mdx/index.mjs +33 -0
- package/dist/esm/Mdx/index.mjs.map +1 -0
- package/dist/esm/Mdx/index.native.js +34 -0
- package/dist/esm/Mdx/index.native.js.map +1 -0
- package/dist/esm/Mdx/mdx.spec.mjs +140 -0
- package/dist/esm/Mdx/mdx.spec.mjs.map +1 -0
- package/dist/esm/Mdx/mdx.spec.native.js +156 -0
- package/dist/esm/Mdx/mdx.spec.native.js.map +1 -0
- package/dist/esm/MdxCodeBlock/index.mjs +149 -0
- package/dist/esm/MdxCodeBlock/index.mjs.map +1 -0
- package/dist/esm/MdxCodeBlock/index.native.js +166 -0
- package/dist/esm/MdxCodeBlock/index.native.js.map +1 -0
- package/dist/esm/MdxCodeBlock/mdxCodeBlock.spec.mjs +91 -0
- package/dist/esm/MdxCodeBlock/mdxCodeBlock.spec.mjs.map +1 -0
- package/dist/esm/MdxCodeBlock/mdxCodeBlock.spec.native.js +96 -0
- package/dist/esm/MdxCodeBlock/mdxCodeBlock.spec.native.js.map +1 -0
- package/dist/esm/MdxCodeBlock/mdxCodeBlockContext.mjs +4 -0
- package/dist/esm/MdxCodeBlock/mdxCodeBlockContext.mjs.map +1 -0
- package/dist/esm/MdxCodeBlock/mdxCodeBlockContext.native.js +4 -0
- package/dist/esm/MdxCodeBlock/mdxCodeBlockContext.native.js.map +1 -0
- package/dist/esm/Notice/index.mjs +68 -0
- package/dist/esm/Notice/index.mjs.map +1 -0
- package/dist/esm/Notice/index.native.js +69 -0
- package/dist/esm/Notice/index.native.js.map +1 -0
- package/dist/esm/SimpleTable/index.mjs +107 -0
- package/dist/esm/SimpleTable/index.mjs.map +1 -0
- package/dist/esm/SimpleTable/index.native.js +134 -0
- package/dist/esm/SimpleTable/index.native.js.map +1 -0
- package/dist/esm/Table/index.mjs +91 -0
- package/dist/esm/Table/index.mjs.map +1 -0
- package/dist/esm/Table/index.native.js +97 -0
- package/dist/esm/Table/index.native.js.map +1 -0
- package/dist/esm/Tabs/index.mjs +67 -0
- package/dist/esm/Tabs/index.mjs.map +1 -0
- package/dist/esm/Tabs/index.native.js +74 -0
- package/dist/esm/Tabs/index.native.js.map +1 -0
- package/dist/esm/Ul/index.mjs +10 -0
- package/dist/esm/Ul/index.mjs.map +1 -0
- package/dist/esm/Ul/index.native.js +10 -0
- package/dist/esm/Ul/index.native.js.map +1 -0
- package/dist/esm/Ul/ul.spec.mjs +151 -0
- package/dist/esm/Ul/ul.spec.mjs.map +1 -0
- package/dist/esm/Ul/ul.spec.native.js +151 -0
- package/dist/esm/Ul/ul.spec.native.js.map +1 -0
- package/dist/esm/Video/index.mjs +59 -0
- package/dist/esm/Video/index.mjs.map +1 -0
- package/dist/esm/Video/index.native.js +61 -0
- package/dist/esm/Video/index.native.js.map +1 -0
- package/dist/esm/components/Blockquote.mjs +22 -0
- package/dist/esm/components/Blockquote.mjs.map +1 -0
- package/dist/esm/components/Blockquote.native.js +23 -0
- package/dist/esm/components/Blockquote.native.js.map +1 -0
- package/dist/esm/components/Break.mjs +9 -0
- package/dist/esm/components/Break.mjs.map +1 -0
- package/dist/esm/components/Break.native.js +9 -0
- package/dist/esm/components/Break.native.js.map +1 -0
- package/dist/esm/components/CodeBlock.mjs +84 -0
- package/dist/esm/components/CodeBlock.mjs.map +1 -0
- package/dist/esm/components/CodeBlock.native.js +91 -0
- package/dist/esm/components/CodeBlock.native.js.map +1 -0
- package/dist/esm/components/Heading.mjs +23 -0
- package/dist/esm/components/Heading.mjs.map +1 -0
- package/dist/esm/components/Heading.native.js +24 -0
- package/dist/esm/components/Heading.native.js.map +1 -0
- package/dist/esm/components/HorizontalRule.mjs +9 -0
- package/dist/esm/components/HorizontalRule.mjs.map +1 -0
- package/dist/esm/components/HorizontalRule.native.js +9 -0
- package/dist/esm/components/HorizontalRule.native.js.map +1 -0
- package/dist/esm/components/Image.mjs +28 -0
- package/dist/esm/components/Image.mjs.map +1 -0
- package/dist/esm/components/Image.native.js +29 -0
- package/dist/esm/components/Image.native.js.map +1 -0
- package/dist/esm/components/InlineCode.mjs +23 -0
- package/dist/esm/components/InlineCode.mjs.map +1 -0
- package/dist/esm/components/InlineCode.native.js +24 -0
- package/dist/esm/components/InlineCode.native.js.map +1 -0
- package/dist/esm/components/InlineStyles.mjs +28 -0
- package/dist/esm/components/InlineStyles.mjs.map +1 -0
- package/dist/esm/components/InlineStyles.native.js +31 -0
- package/dist/esm/components/InlineStyles.native.js.map +1 -0
- package/dist/esm/components/Link.mjs +29 -0
- package/dist/esm/components/Link.mjs.map +1 -0
- package/dist/esm/components/Link.native.js +30 -0
- package/dist/esm/components/Link.native.js.map +1 -0
- package/dist/esm/components/List.mjs +48 -0
- package/dist/esm/components/List.mjs.map +1 -0
- package/dist/esm/components/List.native.js +50 -0
- package/dist/esm/components/List.native.js.map +1 -0
- package/dist/esm/components/Paragraph.mjs +13 -0
- package/dist/esm/components/Paragraph.mjs.map +1 -0
- package/dist/esm/components/Paragraph.native.js +14 -0
- package/dist/esm/components/Paragraph.native.js.map +1 -0
- package/dist/esm/components/Table.mjs +59 -0
- package/dist/esm/components/Table.mjs.map +1 -0
- package/dist/esm/components/Table.native.js +62 -0
- package/dist/esm/components/Table.native.js.map +1 -0
- package/dist/esm/components/index.mjs +14 -0
- package/dist/esm/components/index.mjs.map +1 -0
- package/dist/esm/components/index.native.js +14 -0
- package/dist/esm/components/index.native.js.map +1 -0
- package/dist/esm/hooks/index.mjs +4 -0
- package/dist/esm/hooks/index.mjs.map +1 -0
- package/dist/esm/hooks/index.native.js +4 -0
- package/dist/esm/hooks/index.native.js.map +1 -0
- package/dist/esm/hooks/useCompileAndEvaluateMdx.mjs +17 -0
- package/dist/esm/hooks/useCompileAndEvaluateMdx.mjs.map +1 -0
- package/dist/esm/hooks/useCompileAndEvaluateMdx.native.js +17 -0
- package/dist/esm/hooks/useCompileAndEvaluateMdx.native.js.map +1 -0
- package/dist/esm/hooks/useCompileAndEvaluateMdx.spec.mjs +35 -0
- package/dist/esm/hooks/useCompileAndEvaluateMdx.spec.mjs.map +1 -0
- package/dist/esm/hooks/useCompileAndEvaluateMdx.spec.native.js +47 -0
- package/dist/esm/hooks/useCompileAndEvaluateMdx.spec.native.js.map +1 -0
- package/dist/esm/hooks/useCompileMdx.mjs +44 -0
- package/dist/esm/hooks/useCompileMdx.mjs.map +1 -0
- package/dist/esm/hooks/useCompileMdx.native.js +44 -0
- package/dist/esm/hooks/useCompileMdx.native.js.map +1 -0
- package/dist/esm/hooks/useEvaluateMdx.mjs +22 -0
- package/dist/esm/hooks/useEvaluateMdx.mjs.map +1 -0
- package/dist/esm/hooks/useEvaluateMdx.native.js +24 -0
- package/dist/esm/hooks/useEvaluateMdx.native.js.map +1 -0
- package/dist/esm/icons/index.mjs +175 -0
- package/dist/esm/icons/index.mjs.map +1 -0
- package/dist/esm/icons/index.native.js +193 -0
- package/dist/esm/icons/index.native.js.map +1 -0
- package/dist/esm/index.mjs +21 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +21 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/mdx.spec.mjs +377 -0
- package/dist/esm/mdx.spec.mjs.map +1 -0
- package/dist/esm/mdx.spec.native.js +439 -0
- package/dist/esm/mdx.spec.native.js.map +1 -0
- package/dist/esm/mdxComponents.mjs +291 -0
- package/dist/esm/mdxComponents.mjs.map +1 -0
- package/dist/esm/mdxComponents.native.js +347 -0
- package/dist/esm/mdxComponents.native.js.map +1 -0
- package/dist/esm/parser.mjs +12 -0
- package/dist/esm/parser.mjs.map +1 -0
- package/dist/esm/parser.native.js +12 -0
- package/dist/esm/parser.native.js.map +1 -0
- package/dist/esm/parser.spec.mjs +110 -0
- package/dist/esm/parser.spec.mjs.map +1 -0
- package/dist/esm/parser.spec.native.js +112 -0
- package/dist/esm/parser.spec.native.js.map +1 -0
- package/dist/esm/renderer.mjs +300 -0
- package/dist/esm/renderer.mjs.map +1 -0
- package/dist/esm/renderer.native.js +319 -0
- package/dist/esm/renderer.native.js.map +1 -0
- package/dist/esm/shared/colorRamps.mjs +45 -0
- package/dist/esm/shared/colorRamps.mjs.map +1 -0
- package/dist/esm/shared/colorRamps.native.js +45 -0
- package/dist/esm/shared/colorRamps.native.js.map +1 -0
- package/dist/esm/shared/index.mjs +2 -0
- package/dist/esm/shared/index.mjs.map +1 -0
- package/dist/esm/shared/index.native.js +2 -0
- package/dist/esm/shared/index.native.js.map +1 -0
- package/dist/esm/shiki/highlighter.mjs +59 -0
- package/dist/esm/shiki/highlighter.mjs.map +1 -0
- package/dist/esm/shiki/highlighter.native.js +61 -0
- package/dist/esm/shiki/highlighter.native.js.map +1 -0
- package/dist/esm/shiki/index.mjs +3 -0
- package/dist/esm/shiki/index.mjs.map +1 -0
- package/dist/esm/shiki/index.native.js +3 -0
- package/dist/esm/shiki/index.native.js.map +1 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +2 -0
- package/dist/esm/types.native.js.map +1 -0
- package/dist/esm/util/rehypeMetaAttributes.mjs +20 -0
- package/dist/esm/util/rehypeMetaAttributes.mjs.map +1 -0
- package/dist/esm/util/rehypeMetaAttributes.native.js +21 -0
- package/dist/esm/util/rehypeMetaAttributes.native.js.map +1 -0
- package/dist/esm/util/util.spec.mjs +82 -0
- package/dist/esm/util/util.spec.mjs.map +1 -0
- package/dist/esm/util/util.spec.native.js +82 -0
- package/dist/esm/util/util.spec.native.js.map +1 -0
- package/dist/jsx/Aside/index.mjs +86 -0
- package/dist/jsx/Aside/index.mjs.map +1 -0
- package/dist/jsx/Aside/index.native.js +119 -0
- package/dist/jsx/Aside/index.native.js.map +1 -0
- package/dist/jsx/ExternalIcon/ExternalIcon.spec.mjs +38 -0
- package/dist/jsx/ExternalIcon/ExternalIcon.spec.mjs.map +1 -0
- package/dist/jsx/ExternalIcon/ExternalIcon.spec.native.js +40 -0
- package/dist/jsx/ExternalIcon/ExternalIcon.spec.native.js.map +1 -0
- package/dist/jsx/ExternalIcon/index.mjs +21 -0
- package/dist/jsx/ExternalIcon/index.mjs.map +1 -0
- package/dist/jsx/ExternalIcon/index.native.js +51 -0
- package/dist/jsx/ExternalIcon/index.native.js.map +1 -0
- package/dist/jsx/Hr/hr.spec.mjs +22 -0
- package/dist/jsx/Hr/hr.spec.mjs.map +1 -0
- package/dist/jsx/Hr/hr.spec.native.js +24 -0
- package/dist/jsx/Hr/hr.spec.native.js.map +1 -0
- package/dist/jsx/Hr/index.mjs +16 -0
- package/dist/jsx/Hr/index.mjs.map +1 -0
- package/dist/jsx/Hr/index.native.js +46 -0
- package/dist/jsx/Hr/index.native.js.map +1 -0
- package/dist/jsx/Li/index.mjs +13 -0
- package/dist/jsx/Li/index.mjs.map +1 -0
- package/dist/jsx/Li/index.native.js +41 -0
- package/dist/jsx/Li/index.native.js.map +1 -0
- package/dist/jsx/Li/li.spec.mjs +46 -0
- package/dist/jsx/Li/li.spec.mjs.map +1 -0
- package/dist/jsx/Li/li.spec.native.js +50 -0
- package/dist/jsx/Li/li.spec.native.js.map +1 -0
- package/dist/jsx/Markdown.mjs +41 -0
- package/dist/jsx/Markdown.mjs.map +1 -0
- package/dist/jsx/Markdown.native.js +71 -0
- package/dist/jsx/Markdown.native.js.map +1 -0
- package/dist/jsx/Markdown.stories.mjs +125 -0
- package/dist/jsx/Markdown.stories.mjs.map +1 -0
- package/dist/jsx/Markdown.stories.native.js +162 -0
- package/dist/jsx/Markdown.stories.native.js.map +1 -0
- package/dist/jsx/Mdx/index.mjs +33 -0
- package/dist/jsx/Mdx/index.mjs.map +1 -0
- package/dist/jsx/Mdx/index.native.js +62 -0
- package/dist/jsx/Mdx/index.native.js.map +1 -0
- package/dist/jsx/Mdx/mdx.spec.mjs +140 -0
- package/dist/jsx/Mdx/mdx.spec.mjs.map +1 -0
- package/dist/jsx/Mdx/mdx.spec.native.js +158 -0
- package/dist/jsx/Mdx/mdx.spec.native.js.map +1 -0
- package/dist/jsx/MdxCodeBlock/index.mjs +149 -0
- package/dist/jsx/MdxCodeBlock/index.mjs.map +1 -0
- package/dist/jsx/MdxCodeBlock/index.native.js +205 -0
- package/dist/jsx/MdxCodeBlock/index.native.js.map +1 -0
- package/dist/jsx/MdxCodeBlock/mdxCodeBlock.spec.mjs +91 -0
- package/dist/jsx/MdxCodeBlock/mdxCodeBlock.spec.mjs.map +1 -0
- package/dist/jsx/MdxCodeBlock/mdxCodeBlock.spec.native.js +122 -0
- package/dist/jsx/MdxCodeBlock/mdxCodeBlock.spec.native.js.map +1 -0
- package/dist/jsx/MdxCodeBlock/mdxCodeBlockContext.mjs +4 -0
- package/dist/jsx/MdxCodeBlock/mdxCodeBlockContext.mjs.map +1 -0
- package/dist/jsx/MdxCodeBlock/mdxCodeBlockContext.native.js +32 -0
- package/dist/jsx/MdxCodeBlock/mdxCodeBlockContext.native.js.map +1 -0
- package/dist/jsx/Notice/index.mjs +68 -0
- package/dist/jsx/Notice/index.mjs.map +1 -0
- package/dist/jsx/Notice/index.native.js +98 -0
- package/dist/jsx/Notice/index.native.js.map +1 -0
- package/dist/jsx/SimpleTable/index.mjs +107 -0
- package/dist/jsx/SimpleTable/index.mjs.map +1 -0
- package/dist/jsx/SimpleTable/index.native.js +162 -0
- package/dist/jsx/SimpleTable/index.native.js.map +1 -0
- package/dist/jsx/Table/index.mjs +91 -0
- package/dist/jsx/Table/index.mjs.map +1 -0
- package/dist/jsx/Table/index.native.js +130 -0
- package/dist/jsx/Table/index.native.js.map +1 -0
- package/dist/jsx/Tabs/index.mjs +67 -0
- package/dist/jsx/Tabs/index.mjs.map +1 -0
- package/dist/jsx/Tabs/index.native.js +103 -0
- package/dist/jsx/Tabs/index.native.js.map +1 -0
- package/dist/jsx/Ul/index.mjs +10 -0
- package/dist/jsx/Ul/index.mjs.map +1 -0
- package/dist/jsx/Ul/index.native.js +38 -0
- package/dist/jsx/Ul/index.native.js.map +1 -0
- package/dist/jsx/Ul/ul.spec.mjs +151 -0
- package/dist/jsx/Ul/ul.spec.mjs.map +1 -0
- package/dist/jsx/Ul/ul.spec.native.js +153 -0
- package/dist/jsx/Ul/ul.spec.native.js.map +1 -0
- package/dist/jsx/Video/index.mjs +59 -0
- package/dist/jsx/Video/index.mjs.map +1 -0
- package/dist/jsx/Video/index.native.js +89 -0
- package/dist/jsx/Video/index.native.js.map +1 -0
- package/dist/jsx/components/Blockquote.mjs +22 -0
- package/dist/jsx/components/Blockquote.mjs.map +1 -0
- package/dist/jsx/components/Blockquote.native.js +51 -0
- package/dist/jsx/components/Blockquote.native.js.map +1 -0
- package/dist/jsx/components/Break.mjs +9 -0
- package/dist/jsx/components/Break.mjs.map +1 -0
- package/dist/jsx/components/Break.native.js +37 -0
- package/dist/jsx/components/Break.native.js.map +1 -0
- package/dist/jsx/components/CodeBlock.mjs +84 -0
- package/dist/jsx/components/CodeBlock.mjs.map +1 -0
- package/dist/jsx/components/CodeBlock.native.js +119 -0
- package/dist/jsx/components/CodeBlock.native.js.map +1 -0
- package/dist/jsx/components/Heading.mjs +23 -0
- package/dist/jsx/components/Heading.mjs.map +1 -0
- package/dist/jsx/components/Heading.native.js +52 -0
- package/dist/jsx/components/Heading.native.js.map +1 -0
- package/dist/jsx/components/HorizontalRule.mjs +9 -0
- package/dist/jsx/components/HorizontalRule.mjs.map +1 -0
- package/dist/jsx/components/HorizontalRule.native.js +37 -0
- package/dist/jsx/components/HorizontalRule.native.js.map +1 -0
- package/dist/jsx/components/Image.mjs +28 -0
- package/dist/jsx/components/Image.mjs.map +1 -0
- package/dist/jsx/components/Image.native.js +57 -0
- package/dist/jsx/components/Image.native.js.map +1 -0
- package/dist/jsx/components/InlineCode.mjs +23 -0
- package/dist/jsx/components/InlineCode.mjs.map +1 -0
- package/dist/jsx/components/InlineCode.native.js +52 -0
- package/dist/jsx/components/InlineCode.native.js.map +1 -0
- package/dist/jsx/components/InlineStyles.mjs +28 -0
- package/dist/jsx/components/InlineStyles.mjs.map +1 -0
- package/dist/jsx/components/InlineStyles.native.js +61 -0
- package/dist/jsx/components/InlineStyles.native.js.map +1 -0
- package/dist/jsx/components/Link.mjs +29 -0
- package/dist/jsx/components/Link.mjs.map +1 -0
- package/dist/jsx/components/Link.native.js +58 -0
- package/dist/jsx/components/Link.native.js.map +1 -0
- package/dist/jsx/components/List.mjs +48 -0
- package/dist/jsx/components/List.mjs.map +1 -0
- package/dist/jsx/components/List.native.js +79 -0
- package/dist/jsx/components/List.native.js.map +1 -0
- package/dist/jsx/components/Paragraph.mjs +13 -0
- package/dist/jsx/components/Paragraph.mjs.map +1 -0
- package/dist/jsx/components/Paragraph.native.js +42 -0
- package/dist/jsx/components/Paragraph.native.js.map +1 -0
- package/dist/jsx/components/Table.mjs +59 -0
- package/dist/jsx/components/Table.mjs.map +1 -0
- package/dist/jsx/components/Table.native.js +92 -0
- package/dist/jsx/components/Table.native.js.map +1 -0
- package/dist/jsx/components/index.mjs +14 -0
- package/dist/jsx/components/index.mjs.map +1 -0
- package/dist/jsx/components/index.native.js +58 -0
- package/dist/jsx/components/index.native.js.map +1 -0
- package/dist/jsx/hooks/index.mjs +4 -0
- package/dist/jsx/hooks/index.mjs.map +1 -0
- package/dist/jsx/hooks/index.native.js +25 -0
- package/dist/jsx/hooks/index.native.js.map +1 -0
- package/dist/jsx/hooks/useCompileAndEvaluateMdx.mjs +17 -0
- package/dist/jsx/hooks/useCompileAndEvaluateMdx.mjs.map +1 -0
- package/dist/jsx/hooks/useCompileAndEvaluateMdx.native.js +45 -0
- package/dist/jsx/hooks/useCompileAndEvaluateMdx.native.js.map +1 -0
- package/dist/jsx/hooks/useCompileAndEvaluateMdx.spec.mjs +35 -0
- package/dist/jsx/hooks/useCompileAndEvaluateMdx.spec.mjs.map +1 -0
- package/dist/jsx/hooks/useCompileAndEvaluateMdx.spec.native.js +49 -0
- package/dist/jsx/hooks/useCompileAndEvaluateMdx.spec.native.js.map +1 -0
- package/dist/jsx/hooks/useCompileMdx.mjs +44 -0
- package/dist/jsx/hooks/useCompileMdx.mjs.map +1 -0
- package/dist/jsx/hooks/useCompileMdx.native.js +83 -0
- package/dist/jsx/hooks/useCompileMdx.native.js.map +1 -0
- package/dist/jsx/hooks/useEvaluateMdx.mjs +22 -0
- package/dist/jsx/hooks/useEvaluateMdx.mjs.map +1 -0
- package/dist/jsx/hooks/useEvaluateMdx.native.js +63 -0
- package/dist/jsx/hooks/useEvaluateMdx.native.js.map +1 -0
- package/dist/jsx/icons/index.mjs +175 -0
- package/dist/jsx/icons/index.mjs.map +1 -0
- package/dist/jsx/icons/index.native.js +226 -0
- package/dist/jsx/icons/index.native.js.map +1 -0
- package/dist/jsx/index.js +21 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/index.mjs +21 -0
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/index.native.js +54 -0
- package/dist/jsx/index.native.js.map +1 -0
- package/dist/jsx/mdx.spec.mjs +377 -0
- package/dist/jsx/mdx.spec.mjs.map +1 -0
- package/dist/jsx/mdx.spec.native.js +465 -0
- package/dist/jsx/mdx.spec.native.js.map +1 -0
- package/dist/jsx/mdxComponents.mjs +291 -0
- package/dist/jsx/mdxComponents.mjs.map +1 -0
- package/dist/jsx/mdxComponents.native.js +376 -0
- package/dist/jsx/mdxComponents.native.js.map +1 -0
- package/dist/jsx/parser.mjs +12 -0
- package/dist/jsx/parser.mjs.map +1 -0
- package/dist/jsx/parser.native.js +52 -0
- package/dist/jsx/parser.native.js.map +1 -0
- package/dist/jsx/parser.spec.mjs +110 -0
- package/dist/jsx/parser.spec.mjs.map +1 -0
- package/dist/jsx/parser.spec.native.js +114 -0
- package/dist/jsx/parser.spec.native.js.map +1 -0
- package/dist/jsx/renderer.mjs +300 -0
- package/dist/jsx/renderer.mjs.map +1 -0
- package/dist/jsx/renderer.native.js +348 -0
- package/dist/jsx/renderer.native.js.map +1 -0
- package/dist/jsx/shared/colorRamps.mjs +45 -0
- package/dist/jsx/shared/colorRamps.mjs.map +1 -0
- package/dist/jsx/shared/colorRamps.native.js +77 -0
- package/dist/jsx/shared/colorRamps.native.js.map +1 -0
- package/dist/jsx/shared/index.mjs +2 -0
- package/dist/jsx/shared/index.mjs.map +1 -0
- package/dist/jsx/shared/index.native.js +23 -0
- package/dist/jsx/shared/index.native.js.map +1 -0
- package/dist/jsx/shiki/highlighter.mjs +59 -0
- package/dist/jsx/shiki/highlighter.mjs.map +1 -0
- package/dist/jsx/shiki/highlighter.native.js +94 -0
- package/dist/jsx/shiki/highlighter.native.js.map +1 -0
- package/dist/jsx/shiki/index.mjs +3 -0
- package/dist/jsx/shiki/index.mjs.map +1 -0
- package/dist/jsx/shiki/index.native.js +36 -0
- package/dist/jsx/shiki/index.native.js.map +1 -0
- package/dist/jsx/types.mjs +2 -0
- package/dist/jsx/types.mjs.map +1 -0
- package/dist/jsx/types.native.js +21 -0
- package/dist/jsx/types.native.js.map +1 -0
- package/dist/jsx/util/rehypeMetaAttributes.mjs +20 -0
- package/dist/jsx/util/rehypeMetaAttributes.mjs.map +1 -0
- package/dist/jsx/util/rehypeMetaAttributes.native.js +49 -0
- package/dist/jsx/util/rehypeMetaAttributes.native.js.map +1 -0
- package/dist/jsx/util/util.spec.mjs +82 -0
- package/dist/jsx/util/util.spec.mjs.map +1 -0
- package/dist/jsx/util/util.spec.native.js +84 -0
- package/dist/jsx/util/util.spec.native.js.map +1 -0
- package/package.json +94 -0
- package/src/Aside/index.tsx +89 -0
- package/src/ExternalIcon/ExternalIcon.spec.tsx +33 -0
- package/src/ExternalIcon/index.tsx +15 -0
- package/src/Hr/hr.spec.tsx +18 -0
- package/src/Hr/index.tsx +7 -0
- package/src/Li/index.tsx +14 -0
- package/src/Li/li.spec.tsx +33 -0
- package/src/Markdown.stories.tsx +127 -0
- package/src/Markdown.tsx +62 -0
- package/src/Mdx/index.tsx +32 -0
- package/src/Mdx/mdx.spec.tsx +118 -0
- package/src/MdxCodeBlock/index.tsx +168 -0
- package/src/MdxCodeBlock/mdxCodeBlock.spec.tsx +66 -0
- package/src/MdxCodeBlock/mdxCodeBlockContext.ts +15 -0
- package/src/Notice/index.tsx +76 -0
- package/src/SimpleTable/index.tsx +125 -0
- package/src/Table/index.tsx +80 -0
- package/src/Tabs/index.tsx +76 -0
- package/src/Ul/index.ts +11 -0
- package/src/Ul/ul.spec.tsx +131 -0
- package/src/Video/index.tsx +62 -0
- package/src/components/Blockquote.tsx +20 -0
- package/src/components/Break.tsx +6 -0
- package/src/components/CodeBlock.tsx +94 -0
- package/src/components/Heading.tsx +20 -0
- package/src/components/HorizontalRule.tsx +6 -0
- package/src/components/Image.tsx +20 -0
- package/src/components/InlineCode.tsx +21 -0
- package/src/components/InlineStyles.tsx +14 -0
- package/src/components/Link.tsx +26 -0
- package/src/components/List.tsx +41 -0
- package/src/components/Paragraph.tsx +10 -0
- package/src/components/Table.tsx +56 -0
- package/src/components/index.ts +12 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useCompileAndEvaluateMdx.spec.tsx +31 -0
- package/src/hooks/useCompileAndEvaluateMdx.ts +22 -0
- package/src/hooks/useCompileMdx.ts +55 -0
- package/src/hooks/useEvaluateMdx.ts +27 -0
- package/src/icons/index.tsx +116 -0
- package/src/index.ts +33 -0
- package/src/mdx.spec.tsx +347 -0
- package/src/mdxComponents.tsx +225 -0
- package/src/parser.spec.ts +126 -0
- package/src/parser.ts +27 -0
- package/src/renderer.tsx +391 -0
- package/src/shared/colorRamps.ts +52 -0
- package/src/shared/index.ts +1 -0
- package/src/shiki/highlighter.ts +148 -0
- package/src/shiki/index.ts +11 -0
- package/src/types.ts +225 -0
- package/src/util/rehypeMetaAttributes.ts +21 -0
- package/src/util/util.spec.tsx +90 -0
package/src/mdx.spec.tsx
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { screen } from "@testing-library/react";
|
|
2
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
3
|
+
import { Anchor, H1, H2, H3, Text, YStack } from "tamagui";
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { ExternalIcon } from "./ExternalIcon";
|
|
6
|
+
import { HR } from "./Hr";
|
|
7
|
+
import { LI } from "./Li";
|
|
8
|
+
import { MDX } from "./Mdx";
|
|
9
|
+
import { MDXCodeBlock } from "./MdxCodeBlock";
|
|
10
|
+
import { mdxComponents } from "./mdxComponents";
|
|
11
|
+
import { UL } from "./Ul";
|
|
12
|
+
import * as IndexExports from "./index";
|
|
13
|
+
vi.mock("multiplatform.one", () => ({
|
|
14
|
+
isWeb: false,
|
|
15
|
+
}));
|
|
16
|
+
// Create uppercase aliases for tests
|
|
17
|
+
(mdxComponents as any).H1 = mdxComponents.h1 || ((props: any) => <H1 {...props} />);
|
|
18
|
+
(mdxComponents as any).H2 = mdxComponents.h2 || ((props: any) => <H2 {...props} />);
|
|
19
|
+
(mdxComponents as any).H3 = mdxComponents.h3 || ((props: any) => <H3 {...props} />);
|
|
20
|
+
(mdxComponents as any).YStack = mdxComponents.ystack || ((props: any) => <YStack {...props} />);
|
|
21
|
+
if (typeof mdxComponents.Text !== "function") {
|
|
22
|
+
mdxComponents.Text = (props: any) => <Text {...props} />;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (typeof mdxComponents.a !== "function") {
|
|
26
|
+
(mdxComponents as Record<string, React.ComponentType<any>>).a = function Link({
|
|
27
|
+
href,
|
|
28
|
+
children,
|
|
29
|
+
...props
|
|
30
|
+
}: {
|
|
31
|
+
href: string;
|
|
32
|
+
children: React.ReactNode;
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}) {
|
|
35
|
+
return (
|
|
36
|
+
<Anchor href={href} {...props}>
|
|
37
|
+
{children}
|
|
38
|
+
</Anchor>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
vi.mock("tamagui", async (importOriginal) => {
|
|
44
|
+
const actual = await importOriginal<typeof import("tamagui")>();
|
|
45
|
+
const React = require("react");
|
|
46
|
+
const FakeH1 = ({ children, ...props }: any) => React.createElement("h1", props, children);
|
|
47
|
+
FakeH1.displayName = "H1";
|
|
48
|
+
const FakeH2 = ({ children, ...props }: any) => React.createElement("h2", props, children);
|
|
49
|
+
FakeH2.displayName = "H2";
|
|
50
|
+
const FakeH3 = ({ children, ...props }: any) => React.createElement("h3", props, children);
|
|
51
|
+
FakeH3.displayName = "H3";
|
|
52
|
+
const FakeParagraph = ({ children, ...props }: any) => React.createElement("p", props, children);
|
|
53
|
+
FakeParagraph.displayName = "Paragraph";
|
|
54
|
+
const FakeYStack = ({ children, ...props }: any) => React.createElement("Text", props, children);
|
|
55
|
+
FakeYStack.displayName = "YStack";
|
|
56
|
+
const FakeXStack = ({ children, ...props }: any) => React.createElement("Text", props, children);
|
|
57
|
+
FakeXStack.displayName = "XStack";
|
|
58
|
+
const FakeText = ({ children, ...props }: any) => React.createElement("Text", props, children);
|
|
59
|
+
FakeText.displayName = "Text";
|
|
60
|
+
return {
|
|
61
|
+
...actual,
|
|
62
|
+
H1: FakeH1,
|
|
63
|
+
H2: FakeH2,
|
|
64
|
+
H3: FakeH3,
|
|
65
|
+
Paragraph: FakeParagraph,
|
|
66
|
+
YStack: FakeYStack,
|
|
67
|
+
XStack: FakeXStack,
|
|
68
|
+
Text: FakeText,
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
vi.mock("../code/code", () => ({
|
|
73
|
+
CodeInline: ({ children }: { children: React.ReactNode }) => (
|
|
74
|
+
<Text data-testid="code-inline">{children}</Text>
|
|
75
|
+
),
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
vi.mock("./mdxCodeBlock", () => ({
|
|
79
|
+
MDXCodeBlock: ({
|
|
80
|
+
children,
|
|
81
|
+
className: _className,
|
|
82
|
+
isHighlightingLines: _isHighlightingLines,
|
|
83
|
+
showLineNumbers: _showLineNumbers,
|
|
84
|
+
...props
|
|
85
|
+
}: {
|
|
86
|
+
children: React.ReactNode;
|
|
87
|
+
className?: string;
|
|
88
|
+
isHighlightingLines?: boolean;
|
|
89
|
+
showLineNumbers?: boolean;
|
|
90
|
+
[key: string]: any;
|
|
91
|
+
}) => (
|
|
92
|
+
<YStack data-testid="mdx-code-block" {...props}>
|
|
93
|
+
<YStack>{children}</YStack>
|
|
94
|
+
</YStack>
|
|
95
|
+
),
|
|
96
|
+
}));
|
|
97
|
+
|
|
98
|
+
vi.mock("@multiplatform.one/router", async (importOriginal) => {
|
|
99
|
+
const actual = await importOriginal<typeof import("@multiplatform.one/router")>();
|
|
100
|
+
return {
|
|
101
|
+
...actual,
|
|
102
|
+
Link: ({ children, ...props }: any) => <a {...props}>{children}</a>,
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
vi.mock("@tamagui/react-native-svg", () => ({
|
|
107
|
+
Svg: ({ children, ...props }: any) => <svg {...props}>{children}</svg>,
|
|
108
|
+
Path: (props: any) => <path {...props} />,
|
|
109
|
+
Circle: (props: any) => <circle {...props} />,
|
|
110
|
+
Line: (props: any) => <line {...props} />,
|
|
111
|
+
Rect: (props: any) => <rect {...props} />,
|
|
112
|
+
Polyline: (props: any) => <polyline {...props} />,
|
|
113
|
+
}));
|
|
114
|
+
|
|
115
|
+
describe("MDX Components", () => {
|
|
116
|
+
afterEach(() => {
|
|
117
|
+
vi.clearAllMocks();
|
|
118
|
+
});
|
|
119
|
+
describe("Heading Components", () => {
|
|
120
|
+
it.skip("renders H1 with correct props", () => {
|
|
121
|
+
renderWithProviders(<>{(mdxComponents as any).H1({ children: "Test Heading" })}</>);
|
|
122
|
+
const heading = screen.getByRole("heading", { level: 1 });
|
|
123
|
+
expect(heading).toBeTruthy();
|
|
124
|
+
expect(heading.textContent).toBe("Test Heading");
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it.skip("renders H2 with data-heading attribute", () => {
|
|
128
|
+
renderWithProviders(
|
|
129
|
+
<>
|
|
130
|
+
{(mdxComponents as any).H2({
|
|
131
|
+
children: "Test Heading",
|
|
132
|
+
"data-heading": true,
|
|
133
|
+
})}
|
|
134
|
+
</>,
|
|
135
|
+
);
|
|
136
|
+
const heading = screen.getByRole("heading", { level: 2 });
|
|
137
|
+
expect(heading).toBeTruthy();
|
|
138
|
+
expect(heading.textContent).toBe("Test Heading");
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it.skip("renders H3 with link heading", () => {
|
|
142
|
+
renderWithProviders(
|
|
143
|
+
<>
|
|
144
|
+
{(mdxComponents as any).H3({
|
|
145
|
+
children: "Test Heading",
|
|
146
|
+
id: "test-id",
|
|
147
|
+
})}
|
|
148
|
+
</>,
|
|
149
|
+
);
|
|
150
|
+
const heading = screen.getByRole("heading", { level: 3 });
|
|
151
|
+
expect(heading).toBeTruthy();
|
|
152
|
+
expect(heading.getAttribute("id") || heading.getAttribute("nativeID")).toBe("test-id");
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe("Link Component", () => {
|
|
157
|
+
it.skip("renders link with href using only Tamagui components", () => {
|
|
158
|
+
renderWithProviders(
|
|
159
|
+
<>{(mdxComponents.a as any)({ href: "/test", children: "Test Link" })}</>,
|
|
160
|
+
);
|
|
161
|
+
const link = screen.getByRole("link");
|
|
162
|
+
expect(link).toBeTruthy();
|
|
163
|
+
expect(link.getAttribute("href")).toBe("/test");
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
describe("Code Component", () => {
|
|
168
|
+
it.skip("renders inline code when no className provided", () => {
|
|
169
|
+
renderWithProviders(
|
|
170
|
+
<>
|
|
171
|
+
{(mdxComponents as Record<string, any>).code({
|
|
172
|
+
children: "test code",
|
|
173
|
+
hero: false,
|
|
174
|
+
line: undefined,
|
|
175
|
+
scrollable: false,
|
|
176
|
+
className: undefined,
|
|
177
|
+
id: undefined,
|
|
178
|
+
showLineNumbers: undefined,
|
|
179
|
+
collapsible: false,
|
|
180
|
+
})}
|
|
181
|
+
</>,
|
|
182
|
+
);
|
|
183
|
+
const inlineCode = screen.getByTestId("code-inline");
|
|
184
|
+
expect(inlineCode).toBeTruthy();
|
|
185
|
+
expect(inlineCode.textContent).toBe("test code");
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it.skip("renders code block when a className is provided", () => {
|
|
189
|
+
renderWithProviders(
|
|
190
|
+
<>
|
|
191
|
+
{(mdxComponents as Record<string, any>).code({
|
|
192
|
+
children: "test code block",
|
|
193
|
+
className: "language-javascript",
|
|
194
|
+
hero: false,
|
|
195
|
+
line: undefined,
|
|
196
|
+
scrollable: false,
|
|
197
|
+
id: undefined,
|
|
198
|
+
showLineNumbers: undefined,
|
|
199
|
+
collapsible: false,
|
|
200
|
+
})}
|
|
201
|
+
</>,
|
|
202
|
+
);
|
|
203
|
+
const codeBlock = screen.getByTestId("mdx-code-block");
|
|
204
|
+
expect(codeBlock).toBeTruthy();
|
|
205
|
+
expect(codeBlock.textContent).toBe("test code block");
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
describe("List Components", () => {
|
|
209
|
+
it.skip("renders list item", () => {
|
|
210
|
+
renderWithProviders(<>{(mdxComponents.li as any)({ children: "List Item" })}</>);
|
|
211
|
+
expect(screen.getByText("List Item")).toBeTruthy();
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
describe("Blockquote Component", () => {
|
|
215
|
+
it.skip("renders blockquote with correct styling", () => {
|
|
216
|
+
renderWithProviders(<>{(mdxComponents.blockquote as any)({ children: "Quote text" })}</>);
|
|
217
|
+
expect(screen.getByText("Quote text")).toBeTruthy();
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
describe("Custom Text Mappings for YStack and Text", () => {
|
|
222
|
+
it.skip("renders mdxComponents.YStack mapping as Text without additional styling", () => {
|
|
223
|
+
renderWithProviders(<>{(mdxComponents as any).YStack({ children: "Hello YStack" })}</>);
|
|
224
|
+
const textEl = screen.getByText("Hello YStack");
|
|
225
|
+
expect(textEl.tagName).toBe("TEXT");
|
|
226
|
+
expect(textEl.getAttribute("color")).toBeNull();
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe("Non-web MDX Mappings", () => {
|
|
231
|
+
it.skip("renders the div mapping as a Tamagui Text", () => {
|
|
232
|
+
renderWithProviders(
|
|
233
|
+
<>
|
|
234
|
+
{(mdxComponents as Record<string, any>).div({
|
|
235
|
+
"data-testid": "mdx-div",
|
|
236
|
+
children: "Div Content",
|
|
237
|
+
})}
|
|
238
|
+
</>,
|
|
239
|
+
);
|
|
240
|
+
const divElem = screen.getByTestId("mdx-div");
|
|
241
|
+
expect(divElem).toBeTruthy();
|
|
242
|
+
expect(divElem.textContent).toBe("Div Content");
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it.skip("renders the span mapping with 'token punctuation' class setting color to '$red10'", () => {
|
|
246
|
+
renderWithProviders(
|
|
247
|
+
<>
|
|
248
|
+
{(mdxComponents as Record<string, any>).span({
|
|
249
|
+
className: "token punctuation extra",
|
|
250
|
+
"data-testid": "mdx-span",
|
|
251
|
+
children: "Span Content",
|
|
252
|
+
})}
|
|
253
|
+
</>,
|
|
254
|
+
);
|
|
255
|
+
const spanElem = screen.getByTestId("mdx-span");
|
|
256
|
+
expect(spanElem).toBeTruthy();
|
|
257
|
+
expect(spanElem.textContent).toBe("Span Content");
|
|
258
|
+
expect(spanElem.getAttribute("color")).toBe("$red10");
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it.skip("renders the span mapping with an unrelated class without setting color", () => {
|
|
262
|
+
renderWithProviders(
|
|
263
|
+
<>
|
|
264
|
+
{(mdxComponents as Record<string, any>).span({
|
|
265
|
+
className: "other-class",
|
|
266
|
+
"data-testid": "mdx-span-normal",
|
|
267
|
+
children: "Normal Span",
|
|
268
|
+
})}
|
|
269
|
+
</>,
|
|
270
|
+
);
|
|
271
|
+
const spanElem = screen.getByTestId("mdx-span-normal");
|
|
272
|
+
expect(spanElem).toBeTruthy();
|
|
273
|
+
expect(spanElem.textContent).toBe("Normal Span");
|
|
274
|
+
expect(spanElem.getAttribute("color")).toBeNull();
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
describe("Other MDX Mappings", () => {
|
|
279
|
+
it.skip("renders the p mapping as a Paragraph with correct text", () => {
|
|
280
|
+
renderWithProviders(
|
|
281
|
+
<>
|
|
282
|
+
{(mdxComponents as Record<string, any>).p({
|
|
283
|
+
"data-testid": "p-test",
|
|
284
|
+
children: "Paragraph Content",
|
|
285
|
+
})}
|
|
286
|
+
</>,
|
|
287
|
+
);
|
|
288
|
+
const pElem = screen.getByTestId("p-test");
|
|
289
|
+
expect(pElem).toBeDefined();
|
|
290
|
+
expect(pElem.textContent).toBe("Paragraph Content");
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it.skip("renders the h3 mapping and verifies getNonTextChildren functionality", () => {
|
|
294
|
+
renderWithProviders(
|
|
295
|
+
<>
|
|
296
|
+
{(mdxComponents as Record<string, any>).h3({
|
|
297
|
+
id: "heading-test",
|
|
298
|
+
"data-testid": "h3-test",
|
|
299
|
+
children: [
|
|
300
|
+
"This is heading",
|
|
301
|
+
<Text key="sub" data-testid="child-h3">
|
|
302
|
+
Subheading
|
|
303
|
+
</Text>,
|
|
304
|
+
],
|
|
305
|
+
})}
|
|
306
|
+
</>,
|
|
307
|
+
);
|
|
308
|
+
const h3Elem = screen.getByTestId("h3-test");
|
|
309
|
+
expect(h3Elem).toBeDefined();
|
|
310
|
+
expect(h3Elem.textContent).toContain("This is heading");
|
|
311
|
+
const subheadingInstances = screen.getAllByText("Subheading");
|
|
312
|
+
expect(subheadingInstances.length).toBe(2);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
describe("MDX Index Exports", () => {
|
|
318
|
+
it.skip("should export ExternalIcon", () => {
|
|
319
|
+
expect(IndexExports.ExternalIcon).toBeDefined();
|
|
320
|
+
expect(IndexExports.ExternalIcon).toBe(ExternalIcon);
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it.skip("should export HR", () => {
|
|
324
|
+
expect(IndexExports.HR).toBeDefined();
|
|
325
|
+
expect(IndexExports.HR).toBe(HR);
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it.skip("should export LI", () => {
|
|
329
|
+
expect(IndexExports.LI).toBeDefined();
|
|
330
|
+
expect(IndexExports.LI).toBe(LI);
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it.skip("should export MDX", () => {
|
|
334
|
+
expect(IndexExports.MDX).toBeDefined();
|
|
335
|
+
expect(IndexExports.MDX).toBe(MDX);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
it.skip("should export MDXCodeBlock", () => {
|
|
339
|
+
expect(IndexExports.MDXCodeBlock).toBeDefined();
|
|
340
|
+
expect(IndexExports.MDXCodeBlock).toBe(MDXCodeBlock);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it.skip("should export UL", () => {
|
|
344
|
+
expect(IndexExports.UL).toBeDefined();
|
|
345
|
+
expect(IndexExports.UL).toBe(UL);
|
|
346
|
+
});
|
|
347
|
+
});
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { CodeInline, unwrapText } from "@multiplatform.one/components";
|
|
2
|
+
import { useResolvedKnobs } from "@multiplatform.one/theme";
|
|
3
|
+
import { Link } from "@multiplatform.one/router";
|
|
4
|
+
import type { MDXComponents } from "mdx/types";
|
|
5
|
+
import { Children } from "react";
|
|
6
|
+
import type { XStackProps } from "tamagui";
|
|
7
|
+
import { H1, H2, H3, H4, H5, H6, Paragraph, Text, XStack, YStack, styled } from "tamagui";
|
|
8
|
+
import { ExternalIcon } from "./ExternalIcon";
|
|
9
|
+
import { HR } from "./Hr";
|
|
10
|
+
import { LinkIcon } from "./icons";
|
|
11
|
+
import { LI } from "./Li";
|
|
12
|
+
import { MDXCodeBlock } from "./MdxCodeBlock";
|
|
13
|
+
import {
|
|
14
|
+
MDXTable,
|
|
15
|
+
MDXTableBody,
|
|
16
|
+
MDXTableCell,
|
|
17
|
+
MDXTableHead,
|
|
18
|
+
MDXTableHeaderCell,
|
|
19
|
+
MDXTableRow,
|
|
20
|
+
} from "./Table";
|
|
21
|
+
import { UL } from "./Ul";
|
|
22
|
+
|
|
23
|
+
const code = ({
|
|
24
|
+
hero: _hero,
|
|
25
|
+
line,
|
|
26
|
+
scrollable: _scrollable,
|
|
27
|
+
className,
|
|
28
|
+
children,
|
|
29
|
+
id: _id,
|
|
30
|
+
showLineNumbers,
|
|
31
|
+
collapsible: _collapsible,
|
|
32
|
+
...props
|
|
33
|
+
}: any) => {
|
|
34
|
+
if (!className) return <CodeInline>{unwrapText(children)}</CodeInline>;
|
|
35
|
+
return (
|
|
36
|
+
<YStack marginTop="$3">
|
|
37
|
+
<MDXCodeBlock
|
|
38
|
+
className={className}
|
|
39
|
+
isHighlightingLines={line !== undefined}
|
|
40
|
+
showLineNumbers={showLineNumbers !== undefined}
|
|
41
|
+
line={line}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</MDXCodeBlock>
|
|
46
|
+
</YStack>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const TableHighlight = styled(YStack, {
|
|
51
|
+
name: "TableHighlight",
|
|
52
|
+
backgroundColor: "$yellow1",
|
|
53
|
+
fullscreen: true,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export type TableHighlightProps = React.ComponentProps<typeof TableHighlight>;
|
|
57
|
+
|
|
58
|
+
function MdxBlockquote({ children, ...props }: any) {
|
|
59
|
+
const { knobProps } = useResolvedKnobs();
|
|
60
|
+
return (
|
|
61
|
+
<YStack
|
|
62
|
+
marginVertical="$4"
|
|
63
|
+
paddingHorizontal={knobProps.panelPadding.padding}
|
|
64
|
+
style={{ marginLeft: 12 }}
|
|
65
|
+
borderLeftWidth={1}
|
|
66
|
+
borderColor="$borderColor"
|
|
67
|
+
justifyContent="center"
|
|
68
|
+
{...props}
|
|
69
|
+
>
|
|
70
|
+
<Paragraph
|
|
71
|
+
whiteSpace="revert"
|
|
72
|
+
size="$8"
|
|
73
|
+
lineHeight="$9"
|
|
74
|
+
fontWeight="300"
|
|
75
|
+
color="$color"
|
|
76
|
+
opacity={0.65}
|
|
77
|
+
>
|
|
78
|
+
{unwrapText(children)}
|
|
79
|
+
</Paragraph>
|
|
80
|
+
</YStack>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const mdxComponents: MDXComponents = {
|
|
85
|
+
h1: (props) => (
|
|
86
|
+
<H1 fontFamily="$mono" width="max-content" position="relative" marginBottom="$2" {...props} />
|
|
87
|
+
),
|
|
88
|
+
h2: ({ children, ...props }) => (
|
|
89
|
+
<H2
|
|
90
|
+
position="relative"
|
|
91
|
+
width={"fit-content" as any}
|
|
92
|
+
marginTop="$8"
|
|
93
|
+
marginBottom="$4"
|
|
94
|
+
data-heading
|
|
95
|
+
size="$9"
|
|
96
|
+
color="$color12"
|
|
97
|
+
{...props}
|
|
98
|
+
>
|
|
99
|
+
{children}
|
|
100
|
+
</H2>
|
|
101
|
+
),
|
|
102
|
+
h3: ({ children, id, ...props }) => (
|
|
103
|
+
<LinkHeading data-heading marginTop="$6" marginBottom="$2" id={id}>
|
|
104
|
+
<H3
|
|
105
|
+
maxWidth="100%"
|
|
106
|
+
position="relative"
|
|
107
|
+
width={"fit-content" as any}
|
|
108
|
+
nativeID={id}
|
|
109
|
+
size="$8"
|
|
110
|
+
color="$color11"
|
|
111
|
+
fontWeight="600"
|
|
112
|
+
{...props}
|
|
113
|
+
>
|
|
114
|
+
{children}
|
|
115
|
+
</H3>
|
|
116
|
+
{getNonTextChildren(children)}
|
|
117
|
+
</LinkHeading>
|
|
118
|
+
),
|
|
119
|
+
h4: (props) => (
|
|
120
|
+
<H4
|
|
121
|
+
position="relative"
|
|
122
|
+
width={"fit-content" as any}
|
|
123
|
+
marginTop="$8"
|
|
124
|
+
marginBottom="$2"
|
|
125
|
+
size="$8"
|
|
126
|
+
color="$color8"
|
|
127
|
+
data-heading
|
|
128
|
+
{...props}
|
|
129
|
+
fontWeight="400"
|
|
130
|
+
/>
|
|
131
|
+
),
|
|
132
|
+
h5: (props) => <H5 size="$6" fontWeight="600" marginTop="$4" {...props} />,
|
|
133
|
+
h6: (props) => <H6 marginTop="$4" {...props} />,
|
|
134
|
+
p: (props) => <Paragraph render="p" display="block" size="$6" marginVertical="$2" {...props} />,
|
|
135
|
+
a: ({ href = "", children, ...props }) => {
|
|
136
|
+
return (
|
|
137
|
+
<Link href={href}>
|
|
138
|
+
<Paragraph
|
|
139
|
+
render="a"
|
|
140
|
+
fontSize="inherit"
|
|
141
|
+
display="inline"
|
|
142
|
+
cursor="pointer"
|
|
143
|
+
focusVisibleStyle={{
|
|
144
|
+
outlineColor: "$outlineColor",
|
|
145
|
+
outlineWidth: 2,
|
|
146
|
+
outlineStyle: "solid",
|
|
147
|
+
outlineOffset: 2,
|
|
148
|
+
}}
|
|
149
|
+
{...props}
|
|
150
|
+
>
|
|
151
|
+
{children}
|
|
152
|
+
{typeof href === "string" && href.startsWith("http") ? (
|
|
153
|
+
<>
|
|
154
|
+
|
|
155
|
+
<Text fontSize="inherit" display="inline-flex" y={2} style={{ marginLeft: -1 }}>
|
|
156
|
+
<ExternalIcon />
|
|
157
|
+
</Text>
|
|
158
|
+
</>
|
|
159
|
+
) : null}
|
|
160
|
+
</Paragraph>
|
|
161
|
+
</Link>
|
|
162
|
+
);
|
|
163
|
+
},
|
|
164
|
+
hr: (props) => <HR {...props} />,
|
|
165
|
+
ul: ({ children }) => (
|
|
166
|
+
<UL render="ul" marginVertical="$4">
|
|
167
|
+
{Children.toArray(children).map((x) => (typeof x === "string" ? null : x))}
|
|
168
|
+
</UL>
|
|
169
|
+
),
|
|
170
|
+
ol: (props) => <YStack {...props} render="ol" marginBottom="$3" />,
|
|
171
|
+
li: (props) => (
|
|
172
|
+
<LI render="li" size="$6" marginBottom="$1.5" style={{ listStyleType: "disc" }}>
|
|
173
|
+
{props.children}
|
|
174
|
+
</LI>
|
|
175
|
+
),
|
|
176
|
+
strong: (props) => <Paragraph render="strong" fontSize="inherit" {...props} fontWeight="700" />,
|
|
177
|
+
em: (props) => <Paragraph render="em" fontSize="inherit" {...props} fontStyle="italic" />,
|
|
178
|
+
del: (props) => (
|
|
179
|
+
<Paragraph render="del" fontSize="inherit" {...props} textDecorationLine="line-through" />
|
|
180
|
+
),
|
|
181
|
+
img: ({ ...props }) => (
|
|
182
|
+
<YStack render="span" marginVertical="$6">
|
|
183
|
+
<YStack render="img" {...props} maxWidth="100%" />
|
|
184
|
+
</YStack>
|
|
185
|
+
),
|
|
186
|
+
pre: ({ children }) => <>{children}</>,
|
|
187
|
+
code: code as any,
|
|
188
|
+
blockquote: MdxBlockquote,
|
|
189
|
+
table: (props) => <MDXTable {...props} />,
|
|
190
|
+
thead: (props) => <MDXTableHead {...props} />,
|
|
191
|
+
tbody: (props) => <MDXTableBody {...props} />,
|
|
192
|
+
tr: (props) => <MDXTableRow {...props} />,
|
|
193
|
+
th: (props) => <MDXTableHeaderCell {...props} />,
|
|
194
|
+
td: (props) => <MDXTableCell {...props} />,
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const LinkHeading = ({ id, children, ...props }: { id?: string } & XStackProps) => {
|
|
198
|
+
const { knobProps } = useResolvedKnobs();
|
|
199
|
+
return (
|
|
200
|
+
<XStack
|
|
201
|
+
render="a"
|
|
202
|
+
data-heading
|
|
203
|
+
href={`#${id}`}
|
|
204
|
+
id={id}
|
|
205
|
+
data-id={id}
|
|
206
|
+
display="inline-flex"
|
|
207
|
+
alignItems="center"
|
|
208
|
+
{...knobProps.gapLg}
|
|
209
|
+
{...(props as any)}
|
|
210
|
+
>
|
|
211
|
+
{children}
|
|
212
|
+
<YStack render="span" opacity={0.3}>
|
|
213
|
+
<LinkIcon size={12} />
|
|
214
|
+
</YStack>
|
|
215
|
+
</XStack>
|
|
216
|
+
);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const getNonTextChildren = (children: any) => {
|
|
220
|
+
return Children.map(children, (x) => {
|
|
221
|
+
if (typeof x === "string") return null;
|
|
222
|
+
if (x?.type === code) return null;
|
|
223
|
+
return x;
|
|
224
|
+
})?.flat();
|
|
225
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { parseMarkdown, parseMarkdownAsync } from "./parser";
|
|
3
|
+
|
|
4
|
+
describe("parseMarkdown", () => {
|
|
5
|
+
it("parses a heading", () => {
|
|
6
|
+
const ast = parseMarkdown("# Hello");
|
|
7
|
+
expect(ast.type).toBe("root");
|
|
8
|
+
expect(ast.children).toHaveLength(1);
|
|
9
|
+
expect(ast.children[0].type).toBe("heading");
|
|
10
|
+
const heading = ast.children[0] as any;
|
|
11
|
+
expect(heading.depth).toBe(1);
|
|
12
|
+
expect(heading.children[0].value).toBe("Hello");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("parses a paragraph", () => {
|
|
16
|
+
const ast = parseMarkdown("Just some text.");
|
|
17
|
+
expect(ast.children[0].type).toBe("paragraph");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("parses inline formatting", () => {
|
|
21
|
+
const ast = parseMarkdown("**bold** and *italic*");
|
|
22
|
+
const paragraph = ast.children[0] as any;
|
|
23
|
+
expect(paragraph.children[0].type).toBe("strong");
|
|
24
|
+
expect(paragraph.children[2].type).toBe("emphasis");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("parses an unordered list", () => {
|
|
28
|
+
const ast = parseMarkdown("- item 1\n- item 2\n- item 3");
|
|
29
|
+
expect(ast.children[0].type).toBe("list");
|
|
30
|
+
const list = ast.children[0] as any;
|
|
31
|
+
expect(list.ordered).toBe(false);
|
|
32
|
+
expect(list.children).toHaveLength(3);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("parses an ordered list", () => {
|
|
36
|
+
const ast = parseMarkdown("1. first\n2. second");
|
|
37
|
+
const list = ast.children[0] as any;
|
|
38
|
+
expect(list.type).toBe("list");
|
|
39
|
+
expect(list.ordered).toBe(true);
|
|
40
|
+
expect(list.children).toHaveLength(2);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("parses a code block", () => {
|
|
44
|
+
const ast = parseMarkdown("```js\nconsole.log('hi');\n```");
|
|
45
|
+
const code = ast.children[0] as any;
|
|
46
|
+
expect(code.type).toBe("code");
|
|
47
|
+
expect(code.lang).toBe("js");
|
|
48
|
+
expect(code.value).toBe("console.log('hi');");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("parses inline code", () => {
|
|
52
|
+
const ast = parseMarkdown("Use `const x = 1` here.");
|
|
53
|
+
const paragraph = ast.children[0] as any;
|
|
54
|
+
const inlineCode = paragraph.children.find((c: any) => c.type === "inlineCode");
|
|
55
|
+
expect(inlineCode).toBeDefined();
|
|
56
|
+
expect(inlineCode.value).toBe("const x = 1");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("parses a blockquote", () => {
|
|
60
|
+
const ast = parseMarkdown("> A quote");
|
|
61
|
+
expect(ast.children[0].type).toBe("blockquote");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("parses a link", () => {
|
|
65
|
+
const ast = parseMarkdown("[example](https://example.com)");
|
|
66
|
+
const paragraph = ast.children[0] as any;
|
|
67
|
+
const link = paragraph.children[0];
|
|
68
|
+
expect(link.type).toBe("link");
|
|
69
|
+
expect(link.url).toBe("https://example.com");
|
|
70
|
+
expect(link.children[0].value).toBe("example");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("parses an image", () => {
|
|
74
|
+
const ast = parseMarkdown("");
|
|
75
|
+
const paragraph = ast.children[0] as any;
|
|
76
|
+
const image = paragraph.children[0];
|
|
77
|
+
expect(image.type).toBe("image");
|
|
78
|
+
expect(image.url).toBe("image.png");
|
|
79
|
+
expect(image.alt).toBe("alt text");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("parses a horizontal rule", () => {
|
|
83
|
+
const ast = parseMarkdown("---");
|
|
84
|
+
expect(ast.children[0].type).toBe("thematicBreak");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("parses GFM tables", () => {
|
|
88
|
+
const md = "| A | B |\n| --- | --- |\n| 1 | 2 |";
|
|
89
|
+
const ast = parseMarkdown(md);
|
|
90
|
+
expect(ast.children[0].type).toBe("table");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("parses GFM strikethrough", () => {
|
|
94
|
+
const ast = parseMarkdown("~~deleted~~");
|
|
95
|
+
const paragraph = ast.children[0] as any;
|
|
96
|
+
expect(paragraph.children[0].type).toBe("delete");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("parses GFM task lists", () => {
|
|
100
|
+
const ast = parseMarkdown("- [x] done\n- [ ] todo");
|
|
101
|
+
const list = ast.children[0] as any;
|
|
102
|
+
expect(list.children[0].checked).toBe(true);
|
|
103
|
+
expect(list.children[1].checked).toBe(false);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("handles empty input", () => {
|
|
107
|
+
const ast = parseMarkdown("");
|
|
108
|
+
expect(ast.type).toBe("root");
|
|
109
|
+
expect(ast.children).toHaveLength(0);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("handles complex multi-element markdown", () => {
|
|
113
|
+
const md = "# Title\n\nParagraph.\n\n- item\n\n```\ncode\n```";
|
|
114
|
+
const ast = parseMarkdown(md);
|
|
115
|
+
expect(ast.children.length).toBeGreaterThanOrEqual(4);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe("parseMarkdownAsync", () => {
|
|
120
|
+
it("returns the same AST as sync version", async () => {
|
|
121
|
+
const md = "# Hello\n\nWorld";
|
|
122
|
+
const syncAst = parseMarkdown(md);
|
|
123
|
+
const asyncAst = await parseMarkdownAsync(md);
|
|
124
|
+
expect(asyncAst).toEqual(syncAst);
|
|
125
|
+
});
|
|
126
|
+
});
|