# Markdown

Markdown is a lightweight markup language for creating formatted text using a plain-text editor. John Gruber created Markdown in 2004 as an easy-to-read markup language. Markdown is widely used for blogging and instant messaging, and also used elsewhere in online forums, collaborative software, documentation pages, and readme files.
The initial description of Markdown contained ambiguities and raised unanswered questions, causing implementations to both intentionally and accidentally diverge from the original version. This was addressed in 2014 when long-standing Markdown contributors released CommonMark, an unambiguous specification and test suite for Markdown.

## History

Markdown was inspired by pre-existing conventions for marking up plain text in email and usenet posts, such as the earlier markup languages setext (c. 1992), Textile (c. 2002), and reStructuredText (c. 2002).
In 2002 Aaron Swartz created atx and referred to it as "the true structured text format". Gruber created the Markdown language in 2004 with Swartz as his "sounding board". The goal of the language was to enable people "to write using an easy-to-read and easy-to-write plain text format, optionally convert it to structurally valid XHTML (or HTML)".
Another key design goal was readability, that the language be readable as-is, without looking like it has been marked up with tags or formatting instructions, unlike text formatted with "heavier" markup languages, such as Rich Text Format (RTF), HTML, or even wikitext (each of which have obvious in-line tags and formatting instructions which can make the text more difficult for humans to read).
Gruber wrote a Perl script, Markdown.pl, which converts marked-up text input to valid, well-formed XHTML or HTML, encoding angle brackets (<, >) and ampersands (&), which would be misinterpreted as special characters in those languages. It can take the role of a standalone script, a plugin for Blosxom or a Movable Type, or of a text filter for BBEdit.

## Rise and divergence

As Markdown's popularity grew rapidly, many Markdown implementations appeared, driven mostly by the need for additional features such as tables, footnotes, definition lists, and Markdown inside HTML blocks.
The behavior of some of these diverged from the reference implementation, as Markdown was only characterised by an informal specification and a Perl implementation for conversion to HTML.
At the same time, a number of ambiguities in the informal specification had attracted attention. These issues spurred the creation of tools such as Babelmark to compare the output of various implementations, and an effort by some developers of Markdown parsers for standardisation. However, Gruber has argued that complete standardization would be a mistake: "Different sites (and people) have different needs. No one syntax would make all happy."
Gruber avoided using curly braces in Markdown to unofficially reserve them for implementation-specific extensions.

## Standardization

From 2012, a group of people, including Jeff Atwood and John MacFarlane, launched what Atwood characterised as a standardisation effort.
A community website now aims to "document various tools and resources available to document authors and developers, as well as implementors of the various Markdown implementations".
In September 2014, Gruber objected to the usage of "Markdown" in the name of this effort and it was rebranded as CommonMark. CommonMark.org published several versions of a specification, reference implementation, test suite, and "[plans] to announce a finalized 1.0 spec and test suite in 2019".
No 1.0 spec has since been released, as major issues still remain unsolved.
Nonetheless, the following websites and projects have adopted CommonMark: Discourse, GitHub, GitLab, Reddit, Qt, Stack Exchange (Stack Overflow), and Swift.
In March 2016, two relevant informational Internet RFCs were published:
* RFC 7763 introduced MIME type text/markdown.
* RFC 7764 discussed and registered the variants MultiMarkdown, GitHub Flavored Markdown (GFM), Pandoc, and Markdown Extra among others.

## Variants

Websites like Bitbucket, Diaspora, Discord, GitHub, OpenStreetMap, Reddit, SourceForge and Stack Exchange use variants of Markdown to make discussions between users easier.
Depending on implementation, basic inline HTML tags may be supported.
Italic text may be implemented by _underscores_ or *single-asterisks*.

### GitHub Flavored Markdown

GitHub had been using its own variant of Markdown since as early as 2009, which added support for additional formatting such as tables and nesting block content inside list elements, as well as GitHub-specific features such as auto-linking references to commits, issues, usernames, etc.
In 2017, GitHub released a formal specification of its GitHub Flavored Markdown (GFM) that is based on CommonMark. It is a strict superset of CommonMark, following its specification exactly except for tables, strikethrough, autolinks and task lists, which GFM adds as extensions.
Accordingly, GitHub also changed the parser used on their sites, which required that some documents be changed. For instance, GFM now requires that the hash symbol that creates a heading be separated from the heading text by a space character.

### Markdown Extra

Markdown Extra is a lightweight markup language based on Markdown implemented in PHP (originally), Python and Ruby. It adds the following features that are not available with regular Markdown:
* Markdown markup inside HTML blocks
* Elements with id/class attribute
* "Fenced code blocks" that span multiple lines of code
* Tables
* Definition lists
* Footnotes
* Abbreviations
Markdown Extra is supported in some content management systems such as Drupal, Grav (CMS) and TYPO3.

## Examples

| Text using Markdown syntax | Corresponding HTML produced by a Markdown processor | Text viewed in a browser |
| Heading ======= Sub-heading ----------- # Alternative heading ## Alternative sub-heading Paragraphs are separated by a blank line. Two spaces at the end of a line produce a line break. | <h1>Heading</h1> <h2>Sub-heading</h2> <h1>Alternative heading</h1> <h2>Alternative sub-heading</h2> <p>Paragraphs are separated by a blank line.</p> <p>Two spaces at the end of a line<br /> produce a line break.</p> | Heading Sub-heading Alternative heading Alternative sub-heading Paragraphs are separated by a blank line. Two spaces at the end of a line produce a line break. |
| Text attributes _italic_, **bold**, `monospace`. Horizontal rule: --- | <p>Text attributes <em>italic</em>, <strong>bold</strong>, <code>monospace</code>.</p> <p>Horizontal rule:</p> <hr /> | Text attributes italic, bold, monospace. Horizontal rule: |
| Bullet lists nested within numbered list: 1. fruits * apple * banana 2. vegetables - carrot - broccoli | <p>Bullet lists nested within numbered list:</p> <ol> <li>fruits <ul> <li>apple</li> <li>banana</li> </ul></li> <li>vegetables <ul> <li>carrot</li> <li>broccoli</li> </ul></li> </ol> | Bullet lists nested within numbered list: fruits apple banana vegetables carrot broccoli |
| A [link](http://example.com). ![Image](Icon-pictures.png "icon") > Markdown uses email-style characters for blockquoting. > > Multiple paragraphs need to be prepended individually. Most inline <abbr title="Hypertext Markup Language">HTML</abbr> tags are supported. | <p>A <a href="http://example.com">link</a>.</p> <p><img alt="Image" title="icon" src="Icon-pictures.png" /></p> <blockquote> <p>Markdown uses email-style characters for blockquoting.</p> <p>Multiple paragraphs need to be prepended individually.</p> </blockquote> <p>Most inline <abbr title="Hypertext Markup Language">HTML</abbr> tags are supported.</p> | A link. Markdown uses email-style characters for blockquoting. Multiple paragraphs need to be prepended individually. Most inline HTML tags are supported. |

## Implementations

Implementations of Markdown are available for over a dozen programming languages; in addition, many applications, platforms and frameworks support Markdown. For example, Markdown plugins exist for every major blogging platform.
While Markdown is a minimal markup language and is read and edited with a normal text editor, there are specially designed editors that preview the files with styles, which are available for all major platforms. Many general-purpose text and code editors have syntax highlighting plugins for Markdown built into them or available as optional download. Editors may feature a side-by-side preview window or render the code directly in a WYSIWYG fashion.