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