Skip to content

cheat-sheet.md

Markdown cheat sheet

Every piece of syntax MD Doctor understands, with the exact source and the result it renders. Copy a snippet, or open it straight in the editor.

Basic syntax

Headings

Start a line with one to six # characters. One # is the largest heading; leave a space after the last #.

Markdown
# Heading 1
## Heading 2
### Heading 3
Result
Heading 1
Heading 2
Heading 3

Bold and italic

Wrap text in two asterisks for bold and one for italic. Three asterisks make it both.

Markdown
**Bold**, *italic* and ***both***.
Result

Bold, italic and both.

Blockquotes

Start a line with > to quote it. A quote can contain other Markdown, including lists.

Markdown
> Markdown is intended to be as easy-to-read
> and easy-to-write as is feasible.
Result

Markdown is intended to be as easy-to-read and easy-to-write as is feasible.

Bulleted lists

Start each line with -, * or +. Indent by two spaces to nest a list.

Markdown
- Milk
- Bread
  - Sourdough
  - Rye
- Coffee
Result
  • Milk
  • Bread
    • Sourdough
    • Rye
  • Coffee

Numbered lists

Start each line with a number and a period. The first number sets where counting begins.

Markdown
1. Write
2. Preview
3. Export
Result
  1. Write
  2. Preview
  3. Export

Images

Like a link with a leading !. The text in brackets becomes the image's alt text.

Markdown
![MD Doctor icon](/icon.svg "MD Doctor")
Result

MD Doctor icon

Inline code

Wrap code in single backticks to show it in a monospace font.

Markdown
Run `npm run build` to compile.
Result

Run npm run build to compile.

Horizontal rule

Three or more hyphens on a line of their own draw a divider.

Markdown
Above the line

---

Below the line
Result

Above the line


Below the line

Escaping characters

Put a backslash before a character to show it literally instead of as formatting.

Markdown
\*Not italic\* and 1\. not a list
Result

*Not italic* and 1. not a list

Extended syntax (GFM)

Strikethrough

Wrap text in two tildes to cross it out.

Markdown
~~Old price~~ New price
Result

Old price New price

Task lists

Add [ ] or [x] after a list marker to make a checklist.

Markdown
- [x] Draft
- [x] Review
- [ ] Publish
Result
  • Draft
  • Review
  • Publish

Tables

Separate columns with pipes and the header row with hyphens. Colons set each column's alignment.

Markdown
| Format | Export | Notes      |
| :----- | :----: | ---------: |
| MD     |   ✓    | Plain text |
| HTML   |   ✓    | Standalone |
| PDF    |   ✓    | Via print  |
Result
FormatExportNotes
MD✓Plain text
HTML✓Standalone
PDF✓Via print

Code blocks

Fence code with three backticks and name the language for syntax highlighting.

Markdown
```js
const greet = (name) => `Hello, ${name}!`;
console.log(greet("Markdown"));
```
Result
const greet = (name) => `Hello, ${name}!`;
console.log(greet("Markdown"));

Footnotes

Mark a reference with [^1] and write the note anywhere in the document; notes are collected at the end.

Markdown
Markdown was created in 2004.[^1]

[^1]: By John Gruber, with Aaron Swartz.
Result

Markdown was created in 2004.1

Footnotes
  1. By John Gruber, with Aaron Swartz. ↩

Math, diagrams & HTML

Math (LaTeX)

Use $…$ for inline math and $$…$$ on their own lines for display equations, typeset with KaTeX.

Markdown
Inline: $E = mc^2$

$$
\int_0^1 x^2\,dx = \frac{1}{3}
$$
Result

Inline: E=mc2E = mc^2

∫01x2 dx=13\int_0^1 x^2\,dx = \frac{1}{3}

Mermaid diagrams

A code block marked mermaid becomes a flowchart, sequence diagram, Gantt chart and more.

Markdown
```mermaid
flowchart LR
  A[Write] --> B[Preview] --> C[Export]
```
Result
WritePreviewExport

Mermaid diagrams render live in the editor preview.

Inline HTML

Raw HTML fills the gaps Markdown has no syntax for, such as keyboard keys or collapsible sections.

Markdown
Press <kbd>Ctrl</kbd> + <kbd>S</kbd> to save.

<details>
<summary>Show more</summary>

Hidden until opened.

</details>
Result

Press Ctrl + S to save.

Show more

Hidden until opened.

Try it on your own document

Everything above works in the editor, with a live preview as you type.

Open the editor