You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/style-guide/components/markdown.mdx
+35-2Lines changed: 35 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,17 @@
2
2
title: Markdown
3
3
---
4
4
5
-
This component uses `marked` to turn the `text` prop into HTML. This is useful with, for example partial files that have variables you need to format.
5
+
This component uses [`marked`](https://marked.js.org/) to render [CommonMark and various other Markdown flavours](https://marked.js.org/#specifications).
6
+
7
+
:::caution
8
+
9
+
This component can not use [MDX](https://mdxjs.com/) or [Astro](https://docs.astro.build/en/guides/markdown-content/) features, such as [optimised images in the assets directory](https://docs.astro.build/en/guides/images/#images-in-mdx-files).
10
+
11
+
Headings should not be used with this component, as they will not receive an `id`, copyable link or appear in the table of contents.
12
+
13
+
Code blocks should not be used with this component, as they will not receive syntax highlighting or a copy to clipboard button.
14
+
15
+
:::
6
16
7
17
```mdx live
8
18
import { Markdown } from"~/components";
@@ -18,4 +28,27 @@ If you have a variable that needs to be formatted in any special way (for exampl
18
28
<Markdowntext={props.foo} />
19
29
```
20
30
21
-
Note that you need to wrap your variable in curly braces, as well as use `text=` or this will not work.
31
+
Note that you need to wrap your variable in curly braces, as well as use `text=` or this will not work.
32
+
33
+
## Multi-line strings
34
+
35
+
The Markdown component uses the [`dedent`](https://www.npmjs.com/package/dedent) library to remove indentation from multi-line strings.
36
+
37
+
This is because the [CommonMark spec](https://spec.commonmark.org/0.22/#indented-code-blocks) treats indented text as code blocks, unlike [MDX](https://mdxjs.com/docs/what-is-mdx/#:~:text=Indented%20code%20does%20not%20work%20in%20MDX%3A).
38
+
39
+
```mdx live
40
+
import { Markdown } from"~/components";
41
+
42
+
<>
43
+
<Markdown
44
+
text={`
45
+
You need to purchase [Magic WAN](https://www.cloudflare.com/magic-wan/) before you can purchase and use the Magic WAN Connector. The Magic WAN Connector can function as your primary edge device for your network, or be deployed in-line with existing network gear.
46
+
47
+
You also need to purchase a Magic WAN Connector before you can start configuring your settings in the Cloudflare dashboard. After buying a Magic WAN Connector, the device will be registered with your Cloudflare account and show up in your Cloudflare dashboard.
48
+
49
+
Contact your account representative to learn more about purchasing options for the Magic WAN Connector device.
0 commit comments