~kaijanmaki/+junk/indicators-ng

« back to all changes in this revision

Viewing changes to zinc/python/zinc/util/Markdown-2.6.2/tests/extensions/extra/markdown-syntax.html

  • Committer: Antti Kaijanmäki
  • Date: 2015-09-21 20:43:11 UTC
  • Revision ID: antti.kaijanmaki@canonical.com-20150921204311-bnmu8s14n6ovobyu
foo

Show diffs side-by-side

added added

removed removed

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