Sub topic 1
What GitHub Flavored Markdown adds to Markdown
Prerequisites
This chapter assumes you can browse a GitHub repository and commit a change. You should be comfortable editing plain text. You should also know what a project's install and usage steps are. You don't need to know any Markdown syntax yet.
Markdown, CommonMark, and GFM
Markdown is a plain-text format that converts to HTML. The original 2004 description left many edge cases open, so different tools rendered the same file differently.
CommonMark is a written specification with test examples that removes those ambiguities. GitHub Flavored Markdown (GFM) is a strict superset of CommonMark. Every valid CommonMark document renders the same way in GFM, and GFM adds a few extensions.
The four extensions in the GFM spec
The GFM specification adds four features to CommonMark:
| Extension | What it does |
|---|---|
| Tables | Pipe-separated rows with a delimiter row |
| Task lists | `- [ ]` and `- [x]` checkbox items |
| Strikethrough | `~~text~~` draws a line through text |
| Extended autolinks | Bare URLs such as `https://example.com` become links |
Here is a short example that uses three of them:
| Feature | Status |
|:--------------|:------:|
| Tables | done |
| Task lists | ~~todo~~ done |
- [x] Add a table
- [ ] Add a task listCommonMark alone would show this as plain text with pipes and brackets. GFM renders a table and checkboxes.
Features that belong to GitHub, not the spec
GitHub's website renders more than the GFM spec describes. These features work on github.com but may not work in other Markdown tools:
- Alerts such as
[!NOTE], built on blockquotes - Mermaid diagrams and math expressions
- Footnotes
- References such as
#123for issues and@usernamefor people - Emoji shortcodes such as
:tada:
Common errors
- Writing a table without the delimiter row (the line of dashes). Without it, the table does not render.
- Assuming an alert renders everywhere. In a viewer without alert support, it shows as an ordinary blockquote with the marker text visible.
- Using a Markdown preview from an editor that follows only CommonMark, then being surprised by the result on GitHub.
The rest of this tutorial builds on this split. Each later chapter notes whether a feature comes from CommonMark, the GFM spec, or GitHub itself.
Exercise
A teammate pastes a table into a README. On GitHub it renders as a table, but a different Markdown tool shows plain text with pipes. Is the table syntax a CommonMark feature, a GFM spec extension, or a GitHub-only feature? Which of the two tools most likely supports only CommonMark?
Show answer
Tables are a GFM spec extension. CommonMark has no table syntax. GitHub renders GFM, so it shows a table, and the other tool most likely supports only CommonMark.