Markdown cheat sheet

A quick reference for all the Markdown syntax that works on LFMarkdown, with an example you can copy for each one. It follows the CommonMark and GitHub Flavored Markdown specifications, so anything that renders on GitHub renders here too.

Text

**bold**  *italic*  ~~strikethrough~~  `code`
==highlighted==  ||spoiler||  __underline__
H~2~O and x^2^
-# small print

Headings

# Heading 1
## Heading 2
### Heading 3

Every heading gets a link anchor automatically.

Lists

- Bullet
- Another
  - Nested

1. First
2. Second

- [x] Completed task
- [ ] Pending task
[Link text](https://example.com)
![Alt text](https://example.com/image.png)
[[WikiLink]]
[[WikiLink|Custom label]]

Code

Fence a block and name the language for syntax highlighting:

```ruby
def publish(markdown)
  Document.create!(content: markdown)
end
```

Dozens of languages are supported, including JavaScript, TypeScript, Python, Rust, Go, SQL, YAML, JSON, Bash, CSS and HTML. Highlighting happens on the server, so it works with JavaScript turned off.

Tables

| Left | Centre | Right |
|:-----|:------:|------:|
| a    |   b    |     c |

Callouts

> [!NOTE]
> Useful information.

> [!TIP]
> A helpful suggestion.

> [!IMPORTANT]
> Something to pay attention to.

> [!WARNING]
> Something that needs care.

> [!CAUTION]
> Something risky.

Math

Written in TeX, rendered with KaTeX:

Inline: $E = mc^2$

Display:

$$\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$$

Diagrams

Fence a block as mermaid:

```mermaid
graph LR
  Write --> Publish --> Share
```

Flowcharts, sequence diagrams, class diagrams, state diagrams, pie charts and Gantt charts all work.

Front matter

A YAML block at the very top becomes a property card, and its title names the document:

---
title: Release notes
author: Your name
---

Footnotes

Some claim.[^1]

[^1]: The supporting detail.

Limits

Documents are between 3 characters and 500 KB. Raw HTML is removed rather than rendered, which is what keeps published documents safe to open.