Markdown for Writers: Syntax, CommonMark, GFM and Pandoc
Markdown is a way of writing headings, emphasis, lists and links as plain text so the file stays readable before any software touches it. John Gruber announced it on Daring Fireball on 15 March 2004 as a text-to-HTML tool, and his own page states the aim: “The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible”. Three things matter to a writer today: the original syntax, the CommonMark specification that settled its ambiguities (version 0.31.2, dated 28 January 2024, as of November 2026), and GitHub Flavored Markdown, which adds tables and task lists. Pandoc then turns a Markdown file into Word, PDF, EPUB or HTML.
Quick facts
| Item | What to know |
|---|---|
| Original | Gruber’s syntax description and a Perl script, Markdown.pl, developed with help from Aaron Swartz and released in 2004 (CommonMark spec, section 1.1) |
| Latest original download | Markdown 1.0.1, listed on Gruber’s page with the date 17 Dec 2004 |
| Standard | CommonMark 0.31.2 (2024-01-28), the current version on spec.commonmark.org |
| GitHub’s dialect | GFM, spec version 0.29-gfm (2019-04-06), described as “a strict superset of CommonMark” |
| Converter | Pandoc, which reads and writes markdown, commonmark, commonmark_x and gfm |
Where Markdown came from, and why there are “flavors”
Gruber’s syntax page describes the goal this way: Markdown is “intended to be as easy-to-read and easy-to-write as is feasible”, and a document should be “publishable as-is, as plain text”. Everything else follows from that: asterisks around a word look like emphasis even when nothing renders them, and a line starting with # looks like a heading.
The trouble was that the description was prose plus one script. The CommonMark specification says plainly that Gruber’s canonical description “does not specify the syntax unambiguously”. Its examples of the gaps are practical ones: how much indentation a sublist needs, and whether a blank line is needed before a block quote or heading. Different programs answered differently, which is why one file could render differently in two apps. Some of the dozens of implementations written in the following decade also added their own conventions for footnotes and tables.
CommonMark began in 2014 as a group effort by John MacFarlane of Pandoc, who writes the spec, and people from GitHub, Reddit, Stack Overflow, Discourse and Meteor (commonmark.org). The spec attempts to pin every case down with numbered examples; its version list runs from 0.5 (25 October 2014) to 0.31.2. GitHub’s GFM is built on CommonMark, and as of November 2026 the GFM spec is still version 0.29-gfm, dated 6 April 2019, the same day as CommonMark 0.29. Pandoc keeps its own enhanced dialect and also reads the others. For a writer the practical rule is: write the CommonMark core, and use extensions only after checking that the place you publish supports them.
The syntax table
The core below behaves the same in CommonMark and in GFM, except where the “Notes” column says otherwise.
| Element | You type | Notes |
|---|---|---|
| Heading, level 1 to 6 | # Title, ## Section, ### Subsection | CommonMark requires a space after the # characters (section 4.2). Gruber also allowed underlined headings with === and --- |
| Paragraph | A blank line between blocks | A single newline inside a paragraph does not start a new line in standard Markdown |
| Italic | *word* or _word_ | Both forms are documented on GitHub Docs |
| Bold | **word** or __word__ | ***word*** gives bold italic |
| Strikethrough | ~~word~~ | GFM extension, not in CommonMark |
| Bulleted list | - item | Use one marker consistently |
| Numbered list | 1. item | |
| Quote | > text | |
| Inline code | `code` | A backtick pair wraps the text, which suits filenames |
| Code block | Three backticks (or tildes) above and below | Backticks and tildes cannot be mixed in one fence (section 4.5) |
| Link | [label](https://example.com) | |
| Image |  | The path is relative to the document |
| Footnote | text[^1] and [^1]: Note. | GitHub and Pandoc support it; CommonMark itself does not define it |
| Task list | - [x] done and - [ ] open | GFM extension |
| Table | Pipes and a --- separator row | GFM extension (section 4.10 of the GFM spec); Pandoc calls it pipe_tables |
| Escape a symbol | \* | Gruber lists the characters that can be escaped: backslash, backtick, asterisk, underscore, braces, brackets, parentheses, hash, plus, minus, dot and exclamation mark |
Copy and paste: a small document
This sample exercises the elements writers use most. Save it as book-exchange.md and preview it in a Markdown editor. The table at the end is a GFM extension: GitHub and Pandoc render it, while a strict CommonMark previewer shows the pipes as plain text.
## Choose a location
Keep the entrance clear and make the shelf easy to reach.
### Check permission
Confirm the spot with the person responsible for the space. Read the
[building access rules](https://example.com/access) first.
Bring these items:
- A tape measure
- A pencil
- A sheet for recording dimensions
Follow this order:
1. Confirm the location.
2. Measure the available space.
3. Choose a shelf that fits.
> A shelf that blocks the entrance will be moved.
| Task | Owner | Due |
| --- | --- | --- |
| Confirm permission | Organizer | Monday |
| Measure the lobby | Volunteer | Tuesday |
Leave the top-level title out of the body when the publishing system already prints the title from its own field; start with the introduction instead. Run headings in order (level two, then three) so the structure matches the argument. The outlining guide covers how to give each section a job before you start typing.
Line breaks: the rule that surprises everyone
Gruber’s syntax page says single line breaks do not create a new line in the output; to force a break you “end a line with two or more spaces, then type return”. CommonMark adds a second way: a backslash at the end of a line is a hard line break (section 6.7), which the spec calls “a more visible alternative”. Two trailing spaces cannot be seen, and an editor that trims trailing whitespace deletes them. Pandoc’s own Markdown accepts the backslash too, through its escaped_line_breaks extension.
GitHub adds a complication. According to its formatting documentation, a single newline creates a line break in issues, pull requests and discussions, while in .md files you need two trailing spaces, a backslash or a <br/> tag. The same keystrokes therefore give different results depending on where the text lands. For poems and addresses, use the backslash and preview in the target app.
What GFM and CommonMark each add
CommonMark specifies the core syntax only: the 0.31.2 spec has no section on tables, footnotes, strikethrough or task lists. GFM’s own specification marks the extensions it layers on top: tables, task list items, strikethrough, autolinks and disallowed raw HTML. A file that uses tables, task lists, strikethrough or footnotes can look right on GitHub and break in a strict CommonMark app.
| Feature | Gruber 2004 | CommonMark 0.31.2 | GFM 0.29-gfm | Pandoc markdown |
|---|---|---|---|---|
| Headings, lists, links, emphasis | Yes | Yes | Yes | Yes |
| Tables | Not in the original | No | Yes | Yes (pipe_tables) |
| Strikethrough | Not in the original | No | Yes | Yes (strikeout) |
| Task lists | Not in the original | No | Yes | Yes (task_lists) |
| Footnotes | Not in the original | No | Not in the spec; GitHub renders them (not in wikis) | Yes (footnotes) |
| Blank line before a heading | Not required | Not required | Not required | Required (blank_before_header) |
Pandoc’s own markdown reads GFM’s strikethrough and task lists by default: its manual documents the strikeout extension for ~~word~~ and says task lists use “the syntax of GitHub-Flavored Markdown”.
The last row is the one that trips people moving a manuscript between tools. Pandoc’s manual states that “original Markdown syntax does not require a blank line before a heading. Pandoc does require this”. A heading jammed against the preceding paragraph becomes a heading in CommonMark and GFM, but in Pandoc’s default markdown it stays inside the paragraph as plain text. Leave a blank line above and below every heading and list, and the question never arises.
A decision checklist for choosing a dialect
- Will the text be published only on GitHub (README, wiki, issues)? Write GFM, and remember that footnotes do not render in wikis.
- Will it go to several destinations, such as a blog, a PDF and a Word file? Write the CommonMark core and add Pandoc extensions only for what the export needs.
- Does your notes app or publishing platform document its own syntax? Follow that page for anything outside the core, such as internal note links, embedded files and callouts.
- Does the document need citations or a table of contents? Use Pandoc; its
--citeprocand--tocoptions handle these. - After any structural edit, preview, then export a short sample and open it outside the editor.
Converting with Pandoc
Pandoc is a command-line converter. The getting started page gives the basic pattern: -f names the input format, -t the output, and -s makes a standalone file rather than a fragment. Markdown to HTML is the default pairing, so -f markdown -t html can be left off.
# HTML page
pandoc book-exchange.md -s -o book-exchange.html
# Word document
pandoc book-exchange.md -s -o book-exchange.docx
# PDF (needs a PDF engine, LaTeX by default)
pandoc book-exchange.md -s -o book-exchange.pdf
# Treat the input as GitHub Flavored Markdown
pandoc -f gfm book-exchange.md -s -o book-exchange.docx
Pandoc guesses formats from the file extension, so -o name.docx is enough. Notes on each output:
- Word. The manual says
--reference-docwill “use the specified file as a style reference in producing a docx or ODT file”. Build one.docxwith the fonts, margins and heading styles you want, then point every conversion at it. - PDF. By default Pandoc uses LaTeX to make the PDF, so a LaTeX engine must be installed (the getting started page names MacTeX, MiKTeX and texlive for macOS, Windows and Linux). The
--pdf-engineoption chooses another program. - EPUB. Pandoc’s EPUB guide makes a toy ebook with
pandoc mybook.txt -o mybook.epub, where the first two lines,% My Bookand% Sam Smith, set the title and author. For a full book it puts a YAML metadata block (title, author, rights, language) in a separatetitle.txtand lists that file before the chapter files. - Contents list.
--tocincludes an automatically generated table of contents; the manual notes that it has no effect unless-sis used. - Footnotes. Pandoc’s
footnotesextension reads[^1]in the text and[^1]: Here is the footnote.as a definition, which may appear anywhere except inside lists, quotes or tables.
A worked example: one manuscript, three outputs
Take a 4,000-word essay in essay.md with a YAML block at the top (title, author) and footnotes. One source, three commands: the .docx goes to an editor who works in Word, the .pdf is the reading copy, and the .html goes online. The Markdown stays the master. Changes from the editor are copied back into essay.md, so the source never drifts from the published copies.
Check three things in each output. Headings should appear in the right order, links should still point to their targets, and tables should fit the page or a phone-width screen. Pandoc’s manual notes that the cells of pipe_tables “cannot contain block elements like paragraphs and lists”, so a table whose cells need paragraphs should become a short list or a separate section.
Common failures and fixes
- Lists collapse or merge. Indent sublists consistently, and keep a blank line before a list that follows a paragraph. This is one of the cases the CommonMark spec exists to settle.
- Asterisks vanish. An asterisk or underscore can start emphasis. Escape it with a backslash when it must appear literally.
- A heading renders as text. Look for a missing space after the hashes, or, in Pandoc, no blank line above it.
- Images break after moving the file. Relative paths resolve from the document’s folder. Keep the images beside the Markdown.
- Image descriptions. Write the text in the brackets to say what the image adds to the page. The self-editing checklist is the place for a final pass over the whole document.
Keep the Markdown source as well as every export. A PDF is for distribution; the plain-text file remains the version any editor can open.
Sources
- Daring Fireball: Introducing Markdown, 15 March 2004.
- Daring Fireball: Markdown project page.
- Daring Fireball: Markdown syntax documentation.
- CommonMark specification, version 0.31.2.
- CommonMark spec versions index.
- CommonMark project home page: who started it in 2014.
- GitHub Flavored Markdown specification, 0.29-gfm.
- GitHub Docs: basic writing and formatting syntax.
- Pandoc User’s Guide.
- Pandoc: getting started.
- Pandoc: creating an ebook.