Skip to content

Menu

Markdown Cheat Sheet: CommonMark, GFM and GitHub Syntax

Checked against Markdown (CommonMark / GFM) CommonMark 0.31.2; GFM spec 0.29-gfm; examples run on commonmark.js 0.31.2 and markdown-it 15.0.3 on 28 November 2026. Each section links to the official docs it was checked against.

This sheet is for people who write READMEs, docs and pull request descriptions and are tired of a list that renders fine on GitHub and breaks on the docs site. Every feature is labelled by where it works: CommonMark 0.31.2 (the core spec), GFM (GitHub Flavored Markdown, spec 0.29-gfm) or GitHub only. The CommonMark rows were run through commonmark.js 0.31.2 and markdown-it 15.0.3; the GFM and GitHub-only rows are from the specs and GitHub's writing docs.

When to use what

Write to plain CommonMark by default. It is the part every modern renderer agrees on, so your text survives a move from GitHub to a static site generator, a wiki or an LLM prompt. Reach for GFM features (tables, task lists, strikethrough, bare URL links) when you know the target supports them; most hosted git platforms and many renderers do, but a strict CommonMark parser prints them as plain text. We ran a GFM table through commonmark.js and got a paragraph full of pipes.

Keep the GitHub-only features (alerts like > [!NOTE], footnotes, @mentions, emoji shortcodes, issue references) for files that are only ever read on GitHub. Elsewhere they degrade badly: a footnote reference in plain CommonMark became a link pointing at the footnote text, which is worse than no footnote at all.

If you are unsure what your renderer does, paste the text into the Markdown preview before you commit. For tables, generate the pipes with the table generator instead of aligning them by hand, and if you are converting old HTML docs, start with HTML to Markdown and then fix the lists. Our Markdown writing guide covers structure and style; this page is about syntax that parses the way you expect.

CommonMark needs a space after the #. We ran #Title through both parsers and got a paragraph, not a heading.

# Title … ###### Title

ATX headings, levels 1 to 6; a space or tab must follow the hashes

Title =====

Setext heading level 1 (use --- underline for level 2); needs no blank line inside the text

*em* or _em_

Emphasis; * works inside a word (foo*bar*baz) but _ does not, so snake_case_name stays literal

**strong** or __strong__

Strong emphasis with doubled markers; same intraword rule as single markers

line one\

A backslash at the end of a line forces a line break (<br>) in both parsers we ran

line one␣␣

Two or more trailing spaces also make a hard break, but editors often strip them, so prefer the backslash

From the docs, not run by us
*** or --- or ___

Thematic break (horizontal rule): three or more of the same character on their own line

Nested content must line up with the text after the parent's marker, not with the marker. For 1. that means three spaces; for - it means two.

- item + item * item

Bullet markers; switching to a different marker starts a new list (we got two <ul> elements)

3. three 4. four

Ordered list starting at the first number; renders <ol start="3">

1) item

Ordered list with ) delimiter; changing between . and ) also starts a new list

From the docs, not run by us
1. One - child

Nested list indented three spaces under 1. ; with only two spaces the child became a separate top-level list

Para 1. item

Only a list starting at 1 can interrupt a paragraph; 2. item under a paragraph stays part of the paragraph

- a - b

A blank line between items makes the list loose, so each item gets a <p> and extra spacing

From the docs, not run by us
`code`

Inline code span; backslash escapes do not work inside it

`` a `tick` ``

Use a longer backtick run when the code contains backticks; one leading and trailing space is stripped

```ts … ```

Fenced block with an info string (used for syntax highlighting); the closing fence must be at least as long

~~~ … ~~~

Tilde fence; handy when the block itself contains triple backticks

From the docs, not run by us
code

Indented code block (4 spaces); cannot interrupt a paragraph, so it needs a blank line before it

From the docs, not run by us

These rows need a GFM renderer. markdown-it's default preset handles tables and ~~, but not task lists, single-tilde strikethrough or www. links without plugins.

