Jump to content

Markdown

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Wei2912 (talk | contribs) at 16:14, 20 April 2013 (→‎Lists). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Markdown
Filename extension
.md
Internet media typetext/markdown
Developed byJohn Gruber and Aaron Swartz
Initial releaseMarch 25, 2004; 20 years ago (2004-03-25)[1]
Latest release
1.0.1
December 17, 2004; 19 years ago (2004-12-17)[2]
Type of formatMarkup language
Free format?yes[3]
Websitedaringfireball.net/projects/markdown/

Markdown is a lightweight markup language, originally created by John Gruber with substantial contributions from Aaron Swartz, allowing people “to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML)”.[2] The language takes many cues from existing conventions for marking up plain text in email. In other words, Markdown is a text-to-HTML conversion tool (for web writers).

Markdown is also a Perl script written by Gruber, Markdown.pl, which converts marked-up text input to valid, well-formed XHTML or HTML and replaces left-pointing angle brackets ('<') and ampersands with their corresponding character entity references. It can be used as a standalone script, as a plugin for Blosxom or Movable Type, or as a text filter for BBEdit.[2]

Markdown has since been re-implemented by others as a Perl module available on CPAN (Text::Markdown), and in a variety of other programming languages. It is distributed under a BSD-style license[3] and is included with, or available as a plugin for, several content-management systems.[4][5]

Sites such as GitHub, reddit and Stack Overflow use Markdown to facilitate discussion between users.[6][7][8]

Syntax examples

This is not an exhaustive listing of Markdown's syntax, and in many cases multiple styles of syntax are available to accomplish a particular effect. See the full Markdown syntax for more information. Characters which are ordinarily interpreted by Markdown as formatting commands will instead be interpreted literally if preceded by a backslash; for example, the sequence '\*' would output an asterisk rather than beginning a span of emphasized text. Markdown also does not transform any text within a "raw" block-level XHTML element; thus it is possible to include sections of XHTML within a Markdown source document by wrapping them in block-level XHTML tags.

Headings

HTML headings are produced by placing a number of hashes before the header text corresponding to the level of heading desired (HTML offers six levels of headings), like so:

# First-level heading

#### Fourth-level heading

Optionally, headings may be "closed" with hashes that need not match the number of hashes placed at the front of a header, purely for cosmetic purposes.

# First-level heading #

#### Fourth-level heading ####

## Second-level heading #####

The first two heading levels also have an alternative syntax:

First-level heading
===================

Second-level heading
--------------------

Paragraphs

A paragraph is one or more consecutive lines of text separated by one or more blank lines. Normal paragraphs should not be indented with spaces or tabs:

This is a paragraph. It has two sentences.

This is another paragraph. It also has 
two sentences.

Lists

* An item in a bulleted (unordered) list
    * A subitem, indented with 4 spaces
* Another item in a bulleted list

In an ordered list, numbers need not match the order of elements.

1. An item in an enumerated (ordered) list
    1.1. A subitem, indented with 4 spaces
2. Another item in an enumerated list
9. Another item
5. Yet another item

Emphasized text

*emphasis* or _emphasis_  (e.g., italics)
**strong emphasis** or __strong emphasis__ (e.g., boldface)

Code

To include code (formatted in monospace font), you can either surround inline code with backticks (`), like in

Some text with `some code` inside,

or indent several lines of code by at least four spaces, as in:

    line 1 of code
    line 2 of code
    line 3 of code

The latter option makes Markdown retain all whitespace—as opposed to the usual behaviour, which, by removing line breaks and excess spaces, would break indentation and code layout.

Line breaks

When you do want to insert a break tag using Markdown, you end a line with two or more spaces, then type return. For example:

def show_results space space
end

Result:

def show_results
end

You can also use two newlines. For example:

sentence A

sentence B

Result:

sentence A
sentence B

Blockquotes

> "This entire paragraph of text will be enclosed in an HTML blockquote element.
Blockquote elements are reflowable. You may arbitrarily
wrap the text to your liking, and it will all be parsed
into a single blockquote element."

The above would translate into the following HTML:

<blockquote><p>This entire paragraph of text will be enclosed in an HTML blockquote element. Blockquote 
elements are reflowable. You may arbitrarily wrap the text to your liking, and it will all
be parsed into a single blockquote element.</p></blockquote>

Links may be included inline:

[link text here](link.address.here)
Ex. [Markdown](http://en.wikipedia.com/wiki/Markdown)

Alternatively, links can be placed in footnotes outside of the paragraph, being referenced with some sort of reference tag. For example, including the following inline:

[link text here][linkref]

would produce a link if the following showed up outside of the paragraph (or at the end of the document):

[linkref]: link.address.here "link title here"

Images

Images have similar syntax to links with a preceding exclamation point.

![Alt text](/path/to/img.jpg)

Or:

![Alt text](/path/to/img.jpg "Optional title")

Like links, images also have a footnote style syntax

![Alt text][id]

with a reference later in the document defining the URL location.

[id]: url/to/image  "Optional title attribute"

Horizontal rules

Horizontal rules are created by placing three or more hyphens, asterisks, or underscores on a line by themselves. You may use spaces between the hyphens or asterisks. Each of the following lines will produce a horizontal rule:

* * *
***
*****
- - -
---------------------------------------

Editors

While Markdown is a minimal markup language and is easily read and edited with a normal text editor there are special designed editors which preview the files direct with styles. There are a variety of such editors available for all of the major platforms. There are syntax highlighting plugins for markdown built into gedit and vim.

Implementations

Implementations of Markdown are available for many different frameworks, platforms and languages.

There are many more open-source software implementations of Markdown available online.

Standardization

There are no clearly defined Markdown standard, apart from the original writeup and implementation by John Gruber. In late 2012, a standardization effort was started, spurred in part by a blog post of Jeff Atwood[12]. 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"[13]. A tool (named Babelmark2[14]) is also available to "[compare] the output of various implementations" to "promote discussion of how and whether certain vague aspects of the markdown spec should be clarified"[15].

See also

References

  1. ^ http://web.archive.org/web/20040402182332/http://daringfireball.net/projects/markdown/
  2. ^ a b c Markdown 1.0.1 readme source code "Daring Fireball - Markdown". 17-Dec-2004. {{cite web}}: Check date values in: |date= (help)
  3. ^ a b http://daringfireball.net/projects/markdown/license
  4. ^ "MarsEdit 2.3 ties the knot with Tumblr support - Ars Technica". Retrieved 2009-08-11.
  5. ^ "Review: Practical Django Projects - Ars Technica". Retrieved 2009-08-11.
  6. ^ "GitHub Flavored Markdown". github.com. Retrieved 29 March 2013.
  7. ^ "Reddit markdown primer. Or, how do you do all that fancy formatting in your comments, anyway?". reddit.com. Retrieved 29 March 2013.
  8. ^ "Markdown help". http://stackoverflow.com. Retrieved 29 March 2013. {{cite web}}: External link in |publisher= (help)
  9. ^ https://github.com/rstudio/rstudio/blob/master/src/cpp/core/markdown/Markdown.cpp
  10. ^ http://plugins.jetbrains.com/plugin?id=5970
  11. ^ https://github.com/nicoulaj/idea-markdown
  12. ^ http://www.codinghorror.com/blog/2012/10/the-future-of-markdown.html
  13. ^ http://markdown.github.io/
  14. ^ http://johnmacfarlane.net/babelmark2/
  15. ^ http://johnmacfarlane.net/babelmark2/faq.html