|
|
1d434f7 |
Markdown: Basics
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Main
|
|
|
1d434f7 |
Basics
|
|
|
1d434f7 |
Syntax
|
|
|
1d434f7 |
License
|
|
|
1d434f7 |
Dingus
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Getting the Gist of Markdown's Formatting Syntax
|
|
|
1d434f7 |
|
|
|
1d434f7 |
This page offers a brief overview of what it's like to use Markdown.
|
|
|
1d434f7 |
The syntax page provides complete, detailed documentation for
|
|
|
1d434f7 |
every feature, but Markdown should be very easy to pick up simply by
|
|
|
1d434f7 |
looking at a few examples of it in action. The examples on this page
|
|
|
1d434f7 |
are written in a before/after style, showing example syntax and the
|
|
|
1d434f7 |
HTML output produced by Markdown.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
It's also helpful to simply try Markdown out; the Dingus is a
|
|
|
1d434f7 |
web application that allows you type your own Markdown-formatted text
|
|
|
1d434f7 |
and translate it to XHTML.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Note: This document is itself written using Markdown; you
|
|
|
1d434f7 |
can see the source for it by adding '.text' to the URL.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Paragraphs, Headers, Blockquotes
|
|
|
1d434f7 |
|
|
|
1d434f7 |
A paragraph is simply one or more consecutive lines of text, separated
|
|
|
1d434f7 |
by one or more blank lines. (A blank line is any line that looks like a
|
|
|
1d434f7 |
blank line -- a line containing nothing spaces or tabs is considered
|
|
|
1d434f7 |
blank.) Normal paragraphs should not be intended with spaces or tabs.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Markdown offers two styles of headers: Setext and atx.
|
|
|
1d434f7 |
Setext-style headers for <h1> and <h2> are created by
|
|
|
1d434f7 |
"underlining" with equal signs (= ) and hyphens (- ), respectively.
|
|
|
1d434f7 |
To create an atx-style header, you put 1-6 hash marks (# ) at the
|
|
|
1d434f7 |
beginning of the line -- the number of hashes equals the resulting
|
|
|
1d434f7 |
HTML header level.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Blockquotes are indicated using email-style '> ' angle brackets.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Markdown:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
A First Level Header
|
|
|
1d434f7 |
====================
|
|
|
1d434f7 |
|
|
|
1d434f7 |
A Second Level Header
|
|
|
1d434f7 |
---------------------
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Now is the time for all good men to come to
|
|
|
1d434f7 |
the aid of their country. This is just a
|
|
|
1d434f7 |
regular paragraph.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
The quick brown fox jumped over the lazy
|
|
|
1d434f7 |
dog's back.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
### Header 3
|
|
|
1d434f7 |
|
|
|
1d434f7 |
> This is a blockquote.
|
|
|
1d434f7 |
>
|
|
|
1d434f7 |
> This is the second paragraph in the blockquote.
|
|
|
1d434f7 |
>
|
|
|
1d434f7 |
> ## This is an H2 in a blockquote
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Output:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<h1>A First Level Header</h1>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<h2>A Second Level Header</h2>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<p>Now is the time for all good men to come to
|
|
|
1d434f7 |
the aid of their country. This is just a
|
|
|
1d434f7 |
regular paragraph.</p>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<p>The quick brown fox jumped over the lazy
|
|
|
1d434f7 |
dog's back.</p>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<h3>Header 3</h3>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<blockquote>
|
|
|
1d434f7 |
<p>This is a blockquote.</p>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<p>This is the second paragraph in the blockquote.</p>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<h2>This is an H2 in a blockquote</h2>
|
|
|
1d434f7 |
</blockquote>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Phrase Emphasis
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Markdown uses asterisks and underscores to indicate spans of emphasis.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Markdown:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Some of these words *are emphasized*.
|
|
|
1d434f7 |
Some of these words _are emphasized also_.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Use two asterisks for **strong emphasis**.
|
|
|
1d434f7 |
Or, if you prefer, __use two underscores instead__.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Output:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<p>Some of these words <em>are emphasized</em>.
|
|
|
1d434f7 |
Some of these words <em>are emphasized also</em>.</p>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<p>Use two asterisks for <strong>strong emphasis</strong>.
|
|
|
1d434f7 |
Or, if you prefer, <strong>use two underscores instead</strong>.</p>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Lists
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Unordered (bulleted) lists use asterisks, pluses, and hyphens (* ,
|
|
|
1d434f7 |
+ , and - ) as list markers. These three markers are
|
|
|
1d434f7 |
interchangable; this:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
* Candy.
|
|
|
1d434f7 |
* Gum.
|
|
|
1d434f7 |
* Booze.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
this:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
+ Candy.
|
|
|
1d434f7 |
+ Gum.
|
|
|
1d434f7 |
+ Booze.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
and this:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
- Candy.
|
|
|
1d434f7 |
- Gum.
|
|
|
1d434f7 |
- Booze.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
all produce the same output:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<ul>
|
|
|
1d434f7 |
<li>Candy.</li>
|
|
|
1d434f7 |
<li>Gum.</li>
|
|
|
1d434f7 |
<li>Booze.</li>
|
|
|
1d434f7 |
</ul>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Ordered (numbered) lists use regular numbers, followed by periods, as
|
|
|
1d434f7 |
list markers:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
1. Red
|
|
|
1d434f7 |
2. Green
|
|
|
1d434f7 |
3. Blue
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Output:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<ol>
|
|
|
1d434f7 |
<li>Red</li>
|
|
|
1d434f7 |
<li>Green</li>
|
|
|
1d434f7 |
<li>Blue</li>
|
|
|
1d434f7 |
</ol>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
If you put blank lines between items, you'll get <p> tags for the
|
|
|
1d434f7 |
list item text. You can create multi-paragraph list items by indenting
|
|
|
1d434f7 |
the paragraphs by 4 spaces or 1 tab:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
* A list item.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
With multiple paragraphs.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
* Another item in the list.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Output:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<ul>
|
|
|
1d434f7 |
<li><p>A list item.</p>
|
|
|
1d434f7 |
<p>With multiple paragraphs.</p></li>
|
|
|
1d434f7 |
<li><p>Another item in the list.</p></li>
|
|
|
1d434f7 |
</ul>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Links
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Markdown supports two styles for creating links: inline and
|
|
|
1d434f7 |
reference. With both styles, you use square brackets to delimit the
|
|
|
1d434f7 |
text you want to turn into a link.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Inline-style links use parentheses immediately after the link text.
|
|
|
1d434f7 |
For example:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
This is an [example link](http://example.com/).
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Output:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<p>This is an <a href="http://example.com/">
|
|
|
1d434f7 |
example link</a>.</p>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Optionally, you may include a title attribute in the parentheses:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
This is an [example link](http://example.com/ "With a Title").
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Output:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<p>This is an <a href="http://example.com/" title="With a Title">
|
|
|
1d434f7 |
example link</a>.</p>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Reference-style links allow you to refer to your links by names, which
|
|
|
1d434f7 |
you define elsewhere in your document:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
I get 10 times more traffic from [Google][1] than from
|
|
|
1d434f7 |
[Yahoo][2] or [MSN][3].
|
|
|
1d434f7 |
|
|
|
1d434f7 |
[1]: http://google.com/ "Google"
|
|
|
1d434f7 |
[2]: http://search.yahoo.com/ "Yahoo Search"
|
|
|
1d434f7 |
[3]: http://search.msn.com/ "MSN Search"
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Output:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<p>I get 10 times more traffic from <a href="http://google.com/"
|
|
|
1d434f7 |
title="Google">Google</a> than from <a href="http://search.yahoo.com/"
|
|
|
1d434f7 |
title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
|
|
|
1d434f7 |
title="MSN Search">MSN</a>.</p>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
The title attribute is optional. Link names may contain letters,
|
|
|
1d434f7 |
numbers and spaces, but are not case sensitive:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
I start my morning with a cup of coffee and
|
|
|
1d434f7 |
[The New York Times][NY Times].
|
|
|
1d434f7 |
|
|
|
1d434f7 |
[ny times]: http://www.nytimes.com/
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Output:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<p>I start my morning with a cup of coffee and
|
|
|
1d434f7 |
<a href="http://www.nytimes.com/">The New York Times</a>.</p>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Images
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Image syntax is very much like link syntax.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Inline (titles are optional):
|
|
|
1d434f7 |
|
|
|
1d434f7 |
![alt text](/path/to/img.jpg "Title")
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Reference-style:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
![alt text][id]
|
|
|
1d434f7 |
|
|
|
1d434f7 |
[id]: /path/to/img.jpg "Title"
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Both of the above examples produce the same output:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<img src="/path/to/img.jpg" alt="alt text" title="Title" />
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Code
|
|
|
1d434f7 |
|
|
|
1d434f7 |
In a regular paragraph, you can create code span by wrapping text in
|
|
|
1d434f7 |
backtick quotes. Any ampersands (& ) and angle brackets (< or
|
|
|
1d434f7 |
> ) will automatically be translated into HTML entities. This makes
|
|
|
1d434f7 |
it easy to use Markdown to write about HTML example code:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
I strongly recommend against using any `<blink>` tags.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
I wish SmartyPants used named entities like `—`
|
|
|
1d434f7 |
instead of decimal-encoded entites like `—`.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Output:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<p>I strongly recommend against using any
|
|
|
1d434f7 |
<code><blink></code> tags.</p>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<p>I wish SmartyPants used named entities like
|
|
|
1d434f7 |
<code>&mdash;</code> instead of decimal-encoded
|
|
|
1d434f7 |
entites like <code>&#8212;</code>.</p>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
To specify an entire block of pre-formatted code, indent every line of
|
|
|
1d434f7 |
the block by 4 spaces or 1 tab. Just like with code spans, & , < ,
|
|
|
1d434f7 |
and > characters will be escaped automatically.
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Markdown:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
If you want your page to validate under XHTML 1.0 Strict,
|
|
|
1d434f7 |
you've got to put paragraph tags in your blockquotes:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<blockquote>
|
|
|
1d434f7 |
<p>For example.</p>
|
|
|
1d434f7 |
</blockquote>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
|
|
|
1d434f7 |
Output:
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<p>If you want your page to validate under XHTML 1.0 Strict,
|
|
|
1d434f7 |
you've got to put paragraph tags in your blockquotes:</p>
|
|
|
1d434f7 |
|
|
|
1d434f7 |
<pre><code><blockquote>
|
|
|
1d434f7 |
<p>For example.</p>
|
|
|
1d434f7 |
</blockquote>
|
|
|
1d434f7 |
</code></pre>
|
|
|
1d434f7 |
|