Introduction
Markdown is a way of writing formatted text with plain characters, created by John
Gruber with Aaron Swartz in 2004. A # makes a heading, asterisks make
emphasis and a dash starts a list item, so the file reads naturally as written and
converts cleanly to HTML. It is used for README files, documentation, notes and
comments on sites such as GitHub.
The original description left many cases open, so dialects grew.
CommonMark is a precise specification of the
core (version 0.31.2), and GitHub Flavored Markdown (version 0.29-gfm) adds tables, task
list items, strikethrough, extended autolinks and a filter for disallowed raw HTML on
top of it. Files use .md or .markdown, and the media type is
text/markdown (RFC 7763). The .md extension is also used for
Sega Mega Drive ROM images.
Structure
A Markdown file is plain text, normally UTF-8, read one line at a time. Any sequence of characters is a valid document, so there is nothing a file can get wrong; a mark that does not fit the rules is simply text. The document is a sequence of leaf blocks (headings, paragraphs, code, thematic breaks, HTML blocks, link reference definitions) and container blocks (block quotes, lists), and the text of paragraphs and headings holds inlines (emphasis, links, images, code spans). Blank lines separate paragraphs, but a heading, a thematic break or a code fence can follow a paragraph directly.
A heading starts with one to six # characters; a list item starts with
-, +, *, or a number with . or
); a quote starts with >; and code is either indented by
four spaces or fenced by three or more backticks or tildes. Within a line,
*text* and **text** (or the same with _) give
emphasis and strong emphasis, and [text](address) makes a link. Many tools
also read a block of YAML
front matter between two ---
lines at the top of the file, though that is not part of any Markdown specification.
# Packing list
Bring the **essentials** and *nothing* more:
- Tent
- Stove
- [Map of the route](https://example.com/map)
> Check the forecast before leaving.
Also used for
- Sega Mega Drive ROM image – Mega Drive and Genesis cartridge ROMs: 68000 vectors, then a text header.
Links
Software
- Markdown.org editor – online Markdown editor with a live preview (web browsers)
- Visual Studio Code – free code editor with a built-in Markdown preview (Windows, macOS, Linux)
- Obsidian – note-taking app that keeps notes as Markdown files (Windows, macOS, Linux, mobile)
- Typora – Markdown editor that shows formatting as you type (Windows, macOS, Linux)
- Pandoc – command-line converter between Markdown and many other formats (Windows, macOS, Linux)
- GitHub – code hosting site that shows .md files as formatted pages (web browsers)
Developers
- cmark – reference implementation of CommonMark (C)
- markdown-it – Markdown parser (JavaScript)
- Marked – Markdown parser (JavaScript)
- Python-Markdown – Markdown to HTML converter (Python)
Reference
- CommonMark Spec – a precise specification of core Markdown
- GitHub Flavored Markdown Spec – CommonMark plus GitHub’s tables, task list items, strikethrough, extended autolinks and tag filter
- Markdown – John Gruber’s original description
- RFC 7763 – the media type text/markdown