Markdown
Markdown simplifies text formatting with plain text syntax, promoting efficient writing and consistent content across platforms.
#Examples
Markdown is a lightweight markup language that simplifies text formatting. It uses plain text syntax, making it easy to write and read. Markdown enhances content creation and ensures consistency across platforms.
Markdown syntax is intuitive, offering a simple way to structure and style your text:
Element | Markdown Syntax | Output Example |
---|---|---|
Heading 1 | # Heading 1 | Heading 1 |
Heading 2 | ## Heading 2 | Heading 2 |
Paragraph | Plain text | This is a regular paragraph. |
Bold | **bold text** | bold text |
Italic | *italic text* | italic text or italic text |
Unordered list | - Item or * Item |
|
Ordered list | 1. Item |
|
Link | [Link text](URL) | Link to Siteimprove |
Image | ![Image alt text](folder/filename.png) | |
Code | `inline code` or
```language
code block
with multiple lines
```
| inline code
|
Blockquote | > quoted text |
|
#Basic Usage
The markdown string:
This is a markdown string, it contains - A short list - with an *emphasized* word - and a [link](https://www.siteimprove.com)
And the result when rendered via the Markdown
component:
This is a markdown string, it contains
- A short list
- with an emphasized word
- and a link
const md = `This is a markdown string, it contains
- A short list
- with an *emphasized* word
- and a [link](https://www.siteimprove.com)`;
return (
<>
<p>The markdown string:</p>
<pre>{md}</pre>
<p>
And the result when rendered via the <code>Markdown</code> component:
</p>
<Markdown>{md}</Markdown>
</>
);
#HTML Escape
Markdown generally handles HTML characters gracefully, but you can explicitly escape HTML tags if needed. Here's an example:
The markdown string:
> A quote a paragraph <ul><li>Some HTML</li><li>That makes a list</li></ul>
And the result when rendered via the Markdown
(with noEscape) component:
> A quote
a paragraph
<ul><li>Some HTML</li><li>That makes a list</li></ul>
And without noEscape:
> A quote
a paragraph
<ul><li>Some HTML</li><li>That makes a list</li></ul>
const md = `
> A quote
a paragraph
<ul><li>Some HTML</li><li>That makes a list</li></ul>
`;
return (
<>
<p>The markdown string:</p>
<pre>{md}</pre>
<p>
And the result when rendered via the <code>Markdown</code> (with noEscape) component:
</p>
<Markdown noEscape>{md}</Markdown>
<p>And without noEscape:</p>
<Markdown>{md}</Markdown>
</>
);
#Properties
This is a markdown string, it contains
- A short list
- with an emphasized word
- and a link
Property | Description | Defined | Value |
---|---|---|---|
childrenRequired | string | ||
optionsOptional | object | ||
classNameOptional | string Custom className that's applied to the outermost element (only intended for special cases) | ||
noEscapeOptional | boolean | ||
openLinksInNewTabOptional | boolean | ||
data-observe-keyOptional | string Unique string, used by external script e.g. for event tracking | ||
styleOptional | object Style object to apply custom inline styles (only intended for special cases) |
#Guidelines
#Best practices
#Do not use when
#Accessibility
Explore detailed guidelines for this component: Accessibility Specifications