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 36document should be publishable as-is, as plain text, without looking 37like it's been marked up with tags or formatting instructions. While 38Markdown's syntax has been influenced by several existing text-to-HTML 39filters -- 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 41inspiration 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 43characters, which punctuation characters have been carefully chosen so 44as to look like what they mean. E.g., asterisks around a word actually 45look like *emphasis*. Markdown lists look like, well, lists. Even 46blockquotes look like quoted passages of text, assuming you've ever 47used 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 50format for <em>writing</em> for the web.</p> 51<p>Markdown is not a replacement for HTML, or even close to it. Its 52syntax is very small, corresponding only to a very small subset of 53HTML tags. The idea is <em>not</em> to create a syntax that makes it easier 54to insert HTML tags. In my opinion, HTML tags are already easy to 55insert. The idea for Markdown is to make it easy to read, write, and 56edit prose. HTML is a <em>publishing</em> format; Markdown is a <em>writing</em> 57format. Thus, Markdown's formatting syntax only addresses issues that 58can be conveyed in plain text.</p> 59<p>For any markup that is not covered by Markdown's syntax, you simply 60use HTML itself. There's no need to preface it or delimit it to 61indicate that you're switching from Markdown to HTML; you just use 62the tags.</p> 63<p>The only restrictions are that block-level HTML elements -- e.g. <code><div></code>, 64<code><table></code>, <code><pre></code>, <code><p></code>, etc. -- must be separated from surrounding 65content by blank lines, and the start and end tags of the block should 66not be indented with tabs or spaces. Markdown is smart enough not 67to add extra (unwanted) <code><p></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<table> 72 <tr> 73 <td>Foo</td> 74 </tr> 75</table> 76 77This is another regular paragraph. 78</code></pre> 79<p>Note that Markdown formatting syntax is not processed within block-level 80HTML tags. E.g., you can't use Markdown-style <code>*emphasis*</code> inside an 81HTML block.</p> 82<p>Span-level HTML tags -- e.g. <code><span></code>, <code><cite></code>, or <code><del></code> -- can be 83used anywhere in a Markdown paragraph, list item, or header. If you 84want, you can even use HTML tags instead of Markdown formatting; e.g. if 85you'd prefer to use HTML <code><a></code> or <code><img></code> tags instead of Markdown's 86link or image syntax, go right ahead.</p> 87<p>Unlike block-level HTML tags, Markdown syntax <em>is</em> processed within 88span-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><</code> 91and <code>&</code>. Left angle brackets are used to start tags; ampersands are 92used to denote HTML entities. If you want to use them as literal 93characters, you must escape them as entities, e.g. <code>&lt;</code>, and 94<code>&amp;</code>.</p> 95<p>Ampersands in particular are bedeviling for web writers. If you want to 96write about 'AT&T', you need to write '<code>AT&amp;T</code>'. You even need to 97escape 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 104forget, and is probably the single most common source of HTML validation 105errors in otherwise well-marked-up web sites.</p> 106<p>Markdown allows you to use these characters naturally, taking care of 107all the necessary escaping for you. If you use an ampersand as part of 108an HTML entity, it remains unchanged; otherwise it will be translated 109into <code>&amp;</code>.</p> 110<p>So, if you want to include a copyright symbol in your article, you can write:</p> 111<pre><code>&copy; 112</code></pre> 113<p>and Markdown will leave it alone. But if you write:</p> 114<pre><code>AT&T 115</code></pre> 116<p>Markdown will translate it to:</p> 117<pre><code>AT&amp;T 118</code></pre> 119<p>Similarly, because Markdown supports <a href="#html">inline HTML</a>, if you use 120angle brackets as delimiters for HTML tags, Markdown will treat them as 121such. But if you write:</p> 122<pre><code>4 < 5 123</code></pre> 124<p>Markdown will translate it to:</p> 125<pre><code>4 &lt; 5 126</code></pre> 127<p>However, inside Markdown code spans and blocks, angle brackets and 128ampersands are <em>always</em> encoded automatically. This makes it easy to use 129Markdown to write about HTML code. (As opposed to raw HTML, which is a 130terrible format for writing about HTML syntax, because every single <code><</code> 131and <code>&</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 136by one or more blank lines. (A blank line is any line that looks like a 137blank line -- a line containing nothing but spaces or tabs is considered 138blank.) Normal paragraphs should not be indented with spaces or tabs.</p> 139<p>The implication of the "one or more consecutive lines of text" rule is 140that Markdown supports "hard-wrapped" text paragraphs. This differs 141significantly from most other text-to-HTML formatters (including Movable 142Type's "Convert Line Breaks" option) which translate every line break 143character in a paragraph into a <code><br /></code> tag.</p> 144<p>When you <em>do</em> want to insert a <code><br /></code> break tag using Markdown, you 145end a line with two or more spaces, then type return.</p> 146<p>Yes, this takes a tad more effort to create a <code><br /></code>, but a simplistic 147"every line break is a <code><br /></code>" rule wouldn't work for Markdown. 148Markdown's email-style <a href="#blockquote">blockquoting</a> and multi-paragraph <a href="#list">list items</a> 149work 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 153headers) and dashes (for second-level headers). For example:</p> 154<pre><code>This is an H1 155============= 156 157This 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, 162corresponding 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 170cosmetic -- you can use this if you think it looks better. The 171closing hashes don't even need to match the number of hashes 172used to open the header. (The number of opening hashes 173determines 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>></code> characters for blockquoting. If you're 182familiar with quoting passages of text in an email message, then you 183know how to create a blockquote in Markdown. It looks best if you hard 184wrap the text and put a <code>></code> before every line:</p> 185<pre><code>> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, 186> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. 187> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. 188> 189> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse 190> id sem consectetuer libero luctus adipiscing. 191</code></pre> 192<p>Markdown allows you to be lazy and only put the <code>></code> before the first 193line of a hard-wrapped paragraph:</p> 194<pre><code>> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, 195consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. 196Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. 197 198> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse 199id sem consectetuer libero luctus adipiscing. 200</code></pre> 201<p>Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by 202adding additional levels of <code>></code>:</p> 203<pre><code>> This is the first level of quoting. 204> 205> > This is nested blockquote. 206> 207> Back to the first level. 208</code></pre> 209<p>Blockquotes can contain other Markdown elements, including headers, lists, 210and code blocks:</p> 211<pre><code>> ## This is a header. 212> 213> 1. This is the first list item. 214> 2. This is the second list item. 215> 216> Here's some example code: 217> 218> return shell_exec("echo $input | $markdown_script"); 219</code></pre> 220<p>Any decent text editor should make email-style quoting easy. For 221example, with BBEdit, you can make a selection and choose Increase 222Quote 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 -- interchangeably 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 2432. McHale 2443. Parish 245</code></pre> 246<p>It's important to note that the actual numbers you use to mark the 247list have no effect on the HTML output Markdown produces. The HTML 248Markdown produces from the above list is:</p> 249<pre><code><ol> 250<li>Bird</li> 251<li>McHale</li> 252<li>Parish</li> 253</ol> 254</code></pre> 255<p>If you instead wrote the list in Markdown like this:</p> 256<pre><code>1. Bird 2571. McHale 2581. Parish 259</code></pre> 260<p>or even:</p> 261<pre><code>3. Bird 2621. McHale 2638. Parish 264</code></pre> 265<p>you'd get the exact same HTML output. The point is, if you want to, 266you can use ordinal numbers in your ordered Markdown lists, so that 267the numbers in your source match the numbers in your published HTML. 268But 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 270list with the number 1. At some point in the future, Markdown may support 271starting ordered lists at an arbitrary number.</p> 272<p>List markers typically start at the left margin, but may be indented by 273up to three spaces. List markers must be followed by one or more spaces 274or 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. 284Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, 285viverra nec, fringilla in, laoreet vitae, risus. 286* Donec sit amet nisl. Aliquam semper ipsum sit amet velit. 287Suspendisse id sem consectetuer libero luctus adipiscing. 288</code></pre> 289<p>If list items are separated by blank lines, Markdown will wrap the 290items in <code><p></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><ul> 296<li>Bird</li> 297<li>Magic</li> 298</ul> 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><ul> 307<li><p>Bird</p></li> 308<li><p>Magic</p></li> 309</ul> 310</code></pre> 311<p>List items may consist of multiple paragraphs. Each subsequent 312paragraph in a list item must be indented by either 4 spaces 313or 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 3222. Suspendisse id sem consectetuer libero luctus adipiscing. 323</code></pre> 324<p>It looks nice if you indent every line of the subsequent 325paragraphs, but here again, Markdown will allow you to be 326lazy:</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 330only required to indent the first line. Lorem ipsum dolor 331sit 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>></code> 336delimiters need to be indented:</p> 337<pre><code>* A list item with a blockquote: 338 339 > This is a blockquote 340 > inside a list item. 341</code></pre> 342<p>To put a code block within a list item, the code block needs 343to be indented <em>twice</em> -- 8 spaces or two tabs:</p> 344<pre><code>* A list item with a code block: 345 346 <code goes here> 347</code></pre> 348<p>It's worth noting that it's possible to trigger an ordered list by 349accident, 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 353line. 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 358markup source code. Rather than forming normal paragraphs, the lines 359of a code block are interpreted literally. Markdown wraps a code block 360in both <code><pre></code> and <code><code></code> tags.</p> 361<p>To produce a code block in Markdown, simply indent every line of the 362block 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><p>This is a normal paragraph:</p> 369 370<pre><code>This is a code block. 371</code></pre> 372</code></pre> 373<p>One level of indentation -- 4 spaces or 1 tab -- is removed from each 374line 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><p>Here is an example of AppleScript:</p> 383 384<pre><code>tell application "Foo" 385 beep 386end tell 387</code></pre> 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>&</code>) and angle brackets (<code><</code> and <code>></code>) 392are automatically converted into HTML entities. This makes it very 393easy to include example HTML source code using Markdown -- just paste 394it and indent it, and Markdown will handle the hassle of encoding the 395ampersands and angle brackets. For example, this:</p> 396<pre><code> <div class="footer"> 397 &copy; 2004 Foo Corporation 398 </div> 399</code></pre> 400<p>will turn into:</p> 401<pre><code><pre><code>&lt;div class="footer"&gt; 402 &amp;copy; 2004 Foo Corporation 403&lt;/div&gt; 404</code></pre> 405</code></pre> 406<p>Regular Markdown syntax is not processed within code blocks. E.g., 407asterisks are just literal asterisks within a code block. This means 408it'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><hr /></code>) by placing three or 411more hyphens, asterisks, or underscores on a line by themselves. If you 412wish, you may use spaces between the hyphens or asterisks. Each of the 413following 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 432after the link text's closing square bracket. Inside the parentheses, 433put the URL where you want the link to point, along with an <em>optional</em> 434title 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><p>This is <a href="http://example.com/" title="Title"> 441an example</a> inline link.</p> 442 443<p><a href="http://example.net/">This link</a> has no 444title attribute.</p> 445</code></pre> 446<p>If you're referring to a local resource on the same server, you can 447use 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 451which 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, 458on 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]: <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 475or 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 480processing, 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 487link, in which case the link text itself is used as the name. 488Just 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 496multiple 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 503tend to put them immediately after each paragraph in which they're 504used, but if you want, you can put them all at the end of your 505document, 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><p>I get 10 times more traffic from <a href="http://google.com/" 524title="Google">Google</a> than from 525<a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> 526or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p> 527</code></pre> 528<p>For comparison, here is the same paragraph written using 529Markdown's inline link style:</p> 530<pre><code>I get 10 times more traffic from [Google](http://google.com/ "Google") 531than 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 535write. The point is that with reference-style links, your document 536source is vastly more readable. Compare the above examples: using 537reference-style links, the paragraph itself is only 81 characters 538long; with inline-style links, it's 176 characters; and as raw HTML, 539it's 234 characters. In the raw HTML, there's more markup than there 540is text.</p> 541<p>With Markdown's reference-style links, a source document much more 542closely resembles the final output, as rendered in a browser. By 543allowing you to move the markup-related metadata out of the paragraph, 544you can add links without interrupting the narrative flow of your 545prose.</p> 546<h2 id="emphasis">Emphasis</h2> 547<p>Markdown treats asterisks (<code>*</code>) and underscores (<code>_</code>) as indicators of 548emphasis. Text wrapped with one <code>*</code> or <code>_</code> will be wrapped with an 549HTML <code><em></code> tag; double <code>*</code>'s or <code>_</code>'s will be wrapped with an HTML 550<code><strong></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><em>single asterisks</em> 561 562<em>single underscores</em> 563 564<strong>double asterisks</strong> 565 566<strong>double underscores</strong> 567</code></pre> 568<p>You can use whichever style you prefer; the lone restriction is that 569the 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 574literal asterisk or underscore.</p> 575<p>To produce a literal asterisk or underscore at a position where it 576would otherwise be used as an emphasis delimiter, you can backslash 577escape 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>). 582Unlike a pre-formatted code block, a code span indicates code within a 583normal paragraph. For example:</p> 584<pre><code>Use the `printf()` function. 585</code></pre> 586<p>will produce:</p> 587<pre><code><p>Use the <code>printf()</code> function.</p> 588</code></pre> 589<p>To include a literal backtick character within a code span, you can use 590multiple 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><p><code>There is a literal backtick (`) here.</code></p> 595</code></pre> 596<p>The backtick delimiters surrounding a code span may include spaces -- 597one after the opening, one before the closing. This allows you to place 598literal backtick characters at the beginning or end of a code span:</p> 599<pre><code>A single backtick in a code span: `` ` `` 600 601A backtick-delimited string in a code span: `` `foo` `` 602</code></pre> 603<p>will produce:</p> 604<pre><code><p>A single backtick in a code span: <code>`</code></p> 605 606<p>A backtick-delimited string in a code span: <code>`foo`</code></p> 607</code></pre> 608<p>With a code span, ampersands and angle brackets are encoded as HTML 609entities automatically, which makes it easy to include example HTML 610tags. Markdown will turn this:</p> 611<pre><code>Please don't use any `<blink>` tags. 612</code></pre> 613<p>into:</p> 614<pre><code><p>Please don't use any <code>&lt;blink&gt;</code> tags.</p> 615</code></pre> 616<p>You can write this:</p> 617<pre><code>`&#8212;` is the decimal-encoded equivalent of `&mdash;`. 618</code></pre> 619<p>to produce:</p> 620<pre><code><p><code>&amp;#8212;</code> is the decimal-encoded 621equivalent of <code>&amp;mdash;</code>.</p> 622</code></pre> 623<h2 id="images">Images</h2> 624<p>Admittedly, it's fairly difficult to devise a "natural" syntax for 625placing images into a plain text document format.</p> 626<p>Markdown uses an image syntax that is intended to resemble the syntax 627for 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 646are 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 650dimensions of an image; if this is important to you, you can simply 651use regular HTML <code><img></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><http://example.com/> 657</code></pre> 658<p>Markdown will turn this into:</p> 659<pre><code><a href="http://example.com/">http://example.com/</a> 660</code></pre> 661<p>Automatic links for email addresses work similarly, except that 662Markdown will also perform a bit of randomized decimal and hex 663entity-encoding to help obscure your address from address-harvesting 664spambots. For example, Markdown will turn this:</p> 665<pre><code><address@example.com> 666</code></pre> 667<p>into something like this:</p> 668<pre><code><a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65; 669&#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111; 670&#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61; 671&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a> 672</code></pre> 673<p>which will render in a browser as a clickable link to "address@example.com".</p> 674<p>(This sort of entity-encoding trick will indeed fool many, if not 675most, address-harvesting bots, but it definitely won't fool all of 676them. It's better than nothing, but an address published in this way 677will 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 680characters which would otherwise have special meaning in Markdown's 681formatting syntax. For example, if you wanted to surround a word with 682literal asterisks (instead of an HTML <code><em></code> tag), you can backslashes 683before 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>