| A | B | |:--|--:| | 1 | 2 |

Table: header row, then a delimiter row; colons set left, right or centre alignment

| a \| b |

Escape a pipe inside a cell with a backslash; markdown-it rendered the cell as a | b

~~gone~~

Strikethrough with two tildes; GFM also accepts one, three or more are left as text

- [ ] todo - [x] done

Task list items rendered as checkboxes; plain CommonMark shows the brackets as text

From the docs, not run by us
www.example.com

Extended autolink: bare www., http(s):// and email addresses become links; trailing . , ? ! are left out

From the docs, not run by us
<script> <iframe> <style>

GFM's tagfilter disarms nine tags (also title, textarea, xmp, noembed, noframes, plaintext) by escaping the <

From the docs, not run by us

These come from GitHub's writing docs, not the GFM spec. Other renderers usually show them as plain text.

> [!NOTE] > Text

Alert callout; the five types are NOTE, TIP, IMPORTANT, WARNING and CAUTION, and alerts can't be nested

From the docs, not run by us
Text[^1] [^1]: Source.

Footnote; in plain CommonMark it rendered as a link whose href was the footnote text, so only use it on GitHub

From the docs, not run by us
[Setup](#getting-started)

Link to a heading anchor: lowercase, spaces to hyphens, other punctuation removed, duplicates get -1

From the docs, not run by us
[Guide](docs/CONTRIBUTING.md)

Relative link inside a repo; a leading / resolves from the repository root

From the docs, not run by us
<sub>x</sub> <sup>2</sup> <ins>u</ins>

Subscript, superscript and underline via allowed HTML tags

From the docs, not run by us
:+1: @user #123

Emoji shortcodes, mentions and issue references, rendered only on GitHub

From the docs, not run by us
<!-- hidden -->

HTML comment hides text from the rendered view but it stays in the source

From the docs, not run by us

Worked example: Fix a README list that renders differently on GitHub and your docs site

A setup step with a nested command list renders as one flat list on the docs site. Here is the source:

1. Install the CLI
  - npm i -g mytool
2. Run it

We ran this through commonmark.js 0.31.2 and markdown-it 15.0.3. Both produced the same output:

<ol>
<li>Install the CLI</li>
</ol>
<ul>
<li>npm i -g mytool</li>
</ul>
<ol start="2">
<li>Run it</li>
</ol>

Two spaces is less than the width of 1. , so the child is not inside the first item. The parser closes the ordered list, opens a bullet list, then opens a second ordered list that starts at 2. Indent the child by three spaces:

1. Install the CLI
   - npm i -g mytool
2. Run it

Now both parsers nest the <ul> inside the first <li> and keep one <ol>. GitHub's own docs give the same rule: line the child up with the first character of the parent's text. For a marker like 10. that is four spaces, so check long numbered lists too.

Common mistakes

  • Writing #Heading without a space after the hash.

    Add the space. CommonMark treats #Heading as a paragraph, which is also how hashtags stay safe.

  • Indenting nested list items by two spaces under a numbered item.

    Indent to the start of the parent's text: three spaces under 1. , four under 10. .

  • Using footnotes or > [!WARNING] alerts in docs that are built by a non-GitHub renderer.

    Check the renderer's docs first. If it lacks them, use a plain blockquote that starts with Warning: and an inline link instead of a footnote.

  • Putting a GFM table in a file processed by a strict CommonMark parser.

    Enable the table extension in your parser (markdown-it has it on by default) or use an HTML table.

  • A line starting with a year and a full stop, like 1986. A great year, turns into a numbered list.

    Escape the dot: 1986\. A great year.

  • Relying on trailing double spaces for line breaks.

    Use a trailing backslash instead; editors and formatters strip trailing whitespace without warning.

Sources

How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe
Reviews and commentsShow

Comments

Sign in to leave a comment.

Loading comments…