Home | History | Annotate | Download | only in extensions-x-toc
      1 <div class="toc">
      2 <ul>
      3 <li><a href="#overview">Overview</a><ul>
      4 <li><a href="#philosophy">Philosophy</a></li>
      5 <li><a href="#inline-html">Inline HTML</a></li>
      6 <li><a href="#automatic-escaping-for-special-characters">Automatic Escaping for Special Characters</a></li>
      7 </ul>
      8 </li>
      9 <li><a href="#block-elements">Block Elements</a><ul>
     10 <li><a href="#paragraphs-and-line-breaks">Paragraphs and Line Breaks</a></li>
     11 <li><a href="#headers">Headers</a></li>
     12 <li><a href="#blockquotes">Blockquotes</a></li>
     13 <li><a href="#lists">Lists</a></li>
     14 <li><a href="#code-blocks">Code Blocks</a></li>
     15 <li><a href="#horizontal-rules">Horizontal Rules</a></li>
     16 </ul>
     17 </li>
     18 <li><a href="#span-elements">Span Elements</a><ul>
     19 <li><a href="#links">Links</a></li>
     20 <li><a href="#emphasis">Emphasis</a></li>
     21 <li><a href="#code">Code</a></li>
     22 <li><a href="#images">Images</a></li>
     23 </ul>
     24 </li>
     25 <li><a href="#miscellaneous">Miscellaneous</a><ul>
     26 <li><a href="#automatic-links">Automatic Links</a></li>
     27 <li><a href="#backslash-escapes">Backslash Escapes</a></li>
     28 </ul>
     29 </li>
     30 </ul>
     31 </div>
     32 <h1 id="overview">Overview</h1>
     33 <h2 id="philosophy">Philosophy</h2>
     34 <p>Markdown is intended to be as easy-to-read and easy-to-write as is feasible.</p>
     35 <p>Readability, however, is emphasized above all else. A Markdown-formatted
     36 document should be publishable as-is, as plain text, without looking
     37 like it's been marked up with tags or formatting instructions. While
     38 Markdown's syntax has been influenced by several existing text-to-HTML
     39 filters -- including <a href="http://docutils.sourceforge.net/mirror/setext.html">Setext</a>, <a href="http://www.aaronsw.com/2002/atx/">atx</a>, <a href="http://textism.com/tools/textile/">Textile</a>, <a href="http://docutils.sourceforge.net/rst.html">reStructuredText</a>,
     40 <a href="http://www.triptico.com/software/grutatxt.html">Grutatext</a>, and <a href="http://ettext.taint.org/doc/">EtText</a> -- the single biggest source of
     41 inspiration for Markdown's syntax is the format of plain text email.</p>
     42 <p>To this end, Markdown's syntax is comprised entirely of punctuation
     43 characters, which punctuation characters have been carefully chosen so
     44 as to look like what they mean. E.g., asterisks around a word actually
     45 look like *emphasis*. Markdown lists look like, well, lists. Even
     46 blockquotes look like quoted passages of text, assuming you've ever
     47 used email.</p>
     48 <h2 id="inline-html">Inline HTML</h2>
     49 <p>Markdown's syntax is intended for one purpose: to be used as a
     50 format for <em>writing</em> for the web.</p>
     51 <p>Markdown is not a replacement for HTML, or even close to it. Its
     52 syntax is very small, corresponding only to a very small subset of
     53 HTML tags. The idea is <em>not</em> to create a syntax that makes it easier
     54 to insert HTML tags. In my opinion, HTML tags are already easy to
     55 insert. The idea for Markdown is to make it easy to read, write, and
     56 edit prose. HTML is a <em>publishing</em> format; Markdown is a <em>writing</em>
     57 format. Thus, Markdown's formatting syntax only addresses issues that
     58 can be conveyed in plain text.</p>
     59 <p>For any markup that is not covered by Markdown's syntax, you simply
     60 use HTML itself. There's no need to preface it or delimit it to
     61 indicate that you're switching from Markdown to HTML; you just use
     62 the tags.</p>
     63 <p>The only restrictions are that block-level HTML elements -- e.g. <code>&lt;div&gt;</code>,
     64 <code>&lt;table&gt;</code>, <code>&lt;pre&gt;</code>, <code>&lt;p&gt;</code>, etc. -- must be separated from surrounding
     65 content by blank lines, and the start and end tags of the block should
     66 not be indented with tabs or spaces. Markdown is smart enough not
     67 to add extra (unwanted) <code>&lt;p&gt;</code> tags around HTML block-level tags.</p>
     68 <p>For example, to add an HTML table to a Markdown article:</p>
     69 <pre><code>This is a regular paragraph.
     70 
     71 &lt;table&gt;
     72     &lt;tr&gt;
     73         &lt;td&gt;Foo&lt;/td&gt;
     74     &lt;/tr&gt;
     75 &lt;/table&gt;
     76 
     77 This is another regular paragraph.
     78 </code></pre>
     79 <p>Note that Markdown formatting syntax is not processed within block-level
     80 HTML tags. E.g., you can't use Markdown-style <code>*emphasis*</code> inside an
     81 HTML block.</p>
     82 <p>Span-level HTML tags -- e.g. <code>&lt;span&gt;</code>, <code>&lt;cite&gt;</code>, or <code>&lt;del&gt;</code> -- can be
     83 used anywhere in a Markdown paragraph, list item, or header. If you
     84 want, you can even use HTML tags instead of Markdown formatting; e.g. if
     85 you'd prefer to use HTML <code>&lt;a&gt;</code> or <code>&lt;img&gt;</code> tags instead of Markdown's
     86 link or image syntax, go right ahead.</p>
     87 <p>Unlike block-level HTML tags, Markdown syntax <em>is</em> processed within
     88 span-level tags.</p>
     89 <h2 id="automatic-escaping-for-special-characters">Automatic Escaping for Special Characters</h2>
     90 <p>In HTML, there are two characters that demand special treatment: <code>&lt;</code>
     91 and <code>&amp;</code>. Left angle brackets are used to start tags; ampersands are
     92 used to denote HTML entities. If you want to use them as literal
     93 characters, you must escape them as entities, e.g. <code>&amp;lt;</code>, and
     94 <code>&amp;amp;</code>.</p>
     95 <p>Ampersands in particular are bedeviling for web writers. If you want to
     96 write about 'AT&amp;T', you need to write '<code>AT&amp;amp;T</code>'. You even need to
     97 escape ampersands within URLs. Thus, if you want to link to:</p>
     98 <pre><code>http://images.google.com/images?num=30&q=larry+bird
     99 </code></pre>
    100 <p>you need to encode the URL as:</p>
    101 <pre><code>http://images.google.com/images?num=30&amp;q=larry+bird
    102 </code></pre>
    103 <p>in your anchor tag <code>href</code> attribute. Needless to say, this is easy to
    104 forget, and is probably the single most common source of HTML validation
    105 errors in otherwise well-marked-up web sites.</p>
    106 <p>Markdown allows you to use these characters naturally, taking care of
    107 all the necessary escaping for you. If you use an ampersand as part of
    108 an HTML entity, it remains unchanged; otherwise it will be translated
    109 into <code>&amp;amp;</code>.</p>
    110 <p>So, if you want to include a copyright symbol in your article, you can write:</p>
    111 <pre><code>&amp;copy;
    112 </code></pre>
    113 <p>and Markdown will leave it alone. But if you write:</p>
    114 <pre><code>AT&amp;T
    115 </code></pre>
    116 <p>Markdown will translate it to:</p>
    117 <pre><code>AT&amp;amp;T
    118 </code></pre>
    119 <p>Similarly, because Markdown supports <a href="#html">inline HTML</a>, if you use
    120 angle brackets as delimiters for HTML tags, Markdown will treat them as
    121 such. But if you write:</p>
    122 <pre><code>4 &lt; 5
    123 </code></pre>
    124 <p>Markdown will translate it to:</p>
    125 <pre><code>4 &amp;lt; 5
    126 </code></pre>
    127 <p>However, inside Markdown code spans and blocks, angle brackets and
    128 ampersands are <em>always</em> encoded automatically. This makes it easy to use
    129 Markdown to write about HTML code. (As opposed to raw HTML, which is a
    130 terrible format for writing about HTML syntax, because every single <code>&lt;</code>
    131 and <code>&amp;</code> in your example code needs to be escaped.)</p>
    132 <hr />
    133 <h1 id="block-elements">Block Elements</h1>
    134 <h2 id="paragraphs-and-line-breaks">Paragraphs and Line Breaks</h2>
    135 <p>A paragraph is simply one or more consecutive lines of text, separated
    136 by one or more blank lines. (A blank line is any line that looks like a
    137 blank line -- a line containing nothing but spaces or tabs is considered
    138 blank.) Normal paragraphs should not be intended with spaces or tabs.</p>
    139 <p>The implication of the "one or more consecutive lines of text" rule is
    140 that Markdown supports "hard-wrapped" text paragraphs. This differs
    141 significantly from most other text-to-HTML formatters (including Movable
    142 Type's "Convert Line Breaks" option) which translate every line break
    143 character in a paragraph into a <code>&lt;br /&gt;</code> tag.</p>
    144 <p>When you <em>do</em> want to insert a <code>&lt;br /&gt;</code> break tag using Markdown, you
    145 end a line with two or more spaces, then type return.</p>
    146 <p>Yes, this takes a tad more effort to create a <code>&lt;br /&gt;</code>, but a simplistic
    147 "every line break is a <code>&lt;br /&gt;</code>" rule wouldn't work for Markdown.
    148 Markdown's email-style <a href="#blockquote">blockquoting</a> and multi-paragraph <a href="#list">list items</a>
    149 work best -- and look better -- when you format them with hard breaks.</p>
    150 <h2 id="headers">Headers</h2>
    151 <p>Markdown supports two styles of headers, <a href="http://docutils.sourceforge.net/mirror/setext.html">Setext</a> and <a href="http://www.aaronsw.com/2002/atx/">atx</a>.</p>
    152 <p>Setext-style headers are "underlined" using equal signs (for first-level
    153 headers) and dashes (for second-level headers). For example:</p>
    154 <pre><code>This is an H1
    155 =============
    156 
    157 This is an H2
    158 -------------
    159 </code></pre>
    160 <p>Any number of underlining <code>=</code>'s or <code>-</code>'s will work.</p>
    161 <p>Atx-style headers use 1-6 hash characters at the start of the line,
    162 corresponding to header levels 1-6. For example:</p>
    163 <pre><code># This is an H1
    164 
    165 ## This is an H2
    166 
    167 ###### This is an H6
    168 </code></pre>
    169 <p>Optionally, you may "close" atx-style headers. This is purely
    170 cosmetic -- you can use this if you think it looks better. The
    171 closing hashes don't even need to match the number of hashes
    172 used to open the header. (The number of opening hashes
    173 determines the header level.) :</p>
    174 <pre><code># This is an H1 #
    175 
    176 ## This is an H2 ##
    177 
    178 ### This is an H3 ######
    179 </code></pre>
    180 <h2 id="blockquotes">Blockquotes</h2>
    181 <p>Markdown uses email-style <code>&gt;</code> characters for blockquoting. If you're
    182 familiar with quoting passages of text in an email message, then you
    183 know how to create a blockquote in Markdown. It looks best if you hard
    184 wrap the text and put a <code>&gt;</code> before every line:</p>
    185 <pre><code>&gt; This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
    186 &gt; consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
    187 &gt; Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
    188 &gt; 
    189 &gt; Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
    190 &gt; id sem consectetuer libero luctus adipiscing.
    191 </code></pre>
    192 <p>Markdown allows you to be lazy and only put the <code>&gt;</code> before the first
    193 line of a hard-wrapped paragraph:</p>
    194 <pre><code>&gt; This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
    195 consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
    196 Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
    197 
    198 &gt; Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
    199 id sem consectetuer libero luctus adipiscing.
    200 </code></pre>
    201 <p>Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
    202 adding additional levels of <code>&gt;</code>:</p>
    203 <pre><code>&gt; This is the first level of quoting.
    204 &gt;
    205 &gt; &gt; This is nested blockquote.
    206 &gt;
    207 &gt; Back to the first level.
    208 </code></pre>
    209 <p>Blockquotes can contain other Markdown elements, including headers, lists,
    210 and code blocks:</p>
    211 <pre><code>&gt; ## This is a header.
    212 &gt; 
    213 &gt; 1.   This is the first list item.
    214 &gt; 2.   This is the second list item.
    215 &gt; 
    216 &gt; Here's some example code:
    217 &gt; 
    218 &gt;     return shell_exec("echo $input | $markdown_script");
    219 </code></pre>
    220 <p>Any decent text editor should make email-style quoting easy. For
    221 example, with BBEdit, you can make a selection and choose Increase
    222 Quote Level from the Text menu.</p>
    223 <h2 id="lists">Lists</h2>
    224 <p>Markdown supports ordered (numbered) and unordered (bulleted) lists.</p>
    225 <p>Unordered lists use asterisks, pluses, and hyphens -- interchangably
    226 -- as list markers:</p>
    227 <pre><code>*   Red
    228 *   Green
    229 *   Blue
    230 </code></pre>
    231 <p>is equivalent to:</p>
    232 <pre><code>+   Red
    233 +   Green
    234 +   Blue
    235 </code></pre>
    236 <p>and:</p>
    237 <pre><code>-   Red
    238 -   Green
    239 -   Blue
    240 </code></pre>
    241 <p>Ordered lists use numbers followed by periods:</p>
    242 <pre><code>1.  Bird
    243 2.  McHale
    244 3.  Parish
    245 </code></pre>
    246 <p>It's important to note that the actual numbers you use to mark the
    247 list have no effect on the HTML output Markdown produces. The HTML
    248 Markdown produces from the above list is:</p>
    249 <pre><code>&lt;ol&gt;
    250 &lt;li&gt;Bird&lt;/li&gt;
    251 &lt;li&gt;McHale&lt;/li&gt;
    252 &lt;li&gt;Parish&lt;/li&gt;
    253 &lt;/ol&gt;
    254 </code></pre>
    255 <p>If you instead wrote the list in Markdown like this:</p>
    256 <pre><code>1.  Bird
    257 1.  McHale
    258 1.  Parish
    259 </code></pre>
    260 <p>or even:</p>
    261 <pre><code>3. Bird
    262 1. McHale
    263 8. Parish
    264 </code></pre>
    265 <p>you'd get the exact same HTML output. The point is, if you want to,
    266 you can use ordinal numbers in your ordered Markdown lists, so that
    267 the numbers in your source match the numbers in your published HTML.
    268 But if you want to be lazy, you don't have to.</p>
    269 <p>If you do use lazy list numbering, however, you should still start the
    270 list with the number 1. At some point in the future, Markdown may support
    271 starting ordered lists at an arbitrary number.</p>
    272 <p>List markers typically start at the left margin, but may be indented by
    273 up to three spaces. List markers must be followed by one or more spaces
    274 or a tab.</p>
    275 <p>To make lists look nice, you can wrap items with hanging indents:</p>
    276 <pre><code>*   Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
    277     Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
    278     viverra nec, fringilla in, laoreet vitae, risus.
    279 *   Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
    280     Suspendisse id sem consectetuer libero luctus adipiscing.
    281 </code></pre>
    282 <p>But if you want to be lazy, you don't have to:</p>
    283 <pre><code>*   Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
    284 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
    285 viverra nec, fringilla in, laoreet vitae, risus.
    286 *   Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
    287 Suspendisse id sem consectetuer libero luctus adipiscing.
    288 </code></pre>
    289 <p>If list items are separated by blank lines, Markdown will wrap the
    290 items in <code>&lt;p&gt;</code> tags in the HTML output. For example, this input:</p>
    291 <pre><code>*   Bird
    292 *   Magic
    293 </code></pre>
    294 <p>will turn into:</p>
    295 <pre><code>&lt;ul&gt;
    296 &lt;li&gt;Bird&lt;/li&gt;
    297 &lt;li&gt;Magic&lt;/li&gt;
    298 &lt;/ul&gt;
    299 </code></pre>
    300 <p>But this:</p>
    301 <pre><code>*   Bird
    302 
    303 *   Magic
    304 </code></pre>
    305 <p>will turn into:</p>
    306 <pre><code>&lt;ul&gt;
    307 &lt;li&gt;&lt;p&gt;Bird&lt;/p&gt;&lt;/li&gt;
    308 &lt;li&gt;&lt;p&gt;Magic&lt;/p&gt;&lt;/li&gt;
    309 &lt;/ul&gt;
    310 </code></pre>
    311 <p>List items may consist of multiple paragraphs. Each subsequent
    312 paragraph in a list item must be intended by either 4 spaces
    313 or one tab:</p>
    314 <pre><code>1.  This is a list item with two paragraphs. Lorem ipsum dolor
    315     sit amet, consectetuer adipiscing elit. Aliquam hendrerit
    316     mi posuere lectus.
    317 
    318     Vestibulum enim wisi, viverra nec, fringilla in, laoreet
    319     vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
    320     sit amet velit.
    321 
    322 2.  Suspendisse id sem consectetuer libero luctus adipiscing.
    323 </code></pre>
    324 <p>It looks nice if you indent every line of the subsequent
    325 paragraphs, but here again, Markdown will allow you to be
    326 lazy:</p>
    327 <pre><code>*   This is a list item with two paragraphs.
    328 
    329     This is the second paragraph in the list item. You're
    330 only required to indent the first line. Lorem ipsum dolor
    331 sit amet, consectetuer adipiscing elit.
    332 
    333 *   Another item in the same list.
    334 </code></pre>
    335 <p>To put a blockquote within a list item, the blockquote's <code>&gt;</code>
    336 delimiters need to be indented:</p>
    337 <pre><code>*   A list item with a blockquote:
    338 
    339     &gt; This is a blockquote
    340     &gt; inside a list item.
    341 </code></pre>
    342 <p>To put a code block within a list item, the code block needs
    343 to be indented <em>twice</em> -- 8 spaces or two tabs:</p>
    344 <pre><code>*   A list item with a code block:
    345 
    346         &lt;code goes here&gt;
    347 </code></pre>
    348 <p>It's worth noting that it's possible to trigger an ordered list by
    349 accident, by writing something like this:</p>
    350 <pre><code>1986. What a great season.
    351 </code></pre>
    352 <p>In other words, a <em>number-period-space</em> sequence at the beginning of a
    353 line. To avoid this, you can backslash-escape the period:</p>
    354 <pre><code>1986\. What a great season.
    355 </code></pre>
    356 <h2 id="code-blocks">Code Blocks</h2>
    357 <p>Pre-formatted code blocks are used for writing about programming or
    358 markup source code. Rather than forming normal paragraphs, the lines
    359 of a code block are interpreted literally. Markdown wraps a code block
    360 in both <code>&lt;pre&gt;</code> and <code>&lt;code&gt;</code> tags.</p>
    361 <p>To produce a code block in Markdown, simply indent every line of the
    362 block by at least 4 spaces or 1 tab. For example, given this input:</p>
    363 <pre><code>This is a normal paragraph:
    364 
    365     This is a code block.
    366 </code></pre>
    367 <p>Markdown will generate:</p>
    368 <pre><code>&lt;p&gt;This is a normal paragraph:&lt;/p&gt;
    369 
    370 &lt;pre&gt;&lt;code&gt;This is a code block.
    371 &lt;/code&gt;&lt;/pre&gt;
    372 </code></pre>
    373 <p>One level of indentation -- 4 spaces or 1 tab -- is removed from each
    374 line of the code block. For example, this:</p>
    375 <pre><code>Here is an example of AppleScript:
    376 
    377     tell application "Foo"
    378         beep
    379     end tell
    380 </code></pre>
    381 <p>will turn into:</p>
    382 <pre><code>&lt;p&gt;Here is an example of AppleScript:&lt;/p&gt;
    383 
    384 &lt;pre&gt;&lt;code&gt;tell application "Foo"
    385     beep
    386 end tell
    387 &lt;/code&gt;&lt;/pre&gt;
    388 </code></pre>
    389 <p>A code block continues until it reaches a line that is not indented
    390 (or the end of the article).</p>
    391 <p>Within a code block, ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> and <code>&gt;</code>)
    392 are automatically converted into HTML entities. This makes it very
    393 easy to include example HTML source code using Markdown -- just paste
    394 it and indent it, and Markdown will handle the hassle of encoding the
    395 ampersands and angle brackets. For example, this:</p>
    396 <pre><code>    &lt;div class="footer"&gt;
    397         &amp;copy; 2004 Foo Corporation
    398     &lt;/div&gt;
    399 </code></pre>
    400 <p>will turn into:</p>
    401 <pre><code>&lt;pre&gt;&lt;code&gt;&amp;lt;div class="footer"&amp;gt;
    402     &amp;amp;copy; 2004 Foo Corporation
    403 &amp;lt;/div&amp;gt;
    404 &lt;/code&gt;&lt;/pre&gt;
    405 </code></pre>
    406 <p>Regular Markdown syntax is not processed within code blocks. E.g.,
    407 asterisks are just literal asterisks within a code block. This means
    408 it's also easy to use Markdown to write about Markdown's own syntax.</p>
    409 <h2 id="horizontal-rules">Horizontal Rules</h2>
    410 <p>You can produce a horizontal rule tag (<code>&lt;hr /&gt;</code>) by placing three or
    411 more hyphens, asterisks, or underscores on a line by themselves. If you
    412 wish, you may use spaces between the hyphens or asterisks. Each of the
    413 following lines will produce a horizontal rule:</p>
    414 <pre><code>* * *
    415 
    416 ***
    417 
    418 *****
    419 
    420 - - -
    421 
    422 ---------------------------------------
    423 
    424 _ _ _
    425 </code></pre>
    426 <hr />
    427 <h1 id="span-elements">Span Elements</h1>
    428 <h2 id="links">Links</h2>
    429 <p>Markdown supports two style of links: <em>inline</em> and <em>reference</em>.</p>
    430 <p>In both styles, the link text is delimited by [square brackets].</p>
    431 <p>To create an inline link, use a set of regular parentheses immediately
    432 after the link text's closing square bracket. Inside the parentheses,
    433 put the URL where you want the link to point, along with an <em>optional</em>
    434 title for the link, surrounded in quotes. For example:</p>
    435 <pre><code>This is [an example](http://example.com/ "Title") inline link.
    436 
    437 [This link](http://example.net/) has no title attribute.
    438 </code></pre>
    439 <p>Will produce:</p>
    440 <pre><code>&lt;p&gt;This is &lt;a href="http://example.com/" title="Title"&gt;
    441 an example&lt;/a&gt; inline link.&lt;/p&gt;
    442 
    443 &lt;p&gt;&lt;a href="http://example.net/"&gt;This link&lt;/a&gt; has no
    444 title attribute.&lt;/p&gt;
    445 </code></pre>
    446 <p>If you're referring to a local resource on the same server, you can
    447 use relative paths:</p>
    448 <pre><code>See my [About](/about/) page for details.
    449 </code></pre>
    450 <p>Reference-style links use a second set of square brackets, inside
    451 which you place a label of your choosing to identify the link:</p>
    452 <pre><code>This is [an example][id] reference-style link.
    453 </code></pre>
    454 <p>You can optionally use a space to separate the sets of brackets:</p>
    455 <pre><code>This is [an example] [id] reference-style link.
    456 </code></pre>
    457 <p>Then, anywhere in the document, you define your link label like this,
    458 on a line by itself:</p>
    459 <pre><code>[id]: http://example.com/  "Optional Title Here"
    460 </code></pre>
    461 <p>That is:</p>
    462 <ul>
    463 <li>Square brackets containing the link identifier (optionally
    464 indented from the left margin using up to three spaces);</li>
    465 <li>followed by a colon;</li>
    466 <li>followed by one or more spaces (or tabs);</li>
    467 <li>followed by the URL for the link;</li>
    468 <li>optionally followed by a title attribute for the link, enclosed
    469 in double or single quotes.</li>
    470 </ul>
    471 <p>The link URL may, optionally, be surrounded by angle brackets:</p>
    472 <pre><code>[id]: &lt;http://example.com/>;  "Optional Title Here"
    473 </code></pre>
    474 <p>You can put the title attribute on the next line and use extra spaces
    475 or tabs for padding, which tends to look better with longer URLs:</p>
    476 <pre><code>[id]: http://example.com/longish/path/to/resource/here
    477     "Optional Title Here"
    478 </code></pre>
    479 <p>Link definitions are only used for creating links during Markdown
    480 processing, and are stripped from your document in the HTML output.</p>
    481 <p>Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are <em>not</em> case sensitive. E.g. these two links:</p>
    482 <pre><code>[link text][a]
    483 [link text][A]
    484 </code></pre>
    485 <p>are equivalent.</p>
    486 <p>The <em>implicit link name</em> shortcut allows you to omit the name of the
    487 link, in which case the link text itself is used as the name.
    488 Just use an empty set of square brackets -- e.g., to link the word
    489 "Google" to the google.com web site, you could simply write:</p>
    490 <pre><code>[Google][]
    491 </code></pre>
    492 <p>And then define the link:</p>
    493 <pre><code>[Google]: http://google.com/
    494 </code></pre>
    495 <p>Because link names may contain spaces, this shortcut even works for
    496 multiple words in the link text:</p>
    497 <pre><code>Visit [Daring Fireball][] for more information.
    498 </code></pre>
    499 <p>And then define the link:</p>
    500 <pre><code>[Daring Fireball]: http://daringfireball.net/
    501 </code></pre>
    502 <p>Link definitions can be placed anywhere in your Markdown document. I
    503 tend to put them immediately after each paragraph in which they're
    504 used, but if you want, you can put them all at the end of your
    505 document, sort of like footnotes.</p>
    506 <p>Here's an example of reference links in action:</p>
    507 <pre><code>I get 10 times more traffic from [Google] [1] than from
    508 [Yahoo] [2] or [MSN] [3].
    509 
    510   [1]: http://google.com/        "Google"
    511   [2]: http://search.yahoo.com/  "Yahoo Search"
    512   [3]: http://search.msn.com/    "MSN Search"
    513 </code></pre>
    514 <p>Using the implicit link name shortcut, you could instead write:</p>
    515 <pre><code>I get 10 times more traffic from [Google][] than from
    516 [Yahoo][] or [MSN][].
    517 
    518   [google]: http://google.com/        "Google"
    519   [yahoo]:  http://search.yahoo.com/  "Yahoo Search"
    520   [msn]:    http://search.msn.com/    "MSN Search"
    521 </code></pre>
    522 <p>Both of the above examples will produce the following HTML output:</p>
    523 <pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
    524 title="Google"&gt;Google&lt;/a&gt; than from
    525 &lt;a href="http://search.yahoo.com/" title="Yahoo Search"&gt;Yahoo&lt;/a&gt;
    526 or &lt;a href="http://search.msn.com/" title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
    527 </code></pre>
    528 <p>For comparison, here is the same paragraph written using
    529 Markdown's inline link style:</p>
    530 <pre><code>I get 10 times more traffic from [Google](http://google.com/ "Google")
    531 than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
    532 [MSN](http://search.msn.com/ "MSN Search").
    533 </code></pre>
    534 <p>The point of reference-style links is not that they're easier to
    535 write. The point is that with reference-style links, your document
    536 source is vastly more readable. Compare the above examples: using
    537 reference-style links, the paragraph itself is only 81 characters
    538 long; with inline-style links, it's 176 characters; and as raw HTML,
    539 it's 234 characters. In the raw HTML, there's more markup than there
    540 is text.</p>
    541 <p>With Markdown's reference-style links, a source document much more
    542 closely resembles the final output, as rendered in a browser. By
    543 allowing you to move the markup-related metadata out of the paragraph,
    544 you can add links without interrupting the narrative flow of your
    545 prose.</p>
    546 <h2 id="emphasis">Emphasis</h2>
    547 <p>Markdown treats asterisks (<code>*</code>) and underscores (<code>_</code>) as indicators of
    548 emphasis. Text wrapped with one <code>*</code> or <code>_</code> will be wrapped with an
    549 HTML <code>&lt;em&gt;</code> tag; double <code>*</code>'s or <code>_</code>'s will be wrapped with an HTML
    550 <code>&lt;strong&gt;</code> tag. E.g., this input:</p>
    551 <pre><code>*single asterisks*
    552 
    553 _single underscores_
    554 
    555 **double asterisks**
    556 
    557 __double underscores__
    558 </code></pre>
    559 <p>will produce:</p>
    560 <pre><code>&lt;em&gt;single asterisks&lt;/em&gt;
    561 
    562 &lt;em&gt;single underscores&lt;/em&gt;
    563 
    564 &lt;strong&gt;double asterisks&lt;/strong&gt;
    565 
    566 &lt;strong&gt;double underscores&lt;/strong&gt;
    567 </code></pre>
    568 <p>You can use whichever style you prefer; the lone restriction is that
    569 the same character must be used to open and close an emphasis span.</p>
    570 <p>Emphasis can be used in the middle of a word:</p>
    571 <pre><code>un*fucking*believable
    572 </code></pre>
    573 <p>But if you surround an <code>*</code> or <code>_</code> with spaces, it'll be treated as a
    574 literal asterisk or underscore.</p>
    575 <p>To produce a literal asterisk or underscore at a position where it
    576 would otherwise be used as an emphasis delimiter, you can backslash
    577 escape it:</p>
    578 <pre><code>\*this text is surrounded by literal asterisks\*
    579 </code></pre>
    580 <h2 id="code">Code</h2>
    581 <p>To indicate a span of code, wrap it with backtick quotes (<code>`</code>).
    582 Unlike a pre-formatted code block, a code span indicates code within a
    583 normal paragraph. For example:</p>
    584 <pre><code>Use the `printf()` function.
    585 </code></pre>
    586 <p>will produce:</p>
    587 <pre><code>&lt;p&gt;Use the &lt;code&gt;printf()&lt;/code&gt; function.&lt;/p&gt;
    588 </code></pre>
    589 <p>To include a literal backtick character within a code span, you can use
    590 multiple backticks as the opening and closing delimiters:</p>
    591 <pre><code>``There is a literal backtick (`) here.``
    592 </code></pre>
    593 <p>which will produce this:</p>
    594 <pre><code>&lt;p&gt;&lt;code&gt;There is a literal backtick (`) here.&lt;/code&gt;&lt;/p&gt;
    595 </code></pre>
    596 <p>The backtick delimiters surrounding a code span may include spaces --
    597 one after the opening, one before the closing. This allows you to place
    598 literal backtick characters at the beginning or end of a code span:</p>
    599 <pre><code>A single backtick in a code span: `` ` ``
    600 
    601 A backtick-delimited string in a code span: `` `foo` ``
    602 </code></pre>
    603 <p>will produce:</p>
    604 <pre><code>&lt;p&gt;A single backtick in a code span: &lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
    605 
    606 &lt;p&gt;A backtick-delimited string in a code span: &lt;code&gt;`foo`&lt;/code&gt;&lt;/p&gt;
    607 </code></pre>
    608 <p>With a code span, ampersands and angle brackets are encoded as HTML
    609 entities automatically, which makes it easy to include example HTML
    610 tags. Markdown will turn this:</p>
    611 <pre><code>Please don't use any `&lt;blink&gt;` tags.
    612 </code></pre>
    613 <p>into:</p>
    614 <pre><code>&lt;p&gt;Please don't use any &lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
    615 </code></pre>
    616 <p>You can write this:</p>
    617 <pre><code>`&amp;#8212;` is the decimal-encoded equivalent of `&amp;mdash;`.
    618 </code></pre>
    619 <p>to produce:</p>
    620 <pre><code>&lt;p&gt;&lt;code&gt;&amp;amp;#8212;&lt;/code&gt; is the decimal-encoded
    621 equivalent of &lt;code&gt;&amp;amp;mdash;&lt;/code&gt;.&lt;/p&gt;
    622 </code></pre>
    623 <h2 id="images">Images</h2>
    624 <p>Admittedly, it's fairly difficult to devise a "natural" syntax for
    625 placing images into a plain text document format.</p>
    626 <p>Markdown uses an image syntax that is intended to resemble the syntax
    627 for links, allowing for two styles: <em>inline</em> and <em>reference</em>.</p>
    628 <p>Inline image syntax looks like this:</p>
    629 <pre><code>![Alt text](/path/to/img.jpg)
    630 
    631 ![Alt text](/path/to/img.jpg "Optional title")
    632 </code></pre>
    633 <p>That is:</p>
    634 <ul>
    635 <li>An exclamation mark: <code>!</code>;</li>
    636 <li>followed by a set of square brackets, containing the <code>alt</code>
    637 attribute text for the image;</li>
    638 <li>followed by a set of parentheses, containing the URL or path to
    639 the image, and an optional <code>title</code> attribute enclosed in double
    640 or single quotes.</li>
    641 </ul>
    642 <p>Reference-style image syntax looks like this:</p>
    643 <pre><code>![Alt text][id]
    644 </code></pre>
    645 <p>Where "id" is the name of a defined image reference. Image references
    646 are defined using syntax identical to link references:</p>
    647 <pre><code>[id]: url/to/image  "Optional title attribute"
    648 </code></pre>
    649 <p>As of this writing, Markdown has no syntax for specifying the
    650 dimensions of an image; if this is important to you, you can simply
    651 use regular HTML <code>&lt;img&gt;</code> tags.</p>
    652 <hr />
    653 <h1 id="miscellaneous">Miscellaneous</h1>
    654 <h2 id="automatic-links">Automatic Links</h2>
    655 <p>Markdown supports a shortcut style for creating "automatic" links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this:</p>
    656 <pre><code>&lt;http://example.com/>;
    657 </code></pre>
    658 <p>Markdown will turn this into:</p>
    659 <pre><code>&lt;a href="http://example.com/"&gt;http://example.com/</a>;
    660 </code></pre>
    661 <p>Automatic links for email addresses work similarly, except that
    662 Markdown will also perform a bit of randomized decimal and hex
    663 entity-encoding to help obscure your address from address-harvesting
    664 spambots. For example, Markdown will turn this:</p>
    665 <pre><code>&lt;address (a] example.com&gt;
    666 </code></pre>
    667 <p>into something like this:</p>
    668 <pre><code>&lt;a href="&amp;#x6D;&amp;#x61;i&amp;#x6C;&amp;#x74;&amp;#x6F;:&amp;#x61;&amp;#x64;&amp;#x64;&amp;#x72;&amp;#x65;
    669 &amp;#115;&amp;#115;&amp;#64;&amp;#101;&amp;#120;&amp;#x61;&amp;#109;&amp;#x70;&amp;#x6C;e&amp;#x2E;&amp;#99;&amp;#111;
    670 &amp;#109;"&gt;&amp;#x61;&amp;#x64;&amp;#x64;&amp;#x72;&amp;#x65;&amp;#115;&amp;#115;&amp;#64;&amp;#101;&amp;#120;&amp;#x61;
    671 &amp;#109;&amp;#x70;&amp;#x6C;e&amp;#x2E;&amp;#99;&amp;#111;&amp;#109;&lt;/a&gt;
    672 </code></pre>
    673 <p>which will render in a browser as a clickable link to "address (a] example.com".</p>
    674 <p>(This sort of entity-encoding trick will indeed fool many, if not
    675 most, address-harvesting bots, but it definitely won't fool all of
    676 them. It's better than nothing, but an address published in this way
    677 will probably eventually start receiving spam.)</p>
    678 <h2 id="backslash-escapes">Backslash Escapes</h2>
    679 <p>Markdown allows you to use backslash escapes to generate literal
    680 characters which would otherwise have special meaning in Markdown's
    681 formatting syntax. For example, if you wanted to surround a word with
    682 literal asterisks (instead of an HTML <code>&lt;em&gt;</code> tag), you can backslashes
    683 before the asterisks, like this:</p>
    684 <pre><code>\*literal asterisks\*
    685 </code></pre>
    686 <p>Markdown provides backslash escapes for the following characters:</p>
    687 <pre><code>\   backslash
    688 `   backtick
    689 *   asterisk
    690 _   underscore
    691 {}  curly braces
    692 []  square brackets
    693 ()  parentheses
    694 #   hash mark
    695 +   plus sign
    696 -   minus sign (hyphen)
    697 .   dot
    698 !   exclamation mark
    699 </code></pre>