User Tools

Site Tools


manuals:markdown

Markdown Cheatsheet

A quick reference for Markdown syntax. This file is itself written in Markdown, so you can open it in any editor or previewer to see the rendered result next to the raw syntax.

Covers CommonMark plus widely supported extensions (GitHub Flavored Markdown). Extensions are marked (GFM); support varies by app.

Headings

# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6
Tip: leave a blank line before and after headings, and put a space after the #.

Text Formatting

StyleSyntaxResult
Bold**bold** or __bold__bold
Italic*italic* or _italic_italic
Bold + italic***both***both
Strikethrough (GFM)~~text~~text
Inline code`code`code
Highlight (some apps)==text====text==
Subscript (some apps)H~2~OH~2~O
Superscript (some apps)X^2^X^2^

Paragraphs and Line Breaks

Separate paragraphs with a blank line:

First paragraph.
 
Second paragraph.

Force a line break within a paragraph by ending a line with two spaces or a backslash:

Line one··
Line two
 
Line one\
Line two

(·· above stands for two trailing spaces.)


Lists

Unordered

- Item
- Item
  - Nested item (indent 2 or 4 spaces)
  - Nested item
* Asterisks work too
+ So do plus signs

Ordered

1. First
2. Second
3. Third
   1. Nested
   2. Nested
The actual numbers don't matter to most renderers: 1. 1. 1. still renders as 1, 2, 3.

Multi-paragraph list items

1. First item
 
   Indented paragraph belongs to the first item.
 
2. Second item

[Inline link](https://example.com)
[Link with title](https://example.com "Hover title")
<https://example.com>                      (auto-link)
[Reference link][ref]
[Relative link](../docs/guide.md)
[Jump to section](#headings)
 
[ref]: https://example.com "Optional title"

Images

![Alt text](path/to/image.png)
![Alt text](path/to/image.png "Optional title")
![Alt text][img-ref]
 
[img-ref]: path/to/image.png

Clickable image (image inside a link):

[![Alt text](image.png)](https://example.com)

Blockquotes

> A quote.
>
> A second paragraph in the same quote.
>
> > A nested quote.

Code

Inline

Use `printf()` to print.
Use ``code with a ` backtick`` inside double backticks.

Fenced code blocks

Use three backticks (or three tildes) and an optional language for syntax highlighting:

```python
def hello():
    print("Hello, world!")
{ "name": "example" }
echo "tildes work too"
To show a code fence *inside* a code block, wrap it in a longer fence (four backticks), as this cheatsheet does.

### Indented code block

Indent every line by 4 spaces (or 1 tab):

```markdown
    This is a code block.
    No language highlighting here.

Horizontal Rules

Any of these on their own line (with blank lines around):

---
***
___

Tables (GFM)

| Left | Center | Right |
|:-----|:------:|------:|
| a    |   b    |     c |
| 1    |   2    |     3 |

Renders as:

LeftCenterRight
abc
123

- Colons in the separator row control alignment. - Pipes don't need to line up; it just looks nicer. - Escape a literal pipe inside a cell with \|.


Task Lists (GFM)

- [x] Done
- [ ] Not done
- [ ] Also not done

- [x] Done - [ ] Not done - [ ] Also not done


Footnotes

Supported by many renderers (GitHub, Pandoc, many static-site generators):

Here is a statement with a footnote.[^1]
 
[^1]: This is the footnote text.

Escaping Characters

Put a backslash before a character to show it literally:

\*not italic\*
\# not a heading
1\. not a list

Characters you can escape:

\   `   *   _   {}   []   ()   #   +   -   .   !   |   <   >

HTML in Markdown

Most renderers allow inline HTML for things Markdown can't do:

<details>
<summary>Click to expand</summary>
 
Hidden content here. Markdown works inside if separated by blank lines.
 
</details>
 
Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy.
 
<br>
 
<!-- This is a comment and won't render -->

Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy.

<details> <summary>Click to expand</summary>

Hidden content here.

</details>

<!– This is a comment and won't render –>


Tips

- Blank lines matter. Put one before and after headings, lists, code blocks, tables, and blockquotes. - Stay consistent. Pick - or * for bullets and stick with it. - Name your code fences. Adding a language (js, python, bash, …) enables syntax highlighting. - Use relative links for files in the same repo so they keep working when it's cloned. - Preview as you go. VS Code (Ctrl/Cmd+Shift+V), Obsidian, Typora, and GitHub all render Markdown live. - Renderer differences. Tables, task lists, footnotes, highlight, and sub/superscript aren't part of original Markdown; check what your target app supports.


Save this file as markdown-cheatsheet.md and keep it handy.

manuals/markdown.txt · Last modified: by oscar