Commit 28caf01c8082dbed3a5ca87b070ffe5657514f01

Moved test dir back out of markdown lib. We don't need to install the tests in everyones site-packages. We just need to distrubute them in the tarball for people to run before installing etc.
  
11recursive-include bin *
22recursive-include markdown *.py
33recursive-include docs *
4recursive-include markdown/tests *.txt *.html *.cfg *.py
5prune markdown/extensions/legacy.py
4recursive-include tests *.txt *.html *.cfg *.py
65include setup.py
76include MANIFEST
  
1import os
2import markdown
3import codecs
4import difflib
5import nose
6import util
7from plugins import HtmlOutput, Markdown
8try:
9 import tidy
10except ImportError:
11 tidy = None
12
13
14test_dir = os.path.abspath(os.path.dirname(__file__))
15
16def relpath(path, start=test_dir):
17 """ reimplement relpath for python 2.3-2.5 from 2.6 """
18 if not path:
19 raise ValueError('no path secified')
20 start_list = os.path.abspath(start).split(os.path.sep)
21 path_list = os.path.abspath(path).split(os.path.sep)
22 # Work out how much of the filepath is shared by start and path.
23 i = len(os.path.commonprefix([start_list, path_list]))
24 rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:]
25 if not rel_list:
26 return test_dir
27 return os.path.join(*rel_list)
28
29def get_section(file, config):
30 """ Get name of config section for given file. """
31 filename = os.path.basename(file)
32 if config.has_section(filename):
33 return filename
34 else:
35 return 'DEFAULT'
36
37def get_args(file, config):
38 """ Get args to pass to markdown from config for a given file. """
39 args = {}
40 section = get_section(file, config)
41 for key in ['extensions', 'safe_mode', 'output_format']:
42 args[key] = config.get(section, key)
43 return args
44
45def normalize(text):
46 """ Normalize whitespace for a string of html using tidy. """
47 return str(tidy.parseString(text.encode('utf-8'),
48 drop_empty_paras=0,
49 fix_backslash=0,
50 fix_bad_comments=0,
51 fix_uri=0,
52 join_styles=0,
53 lower_literals=0,
54 merge_divs=0,
55 output_xhtml=1,
56 quote_ampersand=0,
57 show_body_only=1,
58 char_encoding='utf8',
59 newline='LF')).decode('string-escape')
60
61class CheckSyntax(object):
62 def __init__(self, description=None):
63 if description:
64 self.description = 'TestSyntax: "%s"' % description
65
66 def __call__(self, file, config):
67 """ Compare expected output to actual output and report result. """
68 cfg_section = get_section(file, config)
69 if config.getboolean(cfg_section, 'skip'):
70 raise nose.plugins.skip.SkipTest, 'Test skipped per config.'
71 input_file = file + config.get(cfg_section, 'input_ext')
72 input = codecs.open(input_file, encoding="utf-8").read()
73 output_file = file + config.get(cfg_section, 'output_ext')
74 expected_output = codecs.open(output_file, encoding="utf-8").read()
75 output = markdown.markdown(input, **get_args(file, config))
76 if tidy and config.getboolean(cfg_section, 'normalize'):
77 # Normalize whitespace before comparing.
78 expected_output = normalize(expected_output)
79 output = normalize(output)
80 elif config.getboolean(cfg_section, 'normalize'):
81 # Tidy is not available. Skip this test.
82 raise nose.plugins.skip.SkipTest, 'Test skipped. Tidy not available in system.'
83 diff = [l for l in difflib.unified_diff(expected_output.splitlines(True),
84 output.splitlines(True),
85 output_file,
86 'actual_output.html',
87 n=3)]
88 if diff:
89 raise util.MarkdownSyntaxError('Output from "%s" failed to match expected '
90 'output.\n\n%s' % (input_file, ''.join(diff)))
91
92def TestSyntax():
93 for dir_name, sub_dirs, files in os.walk(test_dir):
94 # Get dir specific config settings.
95 config = util.CustomConfigParser({'extensions': '',
96 'safe_mode': False,
97 'output_format': 'xhtml1',
98 'normalize': '0',
99 'skip': '0',
100 'input_ext': '.txt',
101 'output_ext': '.html'})
102 config.read(os.path.join(dir_name, 'test.cfg'))
103 # Loop through files and generate tests.
104 for file in files:
105 root, ext = os.path.splitext(file)
106 if ext == config.get(get_section(file, config), 'input_ext'):
107 path = os.path.join(dir_name, root)
108 check_syntax = CheckSyntax(description=relpath(path, test_dir))
109 yield check_syntax, path, config
110
111def run():
112 nose.main(addplugins=[HtmlOutput(), Markdown()])
113
114# Hack to make nose run with extensions. Once extensions can be added from
115# setup.cfg, the below line can be removed.
116# See nose [Issue 271](http://code.google.com/p/python-nose/issues/detail?id=271)
117run()
  
1<p>AT&amp;T has an ampersand in their name.</p>
2<p>AT&amp;T is another way to write it.</p>
3<p>This &amp; that.</p>
4<p>4 &lt; 5.</p>
5<p>6 &gt; 5.</p>
6<p>Here's a <a href="http://example.com/?foo=1&amp;bar=2">link</a> with an ampersand in the URL.</p>
7<p>Here's a link with an amersand in the link text: <a href="http://att.com/" title="AT&amp;T">AT&amp;T</a>.</p>
8<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
9<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
  
1AT&T has an ampersand in their name.
2
3AT&amp;T is another way to write it.
4
5This & that.
6
74 < 5.
8
96 > 5.
10
11Here's a [link] [1] with an ampersand in the URL.
12
13Here's a link with an amersand in the link text: [AT&T] [2].
14
15Here's an inline [link](/script?foo=1&bar=2).
16
17Here's an inline [link](</script?foo=1&bar=2>).
18
19
20[1]: http://example.com/?foo=1&bar=2
21[2]: http://att.com/ "AT&T"
  
1<p><a href="simple link" title="title">link</a>
2<img alt="image" src="http://example.com/image.jpg" />
3<a href="http://example.com/(()((())923)(">link</a>
4<img alt="image" src="link(()))(" /></p>
  
1[link](<simple link> "title")
2![image](<http://example.com/image.jpg>)
3[link](<http://example.com/(()((())923)(>)
4![image](<link(()))(>)
  
1<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>
2<p>Https link: <a href="https://example.com">https://example.com</a></p>
3<p>Ftp link: <a href="ftp://example.com">ftp://example.com</a></p>
4<p>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</a></p>
5<ul>
6<li>In a list?</li>
7<li><a href="http://example.com/">http://example.com/</a></li>
8<li>It should.</li>
9</ul>
10<blockquote>
11<p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
12</blockquote>
13<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
14<pre><code>or here: &lt;http://example.com/&gt;
15</code></pre>
  
1Link: <http://example.com/>.
2
3Https link: <https://example.com>
4
5Ftp link: <ftp://example.com>
6
7With an ampersand: <http://example.com/?foo=1&bar=2>
8
9* In a list?
10* <http://example.com/>
11* It should.
12
13> Blockquoted: <http://example.com/>
14
15Auto-links should not occur here: `<http://example.com/>`
16
17 or here: <http://example.com/>
  
1<p>These should all get escaped:</p>
2<p>Backslash: \</p>
3<p>Backtick: `</p>
4<p>Asterisk: *</p>
5<p>Underscore: _</p>
6<p>Left brace: {</p>
7<p>Right brace: }</p>
8<p>Left bracket: [</p>
9<p>Right bracket: ]</p>
10<p>Left paren: (</p>
11<p>Right paren: )</p>
12<p>Greater-than: &gt;</p>
13<p>Hash: #</p>
14<p>Period: .</p>
15<p>Bang: !</p>
16<p>Plus: +</p>
17<p>Minus: -</p>
18<p>These should not, because they occur within a code block:</p>
19<pre><code>Backslash: \\
20
21Backtick: \`
22
23Asterisk: \*
24
25Underscore: \_
26
27Left brace: \{
28
29Right brace: \}
30
31Left bracket: \[
32
33Right bracket: \]
34
35Left paren: \(
36
37Right paren: \)
38
39Greater-than: \&gt;
40
41Hash: \#
42
43Period: \.
44
45Bang: \!
46
47Plus: \+
48
49Minus: \-
50</code></pre>
51<p>Nor should these, which occur in code spans:</p>
52<p>Backslash: <code>\\</code></p>
53<p>Backtick: <code>\`</code></p>
54<p>Asterisk: <code>\*</code></p>
55<p>Underscore: <code>\_</code></p>
56<p>Left brace: <code>\{</code></p>
57<p>Right brace: <code>\}</code></p>
58<p>Left bracket: <code>\[</code></p>
59<p>Right bracket: <code>\]</code></p>
60<p>Left paren: <code>\(</code></p>
61<p>Right paren: <code>\)</code></p>
62<p>Greater-than: <code>\&gt;</code></p>
63<p>Hash: <code>\#</code></p>
64<p>Period: <code>\.</code></p>
65<p>Bang: <code>\!</code></p>
66<p>Plus: <code>\+</code></p>
67<p>Minus: <code>\-</code></p>
  
1These should all get escaped:
2
3Backslash: \\
4
5Backtick: \`
6
7Asterisk: \*
8
9Underscore: \_
10
11Left brace: \{
12
13Right brace: \}
14
15Left bracket: \[
16
17Right bracket: \]
18
19Left paren: \(
20
21Right paren: \)
22
23Greater-than: \>
24
25Hash: \#
26
27Period: \.
28
29Bang: \!
30
31Plus: \+
32
33Minus: \-
34
35
36
37These should not, because they occur within a code block:
38
39 Backslash: \\
40
41 Backtick: \`
42
43 Asterisk: \*
44
45 Underscore: \_
46
47 Left brace: \{
48
49 Right brace: \}
50
51 Left bracket: \[
52
53 Right bracket: \]
54
55 Left paren: \(
56
57 Right paren: \)
58
59 Greater-than: \>
60
61 Hash: \#
62
63 Period: \.
64
65 Bang: \!
66
67 Plus: \+
68
69 Minus: \-
70
71
72Nor should these, which occur in code spans:
73
74Backslash: `\\`
75
76Backtick: `` \` ``
77
78Asterisk: `\*`
79
80Underscore: `\_`
81
82Left brace: `\{`
83
84Right brace: `\}`
85
86Left bracket: `\[`
87
88Right bracket: `\]`
89
90Left paren: `\(`
91
92Right paren: `\)`
93
94Greater-than: `\>`
95
96Hash: `\#`
97
98Period: `\.`
99
100Bang: `\!`
101
102Plus: `\+`
103
104Minus: `\-`
  
1construction:0.000000:0.000000
2amps-and-angle-encoding:0.070000:131072.000000
3auto-links:0.080000:397312.000000
4backlash-escapes:0.270000:884736.000000
5blockquotes-with-dode-blocks:0.020000:0.000000
6hard-wrapped:0.020000:0.000000
7horizontal-rules:0.180000:135168.000000
8inline-html-advanced:0.070000:0.000000
9inline-html-comments:0.080000:0.000000
10inline-html-simple:0.210000:0.000000
11links-inline:0.140000:0.000000
12links-reference:0.170000:0.000000
13literal-quotes:0.090000:0.000000
14markdown-documentation-basics:0.690000:1806336.000000
15markdown-syntax:3.310000:6696960.000000
16nested-blockquotes:0.200000:0.000000
17ordered-and-unordered-list:0.530000:0.000000
18strong-and-em-together:0.200000:0.000000
19tabs:0.200000:0.000000
20tidyness:0.200000:0.000000
  
1<blockquote>
2<p>Example:</p>
3<pre><code>sub status {
4 print "working";
5}
6</code></pre>
7<p>Or:</p>
8<pre><code>sub status {
9 return "working";
10}
11</code></pre>
12</blockquote>
  
1> Example:
2>
3> sub status {
4> print "working";
5> }
6>
7> Or:
8>
9> sub status {
10> return "working";
11> }
  
1<ul>
2<li>
3<p>A list item with a code block</p>
4<pre><code>Some *code*
5</code></pre>
6</li>
7<li>
8<p>Another list item</p>
9<pre><code>More code
10
11And more code
12</code></pre>
13</li>
14</ul>
  
1* A list item with a code block
2
3 Some *code*
4
5* Another list item
6
7 More code
8
9 And more code
  
1<p>In Markdown 1.0.0 and earlier. Version
28. This line turns into a list item.
3Because a hard-wrapped line in the
4middle of a paragraph looked like a
5list item.</p>
6<p>Here's one with a bullet.
7* criminey.</p>
  
1In Markdown 1.0.0 and earlier. Version
28. This line turns into a list item.
3Because a hard-wrapped line in the
4middle of a paragraph looked like a
5list item.
6
7Here's one with a bullet.
8* criminey.
  
1<p>Dashes:</p>
2<hr />
3<hr />
4<hr />
5<hr />
6<pre><code>---
7</code></pre>
8<hr />
9<hr />
10<hr />
11<hr />
12<pre><code>- - -
13</code></pre>
14<p>Asterisks:</p>
15<hr />
16<hr />
17<hr />
18<hr />
19<pre><code>***
20</code></pre>
21<hr />
22<hr />
23<hr />
24<hr />
25<pre><code>* * *
26</code></pre>
27<p>Underscores:</p>
28<hr />
29<hr />
30<hr />
31<hr />
32<pre><code>___
33</code></pre>
34<hr />
35<hr />
36<hr />
37<hr />
38<pre><code>_ _ _
39</code></pre>
  
1Dashes:
2
3---
4
5 ---
6
7 ---
8
9 ---
10
11 ---
12
13- - -
14
15 - - -
16
17 - - -
18
19 - - -
20
21 - - -
22
23
24Asterisks:
25
26***
27
28 ***
29
30 ***
31
32 ***
33
34 ***
35
36* * *
37
38 * * *
39
40 * * *
41
42 * * *
43
44 * * *
45
46
47Underscores:
48
49___
50
51 ___
52
53 ___
54
55 ___
56
57 ___
58
59_ _ _
60
61 _ _ _
62
63 _ _ _
64
65 _ _ _
66
67 _ _ _
  
1<p>Simple block on one line:</p>
2<div>foo</div>
3
4<p>And nested without indentation:</p>
5<div>
6<div>
7<div>
8foo
9</div>
10</div>
11<div>bar</div>
12</div>
  
1Simple block on one line:
2
3<div>foo</div>
4
5And nested without indentation:
6
7<div>
8<div>
9<div>
10foo
11</div>
12</div>
13<div>bar</div>
14</div>
  
1<p>Paragraph one.</p>
2<!-- This is a simple comment -->
3
4<!--
5 This is another comment.
6-->
7
8<p>Paragraph two.</p>
9<!-- one comment block -- -- with two comments -->
10
11<p>The end.</p>
  
1Paragraph one.
2
3<!-- This is a simple comment -->
4
5<!--
6 This is another comment.
7-->
8
9Paragraph two.
10
11<!-- one comment block -- -- with two comments -->
12
13The end.
  
1<p>Here's a simple block:</p>
2<div>
3 foo
4</div>
5
6<p>This should be a code block, though:</p>
7<pre><code>&lt;div&gt;
8 foo
9&lt;/div&gt;
10</code></pre>
11<p>As should this:</p>
12<pre><code>&lt;div&gt;foo&lt;/div&gt;
13</code></pre>
14<p>Now, nested:</p>
15<div>
16 <div>
17 <div>
18 foo
19 </div>
20 </div>
21</div>
22
23<p>This should just be an HTML comment:</p>
24<!-- Comment -->
25
26<p>Multiline:</p>
27<!--
28Blah
29Blah
30-->
31
32<p>Code block:</p>
33<pre><code>&lt;!-- Comment --&gt;
34</code></pre>
35<p>Just plain comment, with trailing spaces on the line:</p>
36<!-- foo -->
37
38<p>Code:</p>
39<pre><code>&lt;hr /&gt;
40</code></pre>
41<p>Hr's:</p>
42<hr>
43
44<hr/>
45
46<hr />
47
48<hr>
49
50<hr/>
51
52<hr />
53
54<hr class="foo" id="bar" />
55
56<hr class="foo" id="bar"/>
57
58<hr class="foo" id="bar" >
  
1Here's a simple block:
2
3<div>
4 foo
5</div>
6
7This should be a code block, though:
8
9 <div>
10 foo
11 </div>
12
13As should this:
14
15 <div>foo</div>
16
17Now, nested:
18
19<div>
20 <div>
21 <div>
22 foo
23 </div>
24 </div>
25</div>
26
27This should just be an HTML comment:
28
29<!-- Comment -->
30
31Multiline:
32
33<!--
34Blah
35Blah
36-->
37
38Code block:
39
40 <!-- Comment -->
41
42Just plain comment, with trailing spaces on the line:
43
44<!-- foo -->
45
46Code:
47
48 <hr />
49
50Hr's:
51
52<hr>
53
54<hr/>
55
56<hr />
57
58<hr>
59
60<hr/>
61
62<hr />
63
64<hr class="foo" id="bar" />
65
66<hr class="foo" id="bar"/>
67
68<hr class="foo" id="bar" >
  
1<p>Just a <a href="/url/">URL</a>.</p>
2<p><a href="/url/" title="title">URL and title</a>.</p>
3<p><a href="/url/" title="title preceded by two spaces">URL and title</a>.</p>
4<p><a href="/url/" title="title preceded by a tab">URL and title</a>.</p>
5<p><a href="">Empty</a>.</p>
  
1Just a [URL](/url/).
2
3[URL and title](/url/ "title").
4
5[URL and title](/url/ "title preceded by two spaces").
6
7[URL and title](/url/ "title preceded by a tab").
8
9[Empty]().
  
1<p>Foo <a href="/url/" title="Title">bar</a>.</p>
2<p>Foo <a href="/url/" title="Title">bar</a>.</p>
3<p>Foo <a href="/url/" title="Title">bar</a>.</p>
4<p>With <a href="/url/">embedded [brackets]</a>.</p>
5<p>Indented <a href="/url">once</a>.</p>
6<p>Indented <a href="/url">twice</a>.</p>
7<p>Indented <a href="/url">thrice</a>.</p>
8<p>Indented [four][] times.</p>
9<pre><code>[four]: /url
10</code></pre>
  
1Foo [bar] [1].
2
3Foo [bar][1].
4
5Foo [bar]
6[1].
7
8[1]: /url/ "Title"
9
10
11With [embedded [brackets]] [b].
12
13
14Indented [once][].
15
16Indented [twice][].
17
18Indented [thrice][].
19
20Indented [four][] times.
21
22 [once]: /url
23
24 [twice]: /url
25
26 [thrice]: /url
27
28 [four]: /url
29
30
31[b]: /url/
  
1<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
2<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
  
1Foo [bar][].
2
3Foo [bar](/url/ "Title with "quotes" inside").
4
5
6 [bar]: /url/ "Title with "quotes" inside"
  
1<h1>Markdown: Basics</h1>
2<ul id="ProjectSubmenu">
3 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
4 <li><a class="selected" title="Markdown Basics">Basics</a></li>
5 <li><a href="/projects/markdown/syntax" 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<h2>Getting the Gist of Markdown's Formatting Syntax</h2>
11<p>This page offers a brief overview of what it's like to use Markdown.
12The <a href="/projects/markdown/syntax" title="Markdown Syntax">syntax page</a> provides complete, detailed documentation for
13every feature, but Markdown should be very easy to pick up simply by
14looking at a few examples of it in action. The examples on this page
15are written in a before/after style, showing example syntax and the
16HTML output produced by Markdown.</p>
17<p>It's also helpful to simply try Markdown out; the <a href="/projects/markdown/dingus" title="Markdown Dingus">Dingus</a> is a
18web application that allows you type your own Markdown-formatted text
19and translate it to XHTML.</p>
20<p><strong>Note:</strong> This document is itself written using Markdown; you
21can <a href="/projects/markdown/basics.text">see the source for it by adding '.text' to the URL</a>.</p>
22<h2>Paragraphs, Headers, Blockquotes</h2>
23<p>A paragraph is simply one or more consecutive lines of text, separated
24by one or more blank lines. (A blank line is any line that looks like a
25blank line -- a line containing nothing spaces or tabs is considered
26blank.) Normal paragraphs should not be intended with spaces or tabs.</p>
27<p>Markdown offers two styles of headers: <em>Setext</em> and <em>atx</em>.
28Setext-style headers for <code>&lt;h1&gt;</code> and <code>&lt;h2&gt;</code> are created by
29"underlining" with equal signs (<code>=</code>) and hyphens (<code>-</code>), respectively.
30To create an atx-style header, you put 1-6 hash marks (<code>#</code>) at the
31beginning of the line -- the number of hashes equals the resulting
32HTML header level.</p>
33<p>Blockquotes are indicated using email-style '<code>&gt;</code>' angle brackets.</p>
34<p>Markdown:</p>
35<pre><code>A First Level Header
36====================
37
38A Second Level Header
39---------------------
40
41Now is the time for all good men to come to
42the aid of their country. This is just a
43regular paragraph.
44
45The quick brown fox jumped over the lazy
46dog's back.
47
48### Header 3
49
50&gt; This is a blockquote.
51&gt;
52&gt; This is the second paragraph in the blockquote.
53&gt;
54&gt; ## This is an H2 in a blockquote
55</code></pre>
56<p>Output:</p>
57<pre><code>&lt;h1&gt;A First Level Header&lt;/h1&gt;
58
59&lt;h2&gt;A Second Level Header&lt;/h2&gt;
60
61&lt;p&gt;Now is the time for all good men to come to
62the aid of their country. This is just a
63regular paragraph.&lt;/p&gt;
64
65&lt;p&gt;The quick brown fox jumped over the lazy
66dog's back.&lt;/p&gt;
67
68&lt;h3&gt;Header 3&lt;/h3&gt;
69
70&lt;blockquote&gt;
71 &lt;p&gt;This is a blockquote.&lt;/p&gt;
72
73 &lt;p&gt;This is the second paragraph in the blockquote.&lt;/p&gt;
74
75 &lt;h2&gt;This is an H2 in a blockquote&lt;/h2&gt;
76&lt;/blockquote&gt;
77</code></pre>
78<h3>Phrase Emphasis</h3>
79<p>Markdown uses asterisks and underscores to indicate spans of emphasis.</p>
80<p>Markdown:</p>
81<pre><code>Some of these words *are emphasized*.
82Some of these words _are emphasized also_.
83
84Use two asterisks for **strong emphasis**.
85Or, if you prefer, __use two underscores instead__.
86</code></pre>
87<p>Output:</p>
88<pre><code>&lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
89Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
90
91&lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
92Or, if you prefer, &lt;strong&gt;use two underscores instead&lt;/strong&gt;.&lt;/p&gt;
93</code></pre>
94<h2>Lists</h2>
95<p>Unordered (bulleted) lists use asterisks, pluses, and hyphens (<code>*</code>,
96<code>+</code>, and <code>-</code>) as list markers. These three markers are
97interchangable; this:</p>
98<pre><code>* Candy.
99* Gum.
100* Booze.
101</code></pre>
102<p>this:</p>
103<pre><code>+ Candy.
104+ Gum.
105+ Booze.
106</code></pre>
107<p>and this:</p>
108<pre><code>- Candy.
109- Gum.
110- Booze.
111</code></pre>
112<p>all produce the same output:</p>
113<pre><code>&lt;ul&gt;
114&lt;li&gt;Candy.&lt;/li&gt;
115&lt;li&gt;Gum.&lt;/li&gt;
116&lt;li&gt;Booze.&lt;/li&gt;
117&lt;/ul&gt;
118</code></pre>
119<p>Ordered (numbered) lists use regular numbers, followed by periods, as
120list markers:</p>
121<pre><code>1. Red
1222. Green
1233. Blue
124</code></pre>
125<p>Output:</p>
126<pre><code>&lt;ol&gt;
127&lt;li&gt;Red&lt;/li&gt;
128&lt;li&gt;Green&lt;/li&gt;
129&lt;li&gt;Blue&lt;/li&gt;
130&lt;/ol&gt;
131</code></pre>
132<p>If you put blank lines between items, you'll get <code>&lt;p&gt;</code> tags for the
133list item text. You can create multi-paragraph list items by indenting
134the paragraphs by 4 spaces or 1 tab:</p>
135<pre><code>* A list item.
136
137 With multiple paragraphs.
138
139* Another item in the list.
140</code></pre>
141<p>Output:</p>
142<pre><code>&lt;ul&gt;
143&lt;li&gt;&lt;p&gt;A list item.&lt;/p&gt;
144&lt;p&gt;With multiple paragraphs.&lt;/p&gt;&lt;/li&gt;
145&lt;li&gt;&lt;p&gt;Another item in the list.&lt;/p&gt;&lt;/li&gt;
146&lt;/ul&gt;
147</code></pre>
148<h3>Links</h3>
149<p>Markdown supports two styles for creating links: <em>inline</em> and
150<em>reference</em>. With both styles, you use square brackets to delimit the
151text you want to turn into a link.</p>
152<p>Inline-style links use parentheses immediately after the link text.
153For example:</p>
154<pre><code>This is an [example link](http://example.com/).
155</code></pre>
156<p>Output:</p>
157<pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/"&gt;
158example link&lt;/a&gt;.&lt;/p&gt;
159</code></pre>
160<p>Optionally, you may include a title attribute in the parentheses:</p>
161<pre><code>This is an [example link](http://example.com/ "With a Title").
162</code></pre>
163<p>Output:</p>
164<pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/" title="With a Title"&gt;
165example link&lt;/a&gt;.&lt;/p&gt;
166</code></pre>
167<p>Reference-style links allow you to refer to your links by names, which
168you define elsewhere in your document:</p>
169<pre><code>I get 10 times more traffic from [Google][1] than from
170[Yahoo][2] or [MSN][3].
171
172[1]: http://google.com/ "Google"
173[2]: http://search.yahoo.com/ "Yahoo Search"
174[3]: http://search.msn.com/ "MSN Search"
175</code></pre>
176<p>Output:</p>
177<pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
178title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
179title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
180title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
181</code></pre>
182<p>The title attribute is optional. Link names may contain letters,
183numbers and spaces, but are <em>not</em> case sensitive:</p>
184<pre><code>I start my morning with a cup of coffee and
185[The New York Times][NY Times].
186
187[ny times]: http://www.nytimes.com/
188</code></pre>
189<p>Output:</p>
190<pre><code>&lt;p&gt;I start my morning with a cup of coffee and
191&lt;a href="http://www.nytimes.com/"&gt;The New York Times&lt;/a&gt;.&lt;/p&gt;
192</code></pre>
193<h3>Images</h3>
194<p>Image syntax is very much like link syntax.</p>
195<p>Inline (titles are optional):</p>
196<pre><code>![alt text](/path/to/img.jpg "Title")
197</code></pre>
198<p>Reference-style:</p>
199<pre><code>![alt text][id]
200
201[id]: /path/to/img.jpg "Title"
202</code></pre>
203<p>Both of the above examples produce the same output:</p>
204<pre><code>&lt;img src="/path/to/img.jpg" alt="alt text" title="Title" /&gt;
205</code></pre>
206<h3>Code</h3>
207<p>In a regular paragraph, you can create code span by wrapping text in
208backtick quotes. Any ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> or
209<code>&gt;</code>) will automatically be translated into HTML entities. This makes
210it easy to use Markdown to write about HTML example code:</p>
211<pre><code>I strongly recommend against using any `&lt;blink&gt;` tags.
212
213I wish SmartyPants used named entities like `&amp;mdash;`
214instead of decimal-encoded entites like `&amp;#8212;`.
215</code></pre>
216<p>Output:</p>
217<pre><code>&lt;p&gt;I strongly recommend against using any
218&lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
219
220&lt;p&gt;I wish SmartyPants used named entities like
221&lt;code&gt;&amp;amp;mdash;&lt;/code&gt; instead of decimal-encoded
222entites like &lt;code&gt;&amp;amp;#8212;&lt;/code&gt;.&lt;/p&gt;
223</code></pre>
224<p>To specify an entire block of pre-formatted code, indent every line of
225the block by 4 spaces or 1 tab. Just like with code spans, <code>&amp;</code>, <code>&lt;</code>,
226and <code>&gt;</code> characters will be escaped automatically.</p>
227<p>Markdown:</p>
228<pre><code>If you want your page to validate under XHTML 1.0 Strict,
229you've got to put paragraph tags in your blockquotes:
230
231 &lt;blockquote&gt;
232 &lt;p&gt;For example.&lt;/p&gt;
233 &lt;/blockquote&gt;
234</code></pre>
235<p>Output:</p>
236<pre><code>&lt;p&gt;If you want your page to validate under XHTML 1.0 Strict,
237you've got to put paragraph tags in your blockquotes:&lt;/p&gt;
238
239&lt;pre&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;
240 &amp;lt;p&amp;gt;For example.&amp;lt;/p&amp;gt;
241&amp;lt;/blockquote&amp;gt;
242&lt;/code&gt;&lt;/pre&gt;
243</code></pre>
  
1Markdown: Basics
2================
3
4<ul id="ProjectSubmenu">
5 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
6 <li><a class="selected" title="Markdown Basics">Basics</a></li>
7 <li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
8 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
9 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
10</ul>
11
12
13Getting the Gist of Markdown's Formatting Syntax
14------------------------------------------------
15
16This page offers a brief overview of what it's like to use Markdown.
17The [syntax page] [s] provides complete, detailed documentation for
18every feature, but Markdown should be very easy to pick up simply by
19looking at a few examples of it in action. The examples on this page
20are written in a before/after style, showing example syntax and the
21HTML output produced by Markdown.
22
23It's also helpful to simply try Markdown out; the [Dingus] [d] is a
24web application that allows you type your own Markdown-formatted text
25and translate it to XHTML.
26
27**Note:** This document is itself written using Markdown; you
28can [see the source for it by adding '.text' to the URL] [src].
29
30 [s]: /projects/markdown/syntax "Markdown Syntax"
31 [d]: /projects/markdown/dingus "Markdown Dingus"
32 [src]: /projects/markdown/basics.text
33
34
35## Paragraphs, Headers, Blockquotes ##
36
37A paragraph is simply one or more consecutive lines of text, separated
38by one or more blank lines. (A blank line is any line that looks like a
39blank line -- a line containing nothing spaces or tabs is considered
40blank.) Normal paragraphs should not be intended with spaces or tabs.
41
42Markdown offers two styles of headers: *Setext* and *atx*.
43Setext-style headers for `<h1>` and `<h2>` are created by
44"underlining" with equal signs (`=`) and hyphens (`-`), respectively.
45To create an atx-style header, you put 1-6 hash marks (`#`) at the
46beginning of the line -- the number of hashes equals the resulting
47HTML header level.
48
49Blockquotes are indicated using email-style '`>`' angle brackets.
50
51Markdown:
52
53 A First Level Header
54 ====================
55
56 A Second Level Header
57 ---------------------
58
59 Now is the time for all good men to come to
60 the aid of their country. This is just a
61 regular paragraph.
62
63 The quick brown fox jumped over the lazy
64 dog's back.
65
66 ### Header 3
67
68 > This is a blockquote.
69 >
70 > This is the second paragraph in the blockquote.
71 >
72 > ## This is an H2 in a blockquote
73
74
75Output:
76
77 <h1>A First Level Header</h1>
78
79 <h2>A Second Level Header</h2>
80
81 <p>Now is the time for all good men to come to
82 the aid of their country. This is just a
83 regular paragraph.</p>
84
85 <p>The quick brown fox jumped over the lazy
86 dog's back.</p>
87
88 <h3>Header 3</h3>
89
90 <blockquote>
91 <p>This is a blockquote.</p>
92
93 <p>This is the second paragraph in the blockquote.</p>
94
95 <h2>This is an H2 in a blockquote</h2>
96 </blockquote>
97
98
99
100### Phrase Emphasis ###
101
102Markdown uses asterisks and underscores to indicate spans of emphasis.
103
104Markdown:
105
106 Some of these words *are emphasized*.
107 Some of these words _are emphasized also_.
108
109 Use two asterisks for **strong emphasis**.
110 Or, if you prefer, __use two underscores instead__.
111
112Output:
113
114 <p>Some of these words <em>are emphasized</em>.
115 Some of these words <em>are emphasized also</em>.</p>
116
117 <p>Use two asterisks for <strong>strong emphasis</strong>.
118 Or, if you prefer, <strong>use two underscores instead</strong>.</p>
119
120
121
122## Lists ##
123
124Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
125`+`, and `-`) as list markers. These three markers are
126interchangable; this:
127
128 * Candy.
129 * Gum.
130 * Booze.
131
132this:
133
134 + Candy.
135 + Gum.
136 + Booze.
137
138and this:
139
140 - Candy.
141 - Gum.
142 - Booze.
143
144all produce the same output:
145
146 <ul>
147 <li>Candy.</li>
148 <li>Gum.</li>
149 <li>Booze.</li>
150 </ul>
151
152Ordered (numbered) lists use regular numbers, followed by periods, as
153list markers:
154
155 1. Red
156 2. Green
157 3. Blue
158
159Output:
160
161 <ol>
162 <li>Red</li>
163 <li>Green</li>
164 <li>Blue</li>
165 </ol>
166
167If you put blank lines between items, you'll get `<p>` tags for the
168list item text. You can create multi-paragraph list items by indenting
169the paragraphs by 4 spaces or 1 tab:
170
171 * A list item.
172
173 With multiple paragraphs.
174
175 * Another item in the list.
176
177Output:
178
179 <ul>
180 <li><p>A list item.</p>
181 <p>With multiple paragraphs.</p></li>
182 <li><p>Another item in the list.</p></li>
183 </ul>
184
185
186
187### Links ###
188
189Markdown supports two styles for creating links: *inline* and
190*reference*. With both styles, you use square brackets to delimit the
191text you want to turn into a link.
192
193Inline-style links use parentheses immediately after the link text.
194For example:
195
196 This is an [example link](http://example.com/).
197
198Output:
199
200 <p>This is an <a href="http://example.com/">
201 example link</a>.</p>
202
203Optionally, you may include a title attribute in the parentheses:
204
205 This is an [example link](http://example.com/ "With a Title").
206
207Output:
208
209 <p>This is an <a href="http://example.com/" title="With a Title">
210 example link</a>.</p>
211
212Reference-style links allow you to refer to your links by names, which
213you define elsewhere in your document:
214
215 I get 10 times more traffic from [Google][1] than from
216 [Yahoo][2] or [MSN][3].
217
218 [1]: http://google.com/ "Google"
219 [2]: http://search.yahoo.com/ "Yahoo Search"
220 [3]: http://search.msn.com/ "MSN Search"
221
222Output:
223
224 <p>I get 10 times more traffic from <a href="http://google.com/"
225 title="Google">Google</a> than from <a href="http://search.yahoo.com/"
226 title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
227 title="MSN Search">MSN</a>.</p>
228
229The title attribute is optional. Link names may contain letters,
230numbers and spaces, but are *not* case sensitive:
231
232 I start my morning with a cup of coffee and
233 [The New York Times][NY Times].
234
235 [ny times]: http://www.nytimes.com/
236
237Output:
238
239 <p>I start my morning with a cup of coffee and
240 <a href="http://www.nytimes.com/">The New York Times</a>.</p>
241
242
243### Images ###
244
245Image syntax is very much like link syntax.
246
247Inline (titles are optional):
248
249 ![alt text](/path/to/img.jpg "Title")
250
251Reference-style:
252
253 ![alt text][id]
254
255 [id]: /path/to/img.jpg "Title"
256
257Both of the above examples produce the same output:
258
259 <img src="/path/to/img.jpg" alt="alt text" title="Title" />
260
261
262
263### Code ###
264
265In a regular paragraph, you can create code span by wrapping text in
266backtick quotes. Any ampersands (`&`) and angle brackets (`<` or
267`>`) will automatically be translated into HTML entities. This makes
268it easy to use Markdown to write about HTML example code:
269
270 I strongly recommend against using any `<blink>` tags.
271
272 I wish SmartyPants used named entities like `&mdash;`
273 instead of decimal-encoded entites like `&#8212;`.
274
275Output:
276
277 <p>I strongly recommend against using any
278 <code>&lt;blink&gt;</code> tags.</p>
279
280 <p>I wish SmartyPants used named entities like
281 <code>&amp;mdash;</code> instead of decimal-encoded
282 entites like <code>&amp;#8212;</code>.</p>
283
284
285To specify an entire block of pre-formatted code, indent every line of
286the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`,
287and `>` characters will be escaped automatically.
288
289Markdown:
290
291 If you want your page to validate under XHTML 1.0 Strict,
292 you've got to put paragraph tags in your blockquotes:
293
294 <blockquote>
295 <p>For example.</p>
296 </blockquote>
297
298Output:
299
300 <p>If you want your page to validate under XHTML 1.0 Strict,
301 you've got to put paragraph tags in your blockquotes:</p>
302
303 <pre><code>&lt;blockquote&gt;
304 &lt;p&gt;For example.&lt;/p&gt;
305 &lt;/blockquote&gt;
306 </code></pre>
  
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
40can <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
48document should be publishable as-is, as plain text, without looking
49like it's been marked up with tags or formatting instructions. While
50Markdown's syntax has been influenced by several existing text-to-HTML
51filters -- 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
53inspiration 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
55characters, which punctuation characters have been carefully chosen so
56as to look like what they mean. E.g., asterisks around a word actually
57look like *emphasis*. Markdown lists look like, well, lists. Even
58blockquotes look like quoted passages of text, assuming you've ever
59used 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
63format for <em>writing</em> for the web.</p>
64<p>Markdown is not a replacement for HTML, or even close to it. Its
65syntax is very small, corresponding only to a very small subset of
66HTML tags. The idea is <em>not</em> to create a syntax that makes it easier
67to insert HTML tags. In my opinion, HTML tags are already easy to
68insert. The idea for Markdown is to make it easy to read, write, and
69edit prose. HTML is a <em>publishing</em> format; Markdown is a <em>writing</em>
70format. Thus, Markdown's formatting syntax only addresses issues that
71can be conveyed in plain text.</p>
72<p>For any markup that is not covered by Markdown's syntax, you simply
73use HTML itself. There's no need to preface it or delimit it to
74indicate that you're switching from Markdown to HTML; you just use
75the 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
78content by blank lines, and the start and end tags of the block should
79not be indented with tabs or spaces. Markdown is smart enough not
80to 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
90This is another regular paragraph.
91</code></pre>
92<p>Note that Markdown formatting syntax is not processed within block-level
93HTML tags. E.g., you can't use Markdown-style <code>*emphasis*</code> inside an
94HTML 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
96used anywhere in a Markdown paragraph, list item, or header. If you
97want, you can even use HTML tags instead of Markdown formatting; e.g. if
98you'd prefer to use HTML <code>&lt;a&gt;</code> or <code>&lt;img&gt;</code> tags instead of Markdown's
99link or image syntax, go right ahead.</p>
100<p>Unlike block-level HTML tags, Markdown syntax <em>is</em> processed within
101span-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>
105and <code>&amp;</code>. Left angle brackets are used to start tags; ampersands are
106used to denote HTML entities. If you want to use them as literal
107characters, 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
110write about 'AT&amp;T', you need to write '<code>AT&amp;amp;T</code>'. You even need to
111escape 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
118forget, and is probably the single most common source of HTML validation
119errors in otherwise well-marked-up web sites.</p>
120<p>Markdown allows you to use these characters naturally, taking care of
121all the necessary escaping for you. If you use an ampersand as part of
122an HTML entity, it remains unchanged; otherwise it will be translated
123into <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
134angle brackets as delimiters for HTML tags, Markdown will treat them as
135such. 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
142ampersands are <em>always</em> encoded automatically. This makes it easy to use
143Markdown to write about HTML code. (As opposed to raw HTML, which is a
144terrible format for writing about HTML syntax, because every single <code>&lt;</code>
145and <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
152by one or more blank lines. (A blank line is any line that looks like a
153blank line -- a line containing nothing but spaces or tabs is considered
154blank.) 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
156that Markdown supports "hard-wrapped" text paragraphs. This differs
157significantly from most other text-to-HTML formatters (including Movable
158Type's "Convert Line Breaks" option) which translate every line break
159character 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
161end 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.
164Markdown's email-style <a href="#blockquote">blockquoting</a> and multi-paragraph <a href="#list">list items</a>
165work 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
170headers) and dashes (for second-level headers). For example:</p>
171<pre><code>This is an H1
172=============
173
174This 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,
179corresponding 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
187cosmetic -- you can use this if you think it looks better. The
188closing hashes don't even need to match the number of hashes
189used to open the header. (The number of opening hashes
190determines 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
200familiar with quoting passages of text in an email message, then you
201know how to create a blockquote in Markdown. It looks best if you hard
202wrap 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
211line of a hard-wrapped paragraph:</p>
212<pre><code>&gt; This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
213consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
214Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
215
216&gt; Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
217id sem consectetuer libero luctus adipiscing.
218</code></pre>
219<p>Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
220adding 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,
228and 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
239example, with BBEdit, you can make a selection and choose Increase
240Quote 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<pre><code>* Red
246* Green
247* Blue
248</code></pre>
249<p>is equivalent to:</p>
250<pre><code>+ Red
251+ Green
252+ Blue
253</code></pre>
254<p>and:</p>
255<pre><code>- Red
256- Green
257- Blue
258</code></pre>
259<p>Ordered lists use numbers followed by periods:</p>
260<pre><code>1. Bird
2612. McHale
2623. Parish
263</code></pre>
264<p>It's important to note that the actual numbers you use to mark the
265list have no effect on the HTML output Markdown produces. The HTML
266Markdown produces from the above list is:</p>
267<pre><code>&lt;ol&gt;
268&lt;li&gt;Bird&lt;/li&gt;
269&lt;li&gt;McHale&lt;/li&gt;
270&lt;li&gt;Parish&lt;/li&gt;
271&lt;/ol&gt;
272</code></pre>
273<p>If you instead wrote the list in Markdown like this:</p>
274<pre><code>1. Bird
2751. McHale
2761. Parish
277</code></pre>
278<p>or even:</p>
279<pre><code>3. Bird
2801. McHale
2818. Parish
282</code></pre>
283<p>you'd get the exact same HTML output. The point is, if you want to,
284you can use ordinal numbers in your ordered Markdown lists, so that
285the numbers in your source match the numbers in your published HTML.
286But if you want to be lazy, you don't have to.</p>
287<p>If you do use lazy list numbering, however, you should still start the
288list with the number 1. At some point in the future, Markdown may support
289starting ordered lists at an arbitrary number.</p>
290<p>List markers typically start at the left margin, but may be indented by
291up to three spaces. List markers must be followed by one or more spaces
292or a tab.</p>
293<p>To make lists look nice, you can wrap items with hanging indents:</p>
294<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
295 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
296 viverra nec, fringilla in, laoreet vitae, risus.
297* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
298 Suspendisse id sem consectetuer libero luctus adipiscing.
299</code></pre>
300<p>But if you want to be lazy, you don't have to:</p>
301<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
302Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
303viverra nec, fringilla in, laoreet vitae, risus.
304* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
305Suspendisse id sem consectetuer libero luctus adipiscing.
306</code></pre>
307<p>If list items are separated by blank lines, Markdown will wrap the
308items in <code>&lt;p&gt;</code> tags in the HTML output. For example, this input:</p>
309<pre><code>* Bird
310* Magic
311</code></pre>
312<p>will turn into:</p>
313<pre><code>&lt;ul&gt;
314&lt;li&gt;Bird&lt;/li&gt;
315&lt;li&gt;Magic&lt;/li&gt;
316&lt;/ul&gt;
317</code></pre>
318<p>But this:</p>
319<pre><code>* Bird
320
321* Magic
322</code></pre>
323<p>will turn into:</p>
324<pre><code>&lt;ul&gt;
325&lt;li&gt;&lt;p&gt;Bird&lt;/p&gt;&lt;/li&gt;
326&lt;li&gt;&lt;p&gt;Magic&lt;/p&gt;&lt;/li&gt;
327&lt;/ul&gt;
328</code></pre>
329<p>List items may consist of multiple paragraphs. Each subsequent
330paragraph in a list item must be intended by either 4 spaces
331or one tab:</p>
332<pre><code>1. This is a list item with two paragraphs. Lorem ipsum dolor
333 sit amet, consectetuer adipiscing elit. Aliquam hendrerit
334 mi posuere lectus.
335
336 Vestibulum enim wisi, viverra nec, fringilla in, laoreet
337 vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
338 sit amet velit.
339
3402. Suspendisse id sem consectetuer libero luctus adipiscing.
341</code></pre>
342<p>It looks nice if you indent every line of the subsequent
343paragraphs, but here again, Markdown will allow you to be
344lazy:</p>
345<pre><code>* This is a list item with two paragraphs.
346
347 This is the second paragraph in the list item. You're
348only required to indent the first line. Lorem ipsum dolor
349sit amet, consectetuer adipiscing elit.
350
351* Another item in the same list.
352</code></pre>
353<p>To put a blockquote within a list item, the blockquote's <code>&gt;</code>
354delimiters need to be indented:</p>
355<pre><code>* A list item with a blockquote:
356
357 &gt; This is a blockquote
358 &gt; inside a list item.
359</code></pre>
360<p>To put a code block within a list item, the code block needs
361to be indented <em>twice</em> -- 8 spaces or two tabs:</p>
362<pre><code>* A list item with a code block:
363
364 &lt;code goes here&gt;
365</code></pre>
366<p>It's worth noting that it's possible to trigger an ordered list by
367accident, by writing something like this:</p>
368<pre><code>1986. What a great season.
369</code></pre>
370<p>In other words, a <em>number-period-space</em> sequence at the beginning of a
371line. To avoid this, you can backslash-escape the period:</p>
372<pre><code>1986\. What a great season.
373</code></pre>
374<h3 id="precode">Code Blocks</h3>
375
376<p>Pre-formatted code blocks are used for writing about programming or
377markup source code. Rather than forming normal paragraphs, the lines
378of a code block are interpreted literally. Markdown wraps a code block
379in both <code>&lt;pre&gt;</code> and <code>&lt;code&gt;</code> tags.</p>
380<p>To produce a code block in Markdown, simply indent every line of the
381block by at least 4 spaces or 1 tab. For example, given this input:</p>
382<pre><code>This is a normal paragraph:
383
384 This is a code block.
385</code></pre>
386<p>Markdown will generate:</p>
387<pre><code>&lt;p&gt;This is a normal paragraph:&lt;/p&gt;
388
389&lt;pre&gt;&lt;code&gt;This is a code block.
390&lt;/code&gt;&lt;/pre&gt;
391</code></pre>
392<p>One level of indentation -- 4 spaces or 1 tab -- is removed from each
393line of the code block. For example, this:</p>
394<pre><code>Here is an example of AppleScript:
395
396 tell application "Foo"
397 beep
398 end tell
399</code></pre>
400<p>will turn into:</p>
401<pre><code>&lt;p&gt;Here is an example of AppleScript:&lt;/p&gt;
402
403&lt;pre&gt;&lt;code&gt;tell application "Foo"
404 beep
405end tell
406&lt;/code&gt;&lt;/pre&gt;
407</code></pre>
408<p>A code block continues until it reaches a line that is not indented
409(or the end of the article).</p>
410<p>Within a code block, ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> and <code>&gt;</code>)
411are automatically converted into HTML entities. This makes it very
412easy to include example HTML source code using Markdown -- just paste
413it and indent it, and Markdown will handle the hassle of encoding the
414ampersands and angle brackets. For example, this:</p>
415<pre><code> &lt;div class="footer"&gt;
416 &amp;copy; 2004 Foo Corporation
417 &lt;/div&gt;
418</code></pre>
419<p>will turn into:</p>
420<pre><code>&lt;pre&gt;&lt;code&gt;&amp;lt;div class="footer"&amp;gt;
421 &amp;amp;copy; 2004 Foo Corporation
422&amp;lt;/div&amp;gt;
423&lt;/code&gt;&lt;/pre&gt;
424</code></pre>
425<p>Regular Markdown syntax is not processed within code blocks. E.g.,
426asterisks are just literal asterisks within a code block. This means
427it's also easy to use Markdown to write about Markdown's own syntax.</p>
428<h3 id="hr">Horizontal Rules</h3>
429
430<p>You can produce a horizontal rule tag (<code>&lt;hr /&gt;</code>) by placing three or
431more hyphens, asterisks, or underscores on a line by themselves. If you
432wish, you may use spaces between the hyphens or asterisks. Each of the
433following lines will produce a horizontal rule:</p>
434<pre><code>* * *
435
436***
437
438*****
439
440- - -
441
442---------------------------------------
443
444_ _ _
445</code></pre>
446<hr />
447<h2 id="span">Span Elements</h2>
448
449<h3 id="link">Links</h3>
450
451<p>Markdown supports two style of links: <em>inline</em> and <em>reference</em>.</p>
452<p>In both styles, the link text is delimited by [square brackets].</p>
453<p>To create an inline link, use a set of regular parentheses immediately
454after the link text's closing square bracket. Inside the parentheses,
455put the URL where you want the link to point, along with an <em>optional</em>
456title for the link, surrounded in quotes. For example:</p>
457<pre><code>This is [an example](http://example.com/ "Title") inline link.
458
459[This link](http://example.net/) has no title attribute.
460</code></pre>
461<p>Will produce:</p>
462<pre><code>&lt;p&gt;This is &lt;a href="http://example.com/" title="Title"&gt;
463an example&lt;/a&gt; inline link.&lt;/p&gt;
464
465&lt;p&gt;&lt;a href="http://example.net/"&gt;This link&lt;/a&gt; has no
466title attribute.&lt;/p&gt;
467</code></pre>
468<p>If you're referring to a local resource on the same server, you can
469use relative paths:</p>
470<pre><code>See my [About](/about/) page for details.
471</code></pre>
472<p>Reference-style links use a second set of square brackets, inside
473which you place a label of your choosing to identify the link:</p>
474<pre><code>This is [an example][id] reference-style link.
475</code></pre>
476<p>You can optionally use a space to separate the sets of brackets:</p>
477<pre><code>This is [an example] [id] reference-style link.
478</code></pre>
479<p>Then, anywhere in the document, you define your link label like this,
480on a line by itself:</p>
481<pre><code>[id]: http://example.com/ "Optional Title Here"
482</code></pre>
483<p>That is:</p>
484<ul>
485<li>Square brackets containing the link identifier (optionally
486 indented from the left margin using up to three spaces);</li>
487<li>followed by a colon;</li>
488<li>followed by one or more spaces (or tabs);</li>
489<li>followed by the URL for the link;</li>
490<li>optionally followed by a title attribute for the link, enclosed
491 in double or single quotes.</li>
492</ul>
493<p>The link URL may, optionally, be surrounded by angle brackets:</p>
494<pre><code>[id]: &lt;http://example.com/&gt; "Optional Title Here"
495</code></pre>
496<p>You can put the title attribute on the next line and use extra spaces
497or tabs for padding, which tends to look better with longer URLs:</p>
498<pre><code>[id]: http://example.com/longish/path/to/resource/here
499 "Optional Title Here"
500</code></pre>
501<p>Link definitions are only used for creating links during Markdown
502processing, and are stripped from your document in the HTML output.</p>
503<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>
504<pre><code>[link text][a]
505[link text][A]
506</code></pre>
507<p>are equivalent.</p>
508<p>The <em>implicit link name</em> shortcut allows you to omit the name of the
509link, in which case the link text itself is used as the name.
510Just use an empty set of square brackets -- e.g., to link the word
511"Google" to the google.com web site, you could simply write:</p>
512<pre><code>[Google][]
513</code></pre>
514<p>And then define the link:</p>
515<pre><code>[Google]: http://google.com/
516</code></pre>
517<p>Because link names may contain spaces, this shortcut even works for
518multiple words in the link text:</p>
519<pre><code>Visit [Daring Fireball][] for more information.
520</code></pre>
521<p>And then define the link:</p>
522<pre><code>[Daring Fireball]: http://daringfireball.net/
523</code></pre>
524<p>Link definitions can be placed anywhere in your Markdown document. I
525tend to put them immediately after each paragraph in which they're
526used, but if you want, you can put them all at the end of your
527document, sort of like footnotes.</p>
528<p>Here's an example of reference links in action:</p>
529<pre><code>I get 10 times more traffic from [Google] [1] than from
530[Yahoo] [2] or [MSN] [3].
531
532 [1]: http://google.com/ "Google"
533 [2]: http://search.yahoo.com/ "Yahoo Search"
534 [3]: http://search.msn.com/ "MSN Search"
535</code></pre>
536<p>Using the implicit link name shortcut, you could instead write:</p>
537<pre><code>I get 10 times more traffic from [Google][] than from
538[Yahoo][] or [MSN][].
539
540 [google]: http://google.com/ "Google"
541 [yahoo]: http://search.yahoo.com/ "Yahoo Search"
542 [msn]: http://search.msn.com/ "MSN Search"
543</code></pre>
544<p>Both of the above examples will produce the following HTML output:</p>
545<pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
546title="Google"&gt;Google&lt;/a&gt; than from
547&lt;a href="http://search.yahoo.com/" title="Yahoo Search"&gt;Yahoo&lt;/a&gt;
548or &lt;a href="http://search.msn.com/" title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
549</code></pre>
550<p>For comparison, here is the same paragraph written using
551Markdown's inline link style:</p>
552<pre><code>I get 10 times more traffic from [Google](http://google.com/ "Google")
553than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
554[MSN](http://search.msn.com/ "MSN Search").
555</code></pre>
556<p>The point of reference-style links is not that they're easier to
557write. The point is that with reference-style links, your document
558source is vastly more readable. Compare the above examples: using
559reference-style links, the paragraph itself is only 81 characters
560long; with inline-style links, it's 176 characters; and as raw HTML,
561it's 234 characters. In the raw HTML, there's more markup than there
562is text.</p>
563<p>With Markdown's reference-style links, a source document much more
564closely resembles the final output, as rendered in a browser. By
565allowing you to move the markup-related metadata out of the paragraph,
566you can add links without interrupting the narrative flow of your
567prose.</p>
568<h3 id="em">Emphasis</h3>
569
570<p>Markdown treats asterisks (<code>*</code>) and underscores (<code>_</code>) as indicators of
571emphasis. Text wrapped with one <code>*</code> or <code>_</code> will be wrapped with an
572HTML <code>&lt;em&gt;</code> tag; double <code>*</code>'s or <code>_</code>'s will be wrapped with an HTML
573<code>&lt;strong&gt;</code> tag. E.g., this input:</p>
574<pre><code>*single asterisks*
575
576_single underscores_
577
578**double asterisks**
579
580__double underscores__
581</code></pre>
582<p>will produce:</p>
583<pre><code>&lt;em&gt;single asterisks&lt;/em&gt;
584
585&lt;em&gt;single underscores&lt;/em&gt;
586
587&lt;strong&gt;double asterisks&lt;/strong&gt;
588
589&lt;strong&gt;double underscores&lt;/strong&gt;
590</code></pre>
591<p>You can use whichever style you prefer; the lone restriction is that
592the same character must be used to open and close an emphasis span.</p>
593<p>Emphasis can be used in the middle of a word:</p>
594<pre><code>un*fucking*believable
595</code></pre>
596<p>But if you surround an <code>*</code> or <code>_</code> with spaces, it'll be treated as a
597literal asterisk or underscore.</p>
598<p>To produce a literal asterisk or underscore at a position where it
599would otherwise be used as an emphasis delimiter, you can backslash
600escape it:</p>
601<pre><code>\*this text is surrounded by literal asterisks\*
602</code></pre>
603<h3 id="code">Code</h3>
604
605<p>To indicate a span of code, wrap it with backtick quotes (<code>`</code>).
606Unlike a pre-formatted code block, a code span indicates code within a
607normal paragraph. For example:</p>
608<pre><code>Use the `printf()` function.
609</code></pre>
610<p>will produce:</p>
611<pre><code>&lt;p&gt;Use the &lt;code&gt;printf()&lt;/code&gt; function.&lt;/p&gt;
612</code></pre>
613<p>To include a literal backtick character within a code span, you can use
614multiple backticks as the opening and closing delimiters:</p>
615<pre><code>``There is a literal backtick (`) here.``
616</code></pre>
617<p>which will produce this:</p>
618<pre><code>&lt;p&gt;&lt;code&gt;There is a literal backtick (`) here.&lt;/code&gt;&lt;/p&gt;
619</code></pre>
620<p>The backtick delimiters surrounding a code span may include spaces --
621one after the opening, one before the closing. This allows you to place
622literal backtick characters at the beginning or end of a code span:</p>
623<pre><code>A single backtick in a code span: `` ` ``
624
625A backtick-delimited string in a code span: `` `foo` ``
626</code></pre>
627<p>will produce:</p>
628<pre><code>&lt;p&gt;A single backtick in a code span: &lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
629
630&lt;p&gt;A backtick-delimited string in a code span: &lt;code&gt;`foo`&lt;/code&gt;&lt;/p&gt;
631</code></pre>
632<p>With a code span, ampersands and angle brackets are encoded as HTML
633entities automatically, which makes it easy to include example HTML
634tags. Markdown will turn this:</p>
635<pre><code>Please don't use any `&lt;blink&gt;` tags.
636</code></pre>
637<p>into:</p>
638<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;
639</code></pre>
640<p>You can write this:</p>
641<pre><code>`&amp;#8212;` is the decimal-encoded equivalent of `&amp;mdash;`.
642</code></pre>
643<p>to produce:</p>
644<pre><code>&lt;p&gt;&lt;code&gt;&amp;amp;#8212;&lt;/code&gt; is the decimal-encoded
645equivalent of &lt;code&gt;&amp;amp;mdash;&lt;/code&gt;.&lt;/p&gt;
646</code></pre>
647<h3 id="img">Images</h3>
648
649<p>Admittedly, it's fairly difficult to devise a "natural" syntax for
650placing images into a plain text document format.</p>
651<p>Markdown uses an image syntax that is intended to resemble the syntax
652for links, allowing for two styles: <em>inline</em> and <em>reference</em>.</p>
653<p>Inline image syntax looks like this:</p>
654<pre><code>![Alt text](/path/to/img.jpg)
655
656![Alt text](/path/to/img.jpg "Optional title")
657</code></pre>
658<p>That is:</p>
659<ul>
660<li>An exclamation mark: <code>!</code>;</li>
661<li>followed by a set of square brackets, containing the <code>alt</code>
662 attribute text for the image;</li>
663<li>followed by a set of parentheses, containing the URL or path to
664 the image, and an optional <code>title</code> attribute enclosed in double
665 or single quotes.</li>
666</ul>
667<p>Reference-style image syntax looks like this:</p>
668<pre><code>![Alt text][id]
669</code></pre>
670<p>Where "id" is the name of a defined image reference. Image references
671are defined using syntax identical to link references:</p>
672<pre><code>[id]: url/to/image "Optional title attribute"
673</code></pre>
674<p>As of this writing, Markdown has no syntax for specifying the
675dimensions of an image; if this is important to you, you can simply
676use regular HTML <code>&lt;img&gt;</code> tags.</p>
677<hr />
678<h2 id="misc">Miscellaneous</h2>
679
680<h3 id="autolink">Automatic Links</h3>
681
682<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>
683<pre><code>&lt;http://example.com/&gt;
684</code></pre>
685<p>Markdown will turn this into:</p>
686<pre><code>&lt;a href="http://example.com/"&gt;http://example.com/&lt;/a&gt;
687</code></pre>
688<p>Automatic links for email addresses work similarly, except that
689Markdown will also perform a bit of randomized decimal and hex
690entity-encoding to help obscure your address from address-harvesting
691spambots. For example, Markdown will turn this:</p>
692<pre><code>&lt;address@example.com&gt;
693</code></pre>
694<p>into something like this:</p>
695<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;
696&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;
697&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;
698&amp;#109;&amp;#x70;&amp;#x6C;e&amp;#x2E;&amp;#99;&amp;#111;&amp;#109;&lt;/a&gt;
699</code></pre>
700<p>which will render in a browser as a clickable link to "address@example.com".</p>
701<p>(This sort of entity-encoding trick will indeed fool many, if not
702most, address-harvesting bots, but it definitely won't fool all of
703them. It's better than nothing, but an address published in this way
704will probably eventually start receiving spam.)</p>
705<h3 id="backslash">Backslash Escapes</h3>
706
707<p>Markdown allows you to use backslash escapes to generate literal
708characters which would otherwise have special meaning in Markdown's
709formatting syntax. For example, if you wanted to surround a word with
710literal asterisks (instead of an HTML <code>&lt;em&gt;</code> tag), you can backslashes
711before the asterisks, like this:</p>
712<pre><code>\*literal asterisks\*
713</code></pre>
714<p>Markdown provides backslash escapes for the following characters:</p>
715<pre><code>\ backslash
716` backtick
717* asterisk
718_ underscore
719{} curly braces
720[] square brackets
721() parentheses
722# hash mark
723+ plus sign
724- minus sign (hyphen)
725. dot
726! exclamation mark
727</code></pre>
  
1Markdown: Syntax
2================
3
4<ul id="ProjectSubmenu">
5 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
6 <li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li>
7 <li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li>
8 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
9 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
10</ul>
11
12
13* [Overview](#overview)
14 * [Philosophy](#philosophy)
15 * [Inline HTML](#html)
16 * [Automatic Escaping for Special Characters](#autoescape)
17* [Block Elements](#block)
18 * [Paragraphs and Line Breaks](#p)
19 * [Headers](#header)
20 * [Blockquotes](#blockquote)
21 * [Lists](#list)
22 * [Code Blocks](#precode)
23 * [Horizontal Rules](#hr)
24* [Span Elements](#span)
25 * [Links](#link)
26 * [Emphasis](#em)
27 * [Code](#code)
28 * [Images](#img)
29* [Miscellaneous](#misc)
30 * [Backslash Escapes](#backslash)
31 * [Automatic Links](#autolink)
32
33
34**Note:** This document is itself written using Markdown; you
35can [see the source for it by adding '.text' to the URL][src].
36
37 [src]: /projects/markdown/syntax.text
38
39* * *
40
41<h2 id="overview">Overview</h2>
42
43<h3 id="philosophy">Philosophy</h3>
44
45Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
46
47Readability, however, is emphasized above all else. A Markdown-formatted
48document should be publishable as-is, as plain text, without looking
49like it's been marked up with tags or formatting instructions. While
50Markdown's syntax has been influenced by several existing text-to-HTML
51filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4],
52[Grutatext] [5], and [EtText] [6] -- the single biggest source of
53inspiration for Markdown's syntax is the format of plain text email.
54
55 [1]: http://docutils.sourceforge.net/mirror/setext.html
56 [2]: http://www.aaronsw.com/2002/atx/
57 [3]: http://textism.com/tools/textile/
58 [4]: http://docutils.sourceforge.net/rst.html
59 [5]: http://www.triptico.com/software/grutatxt.html
60 [6]: http://ettext.taint.org/doc/
61
62To this end, Markdown's syntax is comprised entirely of punctuation
63characters, which punctuation characters have been carefully chosen so
64as to look like what they mean. E.g., asterisks around a word actually
65look like \*emphasis\*. Markdown lists look like, well, lists. Even
66blockquotes look like quoted passages of text, assuming you've ever
67used email.
68
69
70
71<h3 id="html">Inline HTML</h3>
72
73Markdown's syntax is intended for one purpose: to be used as a
74format for *writing* for the web.
75
76Markdown is not a replacement for HTML, or even close to it. Its
77syntax is very small, corresponding only to a very small subset of
78HTML tags. The idea is *not* to create a syntax that makes it easier
79to insert HTML tags. In my opinion, HTML tags are already easy to
80insert. The idea for Markdown is to make it easy to read, write, and
81edit prose. HTML is a *publishing* format; Markdown is a *writing*
82format. Thus, Markdown's formatting syntax only addresses issues that
83can be conveyed in plain text.
84
85For any markup that is not covered by Markdown's syntax, you simply
86use HTML itself. There's no need to preface it or delimit it to
87indicate that you're switching from Markdown to HTML; you just use
88the tags.
89
90The only restrictions are that block-level HTML elements -- e.g. `<div>`,
91`<table>`, `<pre>`, `<p>`, etc. -- must be separated from surrounding
92content by blank lines, and the start and end tags of the block should
93not be indented with tabs or spaces. Markdown is smart enough not
94to add extra (unwanted) `<p>` tags around HTML block-level tags.
95
96For example, to add an HTML table to a Markdown article:
97
98 This is a regular paragraph.
99
100 <table>
101 <tr>
102 <td>Foo</td>
103 </tr>
104 </table>
105
106 This is another regular paragraph.
107
108Note that Markdown formatting syntax is not processed within block-level
109HTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an
110HTML block.
111
112Span-level HTML tags -- e.g. `<span>`, `<cite>`, or `<del>` -- can be
113used anywhere in a Markdown paragraph, list item, or header. If you
114want, you can even use HTML tags instead of Markdown formatting; e.g. if
115you'd prefer to use HTML `<a>` or `<img>` tags instead of Markdown's
116link or image syntax, go right ahead.
117
118Unlike block-level HTML tags, Markdown syntax *is* processed within
119span-level tags.
120
121
122<h3 id="autoescape">Automatic Escaping for Special Characters</h3>
123
124In HTML, there are two characters that demand special treatment: `<`
125and `&`. Left angle brackets are used to start tags; ampersands are
126used to denote HTML entities. If you want to use them as literal
127characters, you must escape them as entities, e.g. `&lt;`, and
128`&amp;`.
129
130Ampersands in particular are bedeviling for web writers. If you want to
131write about 'AT&T', you need to write '`AT&amp;T`'. You even need to
132escape ampersands within URLs. Thus, if you want to link to:
133
134 http://images.google.com/images?num=30&q=larry+bird
135
136you need to encode the URL as:
137
138 http://images.google.com/images?num=30&amp;q=larry+bird
139
140in your anchor tag `href` attribute. Needless to say, this is easy to
141forget, and is probably the single most common source of HTML validation
142errors in otherwise well-marked-up web sites.
143
144Markdown allows you to use these characters naturally, taking care of
145all the necessary escaping for you. If you use an ampersand as part of
146an HTML entity, it remains unchanged; otherwise it will be translated
147into `&amp;`.
148
149So, if you want to include a copyright symbol in your article, you can write:
150
151 &copy;
152
153and Markdown will leave it alone. But if you write:
154
155 AT&T
156
157Markdown will translate it to:
158
159 AT&amp;T
160
161Similarly, because Markdown supports [inline HTML](#html), if you use
162angle brackets as delimiters for HTML tags, Markdown will treat them as
163such. But if you write:
164
165 4 < 5
166
167Markdown will translate it to:
168
169 4 &lt; 5
170
171However, inside Markdown code spans and blocks, angle brackets and
172ampersands are *always* encoded automatically. This makes it easy to use
173Markdown to write about HTML code. (As opposed to raw HTML, which is a
174terrible format for writing about HTML syntax, because every single `<`
175and `&` in your example code needs to be escaped.)
176
177
178* * *
179
180
181<h2 id="block">Block Elements</h2>
182
183
184<h3 id="p">Paragraphs and Line Breaks</h3>
185
186A paragraph is simply one or more consecutive lines of text, separated
187by one or more blank lines. (A blank line is any line that looks like a
188blank line -- a line containing nothing but spaces or tabs is considered
189blank.) Normal paragraphs should not be intended with spaces or tabs.
190
191The implication of the "one or more consecutive lines of text" rule is
192that Markdown supports "hard-wrapped" text paragraphs. This differs
193significantly from most other text-to-HTML formatters (including Movable
194Type's "Convert Line Breaks" option) which translate every line break
195character in a paragraph into a `<br />` tag.
196
197When you *do* want to insert a `<br />` break tag using Markdown, you
198end a line with two or more spaces, then type return.
199
200Yes, this takes a tad more effort to create a `<br />`, but a simplistic
201"every line break is a `<br />`" rule wouldn't work for Markdown.
202Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l]
203work best -- and look better -- when you format them with hard breaks.
204
205 [bq]: #blockquote
206 [l]: #list
207
208
209
210<h3 id="header">Headers</h3>
211
212Markdown supports two styles of headers, [Setext] [1] and [atx] [2].
213
214Setext-style headers are "underlined" using equal signs (for first-level
215headers) and dashes (for second-level headers). For example:
216
217 This is an H1
218 =============
219
220 This is an H2
221 -------------
222
223Any number of underlining `=`'s or `-`'s will work.
224
225Atx-style headers use 1-6 hash characters at the start of the line,
226corresponding to header levels 1-6. For example:
227
228 # This is an H1
229
230 ## This is an H2
231
232 ###### This is an H6
233
234Optionally, you may "close" atx-style headers. This is purely
235cosmetic -- you can use this if you think it looks better. The
236closing hashes don't even need to match the number of hashes
237used to open the header. (The number of opening hashes
238determines the header level.) :
239
240 # This is an H1 #
241
242 ## This is an H2 ##
243
244 ### This is an H3 ######
245
246
247<h3 id="blockquote">Blockquotes</h3>
248
249Markdown uses email-style `>` characters for blockquoting. If you're
250familiar with quoting passages of text in an email message, then you
251know how to create a blockquote in Markdown. It looks best if you hard
252wrap the text and put a `>` before every line:
253
254 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
255 > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
256 > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
257 >
258 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
259 > id sem consectetuer libero luctus adipiscing.
260
261Markdown allows you to be lazy and only put the `>` before the first
262line of a hard-wrapped paragraph:
263
264 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
265 consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
266 Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
267
268 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
269 id sem consectetuer libero luctus adipiscing.
270
271Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
272adding additional levels of `>`:
273
274 > This is the first level of quoting.
275 >
276 > > This is nested blockquote.
277 >
278 > Back to the first level.
279
280Blockquotes can contain other Markdown elements, including headers, lists,
281and code blocks:
282
283 > ## This is a header.
284 >
285 > 1. This is the first list item.
286 > 2. This is the second list item.
287 >
288 > Here's some example code:
289 >
290 > return shell_exec("echo $input | $markdown_script");
291
292Any decent text editor should make email-style quoting easy. For
293example, with BBEdit, you can make a selection and choose Increase
294Quote Level from the Text menu.
295
296
297<h3 id="list">Lists</h3>
298
299Markdown supports ordered (numbered) and unordered (bulleted) lists.
300
301Unordered lists use asterisks, pluses, and hyphens -- interchangably
302
303 * Red
304 * Green
305 * Blue
306
307is equivalent to:
308
309 + Red
310 + Green
311 + Blue
312
313and:
314
315 - Red
316 - Green
317 - Blue
318
319Ordered lists use numbers followed by periods:
320
321 1. Bird
322 2. McHale
323 3. Parish
324
325It's important to note that the actual numbers you use to mark the
326list have no effect on the HTML output Markdown produces. The HTML
327Markdown produces from the above list is:
328
329 <ol>
330 <li>Bird</li>
331 <li>McHale</li>
332 <li>Parish</li>
333 </ol>
334
335If you instead wrote the list in Markdown like this:
336
337 1. Bird
338 1. McHale
339 1. Parish
340
341or even:
342
343 3. Bird
344 1. McHale
345 8. Parish
346
347you'd get the exact same HTML output. The point is, if you want to,
348you can use ordinal numbers in your ordered Markdown lists, so that
349the numbers in your source match the numbers in your published HTML.
350But if you want to be lazy, you don't have to.
351
352If you do use lazy list numbering, however, you should still start the
353list with the number 1. At some point in the future, Markdown may support
354starting ordered lists at an arbitrary number.
355
356List markers typically start at the left margin, but may be indented by
357up to three spaces. List markers must be followed by one or more spaces
358or a tab.
359
360To make lists look nice, you can wrap items with hanging indents:
361
362 * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
363 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
364 viverra nec, fringilla in, laoreet vitae, risus.
365 * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
366 Suspendisse id sem consectetuer libero luctus adipiscing.
367
368But if you want to be lazy, you don't have to:
369
370 * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
371 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
372 viverra nec, fringilla in, laoreet vitae, risus.
373 * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
374 Suspendisse id sem consectetuer libero luctus adipiscing.
375
376If list items are separated by blank lines, Markdown will wrap the
377items in `<p>` tags in the HTML output. For example, this input:
378
379 * Bird
380 * Magic
381
382will turn into:
383
384 <ul>
385 <li>Bird</li>
386 <li>Magic</li>
387 </ul>
388
389But this:
390
391 * Bird
392
393 * Magic
394
395will turn into:
396
397 <ul>
398 <li><p>Bird</p></li>
399 <li><p>Magic</p></li>
400 </ul>
401
402List items may consist of multiple paragraphs. Each subsequent
403paragraph in a list item must be intended by either 4 spaces
404or one tab:
405
406 1. This is a list item with two paragraphs. Lorem ipsum dolor
407 sit amet, consectetuer adipiscing elit. Aliquam hendrerit
408 mi posuere lectus.
409
410 Vestibulum enim wisi, viverra nec, fringilla in, laoreet
411 vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
412 sit amet velit.
413
414 2. Suspendisse id sem consectetuer libero luctus adipiscing.
415
416It looks nice if you indent every line of the subsequent
417paragraphs, but here again, Markdown will allow you to be
418lazy:
419
420 * This is a list item with two paragraphs.
421
422 This is the second paragraph in the list item. You're
423 only required to indent the first line. Lorem ipsum dolor
424 sit amet, consectetuer adipiscing elit.
425
426 * Another item in the same list.
427
428To put a blockquote within a list item, the blockquote's `>`
429delimiters need to be indented:
430
431 * A list item with a blockquote:
432
433 > This is a blockquote
434 > inside a list item.
435
436To put a code block within a list item, the code block needs
437to be indented *twice* -- 8 spaces or two tabs:
438
439 * A list item with a code block:
440
441 <code goes here>
442
443
444It's worth noting that it's possible to trigger an ordered list by
445accident, by writing something like this:
446
447 1986. What a great season.
448
449In other words, a *number-period-space* sequence at the beginning of a
450line. To avoid this, you can backslash-escape the period:
451
452 1986\. What a great season.
453
454
455
456<h3 id="precode">Code Blocks</h3>
457
458Pre-formatted code blocks are used for writing about programming or
459markup source code. Rather than forming normal paragraphs, the lines
460of a code block are interpreted literally. Markdown wraps a code block
461in both `<pre>` and `<code>` tags.
462
463To produce a code block in Markdown, simply indent every line of the
464block by at least 4 spaces or 1 tab. For example, given this input:
465
466 This is a normal paragraph:
467
468 This is a code block.
469
470Markdown will generate:
471
472 <p>This is a normal paragraph:</p>
473
474 <pre><code>This is a code block.
475 </code></pre>
476
477One level of indentation -- 4 spaces or 1 tab -- is removed from each
478line of the code block. For example, this:
479
480 Here is an example of AppleScript:
481
482 tell application "Foo"
483 beep
484 end tell
485
486will turn into:
487
488 <p>Here is an example of AppleScript:</p>
489
490 <pre><code>tell application "Foo"
491 beep
492 end tell
493 </code></pre>
494
495A code block continues until it reaches a line that is not indented
496(or the end of the article).
497
498Within a code block, ampersands (`&`) and angle brackets (`<` and `>`)
499are automatically converted into HTML entities. This makes it very
500easy to include example HTML source code using Markdown -- just paste
501it and indent it, and Markdown will handle the hassle of encoding the
502ampersands and angle brackets. For example, this:
503
504 <div class="footer">
505 &copy; 2004 Foo Corporation
506 </div>
507
508will turn into:
509
510 <pre><code>&lt;div class="footer"&gt;
511 &amp;copy; 2004 Foo Corporation
512 &lt;/div&gt;
513 </code></pre>
514
515Regular Markdown syntax is not processed within code blocks. E.g.,
516asterisks are just literal asterisks within a code block. This means
517it's also easy to use Markdown to write about Markdown's own syntax.
518
519
520
521<h3 id="hr">Horizontal Rules</h3>
522
523You can produce a horizontal rule tag (`<hr />`) by placing three or
524more hyphens, asterisks, or underscores on a line by themselves. If you
525wish, you may use spaces between the hyphens or asterisks. Each of the
526following lines will produce a horizontal rule:
527
528 * * *
529
530 ***
531
532 *****
533
534 - - -
535
536 ---------------------------------------
537
538 _ _ _
539
540
541* * *
542
543<h2 id="span">Span Elements</h2>
544
545<h3 id="link">Links</h3>
546
547Markdown supports two style of links: *inline* and *reference*.
548
549In both styles, the link text is delimited by [square brackets].
550
551To create an inline link, use a set of regular parentheses immediately
552after the link text's closing square bracket. Inside the parentheses,
553put the URL where you want the link to point, along with an *optional*
554title for the link, surrounded in quotes. For example:
555
556 This is [an example](http://example.com/ "Title") inline link.
557
558 [This link](http://example.net/) has no title attribute.
559
560Will produce:
561
562 <p>This is <a href="http://example.com/" title="Title">
563 an example</a> inline link.</p>
564
565 <p><a href="http://example.net/">This link</a> has no
566 title attribute.</p>
567
568If you're referring to a local resource on the same server, you can
569use relative paths:
570
571 See my [About](/about/) page for details.
572
573Reference-style links use a second set of square brackets, inside
574which you place a label of your choosing to identify the link:
575
576 This is [an example][id] reference-style link.
577
578You can optionally use a space to separate the sets of brackets:
579
580 This is [an example] [id] reference-style link.
581
582Then, anywhere in the document, you define your link label like this,
583on a line by itself:
584
585 [id]: http://example.com/ "Optional Title Here"
586
587That is:
588
589* Square brackets containing the link identifier (optionally
590 indented from the left margin using up to three spaces);
591* followed by a colon;
592* followed by one or more spaces (or tabs);
593* followed by the URL for the link;
594* optionally followed by a title attribute for the link, enclosed
595 in double or single quotes.
596
597The link URL may, optionally, be surrounded by angle brackets:
598
599 [id]: <http://example.com/> "Optional Title Here"
600
601You can put the title attribute on the next line and use extra spaces
602or tabs for padding, which tends to look better with longer URLs:
603
604 [id]: http://example.com/longish/path/to/resource/here
605 "Optional Title Here"
606
607Link definitions are only used for creating links during Markdown
608processing, and are stripped from your document in the HTML output.
609
610Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are *not* case sensitive. E.g. these two links:
611
612 [link text][a]
613 [link text][A]
614
615are equivalent.
616
617The *implicit link name* shortcut allows you to omit the name of the
618link, in which case the link text itself is used as the name.
619Just use an empty set of square brackets -- e.g., to link the word
620"Google" to the google.com web site, you could simply write:
621
622 [Google][]
623
624And then define the link:
625
626 [Google]: http://google.com/
627
628Because link names may contain spaces, this shortcut even works for
629multiple words in the link text:
630
631 Visit [Daring Fireball][] for more information.
632
633And then define the link:
634
635 [Daring Fireball]: http://daringfireball.net/
636
637Link definitions can be placed anywhere in your Markdown document. I
638tend to put them immediately after each paragraph in which they're
639used, but if you want, you can put them all at the end of your
640document, sort of like footnotes.
641
642Here's an example of reference links in action:
643
644 I get 10 times more traffic from [Google] [1] than from
645 [Yahoo] [2] or [MSN] [3].
646
647 [1]: http://google.com/ "Google"
648 [2]: http://search.yahoo.com/ "Yahoo Search"
649 [3]: http://search.msn.com/ "MSN Search"
650
651Using the implicit link name shortcut, you could instead write:
652
653 I get 10 times more traffic from [Google][] than from
654 [Yahoo][] or [MSN][].
655
656 [google]: http://google.com/ "Google"
657 [yahoo]: http://search.yahoo.com/ "Yahoo Search"
658 [msn]: http://search.msn.com/ "MSN Search"
659
660Both of the above examples will produce the following HTML output:
661
662 <p>I get 10 times more traffic from <a href="http://google.com/"
663 title="Google">Google</a> than from
664 <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
665 or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
666
667For comparison, here is the same paragraph written using
668Markdown's inline link style:
669
670 I get 10 times more traffic from [Google](http://google.com/ "Google")
671 than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
672 [MSN](http://search.msn.com/ "MSN Search").
673
674The point of reference-style links is not that they're easier to
675write. The point is that with reference-style links, your document
676source is vastly more readable. Compare the above examples: using
677reference-style links, the paragraph itself is only 81 characters
678long; with inline-style links, it's 176 characters; and as raw HTML,
679it's 234 characters. In the raw HTML, there's more markup than there
680is text.
681
682With Markdown's reference-style links, a source document much more
683closely resembles the final output, as rendered in a browser. By
684allowing you to move the markup-related metadata out of the paragraph,
685you can add links without interrupting the narrative flow of your
686prose.
687
688
689<h3 id="em">Emphasis</h3>
690
691Markdown treats asterisks (`*`) and underscores (`_`) as indicators of
692emphasis. Text wrapped with one `*` or `_` will be wrapped with an
693HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML
694`<strong>` tag. E.g., this input:
695
696 *single asterisks*
697
698 _single underscores_
699
700 **double asterisks**
701
702 __double underscores__
703
704will produce:
705
706 <em>single asterisks</em>
707
708 <em>single underscores</em>
709
710 <strong>double asterisks</strong>
711
712 <strong>double underscores</strong>
713
714You can use whichever style you prefer; the lone restriction is that
715the same character must be used to open and close an emphasis span.
716
717Emphasis can be used in the middle of a word:
718
719 un*fucking*believable
720
721But if you surround an `*` or `_` with spaces, it'll be treated as a
722literal asterisk or underscore.
723
724To produce a literal asterisk or underscore at a position where it
725would otherwise be used as an emphasis delimiter, you can backslash
726escape it:
727
728 \*this text is surrounded by literal asterisks\*
729
730
731
732<h3 id="code">Code</h3>
733
734To indicate a span of code, wrap it with backtick quotes (`` ` ``).
735Unlike a pre-formatted code block, a code span indicates code within a
736normal paragraph. For example:
737
738 Use the `printf()` function.
739
740will produce:
741
742 <p>Use the <code>printf()</code> function.</p>
743
744To include a literal backtick character within a code span, you can use
745multiple backticks as the opening and closing delimiters:
746
747 ``There is a literal backtick (`) here.``
748
749which will produce this:
750
751 <p><code>There is a literal backtick (`) here.</code></p>
752
753The backtick delimiters surrounding a code span may include spaces --
754one after the opening, one before the closing. This allows you to place
755literal backtick characters at the beginning or end of a code span:
756
757 A single backtick in a code span: `` ` ``
758
759 A backtick-delimited string in a code span: `` `foo` ``
760
761will produce:
762
763 <p>A single backtick in a code span: <code>`</code></p>
764
765 <p>A backtick-delimited string in a code span: <code>`foo`</code></p>
766
767With a code span, ampersands and angle brackets are encoded as HTML
768entities automatically, which makes it easy to include example HTML
769tags. Markdown will turn this:
770
771 Please don't use any `<blink>` tags.
772
773into:
774
775 <p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>
776
777You can write this:
778
779 `&#8212;` is the decimal-encoded equivalent of `&mdash;`.
780
781to produce:
782
783 <p><code>&amp;#8212;</code> is the decimal-encoded
784 equivalent of <code>&amp;mdash;</code>.</p>
785
786
787
788<h3 id="img">Images</h3>
789
790Admittedly, it's fairly difficult to devise a "natural" syntax for
791placing images into a plain text document format.
792
793Markdown uses an image syntax that is intended to resemble the syntax
794for links, allowing for two styles: *inline* and *reference*.
795
796Inline image syntax looks like this:
797
798 ![Alt text](/path/to/img.jpg)
799
800 ![Alt text](/path/to/img.jpg "Optional title")
801
802That is:
803
804* An exclamation mark: `!`;
805* followed by a set of square brackets, containing the `alt`
806 attribute text for the image;
807* followed by a set of parentheses, containing the URL or path to
808 the image, and an optional `title` attribute enclosed in double
809 or single quotes.
810
811Reference-style image syntax looks like this:
812
813 ![Alt text][id]
814
815Where "id" is the name of a defined image reference. Image references
816are defined using syntax identical to link references:
817
818 [id]: url/to/image "Optional title attribute"
819
820As of this writing, Markdown has no syntax for specifying the
821dimensions of an image; if this is important to you, you can simply
822use regular HTML `<img>` tags.
823
824
825* * *
826
827
828<h2 id="misc">Miscellaneous</h2>
829
830<h3 id="autolink">Automatic Links</h3>
831
832Markdown 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:
833
834 <http://example.com/>
835
836Markdown will turn this into:
837
838 <a href="http://example.com/">http://example.com/</a>
839
840Automatic links for email addresses work similarly, except that
841Markdown will also perform a bit of randomized decimal and hex
842entity-encoding to help obscure your address from address-harvesting
843spambots. For example, Markdown will turn this:
844
845 <address@example.com>
846
847into something like this:
848
849 <a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;
850 &#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;
851 &#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
852 &#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
853
854which will render in a browser as a clickable link to "address@example.com".
855
856(This sort of entity-encoding trick will indeed fool many, if not
857most, address-harvesting bots, but it definitely won't fool all of
858them. It's better than nothing, but an address published in this way
859will probably eventually start receiving spam.)
860
861
862
863<h3 id="backslash">Backslash Escapes</h3>
864
865Markdown allows you to use backslash escapes to generate literal
866characters which would otherwise have special meaning in Markdown's
867formatting syntax. For example, if you wanted to surround a word with
868literal asterisks (instead of an HTML `<em>` tag), you can backslashes
869before the asterisks, like this:
870
871 \*literal asterisks\*
872
873Markdown provides backslash escapes for the following characters:
874
875 \ backslash
876 ` backtick
877 * asterisk
878 _ underscore
879 {} curly braces
880 [] square brackets
881 () parentheses
882 # hash mark
883 + plus sign
884 - minus sign (hyphen)
885 . dot
886 ! exclamation mark
  
1<blockquote>
2<p>foo</p>
3<blockquote>
4<p>bar</p>
5</blockquote>
6<p>foo</p>
7</blockquote>
  
1> foo
2>
3> > bar
4>
5> foo
  
1<h2>Unordered</h2>
2<p>Asterisks tight:</p>
3<ul>
4<li>asterisk 1</li>
5<li>asterisk 2</li>
6<li>asterisk 3</li>
7</ul>
8<p>Asterisks loose:</p>
9<ul>
10<li>
11<p>asterisk 1</p>
12</li>
13<li>
14<p>asterisk 2</p>
15</li>
16<li>
17<p>asterisk 3</p>
18</li>
19</ul>
20<hr />
21<p>Pluses tight:</p>
22<ul>
23<li>Plus 1</li>
24<li>Plus 2</li>
25<li>Plus 3</li>
26</ul>
27<p>Pluses loose:</p>
28<ul>
29<li>
30<p>Plus 1</p>
31</li>
32<li>
33<p>Plus 2</p>
34</li>
35<li>
36<p>Plus 3</p>
37</li>
38</ul>
39<hr />
40<p>Minuses tight:</p>
41<ul>
42<li>Minus 1</li>
43<li>Minus 2</li>
44<li>Minus 3</li>
45</ul>
46<p>Minuses loose:</p>
47<ul>
48<li>
49<p>Minus 1</p>
50</li>
51<li>
52<p>Minus 2</p>
53</li>
54<li>
55<p>Minus 3</p>
56</li>
57</ul>
58<h2>Ordered</h2>
59<p>Tight:</p>
60<ol>
61<li>First</li>
62<li>Second</li>
63<li>Third</li>
64</ol>
65<p>and:</p>
66<ol>
67<li>One</li>
68<li>Two</li>
69<li>Three</li>
70</ol>
71<p>Loose using tabs:</p>
72<ol>
73<li>
74<p>First</p>
75</li>
76<li>
77<p>Second</p>
78</li>
79<li>
80<p>Third</p>
81</li>
82</ol>
83<p>and using spaces:</p>
84<ol>
85<li>
86<p>One</p>
87</li>
88<li>
89<p>Two</p>
90</li>
91<li>
92<p>Three</p>
93</li>
94</ol>
95<p>Multiple paragraphs:</p>
96<ol>
97<li>
98<p>Item 1, graf one.</p>
99<p>Item 2. graf two. The quick brown fox jumped over the lazy dog's
100back.</p>
101</li>
102<li>
103<p>Item 2.</p>
104</li>
105<li>
106<p>Item 3.</p>
107</li>
108</ol>
109<h2>Nested</h2>
110<ul>
111<li>Tab<ul>
112<li>Tab<ul>
113<li>Tab</li>
114</ul>
115</li>
116</ul>
117</li>
118</ul>
119<p>Here's another:</p>
120<ol>
121<li>First</li>
122<li>Second:<ul>
123<li>Fee</li>
124<li>Fie</li>
125<li>Foe</li>
126</ul>
127</li>
128<li>Third</li>
129</ol>
130<p>Same thing but with paragraphs:</p>
131<ol>
132<li>
133<p>First</p>
134</li>
135<li>
136<p>Second:</p>
137<ul>
138<li>Fee</li>
139<li>Fie</li>
140<li>Foe</li>
141</ul>
142</li>
143<li>
144<p>Third</p>
145</li>
146</ol>
  
1## Unordered
2
3Asterisks tight:
4
5* asterisk 1
6* asterisk 2
7* asterisk 3
8
9
10Asterisks loose:
11
12* asterisk 1
13
14* asterisk 2
15
16* asterisk 3
17
18* * *
19
20Pluses tight:
21
22+ Plus 1
23+ Plus 2
24+ Plus 3
25
26
27Pluses loose:
28
29+ Plus 1
30
31+ Plus 2
32
33+ Plus 3
34
35* * *
36
37
38Minuses tight:
39
40- Minus 1
41- Minus 2
42- Minus 3
43
44
45Minuses loose:
46
47- Minus 1
48
49- Minus 2
50
51- Minus 3
52
53
54## Ordered
55
56Tight:
57
581. First
592. Second
603. Third
61
62and:
63
641. One
652. Two
663. Three
67
68
69Loose using tabs:
70
711. First
72
732. Second
74
753. Third
76
77and using spaces:
78
791. One
80
812. Two
82
833. Three
84
85Multiple paragraphs:
86
871. Item 1, graf one.
88
89 Item 2. graf two. The quick brown fox jumped over the lazy dog's
90 back.
91
922. Item 2.
93
943. Item 3.
95
96
97
98## Nested
99
100* Tab
101 * Tab
102 * Tab
103
104Here's another:
105
1061. First
1072. Second:
108 * Fee
109 * Fie
110 * Foe
1113. Third
112
113Same thing but with paragraphs:
114
1151. First
116
1172. Second:
118 * Fee
119 * Fie
120 * Foe
121
1223. Third
  
1<p><strong><em>This is strong and em.</em></strong></p>
2<p>So is <strong><em>this</em></strong> word.</p>
3<p><strong><em>This is strong and em.</em></strong></p>
4<p>So is <strong><em>this</em></strong> word.</p>
  
1***This is strong and em.***
2
3So is ***this*** word.
4
5___This is strong and em.___
6
7So is ___this___ word.
  
1<ul>
2<li>
3<p>this is a list item
4 indented with tabs</p>
5</li>
6<li>
7<p>this is a list item
8 indented with spaces</p>
9</li>
10</ul>
11<p>Code:</p>
12<pre><code>this code block is indented by one tab
13</code></pre>
14<p>And:</p>
15<pre><code> this code block is indented by two tabs
16</code></pre>
17<p>And:</p>
18<pre><code>+ this is an example list item
19 indented with tabs
20
21+ this is an example list item
22 indented with spaces
23</code></pre>
  
1+ this is a list item
2 indented with tabs
3
4+ this is a list item
5 indented with spaces
6
7Code:
8
9 this code block is indented by one tab
10
11And:
12
13 this code block is indented by two tabs
14
15And:
16
17 + this is an example list item
18 indented with tabs
19
20 + this is an example list item
21 indented with spaces
  
1<blockquote>
2<p>A list within a blockquote:</p>
3<ul>
4<li>asterisk 1</li>
5<li>asterisk 2</li>
6<li>asterisk 3</li>
7</ul>
8</blockquote>
  
1> A list within a blockquote:
2>
3> * asterisk 1
4> * asterisk 2
5> * asterisk 3
  
1<p>Some text</p>
2<table class="codehilitetable"><tr><td class="linenos"><pre>1
32
43
54
65
76</pre></td><td class="code"><div class="codehilite"><pre><span class="k">def</span> <span class="nf">__init__</span> <span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">pattern</span><span class="p">)</span> <span class="p">:</span>
8 <span class="bp">self</span><span class="o">.</span><span class="n">pattern</span> <span class="o">=</span> <span class="n">pattern</span>
9 <span class="bp">self</span><span class="o">.</span><span class="n">compiled_re</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s">&quot;^(.*)</span><span class="si">%s</span><span class="s">(.*)$&quot;</span> <span class="o">%</span> <span class="n">pattern</span><span class="p">,</span> <span class="n">re</span><span class="o">.</span><span class="n">DOTALL</span><span class="p">)</span>
10
11<span class="k">def</span> <span class="nf">getCompiledRegExp</span> <span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="p">:</span>
12 <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">compiled_re</span>
13</pre></div>
14</td></tr></table>
15
16<p>More text</p>
  
1
2Some text
3
4 #!python
5 def __init__ (self, pattern) :
6 self.pattern = pattern
7 self.compiled_re = re.compile("^(.*)%s(.*)$" % pattern, re.DOTALL)
8
9 def getCompiledRegExp (self) :
10 return self.compiled_re
11
12More text
  
1<p>An <abbr title="Abbreviation">ABBR</abbr>: "<abbr title="Reference">REF</abbr>".
2ref and REFERENCE should be ignored.</p>
3<p>The <abbr title="Hyper Text Markup Language">HTML</abbr> specification
4is maintained by the <abbr title="World Wide Web Consortium">W3C</abbr>.</p>
  
1An ABBR: "REF".
2ref and REFERENCE should be ignored.
3
4*[REF]: Reference
5*[ABBR]: This gets overriden by the next one.
6*[ABBR]: Abbreviation
7
8The HTML specification
9is maintained by the W3C.
10
11*[HTML]: Hyper Text Markup Language
12*[W3C]: World Wide Web Consortium
  
1<p>This is the body with a footnote<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> or two<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup> or more<sup id="fnref:3"><a href="#fn:3" rel="footnote">3</a></sup> <sup id="fnref:4"><a href="#fn:4" rel="footnote">4</a></sup>.</p>
2<div class="footnote">
3<hr />
4<ol>
5<li id="fn:1">
6<p>Footnote that ends with a list:</p>
7<ul>
8<li>item 1</li>
9<li>item 2</li>
10</ul>
11<p><a href="#fnref:1" rev="footnote" title="Jump back to footnote 1 in the text">&#8617;</a></p>
12</li>
13<li id="fn:2">
14<blockquote>
15<p>This footnote is a blockquote.
16</p>
17</blockquote>
18<p><a href="#fnref:2" rev="footnote" title="Jump back to footnote 2 in the text">&#8617;</a></p>
19</li>
20<li id="fn:3">
21<p>A simple oneliner.
22&#160;<a href="#fnref:3" rev="footnote" title="Jump back to footnote 3 in the text">&#8617;</a></p>
23</li>
24<li id="fn:4">
25<p>A footnote with multiple paragraphs.</p>
26<p>Paragraph two.&#160;<a href="#fnref:4" rev="footnote" title="Jump back to footnote 4 in the text">&#8617;</a></p>
27</li>
28</ol>
29</div>
  
1This is the body with a footnote[^1] or two[^2] or more[^3] [^4].
2
3[^1]: Footnote that ends with a list:
4
5 * item 1
6 * item 2
7
8[^2]: > This footnote is a blockquote.
9
10[^3]: A simple oneliner.
11
12[^4]: A footnote with multiple paragraphs.
13
14 Paragraph two.
  
1<p>some text</p>
2<dl>
3<dt>term 1</dt>
4<dd>
5<p>def 1-1</p>
6</dd>
7<dd>
8<p>def 2-2</p>
9</dd>
10<dt>term 2</dt>
11<dt>term 3</dt>
12<dd>
13<p>def 2-1
14line 2 of def 2-1</p>
15</dd>
16<dd>
17<p>def 2-2</p>
18<p>par 2 of def2-2</p>
19</dd>
20</dl>
21<p>more text</p>
  
1some text
2
3term 1
4
5: def 1-1
6
7: def 2-2
8
9term 2
10term 3
11
12: def 2-1
13 line 2 of def 2-1
14
15: def 2-2
16
17 par 2 of def2-2
18
19more text
  
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
40can <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
48document should be publishable as-is, as plain text, without looking
49like it's been marked up with tags or formatting instructions. While
50Markdown's syntax has been influenced by several existing text-to-HTML
51filters -- 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
53inspiration 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
55characters, which punctuation characters have been carefully chosen so
56as to look like what they mean. E.g., asterisks around a word actually
57look like *emphasis*. Markdown lists look like, well, lists. Even
58blockquotes look like quoted passages of text, assuming you've ever
59used 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
63format for <em>writing</em> for the web.</p>
64<p>Markdown is not a replacement for HTML, or even close to it. Its
65syntax is very small, corresponding only to a very small subset of
66HTML tags. The idea is <em>not</em> to create a syntax that makes it easier
67to insert HTML tags. In my opinion, HTML tags are already easy to
68insert. The idea for Markdown is to make it easy to read, write, and
69edit prose. HTML is a <em>publishing</em> format; Markdown is a <em>writing</em>
70format. Thus, Markdown's formatting syntax only addresses issues that
71can be conveyed in plain text.</p>
72<p>For any markup that is not covered by Markdown's syntax, you simply
73use HTML itself. There's no need to preface it or delimit it to
74indicate that you're switching from Markdown to HTML; you just use
75the 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
78content by blank lines, and the start and end tags of the block should
79not be indented with tabs or spaces. Markdown is smart enough not
80to 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
90This is another regular paragraph.
91</code></pre>
92<p>Note that Markdown formatting syntax is not processed within block-level
93HTML tags. E.g., you can't use Markdown-style <code>*emphasis*</code> inside an
94HTML 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
96used anywhere in a Markdown paragraph, list item, or header. If you
97want, you can even use HTML tags instead of Markdown formatting; e.g. if
98you'd prefer to use HTML <code>&lt;a&gt;</code> or <code>&lt;img&gt;</code> tags instead of Markdown's
99link or image syntax, go right ahead.</p>
100<p>Unlike block-level HTML tags, Markdown syntax <em>is</em> processed within
101span-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>
105and <code>&amp;</code>. Left angle brackets are used to start tags; ampersands are
106used to denote HTML entities. If you want to use them as literal
107characters, 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
110write about 'AT&amp;T', you need to write '<code>AT&amp;amp;T</code>'. You even need to
111escape 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
118forget, and is probably the single most common source of HTML validation
119errors in otherwise well-marked-up web sites.</p>
120<p>Markdown allows you to use these characters naturally, taking care of
121all the necessary escaping for you. If you use an ampersand as part of
122an HTML entity, it remains unchanged; otherwise it will be translated
123into <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
134angle brackets as delimiters for HTML tags, Markdown will treat them as
135such. 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
142ampersands are <em>always</em> encoded automatically. This makes it easy to use
143Markdown to write about HTML code. (As opposed to raw HTML, which is a
144terrible format for writing about HTML syntax, because every single <code>&lt;</code>
145and <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
152by one or more blank lines. (A blank line is any line that looks like a
153blank line -- a line containing nothing but spaces or tabs is considered
154blank.) 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
156that Markdown supports "hard-wrapped" text paragraphs. This differs
157significantly from most other text-to-HTML formatters (including Movable
158Type's "Convert Line Breaks" option) which translate every line break
159character 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
161end 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.
164Markdown's email-style <a href="#blockquote">blockquoting</a> and multi-paragraph <a href="#list">list items</a>
165work 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
170headers) and dashes (for second-level headers). For example:</p>
171<pre><code>This is an H1
172=============
173
174This 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,
179corresponding 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
187cosmetic -- you can use this if you think it looks better. The
188closing hashes don't even need to match the number of hashes
189used to open the header. (The number of opening hashes
190determines 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
200familiar with quoting passages of text in an email message, then you
201know how to create a blockquote in Markdown. It looks best if you hard
202wrap 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
211line of a hard-wrapped paragraph:</p>
212<pre><code>&gt; This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
213consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
214Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
215
216&gt; Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
217id sem consectetuer libero luctus adipiscing.
218</code></pre>
219<p>Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
220adding 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,
228and 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
239example, with BBEdit, you can make a selection and choose Increase
240Quote 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<pre><code>* Red
246* Green
247* Blue
248</code></pre>
249<p>is equivalent to:</p>
250<pre><code>+ Red
251+ Green
252+ Blue
253</code></pre>
254<p>and:</p>
255<pre><code>- Red
256- Green
257- Blue
258</code></pre>
259<p>Ordered lists use numbers followed by periods:</p>
260<pre><code>1. Bird
2612. McHale
2623. Parish
263</code></pre>
264<p>It's important to note that the actual numbers you use to mark the
265list have no effect on the HTML output Markdown produces. The HTML
266Markdown produces from the above list is:</p>
267<pre><code>&lt;ol&gt;
268&lt;li&gt;Bird&lt;/li&gt;
269&lt;li&gt;McHale&lt;/li&gt;
270&lt;li&gt;Parish&lt;/li&gt;
271&lt;/ol&gt;
272</code></pre>
273<p>If you instead wrote the list in Markdown like this:</p>
274<pre><code>1. Bird
2751. McHale
2761. Parish
277</code></pre>
278<p>or even:</p>
279<pre><code>3. Bird
2801. McHale
2818. Parish
282</code></pre>
283<p>you'd get the exact same HTML output. The point is, if you want to,
284you can use ordinal numbers in your ordered Markdown lists, so that
285the numbers in your source match the numbers in your published HTML.
286But if you want to be lazy, you don't have to.</p>
287<p>If you do use lazy list numbering, however, you should still start the
288list with the number 1. At some point in the future, Markdown may support
289starting ordered lists at an arbitrary number.</p>
290<p>List markers typically start at the left margin, but may be indented by
291up to three spaces. List markers must be followed by one or more spaces
292or a tab.</p>
293<p>To make lists look nice, you can wrap items with hanging indents:</p>
294<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
295 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
296 viverra nec, fringilla in, laoreet vitae, risus.
297* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
298 Suspendisse id sem consectetuer libero luctus adipiscing.
299</code></pre>
300<p>But if you want to be lazy, you don't have to:</p>
301<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
302Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
303viverra nec, fringilla in, laoreet vitae, risus.
304* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
305Suspendisse id sem consectetuer libero luctus adipiscing.
306</code></pre>
307<p>If list items are separated by blank lines, Markdown will wrap the
308items in <code>&lt;p&gt;</code> tags in the HTML output. For example, this input:</p>
309<pre><code>* Bird
310* Magic
311</code></pre>
312<p>will turn into:</p>
313<pre><code>&lt;ul&gt;
314&lt;li&gt;Bird&lt;/li&gt;
315&lt;li&gt;Magic&lt;/li&gt;
316&lt;/ul&gt;
317</code></pre>
318<p>But this:</p>
319<pre><code>* Bird
320
321* Magic
322</code></pre>
323<p>will turn into:</p>
324<pre><code>&lt;ul&gt;
325&lt;li&gt;&lt;p&gt;Bird&lt;/p&gt;&lt;/li&gt;
326&lt;li&gt;&lt;p&gt;Magic&lt;/p&gt;&lt;/li&gt;
327&lt;/ul&gt;
328</code></pre>
329<p>List items may consist of multiple paragraphs. Each subsequent
330paragraph in a list item must be intended by either 4 spaces
331or one tab:</p>
332<pre><code>1. This is a list item with two paragraphs. Lorem ipsum dolor
333 sit amet, consectetuer adipiscing elit. Aliquam hendrerit
334 mi posuere lectus.
335
336 Vestibulum enim wisi, viverra nec, fringilla in, laoreet
337 vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
338 sit amet velit.
339
3402. Suspendisse id sem consectetuer libero luctus adipiscing.
341</code></pre>
342<p>It looks nice if you indent every line of the subsequent
343paragraphs, but here again, Markdown will allow you to be
344lazy:</p>
345<pre><code>* This is a list item with two paragraphs.
346
347 This is the second paragraph in the list item. You're
348only required to indent the first line. Lorem ipsum dolor
349sit amet, consectetuer adipiscing elit.
350
351* Another item in the same list.
352</code></pre>
353<p>To put a blockquote within a list item, the blockquote's <code>&gt;</code>
354delimiters need to be indented:</p>
355<pre><code>* A list item with a blockquote:
356
357 &gt; This is a blockquote
358 &gt; inside a list item.
359</code></pre>
360<p>To put a code block within a list item, the code block needs
361to be indented <em>twice</em> -- 8 spaces or two tabs:</p>
362<pre><code>* A list item with a code block:
363
364 &lt;code goes here&gt;
365</code></pre>
366<p>It's worth noting that it's possible to trigger an ordered list by
367accident, by writing something like this:</p>
368<pre><code>1986. What a great season.
369</code></pre>
370<p>In other words, a <em>number-period-space</em> sequence at the beginning of a
371line. To avoid this, you can backslash-escape the period:</p>
372<pre><code>1986\. What a great season.
373</code></pre>
374<h3 id="precode">Code Blocks</h3>
375
376<p>Pre-formatted code blocks are used for writing about programming or
377markup source code. Rather than forming normal paragraphs, the lines
378of a code block are interpreted literally. Markdown wraps a code block
379in both <code>&lt;pre&gt;</code> and <code>&lt;code&gt;</code> tags.</p>
380<p>To produce a code block in Markdown, simply indent every line of the
381block by at least 4 spaces or 1 tab. For example, given this input:</p>
382<pre><code>This is a normal paragraph:
383
384 This is a code block.
385</code></pre>
386<p>Markdown will generate:</p>
387<pre><code>&lt;p&gt;This is a normal paragraph:&lt;/p&gt;
388
389&lt;pre&gt;&lt;code&gt;This is a code block.
390&lt;/code&gt;&lt;/pre&gt;
391</code></pre>
392<p>One level of indentation -- 4 spaces or 1 tab -- is removed from each
393line of the code block. For example, this:</p>
394<pre><code>Here is an example of AppleScript:
395
396 tell application "Foo"
397 beep
398 end tell
399</code></pre>
400<p>will turn into:</p>
401<pre><code>&lt;p&gt;Here is an example of AppleScript:&lt;/p&gt;
402
403&lt;pre&gt;&lt;code&gt;tell application "Foo"
404 beep
405end tell
406&lt;/code&gt;&lt;/pre&gt;
407</code></pre>
408<p>A code block continues until it reaches a line that is not indented
409(or the end of the article).</p>
410<p>Within a code block, ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> and <code>&gt;</code>)
411are automatically converted into HTML entities. This makes it very
412easy to include example HTML source code using Markdown -- just paste
413it and indent it, and Markdown will handle the hassle of encoding the
414ampersands and angle brackets. For example, this:</p>
415<pre><code> &lt;div class="footer"&gt;
416 &amp;copy; 2004 Foo Corporation
417 &lt;/div&gt;
418</code></pre>
419<p>will turn into:</p>
420<pre><code>&lt;pre&gt;&lt;code&gt;&amp;lt;div class="footer"&amp;gt;
421 &amp;amp;copy; 2004 Foo Corporation
422&amp;lt;/div&amp;gt;
423&lt;/code&gt;&lt;/pre&gt;
424</code></pre>
425<p>Regular Markdown syntax is not processed within code blocks. E.g.,
426asterisks are just literal asterisks within a code block. This means
427it's also easy to use Markdown to write about Markdown's own syntax.</p>
428<h3 id="hr">Horizontal Rules</h3>
429
430<p>You can produce a horizontal rule tag (<code>&lt;hr /&gt;</code>) by placing three or
431more hyphens, asterisks, or underscores on a line by themselves. If you
432wish, you may use spaces between the hyphens or asterisks. Each of the
433following lines will produce a horizontal rule:</p>
434<pre><code>* * *
435
436***
437
438*****
439
440- - -
441
442---------------------------------------
443
444_ _ _
445</code></pre>
446<hr />
447<h2 id="span">Span Elements</h2>
448
449<h3 id="link">Links</h3>
450
451<p>Markdown supports two style of links: <em>inline</em> and <em>reference</em>.</p>
452<p>In both styles, the link text is delimited by [square brackets].</p>
453<p>To create an inline link, use a set of regular parentheses immediately
454after the link text's closing square bracket. Inside the parentheses,
455put the URL where you want the link to point, along with an <em>optional</em>
456title for the link, surrounded in quotes. For example:</p>
457<pre><code>This is [an example](http://example.com/ "Title") inline link.
458
459[This link](http://example.net/) has no title attribute.
460</code></pre>
461<p>Will produce:</p>
462<pre><code>&lt;p&gt;This is &lt;a href="http://example.com/" title="Title"&gt;
463an example&lt;/a&gt; inline link.&lt;/p&gt;
464
465&lt;p&gt;&lt;a href="http://example.net/"&gt;This link&lt;/a&gt; has no
466title attribute.&lt;/p&gt;
467</code></pre>
468<p>If you're referring to a local resource on the same server, you can
469use relative paths:</p>
470<pre><code>See my [About](/about/) page for details.
471</code></pre>
472<p>Reference-style links use a second set of square brackets, inside
473which you place a label of your choosing to identify the link:</p>
474<pre><code>This is [an example][id] reference-style link.
475</code></pre>
476<p>You can optionally use a space to separate the sets of brackets:</p>
477<pre><code>This is [an example] [id] reference-style link.
478</code></pre>
479<p>Then, anywhere in the document, you define your link label like this,
480on a line by itself:</p>
481<pre><code>[id]: http://example.com/ "Optional Title Here"
482</code></pre>
483<p>That is:</p>
484<ul>
485<li>Square brackets containing the link identifier (optionally
486 indented from the left margin using up to three spaces);</li>
487<li>followed by a colon;</li>
488<li>followed by one or more spaces (or tabs);</li>
489<li>followed by the URL for the link;</li>
490<li>optionally followed by a title attribute for the link, enclosed
491 in double or single quotes.</li>
492</ul>
493<p>The link URL may, optionally, be surrounded by angle brackets:</p>
494<pre><code>[id]: &lt;http://example.com/&gt; "Optional Title Here"
495</code></pre>
496<p>You can put the title attribute on the next line and use extra spaces
497or tabs for padding, which tends to look better with longer URLs:</p>
498<pre><code>[id]: http://example.com/longish/path/to/resource/here
499 "Optional Title Here"
500</code></pre>
501<p>Link definitions are only used for creating links during Markdown
502processing, and are stripped from your document in the HTML output.</p>
503<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>
504<pre><code>[link text][a]
505[link text][A]
506</code></pre>
507<p>are equivalent.</p>
508<p>The <em>implicit link name</em> shortcut allows you to omit the name of the
509link, in which case the link text itself is used as the name.
510Just use an empty set of square brackets -- e.g., to link the word
511"Google" to the google.com web site, you could simply write:</p>
512<pre><code>[Google][]
513</code></pre>
514<p>And then define the link:</p>
515<pre><code>[Google]: http://google.com/
516</code></pre>
517<p>Because link names may contain spaces, this shortcut even works for
518multiple words in the link text:</p>
519<pre><code>Visit [Daring Fireball][] for more information.
520</code></pre>
521<p>And then define the link:</p>
522<pre><code>[Daring Fireball]: http://daringfireball.net/
523</code></pre>
524<p>Link definitions can be placed anywhere in your Markdown document. I
525tend to put them immediately after each paragraph in which they're
526used, but if you want, you can put them all at the end of your
527document, sort of like footnotes.</p>
528<p>Here's an example of reference links in action:</p>
529<pre><code>I get 10 times more traffic from [Google] [1] than from
530[Yahoo] [2] or [MSN] [3].
531
532 [1]: http://google.com/ "Google"
533 [2]: http://search.yahoo.com/ "Yahoo Search"
534 [3]: http://search.msn.com/ "MSN Search"
535</code></pre>
536<p>Using the implicit link name shortcut, you could instead write:</p>
537<pre><code>I get 10 times more traffic from [Google][] than from
538[Yahoo][] or [MSN][].
539
540 [google]: http://google.com/ "Google"
541 [yahoo]: http://search.yahoo.com/ "Yahoo Search"
542 [msn]: http://search.msn.com/ "MSN Search"
543</code></pre>
544<p>Both of the above examples will produce the following HTML output:</p>
545<pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
546title="Google"&gt;Google&lt;/a&gt; than from
547&lt;a href="http://search.yahoo.com/" title="Yahoo Search"&gt;Yahoo&lt;/a&gt;
548or &lt;a href="http://search.msn.com/" title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
549</code></pre>
550<p>For comparison, here is the same paragraph written using
551Markdown's inline link style:</p>
552<pre><code>I get 10 times more traffic from [Google](http://google.com/ "Google")
553than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
554[MSN](http://search.msn.com/ "MSN Search").
555</code></pre>
556<p>The point of reference-style links is not that they're easier to
557write. The point is that with reference-style links, your document
558source is vastly more readable. Compare the above examples: using
559reference-style links, the paragraph itself is only 81 characters
560long; with inline-style links, it's 176 characters; and as raw HTML,
561it's 234 characters. In the raw HTML, there's more markup than there
562is text.</p>
563<p>With Markdown's reference-style links, a source document much more
564closely resembles the final output, as rendered in a browser. By
565allowing you to move the markup-related metadata out of the paragraph,
566you can add links without interrupting the narrative flow of your
567prose.</p>
568<h3 id="em">Emphasis</h3>
569
570<p>Markdown treats asterisks (<code>*</code>) and underscores (<code>_</code>) as indicators of
571emphasis. Text wrapped with one <code>*</code> or <code>_</code> will be wrapped with an
572HTML <code>&lt;em&gt;</code> tag; double <code>*</code>'s or <code>_</code>'s will be wrapped with an HTML
573<code>&lt;strong&gt;</code> tag. E.g., this input:</p>
574<pre><code>*single asterisks*
575
576_single underscores_
577
578**double asterisks**
579
580__double underscores__
581</code></pre>
582<p>will produce:</p>
583<pre><code>&lt;em&gt;single asterisks&lt;/em&gt;
584
585&lt;em&gt;single underscores&lt;/em&gt;
586
587&lt;strong&gt;double asterisks&lt;/strong&gt;
588
589&lt;strong&gt;double underscores&lt;/strong&gt;
590</code></pre>
591<p>You can use whichever style you prefer; the lone restriction is that
592the same character must be used to open and close an emphasis span.</p>
593<p>Emphasis can be used in the middle of a word:</p>
594<pre><code>un*fucking*believable
595</code></pre>
596<p>But if you surround an <code>*</code> or <code>_</code> with spaces, it'll be treated as a
597literal asterisk or underscore.</p>
598<p>To produce a literal asterisk or underscore at a position where it
599would otherwise be used as an emphasis delimiter, you can backslash
600escape it:</p>
601<pre><code>\*this text is surrounded by literal asterisks\*
602</code></pre>
603<h3 id="code">Code</h3>
604
605<p>To indicate a span of code, wrap it with backtick quotes (<code>`</code>).
606Unlike a pre-formatted code block, a code span indicates code within a
607normal paragraph. For example:</p>
608<pre><code>Use the `printf()` function.
609</code></pre>
610<p>will produce:</p>
611<pre><code>&lt;p&gt;Use the &lt;code&gt;printf()&lt;/code&gt; function.&lt;/p&gt;
612</code></pre>
613<p>To include a literal backtick character within a code span, you can use
614multiple backticks as the opening and closing delimiters:</p>
615<pre><code>``There is a literal backtick (`) here.``
616</code></pre>
617<p>which will produce this:</p>
618<pre><code>&lt;p&gt;&lt;code&gt;There is a literal backtick (`) here.&lt;/code&gt;&lt;/p&gt;
619</code></pre>
620<p>The backtick delimiters surrounding a code span may include spaces --
621one after the opening, one before the closing. This allows you to place
622literal backtick characters at the beginning or end of a code span:</p>
623<pre><code>A single backtick in a code span: `` ` ``
624
625A backtick-delimited string in a code span: `` `foo` ``
626</code></pre>
627<p>will produce:</p>
628<pre><code>&lt;p&gt;A single backtick in a code span: &lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
629
630&lt;p&gt;A backtick-delimited string in a code span: &lt;code&gt;`foo`&lt;/code&gt;&lt;/p&gt;
631</code></pre>
632<p>With a code span, ampersands and angle brackets are encoded as HTML
633entities automatically, which makes it easy to include example HTML
634tags. Markdown will turn this:</p>
635<pre><code>Please don't use any `&lt;blink&gt;` tags.
636</code></pre>
637<p>into:</p>
638<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;
639</code></pre>
640<p>You can write this:</p>
641<pre><code>`&amp;#8212;` is the decimal-encoded equivalent of `&amp;mdash;`.
642</code></pre>
643<p>to produce:</p>
644<pre><code>&lt;p&gt;&lt;code&gt;&amp;amp;#8212;&lt;/code&gt; is the decimal-encoded
645equivalent of &lt;code&gt;&amp;amp;mdash;&lt;/code&gt;.&lt;/p&gt;
646</code></pre>
647<h3 id="img">Images</h3>
648
649<p>Admittedly, it's fairly difficult to devise a "natural" syntax for
650placing images into a plain text document format.</p>
651<p>Markdown uses an image syntax that is intended to resemble the syntax
652for links, allowing for two styles: <em>inline</em> and <em>reference</em>.</p>
653<p>Inline image syntax looks like this:</p>
654<pre><code>![Alt text](/path/to/img.jpg)
655
656![Alt text](/path/to/img.jpg "Optional title")
657</code></pre>
658<p>That is:</p>
659<ul>
660<li>An exclamation mark: <code>!</code>;</li>
661<li>followed by a set of square brackets, containing the <code>alt</code>
662 attribute text for the image;</li>
663<li>followed by a set of parentheses, containing the URL or path to
664 the image, and an optional <code>title</code> attribute enclosed in double
665 or single quotes.</li>
666</ul>
667<p>Reference-style image syntax looks like this:</p>
668<pre><code>![Alt text][id]
669</code></pre>
670<p>Where "id" is the name of a defined image reference. Image references
671are defined using syntax identical to link references:</p>
672<pre><code>[id]: url/to/image "Optional title attribute"
673</code></pre>
674<p>As of this writing, Markdown has no syntax for specifying the
675dimensions of an image; if this is important to you, you can simply
676use regular HTML <code>&lt;img&gt;</code> tags.</p>
677<hr />
678<h2 id="misc">Miscellaneous</h2>
679
680<h3 id="autolink">Automatic Links</h3>
681
682<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>
683<pre><code>&lt;http://example.com/&gt;
684</code></pre>
685<p>Markdown will turn this into:</p>
686<pre><code>&lt;a href="http://example.com/"&gt;http://example.com/&lt;/a&gt;
687</code></pre>
688<p>Automatic links for email addresses work similarly, except that
689Markdown will also perform a bit of randomized decimal and hex
690entity-encoding to help obscure your address from address-harvesting
691spambots. For example, Markdown will turn this:</p>
692<pre><code>&lt;address@example.com&gt;
693</code></pre>
694<p>into something like this:</p>
695<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;
696&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;
697&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;
698&amp;#109;&amp;#x70;&amp;#x6C;e&amp;#x2E;&amp;#99;&amp;#111;&amp;#109;&lt;/a&gt;
699</code></pre>
700<p>which will render in a browser as a clickable link to "address@example.com".</p>
701<p>(This sort of entity-encoding trick will indeed fool many, if not
702most, address-harvesting bots, but it definitely won't fool all of
703them. It's better than nothing, but an address published in this way
704will probably eventually start receiving spam.)</p>
705<h3 id="backslash">Backslash Escapes</h3>
706
707<p>Markdown allows you to use backslash escapes to generate literal
708characters which would otherwise have special meaning in Markdown's
709formatting syntax. For example, if you wanted to surround a word with
710literal asterisks (instead of an HTML <code>&lt;em&gt;</code> tag), you can backslashes
711before the asterisks, like this:</p>
712<pre><code>\*literal asterisks\*
713</code></pre>
714<p>Markdown provides backslash escapes for the following characters:</p>
715<pre><code>\ backslash
716` backtick
717* asterisk
718_ underscore
719{} curly braces
720[] square brackets
721() parentheses
722# hash mark
723+ plus sign
724- minus sign (hyphen)
725. dot
726! exclamation mark
727</code></pre>
  
1Markdown: Syntax
2================
3
4<ul id="ProjectSubmenu">
5 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
6 <li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li>
7 <li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li>
8 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
9 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
10</ul>
11
12
13* [Overview](#overview)
14 * [Philosophy](#philosophy)
15 * [Inline HTML](#html)
16 * [Automatic Escaping for Special Characters](#autoescape)
17* [Block Elements](#block)
18 * [Paragraphs and Line Breaks](#p)
19 * [Headers](#header)
20 * [Blockquotes](#blockquote)
21 * [Lists](#list)
22 * [Code Blocks](#precode)
23 * [Horizontal Rules](#hr)
24* [Span Elements](#span)
25 * [Links](#link)
26 * [Emphasis](#em)
27 * [Code](#code)
28 * [Images](#img)
29* [Miscellaneous](#misc)
30 * [Backslash Escapes](#backslash)
31 * [Automatic Links](#autolink)
32
33
34**Note:** This document is itself written using Markdown; you
35can [see the source for it by adding '.text' to the URL][src].
36
37 [src]: /projects/markdown/syntax.text
38
39* * *
40
41<h2 id="overview">Overview</h2>
42
43<h3 id="philosophy">Philosophy</h3>
44
45Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
46
47Readability, however, is emphasized above all else. A Markdown-formatted
48document should be publishable as-is, as plain text, without looking
49like it's been marked up with tags or formatting instructions. While
50Markdown's syntax has been influenced by several existing text-to-HTML
51filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4],
52[Grutatext] [5], and [EtText] [6] -- the single biggest source of
53inspiration for Markdown's syntax is the format of plain text email.
54
55 [1]: http://docutils.sourceforge.net/mirror/setext.html
56 [2]: http://www.aaronsw.com/2002/atx/
57 [3]: http://textism.com/tools/textile/
58 [4]: http://docutils.sourceforge.net/rst.html
59 [5]: http://www.triptico.com/software/grutatxt.html
60 [6]: http://ettext.taint.org/doc/
61
62To this end, Markdown's syntax is comprised entirely of punctuation
63characters, which punctuation characters have been carefully chosen so
64as to look like what they mean. E.g., asterisks around a word actually
65look like \*emphasis\*. Markdown lists look like, well, lists. Even
66blockquotes look like quoted passages of text, assuming you've ever
67used email.
68
69
70
71<h3 id="html">Inline HTML</h3>
72
73Markdown's syntax is intended for one purpose: to be used as a
74format for *writing* for the web.
75
76Markdown is not a replacement for HTML, or even close to it. Its
77syntax is very small, corresponding only to a very small subset of
78HTML tags. The idea is *not* to create a syntax that makes it easier
79to insert HTML tags. In my opinion, HTML tags are already easy to
80insert. The idea for Markdown is to make it easy to read, write, and
81edit prose. HTML is a *publishing* format; Markdown is a *writing*
82format. Thus, Markdown's formatting syntax only addresses issues that
83can be conveyed in plain text.
84
85For any markup that is not covered by Markdown's syntax, you simply
86use HTML itself. There's no need to preface it or delimit it to
87indicate that you're switching from Markdown to HTML; you just use
88the tags.
89
90The only restrictions are that block-level HTML elements -- e.g. `<div>`,
91`<table>`, `<pre>`, `<p>`, etc. -- must be separated from surrounding
92content by blank lines, and the start and end tags of the block should
93not be indented with tabs or spaces. Markdown is smart enough not
94to add extra (unwanted) `<p>` tags around HTML block-level tags.
95
96For example, to add an HTML table to a Markdown article:
97
98 This is a regular paragraph.
99
100 <table>
101 <tr>
102 <td>Foo</td>
103 </tr>
104 </table>
105
106 This is another regular paragraph.
107
108Note that Markdown formatting syntax is not processed within block-level
109HTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an
110HTML block.
111
112Span-level HTML tags -- e.g. `<span>`, `<cite>`, or `<del>` -- can be
113used anywhere in a Markdown paragraph, list item, or header. If you
114want, you can even use HTML tags instead of Markdown formatting; e.g. if
115you'd prefer to use HTML `<a>` or `<img>` tags instead of Markdown's
116link or image syntax, go right ahead.
117
118Unlike block-level HTML tags, Markdown syntax *is* processed within
119span-level tags.
120
121
122<h3 id="autoescape">Automatic Escaping for Special Characters</h3>
123
124In HTML, there are two characters that demand special treatment: `<`
125and `&`. Left angle brackets are used to start tags; ampersands are
126used to denote HTML entities. If you want to use them as literal
127characters, you must escape them as entities, e.g. `&lt;`, and
128`&amp;`.
129
130Ampersands in particular are bedeviling for web writers. If you want to
131write about 'AT&T', you need to write '`AT&amp;T`'. You even need to
132escape ampersands within URLs. Thus, if you want to link to:
133
134 http://images.google.com/images?num=30&q=larry+bird
135
136you need to encode the URL as:
137
138 http://images.google.com/images?num=30&amp;q=larry+bird
139
140in your anchor tag `href` attribute. Needless to say, this is easy to
141forget, and is probably the single most common source of HTML validation
142errors in otherwise well-marked-up web sites.
143
144Markdown allows you to use these characters naturally, taking care of
145all the necessary escaping for you. If you use an ampersand as part of
146an HTML entity, it remains unchanged; otherwise it will be translated
147into `&amp;`.
148
149So, if you want to include a copyright symbol in your article, you can write:
150
151 &copy;
152
153and Markdown will leave it alone. But if you write:
154
155 AT&T
156
157Markdown will translate it to:
158
159 AT&amp;T
160
161Similarly, because Markdown supports [inline HTML](#html), if you use
162angle brackets as delimiters for HTML tags, Markdown will treat them as
163such. But if you write:
164
165 4 < 5
166
167Markdown will translate it to:
168
169 4 &lt; 5
170
171However, inside Markdown code spans and blocks, angle brackets and
172ampersands are *always* encoded automatically. This makes it easy to use
173Markdown to write about HTML code. (As opposed to raw HTML, which is a
174terrible format for writing about HTML syntax, because every single `<`
175and `&` in your example code needs to be escaped.)
176
177
178* * *
179
180
181<h2 id="block">Block Elements</h2>
182
183
184<h3 id="p">Paragraphs and Line Breaks</h3>
185
186A paragraph is simply one or more consecutive lines of text, separated
187by one or more blank lines. (A blank line is any line that looks like a
188blank line -- a line containing nothing but spaces or tabs is considered
189blank.) Normal paragraphs should not be intended with spaces or tabs.
190
191The implication of the "one or more consecutive lines of text" rule is
192that Markdown supports "hard-wrapped" text paragraphs. This differs
193significantly from most other text-to-HTML formatters (including Movable
194Type's "Convert Line Breaks" option) which translate every line break
195character in a paragraph into a `<br />` tag.
196
197When you *do* want to insert a `<br />` break tag using Markdown, you
198end a line with two or more spaces, then type return.
199
200Yes, this takes a tad more effort to create a `<br />`, but a simplistic
201"every line break is a `<br />`" rule wouldn't work for Markdown.
202Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l]
203work best -- and look better -- when you format them with hard breaks.
204
205 [bq]: #blockquote
206 [l]: #list
207
208
209
210<h3 id="header">Headers</h3>
211
212Markdown supports two styles of headers, [Setext] [1] and [atx] [2].
213
214Setext-style headers are "underlined" using equal signs (for first-level
215headers) and dashes (for second-level headers). For example:
216
217 This is an H1
218 =============
219
220 This is an H2
221 -------------
222
223Any number of underlining `=`'s or `-`'s will work.
224
225Atx-style headers use 1-6 hash characters at the start of the line,
226corresponding to header levels 1-6. For example:
227
228 # This is an H1
229
230 ## This is an H2
231
232 ###### This is an H6
233
234Optionally, you may "close" atx-style headers. This is purely
235cosmetic -- you can use this if you think it looks better. The
236closing hashes don't even need to match the number of hashes
237used to open the header. (The number of opening hashes
238determines the header level.) :
239
240 # This is an H1 #
241
242 ## This is an H2 ##
243
244 ### This is an H3 ######
245
246
247<h3 id="blockquote">Blockquotes</h3>
248
249Markdown uses email-style `>` characters for blockquoting. If you're
250familiar with quoting passages of text in an email message, then you
251know how to create a blockquote in Markdown. It looks best if you hard
252wrap the text and put a `>` before every line:
253
254 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
255 > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
256 > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
257 >
258 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
259 > id sem consectetuer libero luctus adipiscing.
260
261Markdown allows you to be lazy and only put the `>` before the first
262line of a hard-wrapped paragraph:
263
264 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
265 consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
266 Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
267
268 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
269 id sem consectetuer libero luctus adipiscing.
270
271Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
272adding additional levels of `>`:
273
274 > This is the first level of quoting.
275 >
276 > > This is nested blockquote.
277 >
278 > Back to the first level.
279
280Blockquotes can contain other Markdown elements, including headers, lists,
281and code blocks:
282
283 > ## This is a header.
284 >
285 > 1. This is the first list item.
286 > 2. This is the second list item.
287 >
288 > Here's some example code:
289 >
290 > return shell_exec("echo $input | $markdown_script");
291
292Any decent text editor should make email-style quoting easy. For
293example, with BBEdit, you can make a selection and choose Increase
294Quote Level from the Text menu.
295
296
297<h3 id="list">Lists</h3>
298
299Markdown supports ordered (numbered) and unordered (bulleted) lists.
300
301Unordered lists use asterisks, pluses, and hyphens -- interchangably
302
303 * Red
304 * Green
305 * Blue
306
307is equivalent to:
308
309 + Red
310 + Green
311 + Blue
312
313and:
314
315 - Red
316 - Green
317 - Blue
318
319Ordered lists use numbers followed by periods:
320
321 1. Bird
322 2. McHale
323 3. Parish
324
325It's important to note that the actual numbers you use to mark the
326list have no effect on the HTML output Markdown produces. The HTML
327Markdown produces from the above list is:
328
329 <ol>
330 <li>Bird</li>
331 <li>McHale</li>
332 <li>Parish</li>
333 </ol>
334
335If you instead wrote the list in Markdown like this:
336
337 1. Bird
338 1. McHale
339 1. Parish
340
341or even:
342
343 3. Bird
344 1. McHale
345 8. Parish
346
347you'd get the exact same HTML output. The point is, if you want to,
348you can use ordinal numbers in your ordered Markdown lists, so that
349the numbers in your source match the numbers in your published HTML.
350But if you want to be lazy, you don't have to.
351
352If you do use lazy list numbering, however, you should still start the
353list with the number 1. At some point in the future, Markdown may support
354starting ordered lists at an arbitrary number.
355
356List markers typically start at the left margin, but may be indented by
357up to three spaces. List markers must be followed by one or more spaces
358or a tab.
359
360To make lists look nice, you can wrap items with hanging indents:
361
362 * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
363 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
364 viverra nec, fringilla in, laoreet vitae, risus.
365 * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
366 Suspendisse id sem consectetuer libero luctus adipiscing.
367
368But if you want to be lazy, you don't have to:
369
370 * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
371 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
372 viverra nec, fringilla in, laoreet vitae, risus.
373 * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
374 Suspendisse id sem consectetuer libero luctus adipiscing.
375
376If list items are separated by blank lines, Markdown will wrap the
377items in `<p>` tags in the HTML output. For example, this input:
378
379 * Bird
380 * Magic
381
382will turn into:
383
384 <ul>
385 <li>Bird</li>
386 <li>Magic</li>
387 </ul>
388
389But this:
390
391 * Bird
392
393 * Magic
394
395will turn into:
396
397 <ul>
398 <li><p>Bird</p></li>
399 <li><p>Magic</p></li>
400 </ul>
401
402List items may consist of multiple paragraphs. Each subsequent
403paragraph in a list item must be intended by either 4 spaces
404or one tab:
405
406 1. This is a list item with two paragraphs. Lorem ipsum dolor
407 sit amet, consectetuer adipiscing elit. Aliquam hendrerit
408 mi posuere lectus.
409
410 Vestibulum enim wisi, viverra nec, fringilla in, laoreet
411 vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
412 sit amet velit.
413
414 2. Suspendisse id sem consectetuer libero luctus adipiscing.
415
416It looks nice if you indent every line of the subsequent
417paragraphs, but here again, Markdown will allow you to be
418lazy:
419
420 * This is a list item with two paragraphs.
421
422 This is the second paragraph in the list item. You're
423 only required to indent the first line. Lorem ipsum dolor
424 sit amet, consectetuer adipiscing elit.
425
426 * Another item in the same list.
427
428To put a blockquote within a list item, the blockquote's `>`
429delimiters need to be indented:
430
431 * A list item with a blockquote:
432
433 > This is a blockquote
434 > inside a list item.
435
436To put a code block within a list item, the code block needs
437to be indented *twice* -- 8 spaces or two tabs:
438
439 * A list item with a code block:
440
441 <code goes here>
442
443
444It's worth noting that it's possible to trigger an ordered list by
445accident, by writing something like this:
446
447 1986. What a great season.
448
449In other words, a *number-period-space* sequence at the beginning of a
450line. To avoid this, you can backslash-escape the period:
451
452 1986\. What a great season.
453
454
455
456<h3 id="precode">Code Blocks</h3>
457
458Pre-formatted code blocks are used for writing about programming or
459markup source code. Rather than forming normal paragraphs, the lines
460of a code block are interpreted literally. Markdown wraps a code block
461in both `<pre>` and `<code>` tags.
462
463To produce a code block in Markdown, simply indent every line of the
464block by at least 4 spaces or 1 tab. For example, given this input:
465
466 This is a normal paragraph:
467
468 This is a code block.
469
470Markdown will generate:
471
472 <p>This is a normal paragraph:</p>
473
474 <pre><code>This is a code block.
475 </code></pre>
476
477One level of indentation -- 4 spaces or 1 tab -- is removed from each
478line of the code block. For example, this:
479
480 Here is an example of AppleScript:
481
482 tell application "Foo"
483 beep
484 end tell
485
486will turn into:
487
488 <p>Here is an example of AppleScript:</p>
489
490 <pre><code>tell application "Foo"
491 beep
492 end tell
493 </code></pre>
494
495A code block continues until it reaches a line that is not indented
496(or the end of the article).
497
498Within a code block, ampersands (`&`) and angle brackets (`<` and `>`)
499are automatically converted into HTML entities. This makes it very
500easy to include example HTML source code using Markdown -- just paste
501it and indent it, and Markdown will handle the hassle of encoding the
502ampersands and angle brackets. For example, this:
503
504 <div class="footer">
505 &copy; 2004 Foo Corporation
506 </div>
507
508will turn into:
509
510 <pre><code>&lt;div class="footer"&gt;
511 &amp;copy; 2004 Foo Corporation
512 &lt;/div&gt;
513 </code></pre>
514
515Regular Markdown syntax is not processed within code blocks. E.g.,
516asterisks are just literal asterisks within a code block. This means
517it's also easy to use Markdown to write about Markdown's own syntax.
518
519
520
521<h3 id="hr">Horizontal Rules</h3>
522
523You can produce a horizontal rule tag (`<hr />`) by placing three or
524more hyphens, asterisks, or underscores on a line by themselves. If you
525wish, you may use spaces between the hyphens or asterisks. Each of the
526following lines will produce a horizontal rule:
527
528 * * *
529
530 ***
531
532 *****
533
534 - - -
535
536 ---------------------------------------
537
538 _ _ _
539
540
541* * *
542
543<h2 id="span">Span Elements</h2>
544
545<h3 id="link">Links</h3>
546
547Markdown supports two style of links: *inline* and *reference*.
548
549In both styles, the link text is delimited by [square brackets].
550
551To create an inline link, use a set of regular parentheses immediately
552after the link text's closing square bracket. Inside the parentheses,
553put the URL where you want the link to point, along with an *optional*
554title for the link, surrounded in quotes. For example:
555
556 This is [an example](http://example.com/ "Title") inline link.
557
558 [This link](http://example.net/) has no title attribute.
559
560Will produce:
561
562 <p>This is <a href="http://example.com/" title="Title">
563 an example</a> inline link.</p>
564
565 <p><a href="http://example.net/">This link</a> has no
566 title attribute.</p>
567
568If you're referring to a local resource on the same server, you can
569use relative paths:
570
571 See my [About](/about/) page for details.
572
573Reference-style links use a second set of square brackets, inside
574which you place a label of your choosing to identify the link:
575
576 This is [an example][id] reference-style link.
577
578You can optionally use a space to separate the sets of brackets:
579
580 This is [an example] [id] reference-style link.
581
582Then, anywhere in the document, you define your link label like this,
583on a line by itself:
584
585 [id]: http://example.com/ "Optional Title Here"
586
587That is:
588
589* Square brackets containing the link identifier (optionally
590 indented from the left margin using up to three spaces);
591* followed by a colon;
592* followed by one or more spaces (or tabs);
593* followed by the URL for the link;
594* optionally followed by a title attribute for the link, enclosed
595 in double or single quotes.
596
597The link URL may, optionally, be surrounded by angle brackets:
598
599 [id]: <http://example.com/> "Optional Title Here"
600
601You can put the title attribute on the next line and use extra spaces
602or tabs for padding, which tends to look better with longer URLs:
603
604 [id]: http://example.com/longish/path/to/resource/here
605 "Optional Title Here"
606
607Link definitions are only used for creating links during Markdown
608processing, and are stripped from your document in the HTML output.
609
610Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are *not* case sensitive. E.g. these two links:
611
612 [link text][a]
613 [link text][A]
614
615are equivalent.
616
617The *implicit link name* shortcut allows you to omit the name of the
618link, in which case the link text itself is used as the name.
619Just use an empty set of square brackets -- e.g., to link the word
620"Google" to the google.com web site, you could simply write:
621
622 [Google][]
623
624And then define the link:
625
626 [Google]: http://google.com/
627
628Because link names may contain spaces, this shortcut even works for
629multiple words in the link text:
630
631 Visit [Daring Fireball][] for more information.
632
633And then define the link:
634
635 [Daring Fireball]: http://daringfireball.net/
636
637Link definitions can be placed anywhere in your Markdown document. I
638tend to put them immediately after each paragraph in which they're
639used, but if you want, you can put them all at the end of your
640document, sort of like footnotes.
641
642Here's an example of reference links in action:
643
644 I get 10 times more traffic from [Google] [1] than from
645 [Yahoo] [2] or [MSN] [3].
646
647 [1]: http://google.com/ "Google"
648 [2]: http://search.yahoo.com/ "Yahoo Search"
649 [3]: http://search.msn.com/ "MSN Search"
650
651Using the implicit link name shortcut, you could instead write:
652
653 I get 10 times more traffic from [Google][] than from
654 [Yahoo][] or [MSN][].
655
656 [google]: http://google.com/ "Google"
657 [yahoo]: http://search.yahoo.com/ "Yahoo Search"
658 [msn]: http://search.msn.com/ "MSN Search"
659
660Both of the above examples will produce the following HTML output:
661
662 <p>I get 10 times more traffic from <a href="http://google.com/"
663 title="Google">Google</a> than from
664 <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
665 or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
666
667For comparison, here is the same paragraph written using
668Markdown's inline link style:
669
670 I get 10 times more traffic from [Google](http://google.com/ "Google")
671 than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
672 [MSN](http://search.msn.com/ "MSN Search").
673
674The point of reference-style links is not that they're easier to
675write. The point is that with reference-style links, your document
676source is vastly more readable. Compare the above examples: using
677reference-style links, the paragraph itself is only 81 characters
678long; with inline-style links, it's 176 characters; and as raw HTML,
679it's 234 characters. In the raw HTML, there's more markup than there
680is text.
681
682With Markdown's reference-style links, a source document much more
683closely resembles the final output, as rendered in a browser. By
684allowing you to move the markup-related metadata out of the paragraph,
685you can add links without interrupting the narrative flow of your
686prose.
687
688
689<h3 id="em">Emphasis</h3>
690
691Markdown treats asterisks (`*`) and underscores (`_`) as indicators of
692emphasis. Text wrapped with one `*` or `_` will be wrapped with an
693HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML
694`<strong>` tag. E.g., this input:
695
696 *single asterisks*
697
698 _single underscores_
699
700 **double asterisks**
701
702 __double underscores__
703
704will produce:
705
706 <em>single asterisks</em>
707
708 <em>single underscores</em>
709
710 <strong>double asterisks</strong>
711
712 <strong>double underscores</strong>
713
714You can use whichever style you prefer; the lone restriction is that
715the same character must be used to open and close an emphasis span.
716
717Emphasis can be used in the middle of a word:
718
719 un*fucking*believable
720
721But if you surround an `*` or `_` with spaces, it'll be treated as a
722literal asterisk or underscore.
723
724To produce a literal asterisk or underscore at a position where it
725would otherwise be used as an emphasis delimiter, you can backslash
726escape it:
727
728 \*this text is surrounded by literal asterisks\*
729
730
731
732<h3 id="code">Code</h3>
733
734To indicate a span of code, wrap it with backtick quotes (`` ` ``).
735Unlike a pre-formatted code block, a code span indicates code within a
736normal paragraph. For example:
737
738 Use the `printf()` function.
739
740will produce:
741
742 <p>Use the <code>printf()</code> function.</p>
743
744To include a literal backtick character within a code span, you can use
745multiple backticks as the opening and closing delimiters:
746
747 ``There is a literal backtick (`) here.``
748
749which will produce this:
750
751 <p><code>There is a literal backtick (`) here.</code></p>
752
753The backtick delimiters surrounding a code span may include spaces --
754one after the opening, one before the closing. This allows you to place
755literal backtick characters at the beginning or end of a code span:
756
757 A single backtick in a code span: `` ` ``
758
759 A backtick-delimited string in a code span: `` `foo` ``
760
761will produce:
762
763 <p>A single backtick in a code span: <code>`</code></p>
764
765 <p>A backtick-delimited string in a code span: <code>`foo`</code></p>
766
767With a code span, ampersands and angle brackets are encoded as HTML
768entities automatically, which makes it easy to include example HTML
769tags. Markdown will turn this:
770
771 Please don't use any `<blink>` tags.
772
773into:
774
775 <p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>
776
777You can write this:
778
779 `&#8212;` is the decimal-encoded equivalent of `&mdash;`.
780
781to produce:
782
783 <p><code>&amp;#8212;</code> is the decimal-encoded
784 equivalent of <code>&amp;mdash;</code>.</p>
785
786
787
788<h3 id="img">Images</h3>
789
790Admittedly, it's fairly difficult to devise a "natural" syntax for
791placing images into a plain text document format.
792
793Markdown uses an image syntax that is intended to resemble the syntax
794for links, allowing for two styles: *inline* and *reference*.
795
796Inline image syntax looks like this:
797
798 ![Alt text](/path/to/img.jpg)
799
800 ![Alt text](/path/to/img.jpg "Optional title")
801
802That is:
803
804* An exclamation mark: `!`;
805* followed by a set of square brackets, containing the `alt`
806 attribute text for the image;
807* followed by a set of parentheses, containing the URL or path to
808 the image, and an optional `title` attribute enclosed in double
809 or single quotes.
810
811Reference-style image syntax looks like this:
812
813 ![Alt text][id]
814
815Where "id" is the name of a defined image reference. Image references
816are defined using syntax identical to link references:
817
818 [id]: url/to/image "Optional title attribute"
819
820As of this writing, Markdown has no syntax for specifying the
821dimensions of an image; if this is important to you, you can simply
822use regular HTML `<img>` tags.
823
824
825* * *
826
827
828<h2 id="misc">Miscellaneous</h2>
829
830<h3 id="autolink">Automatic Links</h3>
831
832Markdown 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:
833
834 <http://example.com/>
835
836Markdown will turn this into:
837
838 <a href="http://example.com/">http://example.com/</a>
839
840Automatic links for email addresses work similarly, except that
841Markdown will also perform a bit of randomized decimal and hex
842entity-encoding to help obscure your address from address-harvesting
843spambots. For example, Markdown will turn this:
844
845 <address@example.com>
846
847into something like this:
848
849 <a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;
850 &#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;
851 &#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
852 &#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
853
854which will render in a browser as a clickable link to "address@example.com".
855
856(This sort of entity-encoding trick will indeed fool many, if not
857most, address-harvesting bots, but it definitely won't fool all of
858them. It's better than nothing, but an address published in this way
859will probably eventually start receiving spam.)
860
861
862
863<h3 id="backslash">Backslash Escapes</h3>
864
865Markdown allows you to use backslash escapes to generate literal
866characters which would otherwise have special meaning in Markdown's
867formatting syntax. For example, if you wanted to surround a word with
868literal asterisks (instead of an HTML `<em>` tag), you can backslashes
869before the asterisks, like this:
870
871 \*literal asterisks\*
872
873Markdown provides backslash escapes for the following characters:
874
875 \ backslash
876 ` backtick
877 * asterisk
878 _ underscore
879 {} curly braces
880 [] square brackets
881 () parentheses
882 # hash mark
883 + plus sign
884 - minus sign (hyphen)
885 . dot
886 ! exclamation mark
  
1<p>This is the body with footnotes<sup id="fnref:foo"><a href="#fn:foo" rel="footnote">1</a></sup>
2that have named<sup id="fnref:bar"><a href="#fn:bar" rel="footnote">2</a></sup> markers and
3oddly<sup id="fnref:56"><a href="#fn:56" rel="footnote">3</a></sup> numbered<sup id="fnref:99"><a href="#fn:99" rel="footnote">4</a></sup> markers.</p>
4<div class="footnote">
5<hr />
6<ol>
7<li id="fn:foo">
8<p>Footnote marked <code>foo</code>.
9&#160;<a href="#fnref:foo" rev="footnote" title="Jump back to footnote 1 in the text">&#8617;</a></p>
10</li>
11<li id="fn:bar">
12<p>This one is marked <em>bar</em>.
13&#160;<a href="#fnref:bar" rev="footnote" title="Jump back to footnote 2 in the text">&#8617;</a></p>
14</li>
15<li id="fn:56">
16<p>A <strong>numbered</strong> footnote.
17&#160;<a href="#fnref:56" rev="footnote" title="Jump back to footnote 3 in the text">&#8617;</a></p>
18</li>
19<li id="fn:99">
20<p>The last one.
21&#160;<a href="#fnref:99" rev="footnote" title="Jump back to footnote 4 in the text">&#8617;</a></p>
22</li>
23</ol>
24</div>
  
1This is the body with footnotes[^foo]
2that have named[^bar] markers and
3oddly[^56] numbered[^99] markers.
4
5[^foo]: Footnote marked ``foo``.
6[^bar]: This one is marked *bar*.
7[^56]: A __numbered__ footnote.
8[^99]: The last one.
  
1<div>
2
3<p><em>foo</em></p>
4</div>
5
6<div class="baz">
7
8<p><em>bar</em></p>
9</div>
10
11<div>
12
13<p><em>blah</em></p>
14</div>
  
1<div markdown="1">_foo_</div>
2
3<div markdown=1 class="baz">
4_bar_
5</div>
6
7<div markdown>
8
9_blah_
10
11</div>
  
1<p>Some text</p>
2<dl>
3<dt>term1</dt>
4<dd>Def1</dd>
5<dt>term2-1</dt>
6<dt>term2-2</dt>
7<dd>Def2-1</dd>
8<dd>Def2-2</dd>
9</dl>
10<p>more text</p>
11<dl>
12<dt>term <em>3</em></dt>
13<dd>
14<p>def 3
15line <strong>2</strong> of def 3</p>
16<p>paragraph 2 of def 3.</p>
17</dd>
18<dd>
19<p>def 3-2</p>
20<pre><code># A code block in a def
21</code></pre>
22<blockquote>
23<p>a blockquote</p>
24</blockquote>
25<ul>
26<li>
27<p>a list item</p>
28</li>
29<li>
30<blockquote>
31<p>blockquote in list</p>
32</blockquote>
33</li>
34</ul>
35</dd>
36</dl>
37<p>final text.</p>
  
1Some text
2
3term1
4: Def1
5
6term2-1
7term2-2
8: Def2-1
9: Def2-2
10
11more text
12
13term *3*
14: def 3
15 line __2__ of def 3
16
17 paragraph 2 of def 3.
18
19: def 3-2
20
21 # A code block in a def
22
23 > a blockquote
24
25 * a list item
26
27 * > blockquote in list
28
29final text.
  
1<h2>Table Tests</h2>
2<table>
3<thead>
4<tr>
5<th>First Header</th>
6<th>Second Header</th>
7</tr>
8</thead>
9<tbody>
10<tr>
11<td>Content Cell</td>
12<td>Content Cell</td>
13</tr>
14<tr>
15<td>Content Cell</td>
16<td>Content Cell</td>
17</tr>
18</tbody>
19</table>
20<table>
21<thead>
22<tr>
23<th>First Header</th>
24<th>Second Header</th>
25</tr>
26</thead>
27<tbody>
28<tr>
29<td>Content Cell</td>
30<td>Content Cell</td>
31</tr>
32<tr>
33<td>Content Cell</td>
34<td>Content Cell</td>
35</tr>
36</tbody>
37</table>
38<table>
39<thead>
40<tr>
41<th>Item</th>
42<th align="right">Value</th>
43</tr>
44</thead>
45<tbody>
46<tr>
47<td>Computer</td>
48<td align="right">$1600</td>
49</tr>
50<tr>
51<td>Phone</td>
52<td align="right">$12</td>
53</tr>
54<tr>
55<td>Pipe</td>
56<td align="right">$1</td>
57</tr>
58</tbody>
59</table>
60<table>
61<thead>
62<tr>
63<th>Function name</th>
64<th>Description</th>
65</tr>
66</thead>
67<tbody>
68<tr>
69<td><code>help()</code></td>
70<td>Display the help window.</td>
71</tr>
72<tr>
73<td><code>destroy()</code></td>
74<td><strong>Destroy your computer!</strong></td>
75</tr>
76</tbody>
77</table>
78<table>
79<thead>
80<tr>
81<th align="left">foo</th>
82<th align="center">bar</th>
83<th align="right">baz</th>
84</tr>
85</thead>
86<tbody>
87<tr>
88<td align="left" />
89<td align="center">Q</td>
90<td align="right" />
91</tr>
92<tr>
93<td align="left">W</td>
94<td align="center" />
95<td align="right">W</td>
96</tr>
97</tbody>
98</table>
99<table>
100<thead>
101<tr>
102<th>foo</th>
103<th>bar</th>
104<th>baz</th>
105</tr>
106</thead>
107<tbody>
108<tr>
109<td />
110<td>Q</td>
111<td />
112</tr>
113<tr>
114<td>W</td>
115<td />
116<td>W</td>
117</tr>
118</tbody>
119</table>
  
1Table Tests
2-----------
3
4First Header | Second Header
5------------- | -------------
6Content Cell | Content Cell
7Content Cell | Content Cell
8
9| First Header | Second Header |
10| ------------- | ------------- |
11| Content Cell | Content Cell |
12| Content Cell | Content Cell |
13
14| Item | Value |
15| :-------- | -----:|
16| Computer | $1600 |
17| Phone | $12 |
18| Pipe | $1 |
19
20| Function name | Description |
21| ------------- | ------------------------------ |
22| `help()` | Display the help window. |
23| `destroy()` | **Destroy your computer!** |
24
25|foo|bar|baz|
26|:--|:-:|--:|
27| | Q | |
28|W | | W|
29
30foo|bar|baz
31---|---|---
32 | Q |
33 W | | W
  
1[DEFAULT]
2extensions=extra
3
4[loose_def_list]
5extensions=def_list
6
7[simple_def-lists]
8extensions=def_list
9
10[abbr]
11extensions=abbr
12
13[footnotes]
14extensions=footnotes
15
16[tables]
17extensions=tables
  
1[codehilite]
2extensions=codehilite
3
4[toc]
5extensions=toc
6
7[toc_invalid]
8extensions=toc
9
10[toc_nested]
11extensions=toc
12
13[toc_nested2]
14extensions=toc
15
16[wikilinks]
17extensions=wikilinks
  
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>&lt;div&gt;</code>,
64<code>&lt;table&gt;</code>, <code>&lt;pre&gt;</code>, <code>&lt;p&gt;</code>, etc. -- must be separated from surrounding
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>&lt;p&gt;</code> tags around HTML block-level tags.</p>
68<p>For example, to add an HTML table to a Markdown article:</p>
69<pre><code>This is a regular paragraph.
70
71&lt;table&gt;
72 &lt;tr&gt;
73 &lt;td&gt;Foo&lt;/td&gt;
74 &lt;/tr&gt;
75&lt;/table&gt;
76
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>&lt;span&gt;</code>, <code>&lt;cite&gt;</code>, or <code>&lt;del&gt;</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>&lt;a&gt;</code> or <code>&lt;img&gt;</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>&lt;</code>
91and <code>&amp;</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>&amp;lt;</code>, and
94<code>&amp;amp;</code>.</p>
95<p>Ampersands in particular are bedeviling for web writers. If you want to
96write about 'AT&amp;T', you need to write '<code>AT&amp;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&amp;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;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;amp;</code>.</p>
110<p>So, if you want to include a copyright symbol in your article, you can write:</p>
111<pre><code>&amp;copy;
112</code></pre>
113<p>and Markdown will leave it alone. But if you write:</p>
114<pre><code>AT&amp;T
115</code></pre>
116<p>Markdown will translate it to:</p>
117<pre><code>AT&amp;amp;T
118</code></pre>
119<p>Similarly, because Markdown supports <a href="#html">inline HTML</a>, if you use
120angle brackets as delimiters for HTML tags, Markdown will treat them as
121such. But if you write:</p>
122<pre><code>4 &lt; 5
123</code></pre>
124<p>Markdown will translate it to:</p>
125<pre><code>4 &amp;lt; 5
126</code></pre>
127<p>However, inside Markdown code spans and blocks, angle brackets and
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>&lt;</code>
131and <code>&amp;</code> in your example code needs to be escaped.)</p>
132<hr />
133<h1 id="block-elements">Block Elements</h1>
134<h2 id="paragraphs-and-line-breaks">Paragraphs and Line Breaks</h2>
135<p>A paragraph is simply one or more consecutive lines of text, separated
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 intended 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>&lt;br /&gt;</code> tag.</p>
144<p>When you <em>do</em> want to insert a <code>&lt;br /&gt;</code> break tag using Markdown, you
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>&lt;br /&gt;</code>, but a simplistic
147"every line break is a <code>&lt;br /&gt;</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>&gt;</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>&gt;</code> before every line:</p>
185<pre><code>&gt; This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
186&gt; consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
187&gt; Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
188&gt;
189&gt; Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
190&gt; id sem consectetuer libero luctus adipiscing.
191</code></pre>
192<p>Markdown allows you to be lazy and only put the <code>&gt;</code> before the first
193line of a hard-wrapped paragraph:</p>
194<pre><code>&gt; 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&gt; 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>&gt;</code>:</p>
203<pre><code>&gt; This is the first level of quoting.
204&gt;
205&gt; &gt; This is nested blockquote.
206&gt;
207&gt; Back to the first level.
208</code></pre>
209<p>Blockquotes can contain other Markdown elements, including headers, lists,
210and code blocks:</p>
211<pre><code>&gt; ## This is a header.
212&gt;
213&gt; 1. This is the first list item.
214&gt; 2. This is the second list item.
215&gt;
216&gt; Here's some example code:
217&gt;
218&gt; return shell_exec("echo $input | $markdown_script");
219</code></pre>
220<p>Any decent text editor should make email-style quoting easy. For
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 -- interchangably
226<pre><code>* Red
227* Green
228* Blue
229</code></pre>
230<p>is equivalent to:</p>
231<pre><code>+ Red
232+ Green
233+ Blue
234</code></pre>
235<p>and:</p>
236<pre><code>- Red
237- Green
238- Blue
239</code></pre>
240<p>Ordered lists use numbers followed by periods:</p>
241<pre><code>1. Bird
2422. McHale
2433. Parish
244</code></pre>
245<p>It's important to note that the actual numbers you use to mark the
246list have no effect on the HTML output Markdown produces. The HTML
247Markdown produces from the above list is:</p>
248<pre><code>&lt;ol&gt;
249&lt;li&gt;Bird&lt;/li&gt;
250&lt;li&gt;McHale&lt;/li&gt;
251&lt;li&gt;Parish&lt;/li&gt;
252&lt;/ol&gt;
253</code></pre>
254<p>If you instead wrote the list in Markdown like this:</p>
255<pre><code>1. Bird
2561. McHale
2571. Parish
258</code></pre>
259<p>or even:</p>
260<pre><code>3. Bird
2611. McHale
2628. Parish
263</code></pre>
264<p>you'd get the exact same HTML output. The point is, if you want to,
265you can use ordinal numbers in your ordered Markdown lists, so that
266the numbers in your source match the numbers in your published HTML.
267But if you want to be lazy, you don't have to.</p>
268<p>If you do use lazy list numbering, however, you should still start the
269list with the number 1. At some point in the future, Markdown may support
270starting ordered lists at an arbitrary number.</p>
271<p>List markers typically start at the left margin, but may be indented by
272up to three spaces. List markers must be followed by one or more spaces
273or a tab.</p>
274<p>To make lists look nice, you can wrap items with hanging indents:</p>
275<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
276 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
277 viverra nec, fringilla in, laoreet vitae, risus.
278* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
279 Suspendisse id sem consectetuer libero luctus adipiscing.
280</code></pre>
281<p>But if you want to be lazy, you don't have to:</p>
282<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
283Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
284viverra nec, fringilla in, laoreet vitae, risus.
285* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
286Suspendisse id sem consectetuer libero luctus adipiscing.
287</code></pre>
288<p>If list items are separated by blank lines, Markdown will wrap the
289items in <code>&lt;p&gt;</code> tags in the HTML output. For example, this input:</p>
290<pre><code>* Bird
291* Magic
292</code></pre>
293<p>will turn into:</p>
294<pre><code>&lt;ul&gt;
295&lt;li&gt;Bird&lt;/li&gt;
296&lt;li&gt;Magic&lt;/li&gt;
297&lt;/ul&gt;
298</code></pre>
299<p>But this:</p>
300<pre><code>* Bird
301
302* Magic
303</code></pre>
304<p>will turn into:</p>
305<pre><code>&lt;ul&gt;
306&lt;li&gt;&lt;p&gt;Bird&lt;/p&gt;&lt;/li&gt;
307&lt;li&gt;&lt;p&gt;Magic&lt;/p&gt;&lt;/li&gt;
308&lt;/ul&gt;
309</code></pre>
310<p>List items may consist of multiple paragraphs. Each subsequent
311paragraph in a list item must be intended by either 4 spaces
312or one tab:</p>
313<pre><code>1. This is a list item with two paragraphs. Lorem ipsum dolor
314 sit amet, consectetuer adipiscing elit. Aliquam hendrerit
315 mi posuere lectus.
316
317 Vestibulum enim wisi, viverra nec, fringilla in, laoreet
318 vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
319 sit amet velit.
320
3212. Suspendisse id sem consectetuer libero luctus adipiscing.
322</code></pre>
323<p>It looks nice if you indent every line of the subsequent
324paragraphs, but here again, Markdown will allow you to be
325lazy:</p>
326<pre><code>* This is a list item with two paragraphs.
327
328 This is the second paragraph in the list item. You're
329only required to indent the first line. Lorem ipsum dolor
330sit amet, consectetuer adipiscing elit.
331
332* Another item in the same list.
333</code></pre>
334<p>To put a blockquote within a list item, the blockquote's <code>&gt;</code>
335delimiters need to be indented:</p>
336<pre><code>* A list item with a blockquote:
337
338 &gt; This is a blockquote
339 &gt; inside a list item.
340</code></pre>
341<p>To put a code block within a list item, the code block needs
342to be indented <em>twice</em> -- 8 spaces or two tabs:</p>
343<pre><code>* A list item with a code block:
344
345 &lt;code goes here&gt;
346</code></pre>
347<p>It's worth noting that it's possible to trigger an ordered list by
348accident, by writing something like this:</p>
349<pre><code>1986. What a great season.
350</code></pre>
351<p>In other words, a <em>number-period-space</em> sequence at the beginning of a
352line. To avoid this, you can backslash-escape the period:</p>
353<pre><code>1986\. What a great season.
354</code></pre>
355<h2 id="code-blocks">Code Blocks</h2>
356<p>Pre-formatted code blocks are used for writing about programming or
357markup source code. Rather than forming normal paragraphs, the lines
358of a code block are interpreted literally. Markdown wraps a code block
359in both <code>&lt;pre&gt;</code> and <code>&lt;code&gt;</code> tags.</p>
360<p>To produce a code block in Markdown, simply indent every line of the
361block by at least 4 spaces or 1 tab. For example, given this input:</p>
362<pre><code>This is a normal paragraph:
363
364 This is a code block.
365</code></pre>
366<p>Markdown will generate:</p>
367<pre><code>&lt;p&gt;This is a normal paragraph:&lt;/p&gt;
368
369&lt;pre&gt;&lt;code&gt;This is a code block.
370&lt;/code&gt;&lt;/pre&gt;
371</code></pre>
372<p>One level of indentation -- 4 spaces or 1 tab -- is removed from each
373line of the code block. For example, this:</p>
374<pre><code>Here is an example of AppleScript:
375
376 tell application "Foo"
377 beep
378 end tell
379</code></pre>
380<p>will turn into:</p>
381<pre><code>&lt;p&gt;Here is an example of AppleScript:&lt;/p&gt;
382
383&lt;pre&gt;&lt;code&gt;tell application "Foo"
384 beep
385end tell
386&lt;/code&gt;&lt;/pre&gt;
387</code></pre>
388<p>A code block continues until it reaches a line that is not indented
389(or the end of the article).</p>
390<p>Within a code block, ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> and <code>&gt;</code>)
391are automatically converted into HTML entities. This makes it very
392easy to include example HTML source code using Markdown -- just paste
393it and indent it, and Markdown will handle the hassle of encoding the
394ampersands and angle brackets. For example, this:</p>
395<pre><code> &lt;div class="footer"&gt;
396 &amp;copy; 2004 Foo Corporation
397 &lt;/div&gt;
398</code></pre>
399<p>will turn into:</p>
400<pre><code>&lt;pre&gt;&lt;code&gt;&amp;lt;div class="footer"&amp;gt;
401 &amp;amp;copy; 2004 Foo Corporation
402&amp;lt;/div&amp;gt;
403&lt;/code&gt;&lt;/pre&gt;
404</code></pre>
405<p>Regular Markdown syntax is not processed within code blocks. E.g.,
406asterisks are just literal asterisks within a code block. This means
407it's also easy to use Markdown to write about Markdown's own syntax.</p>
408<h2 id="horizontal-rules">Horizontal Rules</h2>
409<p>You can produce a horizontal rule tag (<code>&lt;hr /&gt;</code>) by placing three or
410more hyphens, asterisks, or underscores on a line by themselves. If you
411wish, you may use spaces between the hyphens or asterisks. Each of the
412following lines will produce a horizontal rule:</p>
413<pre><code>* * *
414
415***
416
417*****
418
419- - -
420
421---------------------------------------
422
423_ _ _
424</code></pre>
425<hr />
426<h1 id="span-elements">Span Elements</h1>
427<h2 id="links">Links</h2>
428<p>Markdown supports two style of links: <em>inline</em> and <em>reference</em>.</p>
429<p>In both styles, the link text is delimited by [square brackets].</p>
430<p>To create an inline link, use a set of regular parentheses immediately
431after the link text's closing square bracket. Inside the parentheses,
432put the URL where you want the link to point, along with an <em>optional</em>
433title for the link, surrounded in quotes. For example:</p>
434<pre><code>This is [an example](http://example.com/ "Title") inline link.
435
436[This link](http://example.net/) has no title attribute.
437</code></pre>
438<p>Will produce:</p>
439<pre><code>&lt;p&gt;This is &lt;a href="http://example.com/" title="Title"&gt;
440an example&lt;/a&gt; inline link.&lt;/p&gt;
441
442&lt;p&gt;&lt;a href="http://example.net/"&gt;This link&lt;/a&gt; has no
443title attribute.&lt;/p&gt;
444</code></pre>
445<p>If you're referring to a local resource on the same server, you can
446use relative paths:</p>
447<pre><code>See my [About](/about/) page for details.
448</code></pre>
449<p>Reference-style links use a second set of square brackets, inside
450which you place a label of your choosing to identify the link:</p>
451<pre><code>This is [an example][id] reference-style link.
452</code></pre>
453<p>You can optionally use a space to separate the sets of brackets:</p>
454<pre><code>This is [an example] [id] reference-style link.
455</code></pre>
456<p>Then, anywhere in the document, you define your link label like this,
457on a line by itself:</p>
458<pre><code>[id]: http://example.com/ "Optional Title Here"
459</code></pre>
460<p>That is:</p>
461<ul>
462<li>Square brackets containing the link identifier (optionally
463 indented from the left margin using up to three spaces);</li>
464<li>followed by a colon;</li>
465<li>followed by one or more spaces (or tabs);</li>
466<li>followed by the URL for the link;</li>
467<li>optionally followed by a title attribute for the link, enclosed
468 in double or single quotes.</li>
469</ul>
470<p>The link URL may, optionally, be surrounded by angle brackets:</p>
471<pre><code>[id]: &lt;http://example.com/&gt; "Optional Title Here"
472</code></pre>
473<p>You can put the title attribute on the next line and use extra spaces
474or tabs for padding, which tends to look better with longer URLs:</p>
475<pre><code>[id]: http://example.com/longish/path/to/resource/here
476 "Optional Title Here"
477</code></pre>
478<p>Link definitions are only used for creating links during Markdown
479processing, and are stripped from your document in the HTML output.</p>
480<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>
481<pre><code>[link text][a]
482[link text][A]
483</code></pre>
484<p>are equivalent.</p>
485<p>The <em>implicit link name</em> shortcut allows you to omit the name of the
486link, in which case the link text itself is used as the name.
487Just use an empty set of square brackets -- e.g., to link the word
488"Google" to the google.com web site, you could simply write:</p>
489<pre><code>[Google][]
490</code></pre>
491<p>And then define the link:</p>
492<pre><code>[Google]: http://google.com/
493</code></pre>
494<p>Because link names may contain spaces, this shortcut even works for
495multiple words in the link text:</p>
496<pre><code>Visit [Daring Fireball][] for more information.
497</code></pre>
498<p>And then define the link:</p>
499<pre><code>[Daring Fireball]: http://daringfireball.net/
500</code></pre>
501<p>Link definitions can be placed anywhere in your Markdown document. I
502tend to put them immediately after each paragraph in which they're
503used, but if you want, you can put them all at the end of your
504document, sort of like footnotes.</p>
505<p>Here's an example of reference links in action:</p>
506<pre><code>I get 10 times more traffic from [Google] [1] than from
507[Yahoo] [2] or [MSN] [3].
508
509 [1]: http://google.com/ "Google"
510 [2]: http://search.yahoo.com/ "Yahoo Search"
511 [3]: http://search.msn.com/ "MSN Search"
512</code></pre>
513<p>Using the implicit link name shortcut, you could instead write:</p>
514<pre><code>I get 10 times more traffic from [Google][] than from
515[Yahoo][] or [MSN][].
516
517 [google]: http://google.com/ "Google"
518 [yahoo]: http://search.yahoo.com/ "Yahoo Search"
519 [msn]: http://search.msn.com/ "MSN Search"
520</code></pre>
521<p>Both of the above examples will produce the following HTML output:</p>
522<pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
523title="Google"&gt;Google&lt;/a&gt; than from
524&lt;a href="http://search.yahoo.com/" title="Yahoo Search"&gt;Yahoo&lt;/a&gt;
525or &lt;a href="http://search.msn.com/" title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
526</code></pre>
527<p>For comparison, here is the same paragraph written using
528Markdown's inline link style:</p>
529<pre><code>I get 10 times more traffic from [Google](http://google.com/ "Google")
530than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
531[MSN](http://search.msn.com/ "MSN Search").
532</code></pre>
533<p>The point of reference-style links is not that they're easier to
534write. The point is that with reference-style links, your document
535source is vastly more readable. Compare the above examples: using
536reference-style links, the paragraph itself is only 81 characters
537long; with inline-style links, it's 176 characters; and as raw HTML,
538it's 234 characters. In the raw HTML, there's more markup than there
539is text.</p>
540<p>With Markdown's reference-style links, a source document much more
541closely resembles the final output, as rendered in a browser. By
542allowing you to move the markup-related metadata out of the paragraph,
543you can add links without interrupting the narrative flow of your
544prose.</p>
545<h2 id="emphasis">Emphasis</h2>
546<p>Markdown treats asterisks (<code>*</code>) and underscores (<code>_</code>) as indicators of
547emphasis. Text wrapped with one <code>*</code> or <code>_</code> will be wrapped with an
548HTML <code>&lt;em&gt;</code> tag; double <code>*</code>'s or <code>_</code>'s will be wrapped with an HTML
549<code>&lt;strong&gt;</code> tag. E.g., this input:</p>
550<pre><code>*single asterisks*
551
552_single underscores_
553
554**double asterisks**
555
556__double underscores__
557</code></pre>
558<p>will produce:</p>
559<pre><code>&lt;em&gt;single asterisks&lt;/em&gt;
560
561&lt;em&gt;single underscores&lt;/em&gt;
562
563&lt;strong&gt;double asterisks&lt;/strong&gt;
564
565&lt;strong&gt;double underscores&lt;/strong&gt;
566</code></pre>
567<p>You can use whichever style you prefer; the lone restriction is that
568the same character must be used to open and close an emphasis span.</p>
569<p>Emphasis can be used in the middle of a word:</p>
570<pre><code>un*fucking*believable
571</code></pre>
572<p>But if you surround an <code>*</code> or <code>_</code> with spaces, it'll be treated as a
573literal asterisk or underscore.</p>
574<p>To produce a literal asterisk or underscore at a position where it
575would otherwise be used as an emphasis delimiter, you can backslash
576escape it:</p>
577<pre><code>\*this text is surrounded by literal asterisks\*
578</code></pre>
579<h2 id="code">Code</h2>
580<p>To indicate a span of code, wrap it with backtick quotes (<code>`</code>).
581Unlike a pre-formatted code block, a code span indicates code within a
582normal paragraph. For example:</p>
583<pre><code>Use the `printf()` function.
584</code></pre>
585<p>will produce:</p>
586<pre><code>&lt;p&gt;Use the &lt;code&gt;printf()&lt;/code&gt; function.&lt;/p&gt;
587</code></pre>
588<p>To include a literal backtick character within a code span, you can use
589multiple backticks as the opening and closing delimiters:</p>
590<pre><code>``There is a literal backtick (`) here.``
591</code></pre>
592<p>which will produce this:</p>
593<pre><code>&lt;p&gt;&lt;code&gt;There is a literal backtick (`) here.&lt;/code&gt;&lt;/p&gt;
594</code></pre>
595<p>The backtick delimiters surrounding a code span may include spaces --
596one after the opening, one before the closing. This allows you to place
597literal backtick characters at the beginning or end of a code span:</p>
598<pre><code>A single backtick in a code span: `` ` ``
599
600A backtick-delimited string in a code span: `` `foo` ``
601</code></pre>
602<p>will produce:</p>
603<pre><code>&lt;p&gt;A single backtick in a code span: &lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
604
605&lt;p&gt;A backtick-delimited string in a code span: &lt;code&gt;`foo`&lt;/code&gt;&lt;/p&gt;
606</code></pre>
607<p>With a code span, ampersands and angle brackets are encoded as HTML
608entities automatically, which makes it easy to include example HTML
609tags. Markdown will turn this:</p>
610<pre><code>Please don't use any `&lt;blink&gt;` tags.
611</code></pre>
612<p>into:</p>
613<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;
614</code></pre>
615<p>You can write this:</p>
616<pre><code>`&amp;#8212;` is the decimal-encoded equivalent of `&amp;mdash;`.
617</code></pre>
618<p>to produce:</p>
619<pre><code>&lt;p&gt;&lt;code&gt;&amp;amp;#8212;&lt;/code&gt; is the decimal-encoded
620equivalent of &lt;code&gt;&amp;amp;mdash;&lt;/code&gt;.&lt;/p&gt;
621</code></pre>
622<h2 id="images">Images</h2>
623<p>Admittedly, it's fairly difficult to devise a "natural" syntax for
624placing images into a plain text document format.</p>
625<p>Markdown uses an image syntax that is intended to resemble the syntax
626for links, allowing for two styles: <em>inline</em> and <em>reference</em>.</p>
627<p>Inline image syntax looks like this:</p>
628<pre><code>![Alt text](/path/to/img.jpg)
629
630![Alt text](/path/to/img.jpg "Optional title")
631</code></pre>
632<p>That is:</p>
633<ul>
634<li>An exclamation mark: <code>!</code>;</li>
635<li>followed by a set of square brackets, containing the <code>alt</code>
636 attribute text for the image;</li>
637<li>followed by a set of parentheses, containing the URL or path to
638 the image, and an optional <code>title</code> attribute enclosed in double
639 or single quotes.</li>
640</ul>
641<p>Reference-style image syntax looks like this:</p>
642<pre><code>![Alt text][id]
643</code></pre>
644<p>Where "id" is the name of a defined image reference. Image references
645are defined using syntax identical to link references:</p>
646<pre><code>[id]: url/to/image "Optional title attribute"
647</code></pre>
648<p>As of this writing, Markdown has no syntax for specifying the
649dimensions of an image; if this is important to you, you can simply
650use regular HTML <code>&lt;img&gt;</code> tags.</p>
651<hr />
652<h1 id="miscellaneous">Miscellaneous</h1>
653<h2 id="automatic-links">Automatic Links</h2>
654<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>
655<pre><code>&lt;http://example.com/&gt;
656</code></pre>
657<p>Markdown will turn this into:</p>
658<pre><code>&lt;a href="http://example.com/"&gt;http://example.com/&lt;/a&gt;
659</code></pre>
660<p>Automatic links for email addresses work similarly, except that
661Markdown will also perform a bit of randomized decimal and hex
662entity-encoding to help obscure your address from address-harvesting
663spambots. For example, Markdown will turn this:</p>
664<pre><code>&lt;address@example.com&gt;
665</code></pre>
666<p>into something like this:</p>
667<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;
668&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;
669&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;
670&amp;#109;&amp;#x70;&amp;#x6C;e&amp;#x2E;&amp;#99;&amp;#111;&amp;#109;&lt;/a&gt;
671</code></pre>
672<p>which will render in a browser as a clickable link to "address@example.com".</p>
673<p>(This sort of entity-encoding trick will indeed fool many, if not
674most, address-harvesting bots, but it definitely won't fool all of
675them. It's better than nothing, but an address published in this way
676will probably eventually start receiving spam.)</p>
677<h2 id="backslash-escapes">Backslash Escapes</h2>
678<p>Markdown allows you to use backslash escapes to generate literal
679characters which would otherwise have special meaning in Markdown's
680formatting syntax. For example, if you wanted to surround a word with
681literal asterisks (instead of an HTML <code>&lt;em&gt;</code> tag), you can backslashes
682before the asterisks, like this:</p>
683<pre><code>\*literal asterisks\*
684</code></pre>
685<p>Markdown provides backslash escapes for the following characters:</p>
686<pre><code>\ backslash
687` backtick
688* asterisk
689_ underscore
690{} curly braces
691[] square brackets
692() parentheses
693# hash mark
694+ plus sign
695- minus sign (hyphen)
696. dot
697! exclamation mark
698</code></pre>
  
1
2[TOC]
3
4# Overview
5
6## Philosophy
7
8Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
9
10Readability, however, is emphasized above all else. A Markdown-formatted
11document should be publishable as-is, as plain text, without looking
12like it's been marked up with tags or formatting instructions. While
13Markdown's syntax has been influenced by several existing text-to-HTML
14filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4],
15[Grutatext] [5], and [EtText] [6] -- the single biggest source of
16inspiration for Markdown's syntax is the format of plain text email.
17
18 [1]: http://docutils.sourceforge.net/mirror/setext.html
19 [2]: http://www.aaronsw.com/2002/atx/
20 [3]: http://textism.com/tools/textile/
21 [4]: http://docutils.sourceforge.net/rst.html
22 [5]: http://www.triptico.com/software/grutatxt.html
23 [6]: http://ettext.taint.org/doc/
24
25To this end, Markdown's syntax is comprised entirely of punctuation
26characters, which punctuation characters have been carefully chosen so
27as to look like what they mean. E.g., asterisks around a word actually
28look like \*emphasis\*. Markdown lists look like, well, lists. Even
29blockquotes look like quoted passages of text, assuming you've ever
30used email.
31
32
33
34## Inline HTML
35
36Markdown's syntax is intended for one purpose: to be used as a
37format for *writing* for the web.
38
39Markdown is not a replacement for HTML, or even close to it. Its
40syntax is very small, corresponding only to a very small subset of
41HTML tags. The idea is *not* to create a syntax that makes it easier
42to insert HTML tags. In my opinion, HTML tags are already easy to
43insert. The idea for Markdown is to make it easy to read, write, and
44edit prose. HTML is a *publishing* format; Markdown is a *writing*
45format. Thus, Markdown's formatting syntax only addresses issues that
46can be conveyed in plain text.
47
48For any markup that is not covered by Markdown's syntax, you simply
49use HTML itself. There's no need to preface it or delimit it to
50indicate that you're switching from Markdown to HTML; you just use
51the tags.
52
53The only restrictions are that block-level HTML elements -- e.g. `<div>`,
54`<table>`, `<pre>`, `<p>`, etc. -- must be separated from surrounding
55content by blank lines, and the start and end tags of the block should
56not be indented with tabs or spaces. Markdown is smart enough not
57to add extra (unwanted) `<p>` tags around HTML block-level tags.
58
59For example, to add an HTML table to a Markdown article:
60
61 This is a regular paragraph.
62
63 <table>
64 <tr>
65 <td>Foo</td>
66 </tr>
67 </table>
68
69 This is another regular paragraph.
70
71Note that Markdown formatting syntax is not processed within block-level
72HTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an
73HTML block.
74
75Span-level HTML tags -- e.g. `<span>`, `<cite>`, or `<del>` -- can be
76used anywhere in a Markdown paragraph, list item, or header. If you
77want, you can even use HTML tags instead of Markdown formatting; e.g. if
78you'd prefer to use HTML `<a>` or `<img>` tags instead of Markdown's
79link or image syntax, go right ahead.
80
81Unlike block-level HTML tags, Markdown syntax *is* processed within
82span-level tags.
83
84
85## Automatic Escaping for Special Characters
86
87In HTML, there are two characters that demand special treatment: `<`
88and `&`. Left angle brackets are used to start tags; ampersands are
89used to denote HTML entities. If you want to use them as literal
90characters, you must escape them as entities, e.g. `&lt;`, and
91`&amp;`.
92
93Ampersands in particular are bedeviling for web writers. If you want to
94write about 'AT&T', you need to write '`AT&amp;T`'. You even need to
95escape ampersands within URLs. Thus, if you want to link to:
96
97 http://images.google.com/images?num=30&q=larry+bird
98
99you need to encode the URL as:
100
101 http://images.google.com/images?num=30&amp;q=larry+bird
102
103in your anchor tag `href` 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.
106
107Markdown allows you to use these characters naturally, taking care of
108all the necessary escaping for you. If you use an ampersand as part of
109an HTML entity, it remains unchanged; otherwise it will be translated
110into `&amp;`.
111
112So, if you want to include a copyright symbol in your article, you can write:
113
114 &copy;
115
116and Markdown will leave it alone. But if you write:
117
118 AT&T
119
120Markdown will translate it to:
121
122 AT&amp;T
123
124Similarly, because Markdown supports [inline HTML](#html), if you use
125angle brackets as delimiters for HTML tags, Markdown will treat them as
126such. But if you write:
127
128 4 < 5
129
130Markdown will translate it to:
131
132 4 &lt; 5
133
134However, inside Markdown code spans and blocks, angle brackets and
135ampersands are *always* encoded automatically. This makes it easy to use
136Markdown to write about HTML code. (As opposed to raw HTML, which is a
137terrible format for writing about HTML syntax, because every single `<`
138and `&` in your example code needs to be escaped.)
139
140
141* * *
142
143
144# Block Elements
145
146
147## Paragraphs and Line Breaks
148
149A paragraph is simply one or more consecutive lines of text, separated
150by one or more blank lines. (A blank line is any line that looks like a
151blank line -- a line containing nothing but spaces or tabs is considered
152blank.) Normal paragraphs should not be intended with spaces or tabs.
153
154The implication of the "one or more consecutive lines of text" rule is
155that Markdown supports "hard-wrapped" text paragraphs. This differs
156significantly from most other text-to-HTML formatters (including Movable
157Type's "Convert Line Breaks" option) which translate every line break
158character in a paragraph into a `<br />` tag.
159
160When you *do* want to insert a `<br />` break tag using Markdown, you
161end a line with two or more spaces, then type return.
162
163Yes, this takes a tad more effort to create a `<br />`, but a simplistic
164"every line break is a `<br />`" rule wouldn't work for Markdown.
165Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l]
166work best -- and look better -- when you format them with hard breaks.
167
168 [bq]: #blockquote
169 [l]: #list
170
171
172
173## Headers
174
175Markdown supports two styles of headers, [Setext] [1] and [atx] [2].
176
177Setext-style headers are "underlined" using equal signs (for first-level
178headers) and dashes (for second-level headers). For example:
179
180 This is an H1
181 =============
182
183 This is an H2
184 -------------
185
186Any number of underlining `=`'s or `-`'s will work.
187
188Atx-style headers use 1-6 hash characters at the start of the line,
189corresponding to header levels 1-6. For example:
190
191 # This is an H1
192
193 ## This is an H2
194
195 ###### This is an H6
196
197Optionally, you may "close" atx-style headers. This is purely
198cosmetic -- you can use this if you think it looks better. The
199closing hashes don't even need to match the number of hashes
200used to open the header. (The number of opening hashes
201determines the header level.) :
202
203 # This is an H1 #
204
205 ## This is an H2 ##
206
207 ### This is an H3 ######
208
209
210## Blockquotes
211
212Markdown uses email-style `>` characters for blockquoting. If you're
213familiar with quoting passages of text in an email message, then you
214know how to create a blockquote in Markdown. It looks best if you hard
215wrap the text and put a `>` before every line:
216
217 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
218 > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
219 > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
220 >
221 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
222 > id sem consectetuer libero luctus adipiscing.
223
224Markdown allows you to be lazy and only put the `>` before the first
225line of a hard-wrapped paragraph:
226
227 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
228 consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
229 Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
230
231 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
232 id sem consectetuer libero luctus adipiscing.
233
234Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
235adding additional levels of `>`:
236
237 > This is the first level of quoting.
238 >
239 > > This is nested blockquote.
240 >
241 > Back to the first level.
242
243Blockquotes can contain other Markdown elements, including headers, lists,
244and code blocks:
245
246 > ## This is a header.
247 >
248 > 1. This is the first list item.
249 > 2. This is the second list item.
250 >
251 > Here's some example code:
252 >
253 > return shell_exec("echo $input | $markdown_script");
254
255Any decent text editor should make email-style quoting easy. For
256example, with BBEdit, you can make a selection and choose Increase
257Quote Level from the Text menu.
258
259
260## Lists
261
262Markdown supports ordered (numbered) and unordered (bulleted) lists.
263
264Unordered lists use asterisks, pluses, and hyphens -- interchangably
265
266 * Red
267 * Green
268 * Blue
269
270is equivalent to:
271
272 + Red
273 + Green
274 + Blue
275
276and:
277
278 - Red
279 - Green
280 - Blue
281
282Ordered lists use numbers followed by periods:
283
284 1. Bird
285 2. McHale
286 3. Parish
287
288It's important to note that the actual numbers you use to mark the
289list have no effect on the HTML output Markdown produces. The HTML
290Markdown produces from the above list is:
291
292 <ol>
293 <li>Bird</li>
294 <li>McHale</li>
295 <li>Parish</li>
296 </ol>
297
298If you instead wrote the list in Markdown like this:
299
300 1. Bird
301 1. McHale
302 1. Parish
303
304or even:
305
306 3. Bird
307 1. McHale
308 8. Parish
309
310you'd get the exact same HTML output. The point is, if you want to,
311you can use ordinal numbers in your ordered Markdown lists, so that
312the numbers in your source match the numbers in your published HTML.
313But if you want to be lazy, you don't have to.
314
315If you do use lazy list numbering, however, you should still start the
316list with the number 1. At some point in the future, Markdown may support
317starting ordered lists at an arbitrary number.
318
319List markers typically start at the left margin, but may be indented by
320up to three spaces. List markers must be followed by one or more spaces
321or a tab.
322
323To make lists look nice, you can wrap items with hanging indents:
324
325 * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
326 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
327 viverra nec, fringilla in, laoreet vitae, risus.
328 * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
329 Suspendisse id sem consectetuer libero luctus adipiscing.
330
331But if you want to be lazy, you don't have to:
332
333 * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
334 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
335 viverra nec, fringilla in, laoreet vitae, risus.
336 * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
337 Suspendisse id sem consectetuer libero luctus adipiscing.
338
339If list items are separated by blank lines, Markdown will wrap the
340items in `<p>` tags in the HTML output. For example, this input:
341
342 * Bird
343 * Magic
344
345will turn into:
346
347 <ul>
348 <li>Bird</li>
349 <li>Magic</li>
350 </ul>
351
352But this:
353
354 * Bird
355
356 * Magic
357
358will turn into:
359
360 <ul>
361 <li><p>Bird</p></li>
362 <li><p>Magic</p></li>
363 </ul>
364
365List items may consist of multiple paragraphs. Each subsequent
366paragraph in a list item must be intended by either 4 spaces
367or one tab:
368
369 1. This is a list item with two paragraphs. Lorem ipsum dolor
370 sit amet, consectetuer adipiscing elit. Aliquam hendrerit
371 mi posuere lectus.
372
373 Vestibulum enim wisi, viverra nec, fringilla in, laoreet
374 vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
375 sit amet velit.
376
377 2. Suspendisse id sem consectetuer libero luctus adipiscing.
378
379It looks nice if you indent every line of the subsequent
380paragraphs, but here again, Markdown will allow you to be
381lazy:
382
383 * This is a list item with two paragraphs.
384
385 This is the second paragraph in the list item. You're
386 only required to indent the first line. Lorem ipsum dolor
387 sit amet, consectetuer adipiscing elit.
388
389 * Another item in the same list.
390
391To put a blockquote within a list item, the blockquote's `>`
392delimiters need to be indented:
393
394 * A list item with a blockquote:
395
396 > This is a blockquote
397 > inside a list item.
398
399To put a code block within a list item, the code block needs
400to be indented *twice* -- 8 spaces or two tabs:
401
402 * A list item with a code block:
403
404 <code goes here>
405
406
407It's worth noting that it's possible to trigger an ordered list by
408accident, by writing something like this:
409
410 1986. What a great season.
411
412In other words, a *number-period-space* sequence at the beginning of a
413line. To avoid this, you can backslash-escape the period:
414
415 1986\. What a great season.
416
417
418
419## Code Blocks
420
421Pre-formatted code blocks are used for writing about programming or
422markup source code. Rather than forming normal paragraphs, the lines
423of a code block are interpreted literally. Markdown wraps a code block
424in both `<pre>` and `<code>` tags.
425
426To produce a code block in Markdown, simply indent every line of the
427block by at least 4 spaces or 1 tab. For example, given this input:
428
429 This is a normal paragraph:
430
431 This is a code block.
432
433Markdown will generate:
434
435 <p>This is a normal paragraph:</p>
436
437 <pre><code>This is a code block.
438 </code></pre>
439
440One level of indentation -- 4 spaces or 1 tab -- is removed from each
441line of the code block. For example, this:
442
443 Here is an example of AppleScript:
444
445 tell application "Foo"
446 beep
447 end tell
448
449will turn into:
450
451 <p>Here is an example of AppleScript:</p>
452
453 <pre><code>tell application "Foo"
454 beep
455 end tell
456 </code></pre>
457
458A code block continues until it reaches a line that is not indented
459(or the end of the article).
460
461Within a code block, ampersands (`&`) and angle brackets (`<` and `>`)
462are automatically converted into HTML entities. This makes it very
463easy to include example HTML source code using Markdown -- just paste
464it and indent it, and Markdown will handle the hassle of encoding the
465ampersands and angle brackets. For example, this:
466
467 <div class="footer">
468 &copy; 2004 Foo Corporation
469 </div>
470
471will turn into:
472
473 <pre><code>&lt;div class="footer"&gt;
474 &amp;copy; 2004 Foo Corporation
475 &lt;/div&gt;
476 </code></pre>
477
478Regular Markdown syntax is not processed within code blocks. E.g.,
479asterisks are just literal asterisks within a code block. This means
480it's also easy to use Markdown to write about Markdown's own syntax.
481
482
483
484## Horizontal Rules
485
486You can produce a horizontal rule tag (`<hr />`) by placing three or
487more hyphens, asterisks, or underscores on a line by themselves. If you
488wish, you may use spaces between the hyphens or asterisks. Each of the
489following lines will produce a horizontal rule:
490
491 * * *
492
493 ***
494
495 *****
496
497 - - -
498
499 ---------------------------------------
500
501 _ _ _
502
503
504* * *
505
506# Span Elements
507
508## Links
509
510Markdown supports two style of links: *inline* and *reference*.
511
512In both styles, the link text is delimited by [square brackets].
513
514To create an inline link, use a set of regular parentheses immediately
515after the link text's closing square bracket. Inside the parentheses,
516put the URL where you want the link to point, along with an *optional*
517title for the link, surrounded in quotes. For example:
518
519 This is [an example](http://example.com/ "Title") inline link.
520
521 [This link](http://example.net/) has no title attribute.
522
523Will produce:
524
525 <p>This is <a href="http://example.com/" title="Title">
526 an example</a> inline link.</p>
527
528 <p><a href="http://example.net/">This link</a> has no
529 title attribute.</p>
530
531If you're referring to a local resource on the same server, you can
532use relative paths:
533
534 See my [About](/about/) page for details.
535
536Reference-style links use a second set of square brackets, inside
537which you place a label of your choosing to identify the link:
538
539 This is [an example][id] reference-style link.
540
541You can optionally use a space to separate the sets of brackets:
542
543 This is [an example] [id] reference-style link.
544
545Then, anywhere in the document, you define your link label like this,
546on a line by itself:
547
548 [id]: http://example.com/ "Optional Title Here"
549
550That is:
551
552* Square brackets containing the link identifier (optionally
553 indented from the left margin using up to three spaces);
554* followed by a colon;
555* followed by one or more spaces (or tabs);
556* followed by the URL for the link;
557* optionally followed by a title attribute for the link, enclosed
558 in double or single quotes.
559
560The link URL may, optionally, be surrounded by angle brackets:
561
562 [id]: <http://example.com/> "Optional Title Here"
563
564You can put the title attribute on the next line and use extra spaces
565or tabs for padding, which tends to look better with longer URLs:
566
567 [id]: http://example.com/longish/path/to/resource/here
568 "Optional Title Here"
569
570Link definitions are only used for creating links during Markdown
571processing, and are stripped from your document in the HTML output.
572
573Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are *not* case sensitive. E.g. these two links:
574
575 [link text][a]
576 [link text][A]
577
578are equivalent.
579
580The *implicit link name* shortcut allows you to omit the name of the
581link, in which case the link text itself is used as the name.
582Just use an empty set of square brackets -- e.g., to link the word
583"Google" to the google.com web site, you could simply write:
584
585 [Google][]
586
587And then define the link:
588
589 [Google]: http://google.com/
590
591Because link names may contain spaces, this shortcut even works for
592multiple words in the link text:
593
594 Visit [Daring Fireball][] for more information.
595
596And then define the link:
597
598 [Daring Fireball]: http://daringfireball.net/
599
600Link definitions can be placed anywhere in your Markdown document. I
601tend to put them immediately after each paragraph in which they're
602used, but if you want, you can put them all at the end of your
603document, sort of like footnotes.
604
605Here's an example of reference links in action:
606
607 I get 10 times more traffic from [Google] [1] than from
608 [Yahoo] [2] or [MSN] [3].
609
610 [1]: http://google.com/ "Google"
611 [2]: http://search.yahoo.com/ "Yahoo Search"
612 [3]: http://search.msn.com/ "MSN Search"
613
614Using the implicit link name shortcut, you could instead write:
615
616 I get 10 times more traffic from [Google][] than from
617 [Yahoo][] or [MSN][].
618
619 [google]: http://google.com/ "Google"
620 [yahoo]: http://search.yahoo.com/ "Yahoo Search"
621 [msn]: http://search.msn.com/ "MSN Search"
622
623Both of the above examples will produce the following HTML output:
624
625 <p>I get 10 times more traffic from <a href="http://google.com/"
626 title="Google">Google</a> than from
627 <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
628 or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
629
630For comparison, here is the same paragraph written using
631Markdown's inline link style:
632
633 I get 10 times more traffic from [Google](http://google.com/ "Google")
634 than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
635 [MSN](http://search.msn.com/ "MSN Search").
636
637The point of reference-style links is not that they're easier to
638write. The point is that with reference-style links, your document
639source is vastly more readable. Compare the above examples: using
640reference-style links, the paragraph itself is only 81 characters
641long; with inline-style links, it's 176 characters; and as raw HTML,
642it's 234 characters. In the raw HTML, there's more markup than there
643is text.
644
645With Markdown's reference-style links, a source document much more
646closely resembles the final output, as rendered in a browser. By
647allowing you to move the markup-related metadata out of the paragraph,
648you can add links without interrupting the narrative flow of your
649prose.
650
651
652## Emphasis
653
654Markdown treats asterisks (`*`) and underscores (`_`) as indicators of
655emphasis. Text wrapped with one `*` or `_` will be wrapped with an
656HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML
657`<strong>` tag. E.g., this input:
658
659 *single asterisks*
660
661 _single underscores_
662
663 **double asterisks**
664
665 __double underscores__
666
667will produce:
668
669 <em>single asterisks</em>
670
671 <em>single underscores</em>
672
673 <strong>double asterisks</strong>
674
675 <strong>double underscores</strong>
676
677You can use whichever style you prefer; the lone restriction is that
678the same character must be used to open and close an emphasis span.
679
680Emphasis can be used in the middle of a word:
681
682 un*fucking*believable
683
684But if you surround an `*` or `_` with spaces, it'll be treated as a
685literal asterisk or underscore.
686
687To produce a literal asterisk or underscore at a position where it
688would otherwise be used as an emphasis delimiter, you can backslash
689escape it:
690
691 \*this text is surrounded by literal asterisks\*
692
693
694
695## Code
696
697To indicate a span of code, wrap it with backtick quotes (`` ` ``).
698Unlike a pre-formatted code block, a code span indicates code within a
699normal paragraph. For example:
700
701 Use the `printf()` function.
702
703will produce:
704
705 <p>Use the <code>printf()</code> function.</p>
706
707To include a literal backtick character within a code span, you can use
708multiple backticks as the opening and closing delimiters:
709
710 ``There is a literal backtick (`) here.``
711
712which will produce this:
713
714 <p><code>There is a literal backtick (`) here.</code></p>
715
716The backtick delimiters surrounding a code span may include spaces --
717one after the opening, one before the closing. This allows you to place
718literal backtick characters at the beginning or end of a code span:
719
720 A single backtick in a code span: `` ` ``
721
722 A backtick-delimited string in a code span: `` `foo` ``
723
724will produce:
725
726 <p>A single backtick in a code span: <code>`</code></p>
727
728 <p>A backtick-delimited string in a code span: <code>`foo`</code></p>
729
730With a code span, ampersands and angle brackets are encoded as HTML
731entities automatically, which makes it easy to include example HTML
732tags. Markdown will turn this:
733
734 Please don't use any `<blink>` tags.
735
736into:
737
738 <p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>
739
740You can write this:
741
742 `&#8212;` is the decimal-encoded equivalent of `&mdash;`.
743
744to produce:
745
746 <p><code>&amp;#8212;</code> is the decimal-encoded
747 equivalent of <code>&amp;mdash;</code>.</p>
748
749
750
751## Images
752
753Admittedly, it's fairly difficult to devise a "natural" syntax for
754placing images into a plain text document format.
755
756Markdown uses an image syntax that is intended to resemble the syntax
757for links, allowing for two styles: *inline* and *reference*.
758
759Inline image syntax looks like this:
760
761 ![Alt text](/path/to/img.jpg)
762
763 ![Alt text](/path/to/img.jpg "Optional title")
764
765That is:
766
767* An exclamation mark: `!`;
768* followed by a set of square brackets, containing the `alt`
769 attribute text for the image;
770* followed by a set of parentheses, containing the URL or path to
771 the image, and an optional `title` attribute enclosed in double
772 or single quotes.
773
774Reference-style image syntax looks like this:
775
776 ![Alt text][id]
777
778Where "id" is the name of a defined image reference. Image references
779are defined using syntax identical to link references:
780
781 [id]: url/to/image "Optional title attribute"
782
783As of this writing, Markdown has no syntax for specifying the
784dimensions of an image; if this is important to you, you can simply
785use regular HTML `<img>` tags.
786
787
788* * *
789
790
791# Miscellaneous
792
793## Automatic Links
794
795Markdown 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:
796
797 <http://example.com/>
798
799Markdown will turn this into:
800
801 <a href="http://example.com/">http://example.com/</a>
802
803Automatic links for email addresses work similarly, except that
804Markdown will also perform a bit of randomized decimal and hex
805entity-encoding to help obscure your address from address-harvesting
806spambots. For example, Markdown will turn this:
807
808 <address@example.com>
809
810into something like this:
811
812 <a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;
813 &#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;
814 &#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
815 &#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
816
817which will render in a browser as a clickable link to "address@example.com".
818
819(This sort of entity-encoding trick will indeed fool many, if not
820most, address-harvesting bots, but it definitely won't fool all of
821them. It's better than nothing, but an address published in this way
822will probably eventually start receiving spam.)
823
824
825
826## Backslash Escapes
827
828Markdown allows you to use backslash escapes to generate literal
829characters which would otherwise have special meaning in Markdown's
830formatting syntax. For example, if you wanted to surround a word with
831literal asterisks (instead of an HTML `<em>` tag), you can backslashes
832before the asterisks, like this:
833
834 \*literal asterisks\*
835
836Markdown provides backslash escapes for the following characters:
837
838 \ backslash
839 ` backtick
840 * asterisk
841 _ underscore
842 {} curly braces
843 [] square brackets
844 () parentheses
845 # hash mark
846 + plus sign
847 - minus sign (hyphen)
848 . dot
849 ! exclamation mark
  
1<h2 id="toc">[TOC]</h2>
2<h1 id="header-1">Header 1</h1>
3<p>The TOC marker cannot be inside a header. This test makes sure markdown doesn't
4crash when it encounters this errant syntax. The unexpected output should
5clue the author in that s/he needs to add a blank line between the TOC and
6the <code>&lt;hr&gt;</code>.</p>
  
1[TOC]
2-----
3
4# Header 1
5
6The TOC marker cannot be inside a header. This test makes sure markdown doesn't
7crash when it encounters this errant syntax. The unexpected output should
8clue the author in that s/he needs to add a blank line between the TOC and
9the `<hr>`.
  
1<h1 id="header-a">Header A</h1>
2<h2 id="header-1">Header 1</h2>
3<h3 id="header-i">Header i</h3>
4<h1 id="header-b">Header B</h1>
5<div class="toc">
6<ul>
7<li><a href="#header-a">Header A</a><ul>
8<li><a href="#header-1">Header 1</a><ul>
9<li><a href="#header-i">Header i</a></li>
10</ul>
11</li>
12</ul>
13</li>
14<li><a href="#header-b">Header B</a></li>
15</ul>
16</div>
  
1# Header A
2
3## Header 1
4
5### Header i
6
7# Header B
8
9[TOC]
  
1<div class="toc">
2<ul>
3<li><a href="#start-with-header-other-than-one">Start with header other than one.</a></li>
4<li><a href="#header-3">Header 3</a><ul>
5<li><a href="#header-4">Header 4</a></li>
6</ul>
7</li>
8<li><a href="#header-3_1">Header 3</a></li>
9</ul>
10</div>
11<h3 id="start-with-header-other-than-one">Start with header other than one.</h3>
12<h3 id="header-3">Header 3</h3>
13<h4 id="header-4">Header 4</h4>
14<h3 id="header-3_1">Header 3</h3>
  
1[TOC]
2
3### Start with header other than one.
4
5### Header 3
6
7#### Header 4
8
9### Header 3
  
1<p>Some text with a <a class="wikilink" href="/WikiLink/">WikiLink</a>.</p>
2<p>A link with <a class="wikilink" href="/white_space_and_underscores/">white space and_underscores</a> and a empty one.</p>
3<p>Another with <a class="wikilink" href="/double_spaces/">double spaces</a> and <a class="wikilink" href="/double__underscores/">double__underscores</a> and
4one that <a class="wikilink" href="/has_emphasis_inside/">has <em>emphasis</em> inside</a> and one <a class="wikilink" href="/with_multiple_underscores/">with_multiple_underscores</a>
5and one that is <em><a class="wikilink" href="/emphasised/">emphasised</a></em>.</p>
6<p>And a <a href="http://example.com/RealLink">RealLink</a>.</p>
7<p><a href="http://example.com/And_A_AutoLink">http://example.com/And_A_AutoLink</a></p>
8<p>And a <a href="/MarkdownLink/" title="A MarkdownLink">MarkdownLink</a> for
9completeness.</p>
  
1Some text with a [[WikiLink]].
2
3A link with [[ white space and_underscores ]] and a empty [[ ]] one.
4
5Another with [[double spaces]] and [[double__underscores]] and
6one that [[has _emphasis_ inside]] and one [[with_multiple_underscores]]
7and one that is _[[emphasised]]_.
8
9And a <a href="http://example.com/RealLink">RealLink</a>.
10
11<http://example.com/And_A_AutoLink>
12
13And a [MarkdownLink](/MarkdownLink/ "A MarkdownLink") for
14completeness.
  
1<p>A test of the most<br>
2basic of html/xhtml differences.</p>
  
1A test of the most
2basic of html/xhtml differences.
  
1[DEFAULT]
2output_format=html4
  
1<p>foo</p>
2<div>
3bar
4</div>
  
1foo
2
3<div>
4bar
5</div>
  
1<h1>this is a huge header</h1>
2<h2>this is a smaller header</h2>
  
1# this is a huge header #
2## this is a smaller header ##
  
1<p><a href="http://www.freewisdom.org/this&amp;that">link</a></p>
  
1[link](http://www.freewisdom.org/this&that)
  
1<p>&amp;</p>
2<p>AT&amp;T</p>
  
1<h1>بايثون</h1>
2<p><strong>بايثون</strong> لغة برمجة حديثة بسيطة، واضحة، سريعة ، تستخدم أسلوب البرمجة الكائنية (OOP) وقابلة للتطوير بالإضافة إلى أنها مجانية و مفتوحة المصدر. صُنفت بالأساس كلغة تفسيرية ، بايثون مصممة أصلاً للأداء بعض المهام الخاصة أو المحدودة. إلا أنه يمكن استخدامها بايثون لإنجاز المشاريع الضخمه كأي لغة برمجية أخرى، غالباً ما يُنصح المبتدئين في ميدان البرمجة بتعلم هذه اللغة لأنها من بين أسهل اللغات البرمجية تعلماً.</p>
3<p>نشأت بايثون في مركز CWI (مركز العلوم والحاسب الآلي) بأمستردام على يد جويدو فان رُزوم. تم تطويرها بلغة C. أطلق فان رُزوم اسم "بايثون" على لغته تعبيرًا عن إعجابه بفِرقَة مسرحية هزلية شهيرة من بريطانيا، كانت تطلق على نفسها اسم مونتي بايثون Monty Python.</p>
4<p>تتميز بايثون بمجتمعها النشط ، كما أن لها الكثير من المكتبات البرمجية ذات الأغراض الخاصة والتي برمجها أشخاص من مجتمع هذه اللغة ، مثلاً مكتبة PyGame التي توفر مجموعه من الوظائف من اجل برمجة الالعاب. ويمكن لبايثون التعامل مع العديد من أنواع قواعد البيانات مثل MySQL وغيره.</p>
5<h2>أمثلة</h2>
6<p>مثال Hello World!</p>
7<pre><code>print "Hello World!"
8</code></pre>
9<p>مثال لاستخراج المضروب Factorial :</p>
10<pre><code>num = 1
11x = raw_input('Insert the number please ')
12x = int(x)
13
14if x &gt; 69:
15 print 'Math Error !'
16else:
17 while x &gt; 1:
18 num *= x
19 x = x-1
20
21 print num
22</code></pre>
23<h2>وصلات خارجية</h2>
24<ul>
25<li><a href="http://www.python.org">الموقع الرسمي للغة بايثون</a></li>
26</ul>
27<p>بذرة حاس </p>
  
1
2بايثون
3=====
4
5**بايثون** لغة برمجة حديثة بسيطة، واضحة، سريعة ، تستخدم أسلوب البرمجة الكائنية (OOP) وقابلة للتطوير بالإضافة إلى أنها مجانية و مفتوحة المصدر. صُنفت بالأساس كلغة تفسيرية ، بايثون مصممة أصلاً للأداء بعض المهام الخاصة أو المحدودة. إلا أنه يمكن استخدامها بايثون لإنجاز المشاريع الضخمه كأي لغة برمجية أخرى، غالباً ما يُنصح المبتدئين في ميدان البرمجة بتعلم هذه اللغة لأنها من بين أسهل اللغات البرمجية تعلماً.
6
7نشأت بايثون في مركز CWI (مركز العلوم والحاسب الآلي) بأمستردام على يد جويدو فان رُزوم. تم تطويرها بلغة C. أطلق فان رُزوم اسم "بايثون" على لغته تعبيرًا عن إعجابه بفِرقَة مسرحية هزلية شهيرة من بريطانيا، كانت تطلق على نفسها اسم مونتي بايثون Monty Python.
8
9تتميز بايثون بمجتمعها النشط ، كما أن لها الكثير من المكتبات البرمجية ذات الأغراض الخاصة والتي برمجها أشخاص من مجتمع هذه اللغة ، مثلاً مكتبة PyGame التي توفر مجموعه من الوظائف من اجل برمجة الالعاب. ويمكن لبايثون التعامل مع العديد من أنواع قواعد البيانات مثل MySQL وغيره.
10
11##أمثلة
12مثال Hello World!
13
14 print "Hello World!"
15
16
17مثال لاستخراج المضروب Factorial :
18
19 num = 1
20 x = raw_input('Insert the number please ')
21 x = int(x)
22
23 if x > 69:
24 print 'Math Error !'
25 else:
26 while x > 1:
27 num *= x
28 x = x-1
29
30 print num
31
32
33
34##وصلات خارجية
35* [الموقع الرسمي للغة بايثون](http://www.python.org)
36
37 بذرة حاس
  
1<p id="TABLE.OF.CONTENTS" />
2<ul>
3<li id="TABLEOFCONTENTS" />
4</ul>
5<p id="TABLEOFCONTENTS">Or in the middle of the text </p>
6<p id="tableofcontents" />
  
1{@id=TABLE.OF.CONTENTS}
2
3
4* {@id=TABLEOFCONTENTS}
5
6
7Or in the middle of the text {@id=TABLEOFCONTENTS}
8
9{@id=tableofcontents}
  
1<p><a href="http://some.site/weird*url*thing">http://some.site/weird*url*thing</a></p>
  
1<http://some.site/weird*url*thing>
  
1<p><a href="http://some.site/нечто*очень*странное">http://some.site/нечто*очень*странное</a></p>
  
1<http://some.site/нечто*очень*странное>
  
1<p>\`This should not be in code.\`
2`This also should not be in code.`
3`And finally this should not be in code.`</p>
  
1\\`This should not be in code.\\`
2\`This also should not be in code.\`
3\`And finally this should not be in code.`
  
1construction:0.000000:0.000000
2CRLF_line_ends:0.020000:0.000000
3adjacent-headers:0.020000:0.000000
4amp-in-url:0.020000:0.000000
5ampersand:0.010000:0.000000
6arabic:0.110000:0.000000
7attributes2:0.020000:0.000000
8bidi:0.310000:0.000000
9blank-block-quote:0.010000:0.000000
10blockquote:0.090000:0.000000
11blockquote-hr:0.060000:0.000000
12bold_links:0.020000:0.000000
13br:0.040000:0.000000
14bracket_re:7.490000:0.000000
15code-first-line:0.020000:0.000000
16comments:0.040000:0.000000
17div:0.040000:0.000000
18email:0.030000:0.000000
19funky-list:0.060000:0.000000
20h1:0.040000:0.000000
21hash:0.040000:0.000000
22headers:0.060000:0.000000
23hline:0.020000:0.000000
24html:0.090000:0.000000
25image:0.040000:0.000000
26image-2:0.060000:0.000000
27image_in_links:0.060000:0.000000
28inside_html:0.040000:0.000000
29japanese:0.150000:0.000000
30lazy-block-quote:0.050000:0.000000
31lists:0.110000:0.000000
32lists2:0.040000:0.000000
33lists3:0.040000:0.000000
34lists4:0.050000:0.000000
35lists5:0.070000:0.000000
36markup-inside-p:0.080000:0.000000
37mismatched-tags:0.070000:0.000000
38more_comments:0.060000:0.000000
39multi-line-tags:0.080000:0.000000
40multi-paragraph-block-quote:0.070000:0.000000
41multi-test:0.150000:0.000000
42multiline-comments:0.090000:0.000000
43normalize:0.060000:0.000000
44numeric-entity:0.090000:0.000000
45php:0.080000:0.000000
46pre:0.080000:0.000000
47russian:0.200000:0.000000
48some-test:0.200000:0.000000
49span:0.140000:0.000000
50strong-with-underscores:0.090000:0.000000
51stronintags:0.160000:0.000000
52tabs-in-lists:0.170000:0.000000
53two-spaces:0.160000:0.000000
54uche:0.150000:0.000000
55underscores:0.120000:0.000000
56url_spaces:0.120000:0.000000
  
1<p><strong>Python</strong>(パイソン)は、<a href="http://en.wikipedia.org/wiki/Guido_van_Rossum">Guido van Rossum</a> によって作られたオープンソースのオブジェクト指向スクリプト言語。<a href="http://ja.wikipedia.org/wiki/Perl">Perl</a>とともに欧米で広く普及している。イギリスのテレビ局 BBC が製作したコメディ番組『空飛ぶモンティ・パイソン』にちなんで名付けられた。 (Pythonには、爬虫類のニシキヘビの意味があり、Python言語のマスコットやアイコンとして使われることがある。)</p>
2<p>|||||||||||||||||||||||||||||THIS SHOULD BE LTR|||||||||||||||||||||||||</p>
3<p dir="rtl">|||||||||||||||||||||||||||||THIS SHOULD BE RTL||||||||||||||||||||||||| </p>
4<p dir="ltr">(<strong>بايثون</strong> لغة برمجة حديثة بسيطة، واضحة، سريعة ، تستخدم أسلوب البرمجة الكائنية (THIS SHOULD BE LTR ) وقابلة للتطوير بالإضافة إلى أنها مجانية و مفتوح </p>
5<p>پایتون زبان برنامه‌نویسی تفسیری و سطح بالا ، شی‌گرا و یک زبان برنامه‌نویسی تفسیری سمت سرور قدرتمند است که توسط گیدو ون روسوم در سال ۱۹۹۰ ساخته شد. این زبان در ویژگی‌ها شبیه پرل، روبی، اسکیم، اسمال‌تاک و تی‌سی‌ال است و از مدیریت خودکار حافظه استفاده می‌کند</p>
6<p>Python,是一种面向对象的、直譯式的计算机程序设计语言,也是一种功能强大而完善的通用型语言,已经具有十多年的发展历史,成熟且稳定。</p>
7<p>ބްލޫ ވޭލްގެ ދޫ މަތީގައި އެއްފަހަރާ 50 މީހުންނަށް ތިބެވިދާނެވެ. ބޮޑު މަހުގެ ދުލަކީ އެހާމެ ބޮޑު އެއްޗެކެވެ.</p>
8<p><strong>உருது</strong> 13ஆம் நூற்றாண்டில் உருவான ஒரு இந்தோ-ஐரோப்பிய மொழியாகும். உருது, ஹிந்தியுடன் சேர்த்து "ஹிந்துஸ்தானி" என அழைக்கப்படுகின்றது. மண்டரின், ஆங்கிலம் ஆகியவற்றுக்கு அடுத்தபடியாக மூன்றாவது கூடிய அளவு மக்களால் புரிந்து கொள்ளப்படக்கூடியது ஹிந்துஸ்தானியேயாகும். தாய் மொழியாகப் பேசுபவர்கள் எண்ணிக்கையின் அடிப்படையில் உருது உலகின் 20 ஆவது பெரிய மொழியாகும். 6 கோடி மக்கள் இதனைத் தாய் மொழியாகக் கொண்டுள்ளார்கள். இரண்டாவது மொழியாகக் கொண்டுள்ளவர்கள் உட்பட 11 கோடிப் பேர் இதனைப் பேசுகிறார்கள். உருது பாகிஸ்தானின் அரசகரும மொழியாகவும், இந்தியாவின் அரசகரும மொழிகளுள் ஒன்றாகவும் விளங்குகிறது.</p>
9<p>اردو ہندوآریائی زبانوں کی ہندويورپی شاخ کی ایک زبان ہے جو تيرھويں صدی ميں بر صغير ميں پيدا ہوئی ـ اردو پاکستان کی سرکاری زبان ہے اور بھارت کی سرکاری زبانوں ميں سے ايک ہے۔ اردو بھارت ميں 5 کروڑ اور پاکستان ميں 1 کروڑ لوگوں کی مادری زبان ہے مگر اسے بھارت اور پاکستان کے تقریباً 50 کروڑ لوگ بول اور سمجھ سکتے ھیں ۔ جن میں سے تقریباً 10.5 کروڑ لوگ اسے باقاعدہ بولتے ھیں۔</p>
10<h1>بايثون</h1>
11<p><strong>بايثون</strong> لغة برمجة حديثة بسيطة، واضحة، سريعة ، تستخدم أسلوب البرمجة الكائنية (OOP) وقابلة للتطوير بالإضافة إلى أنها مجانية و مفتوحة المصدر. صُنفت بالأساس كلغة تفسيرية ، بايثون مصممة أصلاً للأداء بعض المهام الخاصة أو المحدودة. إلا أنه يمكن استخدامها بايثون لإنجاز المشاريع الضخمه كأي لغة برمجية أخرى، غالباً ما يُنصح المبتدئين في ميدان البرمجة بتعلم هذه اللغة لأنها من بين أسهل اللغات البرمجية تعلماً.</p>
12<p>|||||||||||||||||||||||||||||THIS SHOULD BE RTL|||||||||||||||||||||||||</p>
13<p>(نشأت بايثون في مركز CWI (مركز العلوم والحاسب الآلي) بأمستردام على يد جويدو فان رُزوم. تم تطويرها بلغة C. أطلق فان رُزوم اسم "بايثون" على لغته تعبيرًا عن إعجابه بفِرقَة مسرحية هزلية شهيرة من بريطانيا، كانت تطلق على نفسها اسم مونتي بايثون Monty Python.</p>
14<p>تتميز بايثون بمجتمعها النشط ، كما أن لها الكثير من المكتبات البرمجية ذات الأغراض الخاصة والتي برمجها أشخاص من مجتمع هذه اللغة ، مثلاً مكتبة PyGame التي توفر مجموعه من الوظائف من اجل برمجة الالعاب. ويمكن لبايثون التعامل مع العديد من أنواع قواعد البيانات مثل MySQL وغيره.</p>
15<h2>أمثلة</h2>
16<p>مثال Hello World!</p>
17<pre><code>print "Hello World!"
18</code></pre>
19<p>مثال لاستخراج المضروب Factorial :</p>
20<pre><code>num = 1
21x = raw_input('Insert the number please ')
22x = int(x)
23
24if x &gt; 69:
25 print 'Math Error !'
26else:
27 while x &gt; 1:
28 num *= x
29 x = x-1
30
31 print num
32</code></pre>
33<h2>وصلات خارجية</h2>
34<ul>
35<li><a href="http://www.python.org">الموقع الرسمي للغة بايثون</a></li>
36</ul>
37<p>بذرة حاس </p>
38<p><strong>Недвард «Нед» Фландерс</strong> (Nedward «Ned» Flanders) — вымышленный персонаж мультсериала «[Симпсоны][]», озвученный Гарри Ширером. Он и его семья живут по соседству от семьи Симпсонов. Набожный христианин, Нед является одним из столпов морали Спрингфилда. В эпизоде «Alone Again, Natura-Diddily» он овдовел, его жена Мод погибла в результате несчастного случая. </p>
39<p>Нед был одним из первых персонажей в мультсериале, который не был членом семьи Симпсонов. Начиная с первых серий, он регулярно появляется в «Симпсонах». Считается, что Нед Фландерс был назван в честь улицы <em>Northeast Flanders St.</em> в <a href="http://www.portland.gov">Портленде</a>, Орегон, родном городе создателя мультсериала Мэтта Грейнинга]]. Надпись на указателе улицы <em>NE Flanders St.</em> хулиганы часто исправляли на <em>NED Flanders St.</em></p>
  
1**Python**(パイソン)は、[Guido van Rossum](http://en.wikipedia.org/wiki/Guido_van_Rossum) によって作られたオープンソースのオブジェクト指向スクリプト言語。[Perl](http://ja.wikipedia.org/wiki/Perl)とともに欧米で広く普及している。イギリスのテレビ局 BBC が製作したコメディ番組『空飛ぶモンティ・パイソン』にちなんで名付けられた。 (Pythonには、爬虫類のニシキヘビの意味があり、Python言語のマスコットやアイコンとして使われることがある。)
2
3|||||||||||||||||||||||||||||THIS SHOULD BE LTR|||||||||||||||||||||||||
4
5|||||||||||||||||||||||||||||THIS SHOULD BE RTL||||||||||||||||||||||||| {@dir=rtl}
6
7
8(**بايثون** لغة برمجة حديثة بسيطة، واضحة، سريعة ، تستخدم أسلوب البرمجة الكائنية (THIS SHOULD BE LTR ) وقابلة للتطوير {@dir=ltr} بالإضافة إلى أنها مجانية و مفتوح
9
10
11
12
13
14پایتون زبان برنامه‌نویسی تفسیری و سطح بالا ، شی‌گرا و یک زبان برنامه‌نویسی تفسیری سمت سرور قدرتمند است که توسط گیدو ون روسوم در سال ۱۹۹۰ ساخته شد. این زبان در ویژگی‌ها شبیه پرل، روبی، اسکیم، اسمال‌تاک و تی‌سی‌ال است و از مدیریت خودکار حافظه استفاده می‌کند
15
16Python,是一种面向对象的、直譯式的计算机程序设计语言,也是一种功能强大而完善的通用型语言,已经具有十多年的发展历史,成熟且稳定。
17
18ބްލޫ ވޭލްގެ ދޫ މަތީގައި އެއްފަހަރާ 50 މީހުންނަށް ތިބެވިދާނެވެ. ބޮޑު މަހުގެ ދުލަކީ އެހާމެ ބޮޑު އެއްޗެކެވެ.
19
20**உருது** 13ஆம் நூற்றாண்டில் உருவான ஒரு இந்தோ-ஐரோப்பிய மொழியாகும். உருது, ஹிந்தியுடன் சேர்த்து "ஹிந்துஸ்தானி" என அழைக்கப்படுகின்றது. மண்டரின், ஆங்கிலம் ஆகியவற்றுக்கு அடுத்தபடியாக மூன்றாவது கூடிய அளவு மக்களால் புரிந்து கொள்ளப்படக்கூடியது ஹிந்துஸ்தானியேயாகும். தாய் மொழியாகப் பேசுபவர்கள் எண்ணிக்கையின் அடிப்படையில் உருது உலகின் 20 ஆவது பெரிய மொழியாகும். 6 கோடி மக்கள் இதனைத் தாய் மொழியாகக் கொண்டுள்ளார்கள். இரண்டாவது மொழியாகக் கொண்டுள்ளவர்கள் உட்பட 11 கோடிப் பேர் இதனைப் பேசுகிறார்கள். உருது பாகிஸ்தானின் அரசகரும மொழியாகவும், இந்தியாவின் அரசகரும மொழிகளுள் ஒன்றாகவும் விளங்குகிறது.
21
22اردو ہندوآریائی زبانوں کی ہندويورپی شاخ کی ایک زبان ہے جو تيرھويں صدی ميں بر صغير ميں پيدا ہوئی ـ اردو پاکستان کی سرکاری زبان ہے اور بھارت کی سرکاری زبانوں ميں سے ايک ہے۔ اردو بھارت ميں 5 کروڑ اور پاکستان ميں 1 کروڑ لوگوں کی مادری زبان ہے مگر اسے بھارت اور پاکستان کے تقریباً 50 کروڑ لوگ بول اور سمجھ سکتے ھیں ۔ جن میں سے تقریباً 10.5 کروڑ لوگ اسے باقاعدہ بولتے ھیں۔
23
24بايثون
25=====
26
27**بايثون** لغة برمجة حديثة بسيطة، واضحة، سريعة ، تستخدم أسلوب البرمجة الكائنية (OOP) وقابلة للتطوير بالإضافة إلى أنها مجانية و مفتوحة المصدر. صُنفت بالأساس كلغة تفسيرية ، بايثون مصممة أصلاً للأداء بعض المهام الخاصة أو المحدودة. إلا أنه يمكن استخدامها بايثون لإنجاز المشاريع الضخمه كأي لغة برمجية أخرى، غالباً ما يُنصح المبتدئين في ميدان البرمجة بتعلم هذه اللغة لأنها من بين أسهل اللغات البرمجية تعلماً.
28
29|||||||||||||||||||||||||||||THIS SHOULD BE RTL|||||||||||||||||||||||||
30
31(نشأت بايثون في مركز CWI (مركز العلوم والحاسب الآلي) بأمستردام على يد جويدو فان رُزوم. تم تطويرها بلغة C. أطلق فان رُزوم اسم "بايثون" على لغته تعبيرًا عن إعجابه بفِرقَة مسرحية هزلية شهيرة من بريطانيا، كانت تطلق على نفسها اسم مونتي بايثون Monty Python.
32
33تتميز بايثون بمجتمعها النشط ، كما أن لها الكثير من المكتبات البرمجية ذات الأغراض الخاصة والتي برمجها أشخاص من مجتمع هذه اللغة ، مثلاً مكتبة PyGame التي توفر مجموعه من الوظائف من اجل برمجة الالعاب. ويمكن لبايثون التعامل مع العديد من أنواع قواعد البيانات مثل MySQL وغيره.
34
35##أمثلة
36مثال Hello World!
37
38 print "Hello World!"
39
40
41مثال لاستخراج المضروب Factorial :
42
43 num = 1
44 x = raw_input('Insert the number please ')
45 x = int(x)
46
47 if x > 69:
48 print 'Math Error !'
49 else:
50 while x > 1:
51 num *= x
52 x = x-1
53
54 print num
55
56
57
58##وصلات خارجية
59* [الموقع الرسمي للغة بايثون](http://www.python.org)
60
61 بذرة حاس
62
63
64**Недвард «Нед» Фландерс** (Nedward «Ned» Flanders) — вымышленный персонаж мультсериала «[Симпсоны][]», озвученный Гарри Ширером. Он и его семья живут по соседству от семьи Симпсонов. Набожный христианин, Нед является одним из столпов морали Спрингфилда. В эпизоде «Alone Again, Natura-Diddily» он овдовел, его жена Мод погибла в результате несчастного случая.
65
66Нед был одним из первых персонажей в мультсериале, который не был членом семьи Симпсонов. Начиная с первых серий, он регулярно появляется в «Симпсонах». Считается, что Нед Фландерс был назван в честь улицы *Northeast Flanders St.* в [Портленде](http://www.portland.gov), Орегон, родном городе создателя мультсериала Мэтта Грейнинга]]. Надпись на указателе улицы *NE Flanders St.* хулиганы часто исправляли на _NED Flanders St._
  
1<p>aaaaaaaaaaa</p>
2<blockquote />
3<p>bbbbbbbbbbb</p>
  
1
2aaaaaaaaaaa
3
4>
5
6bbbbbbbbbbb
  
1<p>Paragraph</p>
2<blockquote>
3<p>Block quote
4Yep</p>
5</blockquote>
6<p>Paragraph</p>
7<blockquote>
8<p>no space
9Nope</p>
10</blockquote>
11<p>Paragraph one</p>
12<blockquote>
13<p>blockquote
14More blockquote.</p>
15</blockquote>
  
1Paragraph
2> Block quote
3> Yep
4
5Paragraph
6>no space
7>Nope
8
9Paragraph one
10> blockquote
11More blockquote.
  
1<p>This is a paragraph.</p>
2<hr />
3<blockquote>
4<p>Block quote with horizontal lines.</p>
5<hr />
6<blockquote>
7<p>Double block quote.</p>
8<hr />
9<p>End of the double block quote.</p>
10</blockquote>
11<p>A new paragraph.
12With multiple lines.
13Even a lazy line.</p>
14<hr />
15<p>The last line.</p>
16</blockquote>
  
1This is a paragraph.
2
3---
4
5> Block quote with horizontal lines.
6
7> ---
8
9> > Double block quote.
10
11> > ---
12
13> > End of the double block quote.
14
15> A new paragraph.
16> With multiple lines.
17Even a lazy line.
18
19> ---
20
21> The last line.
  
1<blockquote>
2<p>blockquote with no whitespace before <code>&gt;</code>.</p>
3</blockquote>
4<p>foo</p>
5<blockquote>
6<p>blockquote with one space before the <code>&gt;</code>.</p>
7</blockquote>
8<p>bar</p>
9<blockquote>
10<p>blockquote with 2 spaces.</p>
11</blockquote>
12<p>baz</p>
13<blockquote>
14<p>this has three spaces so its a paragraph.</p>
15</blockquote>
16<p>blah</p>
17<pre><code>&gt; this one had four so it's a code block.
18</code></pre>
19<blockquote>
20<blockquote>
21<p>this nested blockquote has 0 on level one and 3 (one after the first <code>&gt;</code> + 2 more) on level 2.</p>
22<p>and this has 4 on level 2 - another code block.</p>
23</blockquote>
24</blockquote>
  
1> blockquote with no whitespace before `>`.
2
3foo
4
5 > blockquote with one space before the `>`.
6
7bar
8
9 > blockquote with 2 spaces.
10
11baz
12
13 > this has three spaces so its a paragraph.
14
15blah
16
17 > this one had four so it's a code block.
18
19> > this nested blockquote has 0 on level one and 3 (one after the first `>` + 2 more) on level 2.
20
21> > and this has 4 on level 2 - another code block.
  
1<p><strong>bold <a href="http://example.com">link</a></strong></p>
  
1**bold [link](http://example.com)**
  
1<p>Output:</p>
2<pre><code>&lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
3Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
4
5&lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
6Or, if you prefer, &lt;strong&gt;use two underscores instead&lt;/strong&gt;.&lt;/p&gt;
7</code></pre>
8<h2>Lists</h2>
9<p>Unordered (bulleted) lists use asterisks, pluses, and hyphens (<code>*</code>,
10<code>+</code>, and <code>-</code>) as list markers. These three markers are
11interchangable; this:</p>
  
1Output:
2
3 <p>Some of these words <em>are emphasized</em>.
4 Some of these words <em>are emphasized also</em>.</p>
5
6 <p>Use two asterisks for <strong>strong emphasis</strong>.
7 Or, if you prefer, <strong>use two underscores instead</strong>.</p>
8
9
10
11## Lists ##
12
13Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
14`+`, and `-`) as list markers. These three markers are
15interchangable; this:
  
1<p>[x
2xxx xxx xxx xxx xxx xxx xxx xxx
3xxx xxx xxx xxx xxx xxx xxx xxx
4xxx xxx xxx xxx xxx xxx xxx xxx
5xxx xxx xxx xxx xxx xxx xxx xxx
6xxx xxx xxx xxx xxx xxx xxx xxx
7xxx xxx xxx xxx xxx xxx xxx xxx
8xxx xxx xxx xxx xxx xxx xxx xxx
9xxx xxx xxx xxx xxx xxx xxx xxx
10xxx xxx xxx xxx xxx xxx xxx xxx
11xxx xxx xxx xxx xxx xxx xxx xxx
12xxx xxx xxx xxx xxx xxx xxx xxx
13xxx xxx xxx xxx xxx xxx xxx xxx
14xxx xxx xxx xxx xxx xxx xxx xxx
15xxx xxx xxx xxx xxx xxx xxx xxx
16xxx xxx xxx xxx xxx xxx xxx xxx
17xxx xxx xxx xxx xxx xxx xxx xxx
18xxx xxx xxx xxx xxx xxx xxx xxx
19xxx xxx xxx xxx xxx xxx xxx xxx
20xxx xxx xxx xxx xxx xxx xxx xxx
21xxx xxx xxx xxx xxx xxx xxx xxx
22xxx xxx xxx xxx xxx xxx xxx xxx
23xxx xxx xxx xxx xxx xxx xxx xxx
24xxx xxx xxx xxx xxx xxx xxx xxx
25xxx xxx xxx xxx xxx xxx xxx xxx
26xxx xxx xxx xxx xxx xxx xxx xxx
27xxx xxx xxx xxx xxx xxx xxx xxx
28xxx xxx xxx xxx xxx xxx xxx xxx
29xxx xxx xxx xxx xxx xxx xxx xxx
30xxx xxx xxx xxx xxx xxx xxx xxx
31xxx xxx xxx xxx xxx xxx xxx xxx
32xxx xxx xxx xxx xxx xxx xxx xxx
33xxx xxx xxx xxx xxx xxx xxx xxx
34xxx xxx xxx xxx xxx xxx xxx xxx
35xxx xxx xxx xxx xxx xxx xxx xxx
36xxx xxx xxx xxx xxx xxx xxx xxx
37xxx xxx xxx xxx xxx xxx xxx xxx
38xxx xxx xxx xxx xxx xxx xxx xxx
39xxx xxx xxx xxx xxx xxx xxx xxx
40xxx xxx xxx xxx xxx xxx xxx xxx
41xxx xxx xxx xxx xxx xxx xxx xxx
42xxx xxx xxx xxx xxx xxx xxx xxx
43xxx xxx xxx xxx xxx xxx xxx xxx
44xxx xxx xxx xxx xxx xxx xxx xxx
45xxx xxx xxx xxx xxx xxx xxx xxx
46xxx xxx xxx xxx xxx xxx xxx xxx
47xxx xxx xxx xxx xxx xxx xxx xxx
48xxx xxx xxx xxx xxx xxx xxx xxx
49xxx xxx xxx xxx xxx xxx xxx xxx
50xxx xxx xxx xxx xxx xxx xxx xxx
51xxx xxx xxx xxx xxx xxx xxx xxx
52xxx xxx xxx xxx xxx xxx xxx xxx
53xxx xxx xxx xxx xxx xxx xxx xxx
54xxx xxx xxx xxx xxx xxx xxx xxx
55xxx xxx xxx xxx xxx xxx xxx xxx
56xxx xxx xxx xxx xxx xxx xxx xxx
57xxx xxx xxx xxx xxx xxx xxx xxx
58xxx xxx xxx xxx xxx xxx xxx xxx
59xxx xxx xxx xxx xxx xxx xxx xxx
60xxx xxx xxx xxx xxx xxx xxx xxx</p>
  
1
2[x
3xxx xxx xxx xxx xxx xxx xxx xxx
4xxx xxx xxx xxx xxx xxx xxx xxx
5xxx xxx xxx xxx xxx xxx xxx xxx
6xxx xxx xxx xxx xxx xxx xxx xxx
7xxx xxx xxx xxx xxx xxx xxx xxx
8xxx xxx xxx xxx xxx xxx xxx xxx
9xxx xxx xxx xxx xxx xxx xxx xxx
10xxx xxx xxx xxx xxx xxx xxx xxx
11xxx xxx xxx xxx xxx xxx xxx xxx
12xxx xxx xxx xxx xxx xxx xxx xxx
13xxx xxx xxx xxx xxx xxx xxx xxx
14xxx xxx xxx xxx xxx xxx xxx xxx
15xxx xxx xxx xxx xxx xxx xxx xxx
16xxx xxx xxx xxx xxx xxx xxx xxx
17xxx xxx xxx xxx xxx xxx xxx xxx
18xxx xxx xxx xxx xxx xxx xxx xxx
19xxx xxx xxx xxx xxx xxx xxx xxx
20xxx xxx xxx xxx xxx xxx xxx xxx
21xxx xxx xxx xxx xxx xxx xxx xxx
22xxx xxx xxx xxx xxx xxx xxx xxx
23xxx xxx xxx xxx xxx xxx xxx xxx
24xxx xxx xxx xxx xxx xxx xxx xxx
25xxx xxx xxx xxx xxx xxx xxx xxx
26xxx xxx xxx xxx xxx xxx xxx xxx
27xxx xxx xxx xxx xxx xxx xxx xxx
28xxx xxx xxx xxx xxx xxx xxx xxx
29xxx xxx xxx xxx xxx xxx xxx xxx
30xxx xxx xxx xxx xxx xxx xxx xxx
31xxx xxx xxx xxx xxx xxx xxx xxx
32xxx xxx xxx xxx xxx xxx xxx xxx
33xxx xxx xxx xxx xxx xxx xxx xxx
34xxx xxx xxx xxx xxx xxx xxx xxx
35xxx xxx xxx xxx xxx xxx xxx xxx
36xxx xxx xxx xxx xxx xxx xxx xxx
37xxx xxx xxx xxx xxx xxx xxx xxx
38xxx xxx xxx xxx xxx xxx xxx xxx
39xxx xxx xxx xxx xxx xxx xxx xxx
40xxx xxx xxx xxx xxx xxx xxx xxx
41xxx xxx xxx xxx xxx xxx xxx xxx
42xxx xxx xxx xxx xxx xxx xxx xxx
43xxx xxx xxx xxx xxx xxx xxx xxx
44xxx xxx xxx xxx xxx xxx xxx xxx
45xxx xxx xxx xxx xxx xxx xxx xxx
46xxx xxx xxx xxx xxx xxx xxx xxx
47xxx xxx xxx xxx xxx xxx xxx xxx
48xxx xxx xxx xxx xxx xxx xxx xxx
49xxx xxx xxx xxx xxx xxx xxx xxx
50xxx xxx xxx xxx xxx xxx xxx xxx
51xxx xxx xxx xxx xxx xxx xxx xxx
52xxx xxx xxx xxx xxx xxx xxx xxx
53xxx xxx xxx xxx xxx xxx xxx xxx
54xxx xxx xxx xxx xxx xxx xxx xxx
55xxx xxx xxx xxx xxx xxx xxx xxx
56xxx xxx xxx xxx xxx xxx xxx xxx
57xxx xxx xxx xxx xxx xxx xxx xxx
58xxx xxx xxx xxx xxx xxx xxx xxx
59xxx xxx xxx xxx xxx xxx xxx xxx
60xxx xxx xxx xxx xxx xxx xxx xxx
61xxx xxx xxx xxx xxx xxx xxx xxx
  
1<pre><code>print "This is a code block."
2</code></pre>
  
1 print "This is a code block."
  
1<p>X&lt;0</p>
2<p>X&gt;0</p>
3<!-- A comment -->
4
5<div>as if</div>
  
1X<0
2
3X>0
4
5<!-- A comment -->
6
7<div>as if</div>
  
1<div id="sidebar">
2
3 _foo_
4
5</div>
  
1<div id="sidebar">
2
3 _foo_
4
5</div>
  
1<h1>Title</h1>
2<ul>
3<li><em><a href="http://www.freewisdom.org/projects/python-markdown/">Python in Markdown</a> by some
4 great folks</em> - This <em>does</em> work as expected.</li>
5<li><em><a href="http://www.freewisdom.org/projects/python-markdown/">Python in Markdown</a> by some
6 great folks</em> - This <em>does</em> work as expected.</li>
7<li><a href="http://www.freewisdom.org/projects/python-markdown/"><em>Python in Markdown</em></a> by some
8 great folks - This <em>does</em> work as expected.</li>
9<li><a href="http://www.freewisdom.org/projects/python-markdown/"><em>Python in Markdown</em></a> <em>by some
10 great folks</em> - This <em>does</em> work as expected.</li>
11</ul>
12<p><em><a href="http://www.freewisdom.org/projects/python-markdown/">Python in Markdown</a> by some
13great folks</em> - This <em>does</em> work as expected.</p>
  
1# Title
2
3 - *[Python in Markdown](http://www.freewisdom.org/projects/python-markdown/) by some
4 great folks* - This *does* work as expected.
5 - _[Python in Markdown](http://www.freewisdom.org/projects/python-markdown/) by some
6 great folks_ - This *does* work as expected.
7 - [_Python in Markdown_](http://www.freewisdom.org/projects/python-markdown/) by some
8 great folks - This *does* work as expected.
9 - [_Python in Markdown_](http://www.freewisdom.org/projects/python-markdown/) _by some
10 great folks_ - This *does* work as expected.
11
12_[Python in Markdown](http://www.freewisdom.org/projects/python-markdown/) by some
13great folks_ - This *does* work as expected.
  
1<p>One asterisk: *</p>
2<p>One underscore: _</p>
3<p>Two asterisks: **</p>
4<p>With spaces: * *</p>
5<p>Two underscores __</p>
6<p>with spaces: _ _</p>
7<p>three asterisks: ***</p>
8<p>with spaces: * * *</p>
9<p>three underscores: ___</p>
10<p>with spaces: _ _ _</p>
  
1One asterisk: *
2
3One underscore: _
4
5Two asterisks: **
6
7With spaces: * *
8
9Two underscores __
10
11with spaces: _ _
12
13three asterisks: ***
14
15with spaces: * * *
16
17three underscores: ___
18
19with spaces: _ _ _
  
1<p>asdfasdfadsfasd <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#121;&#117;&#114;&#105;&#64;&#102;&#114;&#101;&#101;&#119;&#105;&#115;&#100;&#111;&#109;&#46;&#111;&#114;&#103;">&#121;&#117;&#114;&#105;&#64;&#102;&#114;&#101;&#101;&#119;&#105;&#115;&#100;&#111;&#109;&#46;&#111;&#114;&#103;</a> or you can say
2instead <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#121;&#117;&#114;&#105;&#64;&#102;&#114;&#101;&#101;&#119;&#105;&#115;&#100;&#111;&#109;&#46;&#111;&#114;&#103;">&#121;&#117;&#114;&#105;&#64;&#102;&#114;&#101;&#101;&#119;&#105;&#115;&#100;&#111;&#109;&#46;&#111;&#114;&#103;</a></p>
  
1
2asdfasdfadsfasd <yuri@freewisdom.org> or you can say
3instead <mailto:yuri@freewisdom.org>
  
1<ol>
2<li>this starts a list <em>with</em> numbers</li>
3<li>this will show as number "2"</li>
4<li>this will show as number "3."</li>
5<li>any number, +, -, or * will keep the list going.</li>
6</ol>
7<p>aaaaaaaaaaaaaaa</p>
8<ul>
9<li>now a normal list</li>
10<li>and more</li>
11</ul>
  
11. this starts a list *with* numbers
2+ this will show as number "2"
3* this will show as number "3."
49. any number, +, -, or * will keep the list going.
5
6aaaaaaaaaaaaaaa
7
8- now a normal list
9- and more
  
1<h2>Header</h2>
2<h1>Header 2</h1>
3<h3>H3</h3>
  
1Header
2------
3
4Header 2
5========
6
7### H3
  
1<p>a</p>
2<pre>
3#!/usr/bin/python
4hello</pre>
5
6<p>a</p>
7<pre>
8!/usr/bin/python
9hello</pre>
10
11<p>a</p>
  
1a
2
3<pre>
4#!/usr/bin/python
5hello</pre>
6
7a
8
9<pre>
10!/usr/bin/python
11hello</pre>
12
13a
  
1<h3>Hello world</h3>
2<p>Line 2
3Line 3</p>
4<h1>[Markdown][5]</h1>
5<h1><a href="http://some.link.com/">Markdown</a></h1>
6<h1>[5]: http://foo.com/</h1>
7<h1>Issue #1: Markdown</h1>
8<p>Text</p>
9<h1>Header</h1>
10<p>Some other text</p>
  
1### Hello world
2Line 2
3Line 3
4
5# [Markdown][5]
6
7# [Markdown](http://some.link.com/)
8
9# [5]: http://foo.com/
10
11# Issue #1: Markdown
12
13Text
14# Header
15Some other text
  
1<h1>Header</h1>
2<p>Next line</p>
  
1
2#Header
3Next line
  
1<p>Here is HTML <!-- **comment** -->
2and once more <p><!--comment--></p></p>
  
1Here is HTML <!-- **comment** -->
2and once more <p><!--comment--></p>
  
1<h1>Block level html</h1>
2
3<p>Some inline <b>stuff<b>.<br />
4</p>
5<p>Now some <arbitrary>arbitrary tags</arbitrary>.</p>
6<div>More block level html.</div>
7
8<div class="foo bar" title="with 'quoted' text." valueless_attr weirdness="<i>foo</i>">
9Html with various attributes.
10</div>
11
12<p>And of course <script>blah</script>.</p>
13<p><a href="script&gt;stuff&lt;/script">this <script>link</a></p>
  
1
2<h1>Block level html</h1>
3
4Some inline <b>stuff<b>.
5
6Now some <arbitrary>arbitrary tags</arbitrary>.
7
8<div>More block level html.</div>
9
10<div class="foo bar" title="with 'quoted' text." valueless_attr weirdness="<i>foo</i>">
11Html with various attributes.
12</div>
13
14And of course <script>blah</script>.
15
16[this <script>link](<script>stuff</script>)
  
1<p><a href="http://src.com/"><em>link!</em></a></p>
2<p><em><a href="http://www.freewisdom.org">link</a></em></p>
  
1[*link!*](http://src.com/)
2
3*[link](http://www.freewisdom.org)*
  
1<p><img alt="Poster" src="http://humane_man.jpg" title="The most humane man." /></p>
  
1
2![Poster](http://humane_man.jpg "The most humane man.")
  
1<p><a href="path/to/image.png"><img alt="altname" src="path/to/img_thumb.png" /></a></p>
  
1
2
3[![altname](path/to/img_thumb.png)](path/to/image.png)
  
1<p><a href="stuff"> <strong>ok</strong>? </a></p>
  
1<a href="stuff"> __ok__? </a>
  
1<h1>パイソン (Python)</h1>
2<p><strong>Python</strong>(パイソン)は、<a href="http://en.wikipedia.org/wiki/Guido_van_Rossum">Guido van Rossum</a> によって作られたオープンソースのオブジェクト指向スクリプト言語。<a href="http://ja.wikipedia.org/wiki/Perl">Perl</a>とともに欧米で広く普及している。イギリスのテレビ局 BBC が製作したコメディ番組『空飛ぶモンティ・パイソン』にちなんで名付けられた。 (Pythonには、爬虫類のニシキヘビの意味があり、Python言語のマスコットやアイコンとして使われることがある。)</p>
3<h2>概要</h2>
4<p>プログラミング言語 Python は初心者から専門家まで幅広いユーザ層を獲得している。利用目的は汎用で、方向性としてはJavaに近い。ただし、最初からネットワーク利用をメインとして考えられているJavaよりセキュリティについてはやや寛大である。多くのプラットフォームをサポートしており(⇒<a href="#somelink">動作するプラットフォーム</a>)、豊富なライブラリがあることから、産業界でも利用が増えつつある。また、Pythonは純粋なプログラミング言語のほかにも、多くの異なる言語で書かれたモジュールをまとめる糊言語のひとつとして位置づけることができる。実際Pythonは多くの商用アプリケーションでスクリプト言語として採用されている(⇒Pythonを使っている製品あるいはソフトウェアの一覧)。豊富なドキュメントをもち、Unicodeによる文字列操作をサポートしており、日本語処理も標準で可能である。</p>
5<p>Python は基本的にインタプリタ上で実行されることを念頭において設計されており、以下のような特徴をもっている:</p>
6<ul>
7<li>動的な型付け。</li>
8<li>オブジェクトのメンバに対するアクセスが制限されていない。(属性や専用のメソッドフックを実装することによって制限は可能。)</li>
9<li>モジュール、クラス、オブジェクト等の言語の要素が内部からアクセス可能であり、リフレクションを利用した記述が可能。</li>
10</ul>
11<p>また、Pythonではインデントによりブロックを指定する構文を採用している(⇒<a href="#jklj">オフサイドルール</a>)。この構文はPythonに慣れたユーザからは称賛をもって受け入れられているが、他の言語のユーザからは批判も多い。このほかにも、大きすぎる実行ファイルや、Javaに比べて遅い処理速度などが欠点として指摘されている。しかし <strong>プロトタイピング</strong> の際にはこれらの点はさして問題とはならないことから、研究開発部門では頻繁に利用されている。</p>
  
1パイソン (Python)
2=======
3
4**Python**(パイソン)は、[Guido van Rossum](http://en.wikipedia.org/wiki/Guido_van_Rossum) によって作られたオープンソースのオブジェクト指向スクリプト言語。[Perl](http://ja.wikipedia.org/wiki/Perl)とともに欧米で広く普及している。イギリスのテレビ局 BBC が製作したコメディ番組『空飛ぶモンティ・パイソン』にちなんで名付けられた。 (Pythonには、爬虫類のニシキヘビの意味があり、Python言語のマスコットやアイコンとして使われることがある。)
5
6## 概要
7プログラミング言語 Python は初心者から専門家まで幅広いユーザ層を獲得している。利用目的は汎用で、方向性としてはJavaに近い。ただし、最初からネットワーク利用をメインとして考えられているJavaよりセキュリティについてはやや寛大である。多くのプラットフォームをサポートしており(⇒[動作するプラットフォーム](#somelink))、豊富なライブラリがあることから、産業界でも利用が増えつつある。また、Pythonは純粋なプログラミング言語のほかにも、多くの異なる言語で書かれたモジュールをまとめる糊言語のひとつとして位置づけることができる。実際Pythonは多くの商用アプリケーションでスクリプト言語として採用されている(⇒Pythonを使っている製品あるいはソフトウェアの一覧)。豊富なドキュメントをもち、Unicodeによる文字列操作をサポートしており、日本語処理も標準で可能である。
8
9Python は基本的にインタプリタ上で実行されることを念頭において設計されており、以下のような特徴をもっている:
10
11* 動的な型付け。
12* オブジェクトのメンバに対するアクセスが制限されていない。(属性や専用のメソッドフックを実装することによって制限は可能。)
13* モジュール、クラス、オブジェクト等の言語の要素が内部からアクセス可能であり、リフレクションを利用した記述が可能。
14
15また、Pythonではインデントによりブロックを指定する構文を採用している(⇒[オフサイドルール](#jklj))。この構文はPythonに慣れたユーザからは称賛をもって受け入れられているが、他の言語のユーザからは批判も多い。このほかにも、大きすぎる実行ファイルや、Javaに比べて遅い処理速度などが欠点として指摘されている。しかし **プロトタイピング** の際にはこれらの点はさして問題とはならないことから、研究開発部門では頻繁に利用されている。
  
1<blockquote>
2<p>Line one of lazy block quote.
3Line two of lazy block quote.</p>
4<p>Line one of paragraph two.
5Line two of paragraph two.</p>
6</blockquote>
  
1> Line one of lazy block quote.
2Line two of lazy block quote.
3
4> Line one of paragraph two.
5Line two of paragraph two.
  
1<p><a href="http://en.wikipedia.org/wiki/ZIP_(file_format)" title="ZIP (file format) - Wikipedia, the free encyclopedia">ZIP archives</a></p>
  
1[ZIP archives](http://en.wikipedia.org/wiki/ZIP_(file_format) "ZIP (file format) - Wikipedia, the free encyclopedia")
  
1<ul>
2<li>A multi-paragraph list,
3unindented.</li>
4</ul>
5<p>Simple tight list</p>
6<ul>
7<li>Uno</li>
8<li>Due</li>
9<li>Tri</li>
10</ul>
11<p>A singleton tight list:</p>
12<ul>
13<li>Uno</li>
14</ul>
15<p>A lose list:</p>
16<ul>
17<li>
18<p>One</p>
19</li>
20<li>
21<p>Two</p>
22</li>
23<li>
24<p>Three</p>
25</li>
26</ul>
27<p>A lose list with paragraphs</p>
28<ul>
29<li>
30<p>One one one one</p>
31<p>one one one one</p>
32</li>
33<li>
34<p>Two two two two</p>
35</li>
36</ul>
  
1
2* A multi-paragraph list,
3unindented.
4
5
6
7Simple tight list
8
9* Uno
10* Due
11* Tri
12
13A singleton tight list:
14
15* Uno
16
17A lose list:
18
19* One
20
21* Two
22
23* Three
24
25A lose list with paragraphs
26
27* One one one one
28
29 one one one one
30
31* Two two two two
  
1<ul>
2<li>blah blah blah
3sdf asdf asdf asdf asdf
4asda asdf asdfasd</li>
5</ul>
  
1* blah blah blah
2sdf asdf asdf asdf asdf
3asda asdf asdfasd
  
1<ul>
2<li>blah blah blah
3sdf asdf asdf asdf asdf
4asda asdf asdfasd</li>
5</ul>
  
1* blah blah blah
2 sdf asdf asdf asdf asdf
3 asda asdf asdfasd
  
1<ul>
2<li>item1</li>
3<li>item2<ol>
4<li>Number 1</li>
5<li>Number 2</li>
6</ol>
7</li>
8</ul>
  
1
2* item1
3* item2
4 1. Number 1
5 2. Number 2
  
1<blockquote>
2<p>This is a test of a block quote
3With just two lines</p>
4</blockquote>
5<p>A paragraph</p>
6<blockquote>
7<p>This is a more difficult case
8With a list item inside the quote</p>
9<ul>
10<li>Alpha</li>
11<li>Beta
12Etc.</li>
13</ul>
14</blockquote>
  
1> This is a test of a block quote
2> With just two lines
3
4A paragraph
5
6> This is a more difficult case
7> With a list item inside the quote
8>
9> * Alpha
10> * Beta
11> Etc.
  
1<p>Test five or more spaces as start of list:</p>
2<ul>
3<li>five spaces</li>
4</ul>
5<p>not first item:</p>
6<ul>
7<li>one space</li>
8<li>five spaces</li>
9</ul>
10<p>loose list:</p>
11<ul>
12<li>
13<p>one space</p>
14</li>
15<li>
16<p>five spaces</p>
17</li>
18</ul>
  
1Test five or more spaces as start of list:
2
3* five spaces
4
5not first item:
6
7* one space
8* five spaces
9
10loose list:
11
12* one space
13
14* five spaces
  
1<p>
2
3_foo_
4
5</p>
6
7<p>
8_foo_
9</p>
10
11<p>_foo_</p>
12
13<p>
14
15_foo_
16</p>
17
18<p>
19_foo_
20
21</p>
  
1<p>
2
3_foo_
4
5</p>
6
7<p>
8_foo_
9</p>
10
11<p>_foo_</p>
12
13<p>
14
15_foo_
16</p>
17
18<p>
19_foo_
20
21</p>
  
1<p>Some text</p>
2
3<div>some more text</div>
4
5<p>and a bit more</p>
6<p>And this output</p>
7
8<p><em>Compatible with PHP Markdown Extra 1.2.2 and Markdown.pl1.0.2b8:</em></p>
9<!-- comment --><p><div>text</div><br /></p><br />
10
11<p>Should be in p</p>
  
1<p>Some text</p><div>some more text</div>
2
3and a bit more
4
5<p>And this output</p> *Compatible with PHP Markdown Extra 1.2.2 and Markdown.pl1.0.2b8:*
6
7<!-- comment --><p><div>text</div><br /></p><br />
8
9Should be in p
  
1<p>This is a [missing link][empty] and a <a href="http://example.com">valid</a> and [missing][again].</p>
  
1This is a [missing link][empty] and a [valid][link] and [missing][again].
2
3[link]: http://example.com
  
1<!--asd@asdfd.com>
2
3<!asd@asdfd.com>
4
5<asd!@asdfd.com>
6
7<p>Test</p>
  
1<!--asd@asdfd.com>
2
3
4<!asd@asdfd.com>
5
6
7<asd!@asdfd.com>
8
9Test
  
1<div>
2
3asdf asdfasd
4
5</div>
  
1
2<div>
3
4asdf asdfasd
5
6</div>
  
1<blockquote>
2<p>This is line one of paragraph one
3This is line two of paragraph one</p>
4<p>This is line one of paragraph two</p>
5<p>This is another blockquote.</p>
6</blockquote>
  
1> This is line one of paragraph one
2> This is line two of paragraph one
3
4> This is line one of paragraph two
5
6
7
8> This is another blockquote.
  
1<h1 id="inthebeginning">Header </h1>
2<p>Now, let's try something <em class="special">inline</em>, to see if it works</p>
3<p>Blah blah blah <a href="http://www.slashdot.org">http://www.slashdot.org</a></p>
4<ul>
5<li>Basic list</li>
6<li>Basic list 2</li>
7</ul>
8<p>addss</p>
9<ul>
10<li>Lazy list</li>
11</ul>
12<p>An <a href="http://example.com" title="Title">example</a> (oops)</p>
13<p>Now, let's use a footnote[^1]. Not bad, eh?
14Let's continue.</p>
15<p>[^1]: Here is the text of the footnote
16 continued on several lines.
17 some more of the footnote, etc.</p>
18<pre><code>Actually, another paragraph too.
19</code></pre>
20<p>And then there is a little bit of text.</p>
  
1
2# Header {@id=inthebeginning}
3
4Now, let's try something *inline{@class=special}*, to see if it works
5
6
7Blah blah blah <http://www.slashdot.org>
8
9* Basic list
10* Basic list 2
11
12addss
13
14 * Lazy list
15
16An [example][ref] (oops)
17
18 [ref]: http://example.com "Title"
19
20
21Now, let's use a footnote[^1]. Not bad, eh?
22Let's continue.
23
24 [^1]: Here is the text of the footnote
25 continued on several lines.
26 some more of the footnote, etc.
27
28 Actually, another paragraph too.
29
30And then there is a little bit of text.
  
1<!--
2
3foo
4
5-->
6
7<p>
8
9foo
10
11</p>
12
13<div>
14
15foo
16
17</div>
  
1<!--
2
3foo
4
5-->
6
7<p>
8
9foo
10
11</p>
12
13
14<div>
15
16foo
17
18</div>
  
1<ul>
2<li>
3<p>item 1</p>
4<p>paragraph 2</p>
5</li>
6<li>
7<p>item 2</p>
8<ul>
9<li>item 2-1</li>
10<li>
11<p>item 2-2</p>
12<ul>
13<li>item 2-2-1</li>
14</ul>
15</li>
16<li>
17<p>item 2-3</p>
18<ul>
19<li>item 2-3-1</li>
20</ul>
21</li>
22</ul>
23</li>
24<li>
25<p>item 3</p>
26</li>
27</ul>
28<p>plain text</p>
29<ul>
30<li>item 1<ul>
31<li>item 1-1</li>
32<li>item 1-2<ul>
33<li>item 1-2-1</li>
34</ul>
35</li>
36</ul>
37</li>
38<li>item 2</li>
39</ul>
  
1* item 1
2
3 paragraph 2
4
5* item 2
6
7 * item 2-1
8 * item 2-2
9
10 * item 2-2-1
11
12 * item 2-3
13
14 * item 2-3-1
15
16* item 3
17
18plain text
19
20* item 1
21 * item 1-1
22 * item 1-2
23 * item 1-2-1
24* item 2
  
1<p><strong><em><a href="http://www.freewisdom.org">link</a></em></strong>
2<strong><em><a href="http://www.freewisdom.org">link</a></em></strong>
3<strong><a href="http://www.freewisdom.org"><em>link</em></a></strong>
4<strong><a href="http://www.freewisdom.org"><em>link</em></a></strong>
5<strong><a href="http://www.freewisdom.org"><em>link</em></a></strong>
6<strong><a href="http://www.freewisdom.org"><em>link</em></a></strong>
7<a href="http://www.freewisdom.org"><strong><em>link</em></strong></a></p>
  
1___[link](http://www.freewisdom.org)___
2***[link](http://www.freewisdom.org)***
3**[*link*](http://www.freewisdom.org)**
4__[_link_](http://www.freewisdom.org)__
5__[*link*](http://www.freewisdom.org)__
6**[_link_](http://www.freewisdom.org)**
7[***link***](http://www.freewisdom.org)
  
1<p><a href="http://www.stuff.com/q?x=1&amp;y=2&lt;&gt;">Link</a></p>
  
1
2[Link](http://www.stuff.com/q?x=1&y=2<>)
  
1<p><a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#117;&#115;&#101;&#114;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;">&#117;&#115;&#101;&#114;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;</a></p>
2<p>This is an entity: &#234; </p>
  
1
2<user@gmail.com>
3
4This is an entity: &#234;
  
1<p>Here is a paragraph, followed by a horizontal rule.</p>
2<hr />
3<p>Followed by another paragraph.</p>
  
1Here is a paragraph, followed by a horizontal rule.
2***
3Followed by another paragraph.
  
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3
4<p><b>This should have a p tag</b></p>
5<!--This is a comment -->
6
7<div>This shouldn't</div>
8
9<?php echo "block_level";?>
10
11<p>&lt;?php echo "not_block_level";?&gt;</p>
  
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3
4<b>This should have a p tag</b>
5
6<!--This is a comment -->
7
8<div>This shouldn't</div>
9
10<?php echo "block_level";?>
11
12 <?php echo "not_block_level";?>
  
1<pre>
2
3aaa
4
5bbb
6</pre>
7
8<pre>
9* and this is pre-formatted content
10* and it should be printed just like this
11* and not formatted as a list
12
13</pre>
  
1<pre>
2
3aaa
4
5bbb
6</pre>
7
8<pre>
9* and this is pre-formatted content
10* and it should be printed just like this
11* and not formatted as a list
12
13</pre>
  
1<p>Preserve whitespace in raw html</p>
2<pre>
3class Foo():
4 bar = 'bar'
5
6 def baz(self):
7 print self.bar
8</pre>
  
1Preserve whitespace in raw html
2
3<pre>
4class Foo():
5 bar = 'bar'
6
7 def baz(self):
8 print self.bar
9</pre>
  
1<h1>Недвард «Нед» Фландерс</h1>
2<p><strong>Недвард «Нед» Фландерс</strong> (Nedward «Ned» Flanders) — вымышленный персонаж мультсериала «[Симпсоны][]», озвученный Гарри Ширером. Он и его семья живут по соседству от семьи Симпсонов. Набожный христианин, Нед является одним из столпов морали Спрингфилда. В эпизоде «Alone Again, Natura-Diddily» он овдовел, его жена Мод погибла в результате несчастного случая. </p>
3<p>Нед был одним из первых персонажей в мультсериале, который не был членом семьи Симпсонов. Начиная с первых серий, он регулярно появляется в «Симпсонах». Считается, что Нед Фландерс был назван в честь улицы <em>Northeast Flanders St.</em> в <a href="http://www.portland.gov">Портленде</a>, Орегон, родном городе создателя мультсериала Мэтта Грейнинга]]. Надпись на указателе улицы <em>NE Flanders St.</em> хулиганы часто исправляли на <em>NED Flanders St.</em></p>
4<h2>Биография</h2>
5<p>Нед Фландерс родился в Нью-Йорке, его родители были битниками. Его отец в точности похож на взрослого Неда, только он носил козлиную бородку. Их отказ от воспитания Неда и то, что они, в общем-то, были плохими родителями («мы ничего в этом не понимаем и не знаем как начать») привело к тому, что Нед превратился в ужасного сорванца. В конце концов они согласились на экспериментальную восьмимесячную шлепологическую терапию Миннесотского Университета (воспоминания Неда в эпизоде «Hurricane Neddy»), которая научила его подавлять чувство злости. Побочным эфектом терапии стало то, что Нед стал ненавидеть своих родителей (это одна из двух вещей которые ненавидит Фландерс, вторая — отделения почты, чьи длинные очереди, суета и угрюмый персонал раздражают его).</p>
6<p>У Неда есть странная привычка добавлять «дидли», «дадли» и другие бессмысленные слова в свои фразы при разговоре, например: «Hi-diddly-ho, neighbor-ino» («Приветик, соседушка»). Это результат сублимации его злости, вызванной сдерживанием гнева, который не имеет никакого другого выхода.</p>
  
1Недвард «Нед» Фландерс
2======================
3
4
5**Недвард «Нед» Фландерс** (Nedward «Ned» Flanders) — вымышленный персонаж мультсериала «[Симпсоны][]», озвученный Гарри Ширером. Он и его семья живут по соседству от семьи Симпсонов. Набожный христианин, Нед является одним из столпов морали Спрингфилда. В эпизоде «Alone Again, Natura-Diddily» он овдовел, его жена Мод погибла в результате несчастного случая.
6
7Нед был одним из первых персонажей в мультсериале, который не был членом семьи Симпсонов. Начиная с первых серий, он регулярно появляется в «Симпсонах». Считается, что Нед Фландерс был назван в честь улицы *Northeast Flanders St.* в [Портленде](http://www.portland.gov), Орегон, родном городе создателя мультсериала Мэтта Грейнинга]]. Надпись на указателе улицы *NE Flanders St.* хулиганы часто исправляли на _NED Flanders St._
8
9## Биография
10
11Нед Фландерс родился в Нью-Йорке, его родители были битниками. Его отец в точности похож на взрослого Неда, только он носил козлиную бородку. Их отказ от воспитания Неда и то, что они, в общем-то, были плохими родителями («мы ничего в этом не понимаем и не знаем как начать») привело к тому, что Нед превратился в ужасного сорванца. В конце концов они согласились на экспериментальную восьмимесячную шлепологическую терапию Миннесотского Университета (воспоминания Неда в эпизоде «Hurricane Neddy»), которая научила его подавлять чувство злости. Побочным эфектом терапии стало то, что Нед стал ненавидеть своих родителей (это одна из двух вещей которые ненавидит Фландерс, вторая — отделения почты, чьи длинные очереди, суета и угрюмый персонал раздражают его).
12
13У Неда есть странная привычка добавлять «дидли», «дадли» и другие бессмысленные слова в свои фразы при разговоре, например: «Hi-diddly-ho, neighbor-ino» («Приветик, соседушка»). Это результат сублимации его злости, вызванной сдерживанием гнева, который не имеет никакого другого выхода.
  
1<p><em>emphasis</em></p>
2<p>this_is_not_emphasis</p>
3<p>[<em>punctuation with emphasis</em>]</p>
4<p>[<em>punctuation_with_emphasis</em>]</p>
5<p>[punctuation_without_emphasis]</p>
  
1_emphasis_
2
3this_is_not_emphasis
4
5[_punctuation with emphasis_]
6
7[_punctuation_with_emphasis_]
8
9[punctuation_without_emphasis]
  
1<hr />
2<ul>
3<li>
4<p>as if</p>
5</li>
6<li>
7<p>as if2</p>
8</li>
9</ul>
10<hr />
11<ul>
12<li>
13<p>as if</p>
14</li>
15<li>
16<p>as if2</p>
17</li>
18</ul>
19<hr />
20<ul>
21<li>as if
22 non_code</li>
23<li>as if2</li>
24</ul>
25<p>Markdown</p>
26<ul>
27<li>Python
28 is ok<ul>
29<li>Therefore i am</li>
30</ul>
31</li>
32<li>
33<p>Perl sucks
34 big time</p>
35<ul>
36<li>But that's
37ok</li>
38</ul>
39</li>
40<li>
41<p>Python is
42ok
43 Or not?</p>
44</li>
45</ul>
46<p>Here is a normal paragraph</p>
47<ol>
48<li>Another list
49with a bunch of items</li>
50<li>
51<p>Mostly fruits</p>
52<ol>
53<li>Apple</li>
54<li>Pare</li>
55</ol>
56</li>
57</ol>
58<p>asdfasdfasd</p>
59<pre><code># This is a code example
60import stuff
61
62Another code example
63* Lists and similar stuff
64
65&gt; Should be ignored
66</code></pre>
  
1----------------------
2
3* as if
4
5* as if2
6
7----------------------
8
9* as if
10
11* as if2
12
13----------------------
14
15* as if
16 non_code
17* as if2
18
19
20
21
22Markdown
23
24* Python
25 is ok
26 * Therefore i am
27
28* Perl sucks
29 big time
30 * But that's
31 ok
32
33* Python is
34ok
35 Or not?
36
37Here is a normal paragraph
38
391. Another list
40with a bunch of items
412. Mostly fruits
42
43
44
45 3. Apple
46 4. Pare
47
48asdfasdfasd
49
50
51 # This is a code example
52 import stuff
53
54 Another code example
55 * Lists and similar stuff
56
57 > Should be ignored
  
1<p><span id="someId"> Foo <em>bar</em> Baz </span></p>
2<div><b>*foo*</b></div>
3
4<div id="someId"> Foo *bar* Baz </div>
5
6<p><baza id="someId"> Foo <em>bar</em> Baz </baza></p>
  
1
2<span id="someId"> Foo *bar* Baz </span>
3
4<div><b>*foo*</b></div>
5
6<div id="someId"> Foo *bar* Baz </div>
7
8<baza id="someId"> Foo *bar* Baz </baza>
  
1<p><strong>this_is_strong</strong></p>
  
1__this_is_strong__
  
1<p>this is a <a href="http://example.com/"><strong>test</strong></a></p>
2<p>this is a second <strong><a href="http://example.com">test</a></strong></p>
3<p>reference <strong>[test][]</strong>
4reference [<strong>test</strong>][]</p>
  
1this is a [**test**](http://example.com/)
2
3this is a second **[test](http://example.com)**
4
5reference **[test][]**
6reference [**test**][]
  
1<p>First a list with a tabbed line</p>
2<ul>
3<li>
4<p>A</p>
5</li>
6<li>
7<p>B</p>
8</li>
9</ul>
10<p>Just a blank line:</p>
11<ul>
12<li>
13<p>A</p>
14</li>
15<li>
16<p>B</p>
17</li>
18</ul>
19<p>Now a list with 4 spaces and some text:</p>
20<ul>
21<li>A
22 abcdef</li>
23<li>B</li>
24</ul>
25<p>Now with a tab and an extra space:</p>
26<ul>
27<li>
28<p>A</p>
29</li>
30<li>
31<p>B</p>
32</li>
33</ul>
34<p>Now a list with 4 spaces:</p>
35<ul>
36<li>
37<p>A</p>
38</li>
39<li>
40<p>B</p>
41</li>
42</ul>
  
1First a list with a tabbed line
2
3* A
4
5* B
6
7Just a blank line:
8
9* A
10
11* B
12
13
14Now a list with 4 spaces and some text:
15
16* A
17 abcdef
18* B
19
20
21Now with a tab and an extra space:
22
23* A
24
25* B
26
27Now a list with 4 spaces:
28
29* A
30
31* B
  
1<p>This line has two spaces at the end<br />
2but this one has none
3but this line has three <br />
4and this is the second from last line
5in this test message</p>
6<ul>
7<li>This list item has two spaces.<br />
8</li>
9<li>
10<p>This has none.
11 This line has three. <br />
12 This line has none.
13 And this line two.<br />
14</p>
15<p>This line has none.</p>
16</li>
17<li>
18<p>This line has none.</p>
19</li>
20</ul>
21<p>And this is the end.</p>
  
1This line has two spaces at the end
2but this one has none
3but this line has three
4and this is the second from last line
5in this test message
6
7* This list item has two spaces.
8* This has none.
9 This line has three.
10 This line has none.
11 And this line two.
12
13 This line has none.
14
15* This line has none.
16
17And this is the end.
  
1<p><img alt="asif" src="http://fourthought.com/images/ftlogo.png" title="Fourthought logo" /></p>
2<p><a href="http://fourthought.com/"><img alt="" src="http://fourthought.com/images/ftlogo.png" style="float: left; margin: 10px; border: none;" title="Fourthought logo" /></a></p>
3<p><a href="http://link.com/"><img alt="text" src="x" /></a></p>
  
1![asif](http://fourthought.com/images/ftlogo.png "Fourthought logo")
2
3[![{@style=float: left; margin: 10px; border:
4none;}](http://fourthought.com/images/ftlogo.png "Fourthought
5logo")](http://fourthought.com/)
6
7[![text](x)](http://link.com/)
  
1<p>THIS_SHOULD_STAY_AS_IS</p>
2<p>Here is some <em>emphasis</em>, ok?</p>
3<p>Ok, at least <em>this</em> should work.</p>
4<p>THIS<strong>SHOULD</strong>STAY</p>
5<p>Here is some <strong>strong</strong> stuff.</p>
6<p>THIS<strong><em>SHOULD</em></strong>STAY?</p>
  
1THIS_SHOULD_STAY_AS_IS
2
3Here is some _emphasis_, ok?
4
5Ok, at least _this_ should work.
6
7THIS__SHOULD__STAY
8
9Here is some __strong__ stuff.
10
11THIS___SHOULD___STAY?
  
1<p><a href="http://wikipedia.org/wiki/Dawn of War">Dawn of War</a></p>
2<p><a href="http://wikipedia.org/wiki/Dawn of War" title="Dawn of War">Dawn of War</a></p>
  
1[Dawn of War](http://wikipedia.org/wiki/Dawn of War)
2
3
4[Dawn of War](http://wikipedia.org/wiki/Dawn of War "Dawn of War")
  
1<HTTP://WWW.SOMEURL.COM>
2
3<hr@company.com>
  
1<p><a href="HTTP://WWW.SOMEURL.COM">HTTP://WWW.SOMEURL.COM</a></p>
2
3<p><a href="mailto:hr@company.com">hr@company.com</a></p>
  
1Tricky combinaisons: backslash with \\-- two dashes backslash with \\> greater than \\\[test](not a link) \\\*no emphasis*
  
1<p>Tricky combinaisons:</p> <p>backslash with \-- two dashes</p> <p>backslash with \> greater than</p> <p>\[test](not a link)</p> <p>\*no emphasis*</p>
  
1From `<!--` to `-->`
2on two lines.
3
4From `<!--`
5to `-->`
6on three lines.
  
1<p>From <code>&lt;!--</code> to <code>--&gt;</code>
2on two lines.</p>
3
4<p>From <code>&lt;!--</code>
5to <code>--&gt;</code>
6on three lines.</p>
  
1
2* List Item:
3
4 code block
5
6 with a blank line
7
8 within a list item.
9
10* code block
11 as first element of a list item
12
13* List Item:
14
15 code block with whitespace on preceding line
  
1<ul>
2<li><p>List Item:</p>
3
4<pre><code>code block
5
6with a blank line
7</code></pre>
8
9<p>within a list item.</p></li>
10<li><pre><code>code block
11as first element of a list item
12</code></pre></li>
13
14<li><p>List Item:</p>
15
16<pre><code>code block with whitespace on preceding line
17</code></pre></li>
18</ul>
  
1
2 Codeblock on second line
  
1<pre><code>Codeblock on second line
2</code></pre>
  
1<michel.fortin@michelf.com>
2
3International domain names: <help@tūdaliņ.lv>
  
1<p><a href="&#109;&#x61;&#105;&#x6c;&#116;&#x6f;&#58;&#x6d;&#105;&#x63;&#104;&#x65;&#108;&#x2e;&#102;&#x6f;&#114;&#x74;&#105;&#x6e;&#64;&#x6d;&#105;&#x63;&#104;&#x65;&#108;&#x66;&#46;&#x63;&#111;&#x6d;">&#x6d;&#105;&#x63;&#104;&#x65;&#108;&#x2e;&#102;&#x6f;&#114;&#x74;&#105;&#x6e;&#64;&#x6d;&#105;&#x63;&#104;&#x65;&#108;&#x66;&#46;&#x63;&#111;&#x6d;</a></p>
2
3<p>International domain names: <a href="&#x6d;&#97;&#105;&#x6c;&#x74;&#111;&#58;&#x68;&#x65;&#108;&#112;&#x40;&#x74;ū&#x64;&#x61;&#108;&#105;ņ&#46;&#108;&#x76;">&#x68;&#x65;&#108;&#112;&#x40;&#x74;ū&#x64;&#x61;&#108;&#105;ņ&#46;&#108;&#x76;</a></p>
  
1Combined emphasis:
2
31. ***test test***
42. ___test test___
53. *test **test***
64. **test *test***
75. ***test* test**
86. ***test** test*
97. ***test* test**
108. **test *test***
119. *test **test***
1210. _test __test___
1311. __test _test___
1412. ___test_ test__
1513. ___test__ test_
1614. ___test_ test__
1715. __test _test___
1816. _test __test___
19
20
21Incorrect nesting:
22
231. *test **test* test**
242. _test __test_ test__
253. **test *test** test*
264. __test _test__ test_
275. *test *test* test*
286. _test _test_ test_
297. **test **test** test**
308. __test __test__ test__
31
32
33
34No emphasis:
35
361. test* test *test
372. test** test **test
383. test_ test _test
394. test__ test __test
40
41
42
43Middle-word emphasis (asterisks):
44
451. *a*b
462. a*b*
473. a*b*c
484. **a**b
495. a**b**
506. a**b**c
51
52
53Middle-word emphasis (underscore):
54
551. _a_b
562. a_b_
573. a_b_c
584. __a__b
595. a__b__
606. a__b__c
61
62my_precious_file.txt
63
64
65## Tricky Cases
66
67E**. **Test** TestTestTest
68
69E**. **Test** Test Test Test
70
71
72## Overlong emphasis
73
74Name: ____________
75Organization: ____
76Region/Country: __
77
78_____Cut here_____
79
80____Cut here____
  
1<p>Combined emphasis:</p>
2
3<ol>
4<li><strong><em>test test</em></strong></li>
5<li><strong><em>test test</em></strong></li>
6<li><em>test <strong>test</strong></em></li>
7<li><strong>test <em>test</em></strong></li>
8<li><strong><em>test</em> test</strong></li>
9<li><em><strong>test</strong> test</em></li>
10<li><strong><em>test</em> test</strong></li>
11<li><strong>test <em>test</em></strong></li>
12<li><em>test <strong>test</strong></em></li>
13<li><em>test <strong>test</strong></em></li>
14<li><strong>test <em>test</em></strong></li>
15<li><strong><em>test</em> test</strong></li>
16<li><em><strong>test</strong> test</em></li>
17<li><strong><em>test</em> test</strong></li>
18<li><strong>test <em>test</em></strong></li>
19<li><em>test <strong>test</strong></em></li>
20</ol>
21
22<p>Incorrect nesting:</p>
23
24<ol>
25<li>*test <strong>test* test</strong></li>
26<li>_test <strong>test_ test</strong></li>
27<li><strong>test *test</strong> test*</li>
28<li><strong>test _test</strong> test_</li>
29<li><em>test *test</em> test*</li>
30<li><em>test _test</em> test_</li>
31<li><strong>test **test</strong> test**</li>
32<li><strong>test __test</strong> test__</li>
33</ol>
34
35<p>No emphasis:</p>
36
37<ol>
38<li>test* test *test</li>
39<li>test** test **test</li>
40<li>test_ test _test</li>
41<li>test__ test __test</li>
42</ol>
43
44<p>Middle-word emphasis (asterisks):</p>
45
46<ol>
47<li><em>a</em>b</li>
48<li>a<em>b</em></li>
49<li>a<em>b</em>c</li>
50<li><strong>a</strong>b</li>
51<li>a<strong>b</strong></li>
52<li>a<strong>b</strong>c</li>
53</ol>
54
55<p>Middle-word emphasis (underscore):</p>
56
57<ol>
58<li><em>a</em>b</li>
59<li>a<em>b</em></li>
60<li>a<em>b</em>c</li>
61<li><strong>a</strong>b</li>
62<li>a<strong>b</strong></li>
63<li>a<strong>b</strong>c</li>
64</ol>
65
66<p>my<em>precious</em>file.txt</p>
67
68<h2>Tricky Cases</h2>
69
70<p>E**. <strong>Test</strong> TestTestTest</p>
71
72<p>E**. <strong>Test</strong> Test Test Test</p>
73
74
75<h2>Overlong emphasis</h2>
76
77<p>Name: ____________<br />
78Organization: ____<br />
79Region/Country: __</p>
80
81<p>_____Cut here_____</p>
82
83<p>____Cut here____</p>
  
1With asterisks
2
3 * List item
4 *
5 * List item
6
7With numbers
8
91. List item
102.
113. List item
12
13With hyphens
14
15- List item
16-
17- List item
18
19With asterisks
20
21 * List item
22 * List item
23 *
24
25With numbers
26
271. List item
282. List item
293.
30
31With hyphens
32
33- List item
34- List item
35-
  
1<p>With asterisks</p>
2
3<ul>
4<li>List item</li>
5<li></li>
6<li>List item</li>
7</ul>
8
9<p>With numbers</p>
10
11<ol>
12<li>List item</li>
13<li></li>
14<li>List item</li>
15</ol>
16
17<p>With hyphens</p>
18
19<ul>
20<li>List item</li>
21<li></li>
22<li>List item</li>
23</ul>
24
25<p>With asterisks</p>
26
27<ul>
28<li>List item</li>
29<li>List item</li>
30<li></li>
31</ul>
32
33<p>With numbers</p>
34
35<ol>
36<li>List item</li>
37<li>List item</li>
38<li></li>
39</ol>
40
41<p>With hyphens</p>
42
43<ul>
44<li>List item</li>
45<li>List item</li>
46<li></li>
47</ul>
  
1Header ====== Header ------ ### Header
2
3 - - -
4
5Header ====== Paragraph Header ------ Paragraph ### Header Paragraph
6
7 - - -
8
9Paragraph Header ====== Paragraph Paragraph Header ------ Paragraph Paragraph ### Header Paragraph
  
1<h1>Header</h1>
2
3<h2>Header</h2>
4
5<h3>Header</h3>
6
7<hr />
8
9<h1>Header</h1>
10
11<p>Paragraph</p>
12
13<h2>Header</h2>
14
15<p>Paragraph</p>
16
17<h3>Header</h3>
18
19<p>Paragraph</p>
20
21<hr />
22
23<p>Paragraph</p>
24
25<h1>Header</h1>
26
27<p>Paragraph</p>
28
29<p>Paragraph</p>
30
31<h2>Header</h2>
32
33<p>Paragraph</p>
34
35<p>Paragraph</p>
36
37<h3>Header</h3>
38
39<p>Paragraph</p>
  
1Horizontal rules:
2
3- - -
4
5* * *
6
7***
8
9---
10
11___
12
13Not horizontal rules (testing for a bug in 1.0.1j):
14
15+++
16
17,,,
18
19===
20
21???
22
23AAA
24
25jjj
26
27j j j
28
29n n n
  
1<p>Horizontal rules:</p>
2
3<hr />
4
5<hr />
6
7<hr />
8
9<hr />
10
11<hr />
12
13<p>Not horizontal rules (testing for a bug in 1.0.1j):</p>
14
15<p>+++</p>
16
17<p>,,,</p>
18
19<p>===</p>
20
21<p>???</p>
22
23<p>AAA</p>
24
25<p>jjj</p>
26
27<p>j j j</p>
28
29<p>n n n</p>
  
1With some attributes:
2
3<div id="test">
4 foo
5</div>
6
7<div id="test"
8 class="nono">
9 foo
10</div>
11
12Hr's:
13
14<hr class="foo"
15 id="bar" >
  
1<p>With some attributes:</p>
2
3<div id="test">
4 foo
5</div>
6
7<div id="test"
8 class="nono">
9 foo
10</div>
11
12<p>Hr's:</p>
13
14<hr class="foo"
15 id="bar" >
  
1<abbr title="` **Attribute Content Is Not A Code Span** `">ACINACS</abbr>
2
3<abbr title="`first backtick!">SB</abbr>
4<abbr title="`second backtick!">SB</abbr>
  
1<p><abbr title="` **Attribute Content Is Not A Code Span** `">ACINACS</abbr></p>
2
3<p><abbr title="`first backtick!">SB</abbr>
4<abbr title="`second backtick!">SB</abbr></p>
  
1Paragraph one.
2
3<!-- double--dash (invalid SGML comment) -->
4
5Paragraph two.
6
7<!-- enclosed tag </div> -->
8
9The end.
  
1<p>Paragraph one.</p>
2
3<!-- double--dash (invalid SGML comment) -->
4
5<p>Paragraph two.</p>
6
7<!-- enclosed tag </div> -->
8
9<p>The end.</p>
  
1Here is a block tag ins:
2
3<ins>
4<p>Some text</p>
5</ins>
6
7<ins>And here it is inside a paragraph.</ins>
8
9And here it is <ins>in the middle of</ins> a paragraph.
10
11<del>
12<p>Some text</p>
13</del>
14
15<del>And here is ins as a paragraph.</del>
16
17And here it is <del>in the middle of</del> a paragraph.
  
1<p>Here is a block tag ins:</p>
2
3<ins>
4<p>Some text</p>
5</ins>
6
7<p><ins>And here it is inside a paragraph.</ins></p>
8
9<p>And here it is <ins>in the middle of</ins> a paragraph.</p>
10
11<del>
12<p>Some text</p>
13</del>
14
15<p><del>And here is ins as a paragraph.</del></p>
16
17<p>And here it is <del>in the middle of</del> a paragraph.</p>
  
1 GNU GENERAL PUBLIC LICENSE
2 Version 2, June 1991
3
4 Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9 Preamble
10
11 The licenses for most software are designed to take away your
12freedom to share and change it. By contrast, the GNU General Public
13License is intended to guarantee your freedom to share and change free
14software--to make sure the software is free for all its users. This
15General Public License applies to most of the Free Software
16Foundation's software and to any other program whose authors commit to
17using it. (Some other Free Software Foundation software is covered by
18the GNU Lesser General Public License instead.) You can apply it to
19your programs, too.
20
21 When we speak of free software, we are referring to freedom, not
22price. Our General Public Licenses are designed to make sure that you
23have the freedom to distribute copies of free software (and charge for
24this service if you wish), that you receive source code or can get it
25if you want it, that you can change the software or use pieces of it
26in new free programs; and that you know you can do these things.
27
28 To protect your rights, we need to make restrictions that forbid
29anyone to deny you these rights or to ask you to surrender the rights.
30These restrictions translate to certain responsibilities for you if you
31distribute copies of the software, or if you modify it.
32
33 For example, if you distribute copies of such a program, whether
34gratis or for a fee, you must give the recipients all the rights that
35you have. You must make sure that they, too, receive or can get the
36source code. And you must show them these terms so they know their
37rights.
38
39 We protect your rights with two steps: (1) copyright the software, and
40(2) offer you this license which gives you legal permission to copy,
41distribute and/or modify the software.
42
43 Also, for each author's protection and ours, we want to make certain
44that everyone understands that there is no warranty for this free
45software. If the software is modified by someone else and passed on, we
46want its recipients to know that what they have is not the original, so
47that any problems introduced by others will not reflect on the original
48authors' reputations.
49
50 Finally, any free program is threatened constantly by software
51patents. We wish to avoid the danger that redistributors of a free
52program will individually obtain patent licenses, in effect making the
53program proprietary. To prevent this, we have made it clear that any
54patent must be licensed for everyone's free use or not licensed at all.
55
56 The precise terms and conditions for copying, distribution and
57modification follow.
58
59 GNU GENERAL PUBLIC LICENSE
60 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
62 0. This License applies to any program or other work which contains
63a notice placed by the copyright holder saying it may be distributed
64under the terms of this General Public License. The "Program", below,
65refers to any such program or work, and a "work based on the Program"
66means either the Program or any derivative work under copyright law:
67that is to say, a work containing the Program or a portion of it,
68either verbatim or with modifications and/or translated into another
69language. (Hereinafter, translation is included without limitation in
70the term "modification".) Each licensee is addressed as "you".
71
72Activities other than copying, distribution and modification are not
73covered by this License; they are outside its scope. The act of
74running the Program is not restricted, and the output from the Program
75is covered only if its contents constitute a work based on the
76Program (independent of having been made by running the Program).
77Whether that is true depends on what the Program does.
78
79 1. You may copy and distribute verbatim copies of the Program's
80source code as you receive it, in any medium, provided that you
81conspicuously and appropriately publish on each copy an appropriate
82copyright notice and disclaimer of warranty; keep intact all the
83notices that refer to this License and to the absence of any warranty;
84and give any other recipients of the Program a copy of this License
85along with the Program.
86
87You may charge a fee for the physical act of transferring a copy, and
88you may at your option offer warranty protection in exchange for a fee.
89
90 2. You may modify your copy or copies of the Program or any portion
91of it, thus forming a work based on the Program, and copy and
92distribute such modifications or work under the terms of Section 1
93above, provided that you also meet all of these conditions:
94
95 a) You must cause the modified files to carry prominent notices
96 stating that you changed the files and the date of any change.
97
98 b) You must cause any work that you distribute or publish, that in
99 whole or in part contains or is derived from the Program or any
100 part thereof, to be licensed as a whole at no charge to all third
101 parties under the terms of this License.
102
103 c) If the modified program normally reads commands interactively
104 when run, you must cause it, when started running for such
105 interactive use in the most ordinary way, to print or display an
106 announcement including an appropriate copyright notice and a
107 notice that there is no warranty (or else, saying that you provide
108 a warranty) and that users may redistribute the program under
109 these conditions, and telling the user how to view a copy of this
110 License. (Exception: if the Program itself is interactive but
111 does not normally print such an announcement, your work based on
112 the Program is not required to print an announcement.)
113
114These requirements apply to the modified work as a whole. If
115identifiable sections of that work are not derived from the Program,
116and can be reasonably considered independent and separate works in
117themselves, then this License, and its terms, do not apply to those
118sections when you distribute them as separate works. But when you
119distribute the same sections as part of a whole which is a work based
120on the Program, the distribution of the whole must be on the terms of
121this License, whose permissions for other licensees extend to the
122entire whole, and thus to each and every part regardless of who wrote it.
123
124Thus, it is not the intent of this section to claim rights or contest
125your rights to work written entirely by you; rather, the intent is to
126exercise the right to control the distribution of derivative or
127collective works based on the Program.
128
129In addition, mere aggregation of another work not based on the Program
130with the Program (or with a work based on the Program) on a volume of
131a storage or distribution medium does not bring the other work under
132the scope of this License.
133
134 3. You may copy and distribute the Program (or a work based on it,
135under Section 2) in object code or executable form under the terms of
136Sections 1 and 2 above provided that you also do one of the following:
137
138 a) Accompany it with the complete corresponding machine-readable
139 source code, which must be distributed under the terms of Sections
140 1 and 2 above on a medium customarily used for software interchange; or,
141
142 b) Accompany it with a written offer, valid for at least three
143 years, to give any third party, for a charge no more than your
144 cost of physically performing source distribution, a complete
145 machine-readable copy of the corresponding source code, to be
146 distributed under the terms of Sections 1 and 2 above on a medium
147 customarily used for software interchange; or,
148
149 c) Accompany it with the information you received as to the offer
150 to distribute corresponding source code. (This alternative is
151 allowed only for noncommercial distribution and only if you
152 received the program in object code or executable form with such
153 an offer, in accord with Subsection b above.)
154
155The source code for a work means the preferred form of the work for
156making modifications to it. For an executable work, complete source
157code means all the source code for all modules it contains, plus any
158associated interface definition files, plus the scripts used to
159control compilation and installation of the executable. However, as a
160special exception, the source code distributed need not include
161anything that is normally distributed (in either source or binary
162form) with the major components (compiler, kernel, and so on) of the
163operating system on which the executable runs, unless that component
164itself accompanies the executable.
165
166If distribution of executable or object code is made by offering
167access to copy from a designated place, then offering equivalent
168access to copy the source code from the same place counts as
169distribution of the source code, even though third parties are not
170compelled to copy the source along with the object code.
171
172 4. You may not copy, modify, sublicense, or distribute the Program
173except as expressly provided under this License. Any attempt
174otherwise to copy, modify, sublicense or distribute the Program is
175void, and will automatically terminate your rights under this License.
176However, parties who have received copies, or rights, from you under
177this License will not have their licenses terminated so long as such
178parties remain in full compliance.
179
180 5. You are not required to accept this License, since you have not
181signed it. However, nothing else grants you permission to modify or
182distribute the Program or its derivative works. These actions are
183prohibited by law if you do not accept this License. Therefore, by
184modifying or distributing the Program (or any work based on the
185Program), you indicate your acceptance of this License to do so, and
186all its terms and conditions for copying, distributing or modifying
187the Program or works based on it.
188
189 6. Each time you redistribute the Program (or any work based on the
190Program), the recipient automatically receives a license from the
191original licensor to copy, distribute or modify the Program subject to
192these terms and conditions. You may not impose any further
193restrictions on the recipients' exercise of the rights granted herein.
194You are not responsible for enforcing compliance by third parties to
195this License.
196
197 7. If, as a consequence of a court judgment or allegation of patent
198infringement or for any other reason (not limited to patent issues),
199conditions are imposed on you (whether by court order, agreement or
200otherwise) that contradict the conditions of this License, they do not
201excuse you from the conditions of this License. If you cannot
202distribute so as to satisfy simultaneously your obligations under this
203License and any other pertinent obligations, then as a consequence you
204may not distribute the Program at all. For example, if a patent
205license would not permit royalty-free redistribution of the Program by
206all those who receive copies directly or indirectly through you, then
207the only way you could satisfy both it and this License would be to
208refrain entirely from distribution of the Program.
209
210If any portion of this section is held invalid or unenforceable under
211any particular circumstance, the balance of the section is intended to
212apply and the section as a whole is intended to apply in other
213circumstances.
214
215It is not the purpose of this section to induce you to infringe any
216patents or other property right claims or to contest validity of any
217such claims; this section has the sole purpose of protecting the
218integrity of the free software distribution system, which is
219implemented by public license practices. Many people have made
220generous contributions to the wide range of software distributed
221through that system in reliance on consistent application of that
222system; it is up to the author/donor to decide if he or she is willing
223to distribute software through any other system and a licensee cannot
224impose that choice.
225
226This section is intended to make thoroughly clear what is believed to
227be a consequence of the rest of this License.
228
229 8. If the distribution and/or use of the Program is restricted in
230certain countries either by patents or by copyrighted interfaces, the
231original copyright holder who places the Program under this License
232may add an explicit geographical distribution limitation excluding
233those countries, so that distribution is permitted only in or among
234countries not thus excluded. In such case, this License incorporates
235the limitation as if written in the body of this License.
236
237 9. The Free Software Foundation may publish revised and/or new versions
238of the General Public License from time to time. Such new versions will
239be similar in spirit to the present version, but may differ in detail to
240address new problems or concerns.
241
242Each version is given a distinguishing version number. If the Program
243specifies a version number of this License which applies to it and "any
244later version", you have the option of following the terms and conditions
245either of that version or of any later version published by the Free
246Software Foundation. If the Program does not specify a version number of
247this License, you may choose any version ever published by the Free Software
248Foundation.
249
250 10. If you wish to incorporate parts of the Program into other free
251programs whose distribution conditions are different, write to the author
252to ask for permission. For software which is copyrighted by the Free
253Software Foundation, write to the Free Software Foundation; we sometimes
254make exceptions for this. Our decision will be guided by the two goals
255of preserving the free status of all derivatives of our free software and
256of promoting the sharing and reuse of software generally.
257
258 NO WARRANTY
259
260 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268REPAIR OR CORRECTION.
269
270 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278POSSIBILITY OF SUCH DAMAGES.
279
280 END OF TERMS AND CONDITIONS
281
282 How to Apply These Terms to Your New Programs
283
284 If you develop a new program, and you want it to be of the greatest
285possible use to the public, the best way to achieve this is to make it
286free software which everyone can redistribute and change under these terms.
287
288 To do so, attach the following notices to the program. It is safest
289to attach them to the start of each source file to most effectively
290convey the exclusion of warranty; and each file should have at least
291the "copyright" line and a pointer to where the full notice is found.
292
293 <one line to give the program's name and a brief idea of what it does.>
294 Copyright (C) <year> <name of author>
295
296 This program is free software; you can redistribute it and/or modify
297 it under the terms of the GNU General Public License as published by
298 the Free Software Foundation; either version 2 of the License, or
299 (at your option) any later version.
300
301 This program is distributed in the hope that it will be useful,
302 but WITHOUT ANY WARRANTY; without even the implied warranty of
303 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 GNU General Public License for more details.
305
306 You should have received a copy of the GNU General Public License along
307 with this program; if not, write to the Free Software Foundation, Inc.,
308 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
310Also add information on how to contact you by electronic and paper mail.
311
312If the program is interactive, make it output a short notice like this
313when it starts in an interactive mode:
314
315 Gnomovision version 69, Copyright (C) year name of author
316 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 This is free software, and you are welcome to redistribute it
318 under certain conditions; type `show c' for details.
319
320The hypothetical commands `show w' and `show c' should show the appropriate
321parts of the General Public License. Of course, the commands you use may
322be called something other than `show w' and `show c'; they could even be
323mouse-clicks or menu items--whatever suits your program.
324
325You should also get your employer (if you work as a programmer) or your
326school, if any, to sign a "copyright disclaimer" for the program, if
327necessary. Here is a sample; alter the names:
328
329 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
332 <signature of Ty Coon>, 1 April 1989
333 Ty Coon, President of Vice
334
335This General Public License does not permit incorporating your program into
336proprietary programs. If your program is a subroutine library, you may
337consider it more useful to permit linking proprietary applications with the
338library. If this is what you want to do, use the GNU Lesser General
339Public License instead of this License.
  
1[silly URL w/ angle brackets](<?}]*+|&)>).
  
1<p><a href="?}]*+|&amp;)">silly URL w/ angle brackets</a>.</p>
  
1# Character Escapes
2
3The MD5 value for `+` is "26b17225b626fb9238849fd60eabdf60".
4
5# HTML Blocks
6
7<p>test</p>
8
9The MD5 value for `<p>test</p>` is:
10
116205333b793f34273d75379350b36826
  
1<h1>Character Escapes</h1>
2
3<p>The MD5 value for <code>+</code> is "26b17225b626fb9238849fd60eabdf60".</p>
4
5<h1>HTML Blocks</h1>
6
7<p>test</p>
8
9<p>The MD5 value for <code>&lt;p&gt;test&lt;/p&gt;</code> is:</p>
10
11<p>6205333b793f34273d75379350b36826</p>
  
1* test
2+ test
3- test
4
51. test
62. test
7
8* test
9+ test
10- test
11
121. test
132. test
  
1<ul>
2<li>test</li>
3<li>test</li>
4<li>test</li>
5</ul>
6
7<ol>
8<li>test</li>
9<li>test</li>
10</ol>
11
12<ul>
13<li>test</li>
14<li>test</li>
15<li>test</li>
16</ul>
17
18<ol>
19<li>test</li>
20<li>test</li>
21</ol>
  
1Valid nesting:
2
3**[Link](url)**
4
5[**Link**](url)
6
7**[**Link**](url)**
8
9Invalid nesting:
10
11[[Link](url)](url)
  
1<p>Valid nesting:</p>
2
3<p><strong><a href="url">Link</a></strong></p>
4
5<p><a href="url"><strong>Link</strong></a></p>
6
7<p><strong><a href="url"><strong>Link</strong></a></strong></p>
8
9<p>Invalid nesting:</p>
10
11<p><a href="url">[Link](url)</a></p>
  
1This tests for a bug where quotes escaped by PHP when using
2`preg_replace` with the `/e` modifier must be correctly unescaped
3(hence the `_UnslashQuotes` function found only in PHP Markdown).
4
5
6
7Headers below should appear exactly as they are typed (no backslash
8added or removed).
9
10Header "quoted\" again \\""
11===========================
12
13Header "quoted\" again \\""
14---------------------------
15
16### Header "quoted\" again \\"" ###
17
18
19
20Test with tabs for `_Detab`:
21
22 Code 'block' with some "tabs" and "quotes"
  
1<p>This tests for a bug where quotes escaped by PHP when using
2<code>preg_replace</code> with the <code>/e</code> modifier must be correctly unescaped
3(hence the <code>_UnslashQuotes</code> function found only in PHP Markdown).</p>
4
5<p>Headers below should appear exactly as they are typed (no backslash
6added or removed).</p>
7
8<h1>Header "quoted\" again \""</h1>
9
10<h2>Header "quoted\" again \""</h2>
11
12<h3>Header "quoted\" again \""</h3>
13
14<p>Test with tabs for <code>_Detab</code>:</p>
15
16<pre><code>Code 'block' with some "tabs" and "quotes"
17</code></pre>
  
1[Inline link 1 with parens](/url\(test\) "title").
2
3[Inline link 2 with parens](</url\(test\)> "title").
4
5[Inline link 3 with non-escaped parens](/url(test) "title").
6
7[Inline link 4 with non-escaped parens](</url(test)> "title").
8
9[Reference link 1 with parens][1].
10
11[Reference link 2 with parens][2].
12
13 [1]: /url(test) "title"
14 [2]: </url(test)> "title"
  
1<p><a href="/url(test)" title="title">Inline link 1 with parens</a>.</p>
2
3<p><a href="/url(test)" title="title">Inline link 2 with parens</a>.</p>
4
5<p><a href="/url(test)" title="title">Inline link 3 with non-escaped parens</a>.</p>
6
7<p><a href="/url(test)" title="title">Inline link 4 with non-escaped parens</a>.</p>
8
9<p><a href="/url(test)" title="title">Reference link 1 with parens</a>.</p>
10
11<p><a href="/url(test)" title="title">Reference link 2 with parens</a>.</p>
  
1[Test](/"style="color:red)
2[Test](/'style='color:red)
3
4![](/"style="border-color:red;border-size:1px;border-style:solid)
5![](/'style='border-color:red;border-size:1px;border-style:solid)
  
1<p><a href="/&quot;style=&quot;color:red">Test</a>
2<a href="/'style='color:red">Test</a></p>
3
4<p><img src="/&quot;style=&quot;border-color:red;border-size:1px;border-style:solid" alt="" />
5<img src="/'style='border-color:red;border-size:1px;border-style:solid" alt="" /></p>
  
1Paragraph and no space: * ciao Paragraph and 1 space: * ciao Paragraph and 3 spaces: * ciao Paragraph and 4 spaces: * ciao Paragraph before header: #Header Paragraph before blockquote: >Some quote.
  
1<p>Paragraph and no space:
2* ciao</p>
3
4<p>Paragraph and 1 space:
5 * ciao</p>
6
7<p>Paragraph and 3 spaces:
8 * ciao</p>
9
10<p>Paragraph and 4 spaces:
11 * ciao</p>
12
13<p>Paragraph before header:</p>
14
15<h1>Header</h1>
16
17<p>Paragraph before blockquote:</p>
18
19<blockquote>
20 <p>Some quote.</p>
21</blockquote>
  
1Some text about HTML, SGML and HTML4.
2
3Let's talk about the U.S.A., (É.U. or É.-U. d'A. in French).
4
5*[HTML4]: Hyper Text Markup Language version 4
6*[HTML]: Hyper Text Markup Language
7*[SGML]: Standard Generalized Markup Language
8*[U.S.A.]: United States of America
9*[É.U.] : États-Unis d'Amérique
10*[É.-U. d'A.] : États-Unis d'Amérique
11
12And here we have a CD, some CDs, and some other CD's.
13
14*[CD]: Compact Disk
15
16Let's transfert documents through TCP/IP, using TCP packets.
17
18*[IP]: Internet Protocol
19*[TCP]: Transmission Control Protocol
20
21 ---
22
23Bienvenue sur [CMS](http://www.bidulecms.com "Bidule CMS").
24
25*[CMS]: Content Management System
26
27 ---
28
29ATCCE
30
31*[ATCCE]: Abbreviation "Testing" Correct 'Character' < Escapes >
  
1<p>Some text about <abbr title="Hyper Text Markup Language">HTML</abbr>, <abbr title="Standard Generalized Markup Language">SGML</abbr> and <abbr title="Hyper Text Markup Language version 4">HTML4</abbr>.</p>
2
3<p>Let's talk about the <abbr title="United States of America">U.S.A.</abbr>, (<abbr title="États-Unis d'Amérique">É.U.</abbr> or <abbr title="États-Unis d'Amérique">É.-U. d'A.</abbr> in French).</p>
4
5<p>And here we have a <abbr title="Compact Disk">CD</abbr>, some CDs, and some other <abbr title="Compact Disk">CD</abbr>'s.</p>
6
7<p>Let's transfert documents through <abbr title="Transmission Control Protocol">TCP</abbr>/<abbr title="Internet Protocol">IP</abbr>, using <abbr title="Transmission Control Protocol">TCP</abbr> packets.</p>
8
9<hr />
10
11<p>Bienvenue sur <a href="http://www.bidulecms.com" title="Bidule CMS"><abbr title="Content Management System">CMS</abbr></a>.</p>
12
13<hr />
14
15<p><abbr title="Abbreviation &quot;Testing&quot; Correct 'Character' &lt; Escapes &gt;">ATCCE</abbr></p>
  
1A simple definition list:
2
3Term 1
4: Definition 1
5
6Term 2
7: Definition 2
8
9With multiple terms:
10
11Term 1
12Term 2
13: Definition 1
14
15Term 3
16Term 4
17: Definition 2
18
19With multiple definitions:
20
21Term 1
22: Definition 1
23: Definition 2
24
25Term 2
26: Definition 3
27: Definition 4
28
29With multiple lines per definition:
30
31Term 1
32: Definition 1 line 1 ...
33Definition 1 line 2
34: Definition 2 line 1 ...
35Definition 2 line 2
36
37Term 2
38: Definition 3 line 2 ...
39 Definition 3 line 2
40: Definition 4 line 2 ...
41 Definition 4 line 2
42
43With paragraphs:
44
45Term 1
46
47: Definition 1 (paragraph)
48
49Term 2
50
51: Definition 2 (paragraph)
52
53With multiple paragraphs:
54
55Term 1
56
57: Definition 1 paragraph 1 line 1 ...
58 Definition 1 paragraph 1 line 2
59
60 Definition 1 paragraph 2 line 1 ...
61 Definition 1 paragraph 2 line 2
62
63Term 2
64
65: Definition 1 paragraph 1 line 1 ...
66Definition 1 paragraph 1 line 2 (lazy)
67
68 Definition 1 paragraph 2 line 1 ...
69Definition 1 paragraph 2 line 2 (lazy)
70
71* * *
72
73A mix:
74
75Term 1
76Term 2
77
78: Definition 1 paragraph 1 line 1 ...
79Definition 1 paragraph 1 line 2 (lazy)
80
81 Definition 1 paragraph 2 line 1 ...
82 Definition 1 paragraph 2 line 2
83
84: Definition 2 paragraph 1 line 1 ...
85Definition 2 paragraph 1 line 2 (lazy)
86
87Term 3
88: Definition 3 (no paragraph)
89: Definition 4 (no paragraph)
90: Definition 5 line 1 ...
91 Definition 5 line 2 (no paragraph)
92
93: Definition 6 paragraph 1 line 1 ...
94Definition 6 paragraph 1 line 2
95: Definition 7 (no paragraph)
96: Definition 8 paragraph 1 line 1 (forced paragraph) ...
97 Definition 8 paragraph 1 line 2
98
99 Definition 8 paragraph 2 line 1
100
101Term 4
102: Definition 9 paragraph 1 line 1 (forced paragraph) ...
103 Definition 9 paragraph 1 line 2
104
105 Definition 9 paragraph 2 line 1
106: Definition 10 (no paragraph)
107
108* * *
109
110Special cases:
111
112Term
113
114: code block
115 as first element of a definition
  
1<p>A simple definition list:</p>
2
3<dl>
4<dt>Term 1</dt>
5<dd>Definition 1</dd>
6
7<dt>Term 2</dt>
8<dd>Definition 2</dd>
9</dl>
10
11<p>With multiple terms:</p>
12
13<dl>
14<dt>Term 1</dt>
15<dt>Term 2</dt>
16<dd>Definition 1</dd>
17
18<dt>Term 3</dt>
19<dt>Term 4</dt>
20<dd>Definition 2</dd>
21</dl>
22
23<p>With multiple definitions:</p>
24
25<dl>
26<dt>Term 1</dt>
27<dd>Definition 1</dd>
28
29<dd>Definition 2</dd>
30
31<dt>Term 2</dt>
32<dd>Definition 3</dd>
33
34<dd>Definition 4</dd>
35</dl>
36
37<p>With multiple lines per definition:</p>
38
39<dl>
40<dt>Term 1</dt>
41<dd>Definition 1 line 1 ...
42Definition 1 line 2</dd>
43
44<dd>Definition 2 line 1 ...
45Definition 2 line 2</dd>
46
47<dt>Term 2</dt>
48<dd>Definition 3 line 2 ...
49Definition 3 line 2</dd>
50
51<dd>Definition 4 line 2 ...
52Definition 4 line 2</dd>
53</dl>
54
55<p>With paragraphs:</p>
56
57<dl>
58<dt>Term 1</dt>
59<dd>
60<p>Definition 1 (paragraph)</p>
61</dd>
62
63<dt>Term 2</dt>
64<dd>
65<p>Definition 2 (paragraph)</p>
66</dd>
67</dl>
68
69<p>With multiple paragraphs:</p>
70
71<dl>
72<dt>Term 1</dt>
73<dd>
74<p>Definition 1 paragraph 1 line 1 ...
75Definition 1 paragraph 1 line 2</p>
76
77<p>Definition 1 paragraph 2 line 1 ...
78Definition 1 paragraph 2 line 2</p>
79</dd>
80
81<dt>Term 2</dt>
82<dd>
83<p>Definition 1 paragraph 1 line 1 ...
84Definition 1 paragraph 1 line 2 (lazy)</p>
85
86<p>Definition 1 paragraph 2 line 1 ...
87Definition 1 paragraph 2 line 2 (lazy)</p>
88</dd>
89</dl>
90
91<hr />
92
93<p>A mix:</p>
94
95<dl>
96<dt>Term 1</dt>
97<dt>Term 2</dt>
98<dd>
99<p>Definition 1 paragraph 1 line 1 ...
100Definition 1 paragraph 1 line 2 (lazy)</p>
101
102<p>Definition 1 paragraph 2 line 1 ...
103Definition 1 paragraph 2 line 2</p>
104</dd>
105
106<dd>
107<p>Definition 2 paragraph 1 line 1 ...
108Definition 2 paragraph 1 line 2 (lazy)</p>
109</dd>
110
111<dt>Term 3</dt>
112<dd>Definition 3 (no paragraph)</dd>
113
114<dd>Definition 4 (no paragraph)</dd>
115
116<dd>Definition 5 line 1 ...
117Definition 5 line 2 (no paragraph)</dd>
118
119<dd>
120<p>Definition 6 paragraph 1 line 1 ...
121Definition 6 paragraph 1 line 2</p>
122</dd>
123
124<dd>Definition 7 (no paragraph)</dd>
125
126<dd>
127<p>Definition 8 paragraph 1 line 1 (forced paragraph) ...
128Definition 8 paragraph 1 line 2</p>
129
130<p>Definition 8 paragraph 2 line 1</p>
131</dd>
132
133<dt>Term 4</dt>
134<dd>
135<p>Definition 9 paragraph 1 line 1 (forced paragraph) ...
136Definition 9 paragraph 1 line 2</p>
137
138<p>Definition 9 paragraph 2 line 1</p>
139</dd>
140
141<dd>Definition 10 (no paragraph)</dd>
142</dl>
143
144<hr />
145
146<p>Special cases:</p>
147
148<dl>
149<dt>Term</dt>
150<dd>
151<pre><code>code block
152as first element of a definition
153</code></pre>
154</dd>
155</dl>
  
1Combined emphasis:
2
31. ***test test***
42. ___test test___
53. *test **test***
64. **test *test***
75. ***test* test**
86. ***test** test*
97. ***test* test**
108. **test *test***
119. *test **test***
1210. _test __test___
1311. __test _test___
1412. ___test_ test__
1513. ___test__ test_
1614. ___test_ test__
1715. __test _test___
1816. _test __test___
19
20
21Incorrect nesting:
22
231. *test **test* test**
242. _test __test_ test__
253. **test *test** test*
264. __test _test__ test_
275. *test *test* test*
286. _test _test_ test_
297. **test **test** test**
308. __test __test__ test__
31
32
33
34No emphasis:
35
361. test* test *test
372. test** test **test
383. test_ test _test
394. test__ test __test
40
41
42
43Middle-word emphasis (asterisks):
44
451. *a*b
462. a*b*
473. a*b*c
484. **a**b
495. a**b**
506. a**b**c
51
52
53Middle-word emphasis (underscore):
54
551. _a_b
562. a_b_
573. a_b_c
584. __a__b
595. a__b__
606. a__b__c
61
62my_precious_file.txt
63
64
65## Tricky Cases
66
67E**. **Test** TestTestTest
68
69E**. **Test** Test Test Test
70
71
72## Overlong emphasis
73
74Name: ____________
75Organization: ____
76Region/Country: __
77
78_____Cut here_____
79
80____Cut here____
  
1<p>Combined emphasis:</p>
2
3<ol>
4<li><strong><em>test test</em></strong></li>
5<li><strong><em>test test</em></strong></li>
6<li><em>test <strong>test</strong></em></li>
7<li><strong>test <em>test</em></strong></li>
8<li><strong><em>test</em> test</strong></li>
9<li><em><strong>test</strong> test</em></li>
10<li><strong><em>test</em> test</strong></li>
11<li><strong>test <em>test</em></strong></li>
12<li><em>test <strong>test</strong></em></li>
13<li><em>test <strong>test</strong></em></li>
14<li><strong>test <em>test</em></strong></li>
15<li><strong><em>test</em> test</strong></li>
16<li><em><strong>test</strong> test</em></li>
17<li><strong><em>test</em> test</strong></li>
18<li><strong>test <em>test</em></strong></li>
19<li><em>test <strong>test</strong></em></li>
20</ol>
21
22<p>Incorrect nesting:</p>
23
24<ol>
25<li>*test <strong>test* test</strong></li>
26<li>_test <strong>test_ test</strong></li>
27<li><strong>test *test</strong> test*</li>
28<li><strong>test _test</strong> test_</li>
29<li><em>test *test</em> test*</li>
30<li><em>test _test</em> test_</li>
31<li><strong>test **test</strong> test**</li>
32<li><strong>test __test</strong> test__</li>
33</ol>
34
35<p>No emphasis:</p>
36
37<ol>
38<li>test* test *test</li>
39<li>test** test **test</li>
40<li>test_ test _test</li>
41<li>test__ test __test</li>
42</ol>
43
44<p>Middle-word emphasis (asterisks):</p>
45
46<ol>
47<li><em>a</em>b</li>
48<li>a<em>b</em></li>
49<li>a<em>b</em>c</li>
50<li><strong>a</strong>b</li>
51<li>a<strong>b</strong></li>
52<li>a<strong>b</strong>c</li>
53</ol>
54
55<p>Middle-word emphasis (underscore):</p>
56
57<ol>
58<li>_a_b</li>
59<li>a_b_</li>
60<li>a_b_c</li>
61<li>__a__b</li>
62<li>a__b__</li>
63<li>a__b__c</li>
64</ol>
65
66<p>my_precious_file.txt</p>
67
68<h2>Tricky Cases</h2>
69
70<p>E**. <strong>Test</strong> TestTestTest</p>
71
72<p>E**. <strong>Test</strong> Test Test Test</p>
73
74
75<h2>Overlong emphasis</h2>
76
77<p>Name: ____________<br />
78Organization: ____<br />
79Region/Country: __</p>
80
81<p>_____Cut here_____</p>
82
83<p>____Cut here____</p>
  
1~~~
2Fenced
3~~~
4
5Code block starting and ending with empty lines:
6~~~
7
8
9Fenced
10
11
12~~~
13
14Indented code block containing fenced code block sample:
15
16 ~~~
17 Fenced
18 ~~~
19
20Fenced code block with indented code block sample:
21
22~~~
23Some text
24
25 Indented code block sample code
26~~~
27
28Fenced code block with long markers:
29
30~~~~~~~~~~~~~~~~~~
31Fenced
32~~~~~~~~~~~~~~~~~~
33
34Fenced code block with fenced code block markers of different length in it:
35
36~~~~
37In code block
38~~~
39Still in code block
40~~~~~
41Still in code block
42~~~~
43
44Fenced code block with Markdown header and horizontal rule:
45
46~~~
47#test
48---
49~~~
50
51Fenced code block with link definitions, footnote definition and
52abbreviation definitions:
53
54~~~
55[example]: http://example.com/
56
57[^1]: Footnote def
58
59*[HTML]: HyperText Markup Language
60~~~
  
1<pre><code>Fenced
2</code></pre>
3
4<p>Code block starting and ending with empty lines:</p>
5
6<pre><code><br /><br />Fenced
7
8
9</code></pre>
10
11<p>Indented code block containing fenced code block sample:</p>
12
13<pre><code>~~~
14Fenced
15~~~
16</code></pre>
17
18<p>Fenced code block with indented code block sample:</p>
19
20<pre><code>Some text
21
22 Indented code block sample code
23</code></pre>
24
25<p>Fenced code block with long markers:</p>
26
27<pre><code>Fenced
28</code></pre>
29
30<p>Fenced code block with fenced code block markers of different length in it:</p>
31
32<pre><code>In code block
33~~~
34Still in code block
35~~~~~
36Still in code block
37</code></pre>
38
39<p>Fenced code block with Markdown header and horizontal rule:</p>
40
41<pre><code>#test
42---
43</code></pre>
44
45<p>Fenced code block with link definitions, footnote definition and
46abbreviation definitions:</p>
47
48<pre><code>[example]: http://example.com/
49
50[^1]: Footnote def
51
52*[HTML]: HyperText Markup Language
53</code></pre>
  
1This is the first paragraph.[^first]
2
3[^first]: This is the first note.
4
5* List item one.[^second]
6* List item two.[^third]
7
8[^third]: This is the third note, defined out of order.
9[^second]: This is the second note.
10[^fourth]: This is the fourth note.
11
12# Header[^fourth]
13
14Some paragraph with a footnote[^1], and another[^2].
15
16[^1]: Content for fifth footnote.
17[^2]: Content for sixth footnote spaning on
18 three lines, with some span-level markup like
19 _emphasis_, a [link][].
20
21[link]: http://www.michelf.com/
22
23Another paragraph with a named footnote[^fn-name].
24
25[^fn-name]:
26 Footnote beginning on the line next to the marker.
27
28This paragraph should not have a footnote marker since
29the footnote is undefined.[^3]
30
31This paragraph should not have a footnote marker since
32the footnote has already been used before.[^1]
33
34This paragraph links to a footnote with plenty of
35block-level content.[^block]
36
37[^block]:
38 Paragraph.
39
40 * List item
41
42 > Blockquote
43
44 Code block
45
46This paragraph host the footnote reference within a
47footnote test[^reference].
48
49[^reference]:
50 This footnote has a footnote of its own.[^nested]
51
52[^nested]:
53 This footnote should appear even though as it is refered
54 from another footnote. But [^reference] should be litteral
55 since the footnote with that name has already been used.
56
57 - - -
58
59Testing unusual footnote name[^1$^!"'].
60
61[^1$^!"']: Haha!
  
1<p>This is the first paragraph.<sup id="fnref:first"><a href="#fn:first" rel="footnote">1</a></sup></p>
2
3<ul>
4<li>List item one.<sup id="fnref:second"><a href="#fn:second" rel="footnote">2</a></sup></li>
5<li>List item two.<sup id="fnref:third"><a href="#fn:third" rel="footnote">3</a></sup></li>
6</ul>
7
8<h1>Header<sup id="fnref:fourth"><a href="#fn:fourth" rel="footnote">4</a></sup></h1>
9
10<p>Some paragraph with a footnote<sup id="fnref:1"><a href="#fn:1" rel="footnote">5</a></sup>, and another<sup id="fnref:2"><a href="#fn:2" rel="footnote">6</a></sup>.</p>
11
12<p>Another paragraph with a named footnote<sup id="fnref:fn-name"><a href="#fn:fn-name" rel="footnote">7</a></sup>.</p>
13
14<p>This paragraph should not have a footnote marker since
15the footnote is undefined.[^3]</p>
16
17<p>This paragraph should not have a footnote marker since
18the footnote has already been used before.[^1]</p>
19
20<p>This paragraph links to a footnote with plenty of
21block-level content.<sup id="fnref:block"><a href="#fn:block" rel="footnote">8</a></sup></p>
22
23<p>This paragraph host the footnote reference within a
24footnote test<sup id="fnref:reference"><a href="#fn:reference" rel="footnote">9</a></sup>.</p>
25
26<hr />
27
28<p>Testing unusual footnote name<sup id="fnref:1$^!&quot;'"><a href="#fn:1$^!&quot;'" rel="footnote">10</a></sup>.</p>
29
30<div class="footnotes">
31<hr />
32<ol>
33
34<li id="fn:first">
35<p>This is the first note.&#160;<a href="#fnref:first" rev="footnote">&#8617;</a></p>
36</li>
37
38<li id="fn:second">
39<p>This is the second note.&#160;<a href="#fnref:second" rev="footnote">&#8617;</a></p>
40</li>
41
42<li id="fn:third">
43<p>This is the third note, defined out of order.&#160;<a href="#fnref:third" rev="footnote">&#8617;</a></p>
44</li>
45
46<li id="fn:fourth">
47<p>This is the fourth note.&#160;<a href="#fnref:fourth" rev="footnote">&#8617;</a></p>
48</li>
49
50<li id="fn:1">
51<p>Content for fifth footnote.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
52</li>
53
54<li id="fn:2">
55<p>Content for sixth footnote spaning on
56three lines, with some span-level markup like
57<em>emphasis</em>, a <a href="http://www.michelf.com/">link</a>.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
58</li>
59
60<li id="fn:fn-name">
61<p>Footnote beginning on the line next to the marker.&#160;<a href="#fnref:fn-name" rev="footnote">&#8617;</a></p>
62</li>
63
64<li id="fn:block">
65<p>Paragraph.</p>
66
67<ul>
68<li>List item</li>
69</ul>
70
71<blockquote>
72 <p>Blockquote</p>
73</blockquote>
74
75<pre><code>Code block
76</code></pre>
77
78<p><a href="#fnref:block" rev="footnote">&#8617;</a></p>
79</li>
80
81<li id="fn:reference">
82<p>This footnote has a footnote of its own.<sup id="fnref:nested"><a href="#fn:nested" rel="footnote">11</a></sup>&#160;<a href="#fnref:reference" rev="footnote">&#8617;</a></p>
83</li>
84
85<li id="fn:1$^!&quot;'">
86<p>Haha!&#160;<a href="#fnref:1$^!&quot;'" rev="footnote">&#8617;</a></p>
87</li>
88
89<li id="fn:nested">
90<p>This footnote should appear even though as it is refered
91from another footnote. But [^reference] should be litteral
92since the footnote with that name has already been used.&#160;<a href="#fnref:nested" rev="footnote">&#8617;</a></p>
93</li>
94
95</ol>
96</div>
  
1# Markdown inside code blocks
2
3<div markdown="1">
4foo
5</div>
6
7<div markdown='1'>
8foo
9</div>
10
11<div markdown=1>
12foo
13</div>
14
15<table>
16<tr><td markdown="1">test _emphasis_ (span)</td></tr>
17</table>
18
19<table>
20<tr><td markdown="span">test _emphasis_ (span)</td></tr>
21</table>
22
23<table>
24<tr><td markdown="block">test _emphasis_ (block)</td></tr>
25</table>
26
27## More complicated
28
29<table>
30<tr><td markdown="1">
31* this is _not_ a list item</td></tr>
32<tr><td markdown="span">
33* this is _not_ a list item</td></tr>
34<tr><td markdown="block">
35* this _is_ a list item
36</td></tr>
37</table>
38
39## With indent
40
41<div>
42 <div markdown="1">
43 This text is no code block: if it was, the
44 closing `<div>` would be too and the HTML block
45 would be invalid.
46
47 Markdown content in HTML blocks is assumed to be
48 indented the same as the block opening tag.
49
50 **This should be the third paragraph after the header.**
51 </div>
52</div>
53
54## Code block with rogue `</div>`s in Markdown code span and block
55
56<div>
57 <div markdown="1">
58
59 This is a code block however:
60
61 </div>
62
63 Funny isn't it? Here is a code span: `</div>`.
64
65 </div>
66</div>
67
68<div>
69 <div markdown="1">
70 * List item, not a code block
71
72Some text
73
74 This is a code block.
75 </div>
76</div>
77
78## No code block in markdown span mode
79
80<p markdown="1">
81 This is not a code block since Markdown parse paragraph
82 content as span. Code spans like `</p>` are allowed though.
83</p>
84
85<p markdown="1">_Hello_ _world_</p>
86
87## Preserving attributes and tags on more than one line:
88
89<p class="test" markdown="1"
90id="12">
91Some _span_ content.
92</p>
93
94
95## Header confusion bug
96
97<table class="canvas">
98<tr>
99<td id="main" markdown="1">Hello World!
100============
101
102Hello World!</td>
103</tr>
104</table>
  
1<h1>Markdown inside code blocks</h1>
2
3<div>
4
5<p>foo</p>
6
7</div>
8
9<div>
10
11<p>foo</p>
12
13</div>
14
15<div>
16
17<p>foo</p>
18
19</div>
20
21<table>
22<tr><td>test <em>emphasis</em> (span)</td></tr>
23</table>
24
25<table>
26<tr><td>test <em>emphasis</em> (span)</td></tr>
27</table>
28
29<table>
30<tr><td>
31
32<p>test <em>emphasis</em> (block)</p>
33
34</td></tr>
35</table>
36
37<h2>More complicated</h2>
38
39<table>
40<tr><td>
41* this is <em>not</em> a list item</td></tr>
42<tr><td>
43* this is <em>not</em> a list item</td></tr>
44<tr><td>
45
46<ul>
47<li>this <em>is</em> a list item</li>
48</ul>
49
50</td></tr>
51</table>
52
53<h2>With indent</h2>
54
55<div>
56 <div>
57
58<p>This text is no code block: if it was, the
59closing <code>&lt;div&gt;</code> would be too and the HTML block
60would be invalid.</p>
61
62<p>Markdown content in HTML blocks is assumed to be
63indented the same as the block opening tag.</p>
64
65<p><strong>This should be the third paragraph after the header.</strong></p>
66
67</div>
68</div>
69
70<h2>Code block with rogue <code>&lt;/div&gt;</code>s in Markdown code span and block</h2>
71
72<div>
73 <div>
74
75<p>This is a code block however:</p>
76
77<pre><code>&lt;/div&gt;
78</code></pre>
79
80<p>Funny isn't it? Here is a code span: <code>&lt;/div&gt;</code>.</p>
81
82</div>
83</div>
84
85<div>
86 <div>
87
88<ul>
89<li>List item, not a code block</li>
90</ul>
91
92<p>Some text</p>
93
94<pre><code>This is a code block.
95</code></pre>
96
97</div>
98</div>
99
100<h2>No code block in markdown span mode</h2>
101
102<p>
103 This is not a code block since Markdown parse paragraph
104 content as span. Code spans like <code>&lt;/p&gt;</code> are allowed though.
105</p>
106
107<p><em>Hello</em> <em>world</em></p>
108
109<h2>Preserving attributes and tags on more than one line:</h2>
110
111<p class="test"
112id="12">
113Some <em>span</em> content.
114</p>
115
116<h2>Header confusion bug</h2>
117
118<table class="canvas">
119<tr>
120<td id="main">Hello World!
121============
122
123Hello World!</td>
124</tr>
125</table>
  
1# Simple tables
2
3Header 1 | Header 2
4--------- | ---------
5Cell 1 | Cell 2
6Cell 3 | Cell 4
7
8With leading pipes:
9
10| Header 1 | Header 2
11| --------- | ---------
12| Cell 1 | Cell 2
13| Cell 3 | Cell 4
14
15With tailing pipes:
16
17Header 1 | Header 2 |
18--------- | --------- |
19Cell 1 | Cell 2 |
20Cell 3 | Cell 4 |
21
22With leading and tailing pipes:
23
24| Header 1 | Header 2 |
25| --------- | --------- |
26| Cell 1 | Cell 2 |
27| Cell 3 | Cell 4 |
28
29* * *
30
31# One-column one-row table
32
33With leading pipes:
34
35| Header
36| -------
37| Cell
38
39With tailing pipes:
40
41Header |
42------- |
43Cell |
44
45With leading and tailing pipes:
46
47| Header |
48| ------- |
49| Cell |
50
51* * *
52
53Table alignement:
54
55| Default | Right | Center | Left |
56| --------- |:--------- |:---------:| ---------:|
57| Long Cell | Long Cell | Long Cell | Long Cell |
58| Cell | Cell | Cell | Cell |
59
60Table alignement (alternate spacing):
61
62| Default | Right | Center | Left |
63| --------- | :-------- | :-------: | --------: |
64| Long Cell | Long Cell | Long Cell | Long Cell |
65| Cell | Cell | Cell | Cell |
66
67* * *
68
69# Empty cells
70
71| Header 1 | Header 2 |
72| --------- | --------- |
73| A | B |
74| C | |
75
76Header 1 | Header 2
77--------- | ---------
78A | B
79 | D
80
81* * *
82
83# Missing tailing pipe
84
85Header 1 | Header 2
86--------- | --------- |
87Cell | Cell |
88Cell | Cell |
89
90Header 1 | Header 2 |
91--------- | ---------
92Cell | Cell |
93Cell | Cell |
94
95Header 1 | Header 2 |
96--------- | --------- |
97Cell | Cell
98Cell | Cell |
99
100Header 1 | Header 2 |
101--------- | --------- |
102Cell | Cell |
103Cell | Cell
  
1<h1>Simple tables</h1>
2
3<table>
4<thead>
5<tr>
6 <th>Header 1</th>
7 <th>Header 2</th>
8</tr>
9</thead>
10<tbody>
11<tr>
12 <td>Cell 1</td>
13 <td>Cell 2</td>
14</tr>
15<tr>
16 <td>Cell 3</td>
17 <td>Cell 4</td>
18</tr>
19</tbody>
20</table>
21
22<p>With leading pipes:</p>
23
24<table>
25<thead>
26<tr>
27 <th>Header 1</th>
28 <th>Header 2</th>
29</tr>
30</thead>
31<tbody>
32<tr>
33 <td>Cell 1</td>
34 <td>Cell 2</td>
35</tr>
36<tr>
37 <td>Cell 3</td>
38 <td>Cell 4</td>
39</tr>
40</tbody>
41</table>
42
43<p>With tailing pipes:</p>
44
45<table>
46<thead>
47<tr>
48 <th>Header 1</th>
49 <th>Header 2</th>
50</tr>
51</thead>
52<tbody>
53<tr>
54 <td>Cell 1</td>
55 <td>Cell 2</td>
56</tr>
57<tr>
58 <td>Cell 3</td>
59 <td>Cell 4</td>
60</tr>
61</tbody>
62</table>
63
64<p>With leading and tailing pipes:</p>
65
66<table>
67<thead>
68<tr>
69 <th>Header 1</th>
70 <th>Header 2</th>
71</tr>
72</thead>
73<tbody>
74<tr>
75 <td>Cell 1</td>
76 <td>Cell 2</td>
77</tr>
78<tr>
79 <td>Cell 3</td>
80 <td>Cell 4</td>
81</tr>
82</tbody>
83</table>
84
85<hr />
86
87<h1>One-column one-row table</h1>
88
89<p>With leading pipes:</p>
90
91<table>
92<thead>
93<tr>
94 <th>Header</th>
95</tr>
96</thead>
97<tbody>
98<tr>
99 <td>Cell</td>
100</tr>
101</tbody>
102</table>
103
104<p>With tailing pipes:</p>
105
106<table>
107<thead>
108<tr>
109 <th>Header</th>
110</tr>
111</thead>
112<tbody>
113<tr>
114 <td>Cell</td>
115</tr>
116</tbody>
117</table>
118
119<p>With leading and tailing pipes:</p>
120
121<table>
122<thead>
123<tr>
124 <th>Header</th>
125</tr>
126</thead>
127<tbody>
128<tr>
129 <td>Cell</td>
130</tr>
131</tbody>
132</table>
133
134<hr />
135
136<p>Table alignement:</p>
137
138<table>
139<thead>
140<tr>
141 <th>Default</th>
142 <th align="left">Right</th>
143 <th align="center">Center</th>
144 <th align="right">Left</th>
145</tr>
146</thead>
147<tbody>
148<tr>
149 <td>Long Cell</td>
150 <td align="left">Long Cell</td>
151 <td align="center">Long Cell</td>
152 <td align="right">Long Cell</td>
153</tr>
154<tr>
155 <td>Cell</td>
156 <td align="left">Cell</td>
157 <td align="center">Cell</td>
158 <td align="right">Cell</td>
159</tr>
160</tbody>
161</table>
162
163<p>Table alignement (alternate spacing):</p>
164
165<table>
166<thead>
167<tr>
168 <th>Default</th>
169 <th align="left">Right</th>
170 <th align="center">Center</th>
171 <th align="right">Left</th>
172</tr>
173</thead>
174<tbody>
175<tr>
176 <td>Long Cell</td>
177 <td align="left">Long Cell</td>
178 <td align="center">Long Cell</td>
179 <td align="right">Long Cell</td>
180</tr>
181<tr>
182 <td>Cell</td>
183 <td align="left">Cell</td>
184 <td align="center">Cell</td>
185 <td align="right">Cell</td>
186</tr>
187</tbody>
188</table>
189
190<hr />
191
192<h1>Empty cells</h1>
193
194<table>
195<thead>
196<tr>
197 <th>Header 1</th>
198 <th>Header 2</th>
199</tr>
200</thead>
201<tbody>
202<tr>
203 <td>A</td>
204 <td>B</td>
205</tr>
206<tr>
207 <td>C</td>
208 <td></td>
209</tr>
210</tbody>
211</table>
212
213<table>
214<thead>
215<tr>
216 <th>Header 1</th>
217 <th>Header 2</th>
218</tr>
219</thead>
220<tbody>
221<tr>
222 <td>A</td>
223 <td>B</td>
224</tr>
225<tr>
226 <td></td>
227 <td>D</td>
228</tr>
229</tbody>
230</table>
231
232<hr />
233
234<h1>Missing tailing pipe</h1>
235
236<table>
237<thead>
238<tr>
239 <th>Header 1</th>
240 <th>Header 2</th>
241</tr>
242</thead>
243<tbody>
244<tr>
245 <td>Cell</td>
246 <td>Cell</td>
247</tr>
248<tr>
249 <td>Cell</td>
250 <td>Cell</td>
251</tr>
252</tbody>
253</table>
254
255<table>
256<thead>
257<tr>
258 <th>Header 1</th>
259 <th>Header 2</th>
260</tr>
261</thead>
262<tbody>
263<tr>
264 <td>Cell</td>
265 <td>Cell</td>
266</tr>
267<tr>
268 <td>Cell</td>
269 <td>Cell</td>
270</tr>
271</tbody>
272</table>
273
274<table>
275<thead>
276<tr>
277 <th>Header 1</th>
278 <th>Header 2</th>
279</tr>
280</thead>
281<tbody>
282<tr>
283 <td>Cell</td>
284 <td>Cell</td>
285</tr>
286<tr>
287 <td>Cell</td>
288 <td>Cell</td>
289</tr>
290</tbody>
291</table>
292
293<table>
294<thead>
295<tr>
296 <th>Header 1</th>
297 <th>Header 2</th>
298</tr>
299</thead>
300<tbody>
301<tr>
302 <td>Cell</td>
303 <td>Cell</td>
304</tr>
305<tr>
306 <td>Cell</td>
307 <td>Cell</td>
308</tr>
309</tbody>
310</table>
  
1[DEFAULT]
2extensions=extra
3normalize=1
4input_ext=.text
5output_ext=.xhtml
6skip=1
  
1[DEFAULT]
2normalize=1
3input_ext=.text
4output_ext=.xhtml
5skip=1
  
1<p>AT&amp;T has an ampersand in their name.</p>
2
3<p>AT&amp;T is another way to write it.</p>
4
5<p>This &amp; that.</p>
6
7<p>4 &lt; 5.</p>
8
9<p>6 > 5.</p>
10
11<p>Here's a <a href="http://example.com/?foo=1&amp;bar=2">link</a> with an ampersand in the URL.</p>
12
13<p>Here's a link with an amersand in the link text: <a href="http://att.com/" title="AT&amp;T">AT&amp;T</a>.</p>
14
15<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
16
17<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
  
1AT&T has an ampersand in their name.
2
3AT&amp;T is another way to write it.
4
5This & that.
6
74 < 5.
8
96 > 5.
10
11Here's a [link] [1] with an ampersand in the URL.
12
13Here's a link with an amersand in the link text: [AT&T] [2].
14
15Here's an inline [link](/script?foo=1&bar=2).
16
17Here's an inline [link](</script?foo=1&bar=2>).
18
19
20[1]: http://example.com/?foo=1&bar=2
21[2]: http://att.com/ "AT&T"
  
1<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>
2
3<p>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</a></p>
4
5<ul>
6<li>In a list?</li>
7<li><a href="http://example.com/">http://example.com/</a></li>
8<li>It should.</li>
9</ul>
10
11<blockquote>
12 <p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
13</blockquote>
14
15<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
16
17<pre><code>or here: &lt;http://example.com/&gt;
18</code></pre>
  
1Link: <http://example.com/>.
2
3With an ampersand: <http://example.com/?foo=1&bar=2>
4
5* In a list?
6* <http://example.com/>
7* It should.
8
9> Blockquoted: <http://example.com/>
10
11Auto-links should not occur here: `<http://example.com/>`
12
13 or here: <http://example.com/>
  
1<p>These should all get escaped:</p>
2
3<p>Backslash: \</p>
4
5<p>Backtick: `</p>
6
7<p>Asterisk: *</p>
8
9<p>Underscore: _</p>
10
11<p>Left brace: {</p>
12
13<p>Right brace: }</p>
14
15<p>Left bracket: [</p>
16
17<p>Right bracket: ]</p>
18
19<p>Left paren: (</p>
20
21<p>Right paren: )</p>
22
23<p>Greater-than: ></p>
24
25<p>Hash: #</p>
26
27<p>Period: .</p>
28
29<p>Bang: !</p>
30
31<p>Plus: +</p>
32
33<p>Minus: -</p>
34
35<p>These should not, because they occur within a code block:</p>
36
37<pre><code>Backslash: \\
38
39Backtick: \`
40
41Asterisk: \*
42
43Underscore: \_
44
45Left brace: \{
46
47Right brace: \}
48
49Left bracket: \[
50
51Right bracket: \]
52
53Left paren: \(
54
55Right paren: \)
56
57Greater-than: \&gt;
58
59Hash: \#
60
61Period: \.
62
63Bang: \!
64
65Plus: \+
66
67Minus: \-
68</code></pre>
69
70<p>Nor should these, which occur in code spans:</p>
71
72<p>Backslash: <code>\\</code></p>
73
74<p>Backtick: <code>\`</code></p>
75
76<p>Asterisk: <code>\*</code></p>
77
78<p>Underscore: <code>\_</code></p>
79
80<p>Left brace: <code>\{</code></p>
81
82<p>Right brace: <code>\}</code></p>
83
84<p>Left bracket: <code>\[</code></p>
85
86<p>Right bracket: <code>\]</code></p>
87
88<p>Left paren: <code>\(</code></p>
89
90<p>Right paren: <code>\)</code></p>
91
92<p>Greater-than: <code>\&gt;</code></p>
93
94<p>Hash: <code>\#</code></p>
95
96<p>Period: <code>\.</code></p>
97
98<p>Bang: <code>\!</code></p>
99
100<p>Plus: <code>\+</code></p>
101
102<p>Minus: <code>\-</code></p>
  
1These should all get escaped:
2
3Backslash: \\
4
5Backtick: \`
6
7Asterisk: \*
8
9Underscore: \_
10
11Left brace: \{
12
13Right brace: \}
14
15Left bracket: \[
16
17Right bracket: \]
18
19Left paren: \(
20
21Right paren: \)
22
23Greater-than: \>
24
25Hash: \#
26
27Period: \.
28
29Bang: \!
30
31Plus: \+
32
33Minus: \-
34
35
36
37These should not, because they occur within a code block:
38
39 Backslash: \\
40
41 Backtick: \`
42
43 Asterisk: \*
44
45 Underscore: \_
46
47 Left brace: \{
48
49 Right brace: \}
50
51 Left bracket: \[
52
53 Right bracket: \]
54
55 Left paren: \(
56
57 Right paren: \)
58
59 Greater-than: \>
60
61 Hash: \#
62
63 Period: \.
64
65 Bang: \!
66
67 Plus: \+
68
69 Minus: \-
70
71
72Nor should these, which occur in code spans:
73
74Backslash: `\\`
75
76Backtick: `` \` ``
77
78Asterisk: `\*`
79
80Underscore: `\_`
81
82Left brace: `\{`
83
84Right brace: `\}`
85
86Left bracket: `\[`
87
88Right bracket: `\]`
89
90Left paren: `\(`
91
92Right paren: `\)`
93
94Greater-than: `\>`
95
96Hash: `\#`
97
98Period: `\.`
99
100Bang: `\!`
101
102Plus: `\+`
103
104Minus: `\-`
  
1<blockquote>
2 <p>Example:</p>
3
4<pre><code>sub status {
5 print "working";
6}
7</code></pre>
8
9 <p>Or:</p>
10
11<pre><code>sub status {
12 return "working";
13}
14</code></pre>
15</blockquote>
  
1> Example:
2>
3> sub status {
4> print "working";
5> }
6>
7> Or:
8>
9> sub status {
10> return "working";
11> }
  
1<p>In Markdown 1.0.0 and earlier. Version
28. This line turns into a list item.
3Because a hard-wrapped line in the
4middle of a paragraph looked like a
5list item.</p>
6
7<p>Here's one with a bullet.
8* criminey.</p>
  
1In Markdown 1.0.0 and earlier. Version
28. This line turns into a list item.
3Because a hard-wrapped line in the
4middle of a paragraph looked like a
5list item.
6
7Here's one with a bullet.
8* criminey.
  
1<p>Dashes:</p>
2
3<hr />
4
5<hr />
6
7<hr />
8
9<hr />
10
11<pre><code>---
12</code></pre>
13
14<hr />
15
16<hr />
17
18<hr />
19
20<hr />
21
22<pre><code>- - -
23</code></pre>
24
25<p>Asterisks:</p>
26
27<hr />
28
29<hr />
30
31<hr />
32
33<hr />
34
35<pre><code>***
36</code></pre>
37
38<hr />
39
40<hr />
41
42<hr />
43
44<hr />
45
46<pre><code>* * *
47</code></pre>
48
49<p>Underscores:</p>
50
51<hr />
52
53<hr />
54
55<hr />
56
57<hr />
58
59<pre><code>___
60</code></pre>
61
62<hr />
63
64<hr />
65
66<hr />
67
68<hr />
69
70<pre><code>_ _ _
71</code></pre>
  
1Dashes:
2
3---
4
5 ---
6
7 ---
8
9 ---
10
11 ---
12
13- - -
14
15 - - -
16
17 - - -
18
19 - - -
20
21 - - -
22
23
24Asterisks:
25
26***
27
28 ***
29
30 ***
31
32 ***
33
34 ***
35
36* * *
37
38 * * *
39
40 * * *
41
42 * * *
43
44 * * *
45
46
47Underscores:
48
49___
50
51 ___
52
53 ___
54
55 ___
56
57 ___
58
59_ _ _
60
61 _ _ _
62
63 _ _ _
64
65 _ _ _
66
67 _ _ _
  
1<p>Simple block on one line:</p>
2
3<div>foo</div>
4
5<p>And nested without indentation:</p>
6
7<div>
8<div>
9<div>
10foo
11</div>
12</div>
13<div>bar</div>
14</div>
  
1Simple block on one line:
2
3<div>foo</div>
4
5And nested without indentation:
6
7<div>
8<div>
9<div>
10foo
11</div>
12</div>
13<div>bar</div>
14</div>
  
1<p>Here's a simple block:</p>
2
3<div>
4 foo
5</div>
6
7<p>This should be a code block, though:</p>
8
9<pre><code>&lt;div&gt;
10 foo
11&lt;/div&gt;
12</code></pre>
13
14<p>As should this:</p>
15
16<pre><code>&lt;div&gt;foo&lt;/div&gt;
17</code></pre>
18
19<p>Now, nested:</p>
20
21<div>
22 <div>
23 <div>
24 foo
25 </div>
26 </div>
27</div>
28
29<p>This should just be an HTML comment:</p>
30
31<!-- Comment -->
32
33<p>Multiline:</p>
34
35<!--
36Blah
37Blah
38-->
39
40<p>Code block:</p>
41
42<pre><code>&lt;!-- Comment --&gt;
43</code></pre>
44
45<p>Just plain comment, with trailing spaces on the line:</p>
46
47<!-- foo -->
48
49<p>Code:</p>
50
51<pre><code>&lt;hr /&gt;
52</code></pre>
53
54<p>Hr's:</p>
55
56<hr>
57
58<hr/>
59
60<hr />
61
62<hr>
63
64<hr/>
65
66<hr />
67
68<hr class="foo" id="bar" />
69
70<hr class="foo" id="bar"/>
71
72<hr class="foo" id="bar" >
  
1Here's a simple block:
2
3<div>
4 foo
5</div>
6
7This should be a code block, though:
8
9 <div>
10 foo
11 </div>
12
13As should this:
14
15 <div>foo</div>
16
17Now, nested:
18
19<div>
20 <div>
21 <div>
22 foo
23 </div>
24 </div>
25</div>
26
27This should just be an HTML comment:
28
29<!-- Comment -->
30
31Multiline:
32
33<!--
34Blah
35Blah
36-->
37
38Code block:
39
40 <!-- Comment -->
41
42Just plain comment, with trailing spaces on the line:
43
44<!-- foo -->
45
46Code:
47
48 <hr />
49
50Hr's:
51
52<hr>
53
54<hr/>
55
56<hr />
57
58<hr>
59
60<hr/>
61
62<hr />
63
64<hr class="foo" id="bar" />
65
66<hr class="foo" id="bar"/>
67
68<hr class="foo" id="bar" >
  
1<p>Paragraph one.</p>
2
3<!-- This is a simple comment -->
4
5<!--
6 This is another comment.
7-->
8
9<p>Paragraph two.</p>
10
11<!-- one comment block -- -- with two comments -->
12
13<p>The end.</p>
  
1Paragraph one.
2
3<!-- This is a simple comment -->
4
5<!--
6 This is another comment.
7-->
8
9Paragraph two.
10
11<!-- one comment block -- -- with two comments -->
12
13The end.
  
1<p>Just a <a href="/url/">URL</a>.</p>
2
3<p><a href="/url/" title="title">URL and title</a>.</p>
4
5<p><a href="/url/" title="title preceded by two spaces">URL and title</a>.</p>
6
7<p><a href="/url/" title="title preceded by a tab">URL and title</a>.</p>
8
9<p><a href="">Empty</a>.</p>
  
1Just a [URL](/url/).
2
3[URL and title](/url/ "title").
4
5[URL and title](/url/ "title preceded by two spaces").
6
7[URL and title](/url/ "title preceded by a tab").
8
9[Empty]().
  
1<p>Foo <a href="/url/" title="Title">bar</a>.</p>
2
3<p>Foo <a href="/url/" title="Title">bar</a>.</p>
4
5<p>Foo <a href="/url/" title="Title">bar</a>.</p>
6
7<p>With <a href="/url/">embedded [brackets]</a>.</p>
8
9<p>Indented <a href="/url">once</a>.</p>
10
11<p>Indented <a href="/url">twice</a>.</p>
12
13<p>Indented <a href="/url">thrice</a>.</p>
14
15<p>Indented [four][] times.</p>
16
17<pre><code>[four]: /url
18</code></pre>
  
1Foo [bar] [1].
2
3Foo [bar][1].
4
5Foo [bar]
6[1].
7
8[1]: /url/ "Title"
9
10
11With [embedded [brackets]] [b].
12
13
14Indented [once][].
15
16Indented [twice][].
17
18Indented [thrice][].
19
20Indented [four][] times.
21
22 [once]: /url
23
24 [twice]: /url
25
26 [thrice]: /url
27
28 [four]: /url
29
30
31[b]: /url/
  
1<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
2
3<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
  
1Foo [bar][].
2
3Foo [bar](/url/ "Title with "quotes" inside").
4
5
6 [bar]: /url/ "Title with "quotes" inside"
  
1<h1>Markdown: Basics</h1>
2
3<ul id="ProjectSubmenu">
4 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
5 <li><a class="selected" title="Markdown Basics">Basics</a></li>
6 <li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
7 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
8 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
9</ul>
10
11<h2>Getting the Gist of Markdown's Formatting Syntax</h2>
12
13<p>This page offers a brief overview of what it's like to use Markdown.
14The <a href="/projects/markdown/syntax" title="Markdown Syntax">syntax page</a> provides complete, detailed documentation for
15every feature, but Markdown should be very easy to pick up simply by
16looking at a few examples of it in action. The examples on this page
17are written in a before/after style, showing example syntax and the
18HTML output produced by Markdown.</p>
19
20<p>It's also helpful to simply try Markdown out; the <a href="/projects/markdown/dingus" title="Markdown Dingus">Dingus</a> is a
21web application that allows you type your own Markdown-formatted text
22and translate it to XHTML.</p>
23
24<p><strong>Note:</strong> This document is itself written using Markdown; you
25can <a href="/projects/markdown/basics.text">see the source for it by adding '.text' to the URL</a>.</p>
26
27<h2>Paragraphs, Headers, Blockquotes</h2>
28
29<p>A paragraph is simply one or more consecutive lines of text, separated
30by one or more blank lines. (A blank line is any line that looks like a
31blank line -- a line containing nothing spaces or tabs is considered
32blank.) Normal paragraphs should not be intended with spaces or tabs.</p>
33
34<p>Markdown offers two styles of headers: <em>Setext</em> and <em>atx</em>.
35Setext-style headers for <code>&lt;h1&gt;</code> and <code>&lt;h2&gt;</code> are created by
36"underlining" with equal signs (<code>=</code>) and hyphens (<code>-</code>), respectively.
37To create an atx-style header, you put 1-6 hash marks (<code>#</code>) at the
38beginning of the line -- the number of hashes equals the resulting
39HTML header level.</p>
40
41<p>Blockquotes are indicated using email-style '<code>&gt;</code>' angle brackets.</p>
42
43<p>Markdown:</p>
44
45<pre><code>A First Level Header
46====================
47
48A Second Level Header
49---------------------
50
51Now is the time for all good men to come to
52the aid of their country. This is just a
53regular paragraph.
54
55The quick brown fox jumped over the lazy
56dog's back.
57
58### Header 3
59
60&gt; This is a blockquote.
61&gt;
62&gt; This is the second paragraph in the blockquote.
63&gt;
64&gt; ## This is an H2 in a blockquote
65</code></pre>
66
67<p>Output:</p>
68
69<pre><code>&lt;h1&gt;A First Level Header&lt;/h1&gt;
70
71&lt;h2&gt;A Second Level Header&lt;/h2&gt;
72
73&lt;p&gt;Now is the time for all good men to come to
74the aid of their country. This is just a
75regular paragraph.&lt;/p&gt;
76
77&lt;p&gt;The quick brown fox jumped over the lazy
78dog's back.&lt;/p&gt;
79
80&lt;h3&gt;Header 3&lt;/h3&gt;
81
82&lt;blockquote&gt;
83 &lt;p&gt;This is a blockquote.&lt;/p&gt;
84
85 &lt;p&gt;This is the second paragraph in the blockquote.&lt;/p&gt;
86
87 &lt;h2&gt;This is an H2 in a blockquote&lt;/h2&gt;
88&lt;/blockquote&gt;
89</code></pre>
90
91<h3>Phrase Emphasis</h3>
92
93<p>Markdown uses asterisks and underscores to indicate spans of emphasis.</p>
94
95<p>Markdown:</p>
96
97<pre><code>Some of these words *are emphasized*.
98Some of these words _are emphasized also_.
99
100Use two asterisks for **strong emphasis**.
101Or, if you prefer, __use two underscores instead__.
102</code></pre>
103
104<p>Output:</p>
105
106<pre><code>&lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
107Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
108
109&lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
110Or, if you prefer, &lt;strong&gt;use two underscores instead&lt;/strong&gt;.&lt;/p&gt;
111</code></pre>
112
113<h2>Lists</h2>
114
115<p>Unordered (bulleted) lists use asterisks, pluses, and hyphens (<code>*</code>,
116<code>+</code>, and <code>-</code>) as list markers. These three markers are
117interchangable; this:</p>
118
119<pre><code>* Candy.
120* Gum.
121* Booze.
122</code></pre>
123
124<p>this:</p>
125
126<pre><code>+ Candy.
127+ Gum.
128+ Booze.
129</code></pre>
130
131<p>and this:</p>
132
133<pre><code>- Candy.
134- Gum.
135- Booze.
136</code></pre>
137
138<p>all produce the same output:</p>
139
140<pre><code>&lt;ul&gt;
141&lt;li&gt;Candy.&lt;/li&gt;
142&lt;li&gt;Gum.&lt;/li&gt;
143&lt;li&gt;Booze.&lt;/li&gt;
144&lt;/ul&gt;
145</code></pre>
146
147<p>Ordered (numbered) lists use regular numbers, followed by periods, as
148list markers:</p>
149
150<pre><code>1. Red
1512. Green
1523. Blue
153</code></pre>
154
155<p>Output:</p>
156
157<pre><code>&lt;ol&gt;
158&lt;li&gt;Red&lt;/li&gt;
159&lt;li&gt;Green&lt;/li&gt;
160&lt;li&gt;Blue&lt;/li&gt;
161&lt;/ol&gt;
162</code></pre>
163
164<p>If you put blank lines between items, you'll get <code>&lt;p&gt;</code> tags for the
165list item text. You can create multi-paragraph list items by indenting
166the paragraphs by 4 spaces or 1 tab:</p>
167
168<pre><code>* A list item.
169
170 With multiple paragraphs.
171
172* Another item in the list.
173</code></pre>
174
175<p>Output:</p>
176
177<pre><code>&lt;ul&gt;
178&lt;li&gt;&lt;p&gt;A list item.&lt;/p&gt;
179&lt;p&gt;With multiple paragraphs.&lt;/p&gt;&lt;/li&gt;
180&lt;li&gt;&lt;p&gt;Another item in the list.&lt;/p&gt;&lt;/li&gt;
181&lt;/ul&gt;
182</code></pre>
183
184<h3>Links</h3>
185
186<p>Markdown supports two styles for creating links: <em>inline</em> and
187<em>reference</em>. With both styles, you use square brackets to delimit the
188text you want to turn into a link.</p>
189
190<p>Inline-style links use parentheses immediately after the link text.
191For example:</p>
192
193<pre><code>This is an [example link](http://example.com/).
194</code></pre>
195
196<p>Output:</p>
197
198<pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/"&gt;
199example link&lt;/a&gt;.&lt;/p&gt;
200</code></pre>
201
202<p>Optionally, you may include a title attribute in the parentheses:</p>
203
204<pre><code>This is an [example link](http://example.com/ "With a Title").
205</code></pre>
206
207<p>Output:</p>
208
209<pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/" title="With a Title"&gt;
210example link&lt;/a&gt;.&lt;/p&gt;
211</code></pre>
212
213<p>Reference-style links allow you to refer to your links by names, which
214you define elsewhere in your document:</p>
215
216<pre><code>I get 10 times more traffic from [Google][1] than from
217[Yahoo][2] or [MSN][3].
218
219[1]: http://google.com/ "Google"
220[2]: http://search.yahoo.com/ "Yahoo Search"
221[3]: http://search.msn.com/ "MSN Search"
222</code></pre>
223
224<p>Output:</p>
225
226<pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
227title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
228title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
229title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
230</code></pre>
231
232<p>The title attribute is optional. Link names may contain letters,
233numbers and spaces, but are <em>not</em> case sensitive:</p>
234
235<pre><code>I start my morning with a cup of coffee and
236[The New York Times][NY Times].
237
238[ny times]: http://www.nytimes.com/
239</code></pre>
240
241<p>Output:</p>
242
243<pre><code>&lt;p&gt;I start my morning with a cup of coffee and
244&lt;a href="http://www.nytimes.com/"&gt;The New York Times&lt;/a&gt;.&lt;/p&gt;
245</code></pre>
246
247<h3>Images</h3>
248
249<p>Image syntax is very much like link syntax.</p>
250
251<p>Inline (titles are optional):</p>
252
253<pre><code>![alt text](/path/to/img.jpg "Title")
254</code></pre>
255
256<p>Reference-style:</p>
257
258<pre><code>![alt text][id]
259
260[id]: /path/to/img.jpg "Title"
261</code></pre>
262
263<p>Both of the above examples produce the same output:</p>
264
265<pre><code>&lt;img src="/path/to/img.jpg" alt="alt text" title="Title" /&gt;
266</code></pre>
267
268<h3>Code</h3>
269
270<p>In a regular paragraph, you can create code span by wrapping text in
271backtick quotes. Any ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> or
272<code>&gt;</code>) will automatically be translated into HTML entities. This makes
273it easy to use Markdown to write about HTML example code:</p>
274
275<pre><code>I strongly recommend against using any `&lt;blink&gt;` tags.
276
277I wish SmartyPants used named entities like `&amp;mdash;`
278instead of decimal-encoded entites like `&amp;#8212;`.
279</code></pre>
280
281<p>Output:</p>
282
283<pre><code>&lt;p&gt;I strongly recommend against using any
284&lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
285
286&lt;p&gt;I wish SmartyPants used named entities like
287&lt;code&gt;&amp;amp;mdash;&lt;/code&gt; instead of decimal-encoded
288entites like &lt;code&gt;&amp;amp;#8212;&lt;/code&gt;.&lt;/p&gt;
289</code></pre>
290
291<p>To specify an entire block of pre-formatted code, indent every line of
292the block by 4 spaces or 1 tab. Just like with code spans, <code>&amp;</code>, <code>&lt;</code>,
293and <code>&gt;</code> characters will be escaped automatically.</p>
294
295<p>Markdown:</p>
296
297<pre><code>If you want your page to validate under XHTML 1.0 Strict,
298you've got to put paragraph tags in your blockquotes:
299
300 &lt;blockquote&gt;
301 &lt;p&gt;For example.&lt;/p&gt;
302 &lt;/blockquote&gt;
303</code></pre>
304
305<p>Output:</p>
306
307<pre><code>&lt;p&gt;If you want your page to validate under XHTML 1.0 Strict,
308you've got to put paragraph tags in your blockquotes:&lt;/p&gt;
309
310&lt;pre&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;
311 &amp;lt;p&amp;gt;For example.&amp;lt;/p&amp;gt;
312&amp;lt;/blockquote&amp;gt;
313&lt;/code&gt;&lt;/pre&gt;
314</code></pre>
  
1Markdown: Basics
2================
3
4<ul id="ProjectSubmenu">
5 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
6 <li><a class="selected" title="Markdown Basics">Basics</a></li>
7 <li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
8 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
9 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
10</ul>
11
12
13Getting the Gist of Markdown's Formatting Syntax
14------------------------------------------------
15
16This page offers a brief overview of what it's like to use Markdown.
17The [syntax page] [s] provides complete, detailed documentation for
18every feature, but Markdown should be very easy to pick up simply by
19looking at a few examples of it in action. The examples on this page
20are written in a before/after style, showing example syntax and the
21HTML output produced by Markdown.
22
23It's also helpful to simply try Markdown out; the [Dingus] [d] is a
24web application that allows you type your own Markdown-formatted text
25and translate it to XHTML.
26
27**Note:** This document is itself written using Markdown; you
28can [see the source for it by adding '.text' to the URL] [src].
29
30 [s]: /projects/markdown/syntax "Markdown Syntax"
31 [d]: /projects/markdown/dingus "Markdown Dingus"
32 [src]: /projects/markdown/basics.text
33
34
35## Paragraphs, Headers, Blockquotes ##
36
37A paragraph is simply one or more consecutive lines of text, separated
38by one or more blank lines. (A blank line is any line that looks like a
39blank line -- a line containing nothing spaces or tabs is considered
40blank.) Normal paragraphs should not be intended with spaces or tabs.
41
42Markdown offers two styles of headers: *Setext* and *atx*.
43Setext-style headers for `<h1>` and `<h2>` are created by
44"underlining" with equal signs (`=`) and hyphens (`-`), respectively.
45To create an atx-style header, you put 1-6 hash marks (`#`) at the
46beginning of the line -- the number of hashes equals the resulting
47HTML header level.
48
49Blockquotes are indicated using email-style '`>`' angle brackets.
50
51Markdown:
52
53 A First Level Header
54 ====================
55
56 A Second Level Header
57 ---------------------
58
59 Now is the time for all good men to come to
60 the aid of their country. This is just a
61 regular paragraph.
62
63 The quick brown fox jumped over the lazy
64 dog's back.
65
66 ### Header 3
67
68 > This is a blockquote.
69 >
70 > This is the second paragraph in the blockquote.
71 >
72 > ## This is an H2 in a blockquote
73
74
75Output:
76
77 <h1>A First Level Header</h1>
78
79 <h2>A Second Level Header</h2>
80
81 <p>Now is the time for all good men to come to
82 the aid of their country. This is just a
83 regular paragraph.</p>
84
85 <p>The quick brown fox jumped over the lazy
86 dog's back.</p>
87
88 <h3>Header 3</h3>
89
90 <blockquote>
91 <p>This is a blockquote.</p>
92
93 <p>This is the second paragraph in the blockquote.</p>
94
95 <h2>This is an H2 in a blockquote</h2>
96 </blockquote>
97
98
99
100### Phrase Emphasis ###
101
102Markdown uses asterisks and underscores to indicate spans of emphasis.
103
104Markdown:
105
106 Some of these words *are emphasized*.
107 Some of these words _are emphasized also_.
108
109 Use two asterisks for **strong emphasis**.
110 Or, if you prefer, __use two underscores instead__.
111
112Output:
113
114 <p>Some of these words <em>are emphasized</em>.
115 Some of these words <em>are emphasized also</em>.</p>
116
117 <p>Use two asterisks for <strong>strong emphasis</strong>.
118 Or, if you prefer, <strong>use two underscores instead</strong>.</p>
119
120
121
122## Lists ##
123
124Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
125`+`, and `-`) as list markers. These three markers are
126interchangable; this:
127
128 * Candy.
129 * Gum.
130 * Booze.
131
132this:
133
134 + Candy.
135 + Gum.
136 + Booze.
137
138and this:
139
140 - Candy.
141 - Gum.
142 - Booze.
143
144all produce the same output:
145
146 <ul>
147 <li>Candy.</li>
148 <li>Gum.</li>
149 <li>Booze.</li>
150 </ul>
151
152Ordered (numbered) lists use regular numbers, followed by periods, as
153list markers:
154
155 1. Red
156 2. Green
157 3. Blue
158
159Output:
160
161 <ol>
162 <li>Red</li>
163 <li>Green</li>
164 <li>Blue</li>
165 </ol>
166
167If you put blank lines between items, you'll get `<p>` tags for the
168list item text. You can create multi-paragraph list items by indenting
169the paragraphs by 4 spaces or 1 tab:
170
171 * A list item.
172
173 With multiple paragraphs.
174
175 * Another item in the list.
176
177Output:
178
179 <ul>
180 <li><p>A list item.</p>
181 <p>With multiple paragraphs.</p></li>
182 <li><p>Another item in the list.</p></li>
183 </ul>
184
185
186
187### Links ###
188
189Markdown supports two styles for creating links: *inline* and
190*reference*. With both styles, you use square brackets to delimit the
191text you want to turn into a link.
192
193Inline-style links use parentheses immediately after the link text.
194For example:
195
196 This is an [example link](http://example.com/).
197
198Output:
199
200 <p>This is an <a href="http://example.com/">
201 example link</a>.</p>
202
203Optionally, you may include a title attribute in the parentheses:
204
205 This is an [example link](http://example.com/ "With a Title").
206
207Output:
208
209 <p>This is an <a href="http://example.com/" title="With a Title">
210 example link</a>.</p>
211
212Reference-style links allow you to refer to your links by names, which
213you define elsewhere in your document:
214
215 I get 10 times more traffic from [Google][1] than from
216 [Yahoo][2] or [MSN][3].
217
218 [1]: http://google.com/ "Google"
219 [2]: http://search.yahoo.com/ "Yahoo Search"
220 [3]: http://search.msn.com/ "MSN Search"
221
222Output:
223
224 <p>I get 10 times more traffic from <a href="http://google.com/"
225 title="Google">Google</a> than from <a href="http://search.yahoo.com/"
226 title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
227 title="MSN Search">MSN</a>.</p>
228
229The title attribute is optional. Link names may contain letters,
230numbers and spaces, but are *not* case sensitive:
231
232 I start my morning with a cup of coffee and
233 [The New York Times][NY Times].
234
235 [ny times]: http://www.nytimes.com/
236
237Output:
238
239 <p>I start my morning with a cup of coffee and
240 <a href="http://www.nytimes.com/">The New York Times</a>.</p>
241
242
243### Images ###
244
245Image syntax is very much like link syntax.
246
247Inline (titles are optional):
248
249 ![alt text](/path/to/img.jpg "Title")
250
251Reference-style:
252
253 ![alt text][id]
254
255 [id]: /path/to/img.jpg "Title"
256
257Both of the above examples produce the same output:
258
259 <img src="/path/to/img.jpg" alt="alt text" title="Title" />
260
261
262
263### Code ###
264
265In a regular paragraph, you can create code span by wrapping text in
266backtick quotes. Any ampersands (`&`) and angle brackets (`<` or
267`>`) will automatically be translated into HTML entities. This makes
268it easy to use Markdown to write about HTML example code:
269
270 I strongly recommend against using any `<blink>` tags.
271
272 I wish SmartyPants used named entities like `&mdash;`
273 instead of decimal-encoded entites like `&#8212;`.
274
275Output:
276
277 <p>I strongly recommend against using any
278 <code>&lt;blink&gt;</code> tags.</p>
279
280 <p>I wish SmartyPants used named entities like
281 <code>&amp;mdash;</code> instead of decimal-encoded
282 entites like <code>&amp;#8212;</code>.</p>
283
284
285To specify an entire block of pre-formatted code, indent every line of
286the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`,
287and `>` characters will be escaped automatically.
288
289Markdown:
290
291 If you want your page to validate under XHTML 1.0 Strict,
292 you've got to put paragraph tags in your blockquotes:
293
294 <blockquote>
295 <p>For example.</p>
296 </blockquote>
297
298Output:
299
300 <p>If you want your page to validate under XHTML 1.0 Strict,
301 you've got to put paragraph tags in your blockquotes:</p>
302
303 <pre><code>&lt;blockquote&gt;
304 &lt;p&gt;For example.&lt;/p&gt;
305 &lt;/blockquote&gt;
306 </code></pre>
  
1<h1>Markdown: Syntax</h1>
2
3<ul id="ProjectSubmenu">
4 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
5 <li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li>
6 <li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li>
7 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
8 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
9</ul>
10
11<ul>
12<li><a href="#overview">Overview</a>
13<ul>
14<li><a href="#philosophy">Philosophy</a></li>
15<li><a href="#html">Inline HTML</a></li>
16<li><a href="#autoescape">Automatic Escaping for Special Characters</a></li>
17</ul></li>
18<li><a href="#block">Block Elements</a>
19<ul>
20<li><a href="#p">Paragraphs and Line Breaks</a></li>
21<li><a href="#header">Headers</a></li>
22<li><a href="#blockquote">Blockquotes</a></li>
23<li><a href="#list">Lists</a></li>
24<li><a href="#precode">Code Blocks</a></li>
25<li><a href="#hr">Horizontal Rules</a></li>
26</ul></li>
27<li><a href="#span">Span Elements</a>
28<ul>
29<li><a href="#link">Links</a></li>
30<li><a href="#em">Emphasis</a></li>
31<li><a href="#code">Code</a></li>
32<li><a href="#img">Images</a></li>
33</ul></li>
34<li><a href="#misc">Miscellaneous</a>
35<ul>
36<li><a href="#backslash">Backslash Escapes</a></li>
37<li><a href="#autolink">Automatic Links</a></li>
38</ul></li>
39</ul>
40
41<p><strong>Note:</strong> This document is itself written using Markdown; you
42can <a href="/projects/markdown/syntax.text">see the source for it by adding '.text' to the URL</a>.</p>
43
44<hr />
45
46<h2 id="overview">Overview</h2>
47
48<h3 id="philosophy">Philosophy</h3>
49
50<p>Markdown is intended to be as easy-to-read and easy-to-write as is feasible.</p>
51
52<p>Readability, however, is emphasized above all else. A Markdown-formatted
53document should be publishable as-is, as plain text, without looking
54like it's been marked up with tags or formatting instructions. While
55Markdown's syntax has been influenced by several existing text-to-HTML
56filters -- 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>,
57<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
58inspiration for Markdown's syntax is the format of plain text email.</p>
59
60<p>To this end, Markdown's syntax is comprised entirely of punctuation
61characters, which punctuation characters have been carefully chosen so
62as to look like what they mean. E.g., asterisks around a word actually
63look like *emphasis*. Markdown lists look like, well, lists. Even
64blockquotes look like quoted passages of text, assuming you've ever
65used email.</p>
66
67<h3 id="html">Inline HTML</h3>
68
69<p>Markdown's syntax is intended for one purpose: to be used as a
70format for <em>writing</em> for the web.</p>
71
72<p>Markdown is not a replacement for HTML, or even close to it. Its
73syntax is very small, corresponding only to a very small subset of
74HTML tags. The idea is <em>not</em> to create a syntax that makes it easier
75to insert HTML tags. In my opinion, HTML tags are already easy to
76insert. The idea for Markdown is to make it easy to read, write, and
77edit prose. HTML is a <em>publishing</em> format; Markdown is a <em>writing</em>
78format. Thus, Markdown's formatting syntax only addresses issues that
79can be conveyed in plain text.</p>
80
81<p>For any markup that is not covered by Markdown's syntax, you simply
82use HTML itself. There's no need to preface it or delimit it to
83indicate that you're switching from Markdown to HTML; you just use
84the tags.</p>
85
86<p>The only restrictions are that block-level HTML elements -- e.g. <code>&lt;div&gt;</code>,
87<code>&lt;table&gt;</code>, <code>&lt;pre&gt;</code>, <code>&lt;p&gt;</code>, etc. -- must be separated from surrounding
88content by blank lines, and the start and end tags of the block should
89not be indented with tabs or spaces. Markdown is smart enough not
90to add extra (unwanted) <code>&lt;p&gt;</code> tags around HTML block-level tags.</p>
91
92<p>For example, to add an HTML table to a Markdown article:</p>
93
94<pre><code>This is a regular paragraph.
95
96&lt;table&gt;
97 &lt;tr&gt;
98 &lt;td&gt;Foo&lt;/td&gt;
99 &lt;/tr&gt;
100&lt;/table&gt;
101
102This is another regular paragraph.
103</code></pre>
104
105<p>Note that Markdown formatting syntax is not processed within block-level
106HTML tags. E.g., you can't use Markdown-style <code>*emphasis*</code> inside an
107HTML block.</p>
108
109<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
110used anywhere in a Markdown paragraph, list item, or header. If you
111want, you can even use HTML tags instead of Markdown formatting; e.g. if
112you'd prefer to use HTML <code>&lt;a&gt;</code> or <code>&lt;img&gt;</code> tags instead of Markdown's
113link or image syntax, go right ahead.</p>
114
115<p>Unlike block-level HTML tags, Markdown syntax <em>is</em> processed within
116span-level tags.</p>
117
118<h3 id="autoescape">Automatic Escaping for Special Characters</h3>
119
120<p>In HTML, there are two characters that demand special treatment: <code>&lt;</code>
121and <code>&amp;</code>. Left angle brackets are used to start tags; ampersands are
122used to denote HTML entities. If you want to use them as literal
123characters, you must escape them as entities, e.g. <code>&amp;lt;</code>, and
124<code>&amp;amp;</code>.</p>
125
126<p>Ampersands in particular are bedeviling for web writers. If you want to
127write about 'AT&amp;T', you need to write '<code>AT&amp;amp;T</code>'. You even need to
128escape ampersands within URLs. Thus, if you want to link to:</p>
129
130<pre><code>http://images.google.com/images?num=30&amp;q=larry+bird
131</code></pre>
132
133<p>you need to encode the URL as:</p>
134
135<pre><code>http://images.google.com/images?num=30&amp;amp;q=larry+bird
136</code></pre>
137
138<p>in your anchor tag <code>href</code> attribute. Needless to say, this is easy to
139forget, and is probably the single most common source of HTML validation
140errors in otherwise well-marked-up web sites.</p>
141
142<p>Markdown allows you to use these characters naturally, taking care of
143all the necessary escaping for you. If you use an ampersand as part of
144an HTML entity, it remains unchanged; otherwise it will be translated
145into <code>&amp;amp;</code>.</p>
146
147<p>So, if you want to include a copyright symbol in your article, you can write:</p>
148
149<pre><code>&amp;copy;
150</code></pre>
151
152<p>and Markdown will leave it alone. But if you write:</p>
153
154<pre><code>AT&amp;T
155</code></pre>
156
157<p>Markdown will translate it to:</p>
158
159<pre><code>AT&amp;amp;T
160</code></pre>
161
162<p>Similarly, because Markdown supports <a href="#html">inline HTML</a>, if you use
163angle brackets as delimiters for HTML tags, Markdown will treat them as
164such. But if you write:</p>
165
166<pre><code>4 &lt; 5
167</code></pre>
168
169<p>Markdown will translate it to:</p>
170
171<pre><code>4 &amp;lt; 5
172</code></pre>
173
174<p>However, inside Markdown code spans and blocks, angle brackets and
175ampersands are <em>always</em> encoded automatically. This makes it easy to use
176Markdown to write about HTML code. (As opposed to raw HTML, which is a
177terrible format for writing about HTML syntax, because every single <code>&lt;</code>
178and <code>&amp;</code> in your example code needs to be escaped.)</p>
179
180<hr />
181
182<h2 id="block">Block Elements</h2>
183
184<h3 id="p">Paragraphs and Line Breaks</h3>
185
186<p>A paragraph is simply one or more consecutive lines of text, separated
187by one or more blank lines. (A blank line is any line that looks like a
188blank line -- a line containing nothing but spaces or tabs is considered
189blank.) Normal paragraphs should not be intended with spaces or tabs.</p>
190
191<p>The implication of the "one or more consecutive lines of text" rule is
192that Markdown supports "hard-wrapped" text paragraphs. This differs
193significantly from most other text-to-HTML formatters (including Movable
194Type's "Convert Line Breaks" option) which translate every line break
195character in a paragraph into a <code>&lt;br /&gt;</code> tag.</p>
196
197<p>When you <em>do</em> want to insert a <code>&lt;br /&gt;</code> break tag using Markdown, you
198end a line with two or more spaces, then type return.</p>
199
200<p>Yes, this takes a tad more effort to create a <code>&lt;br /&gt;</code>, but a simplistic
201"every line break is a <code>&lt;br /&gt;</code>" rule wouldn't work for Markdown.
202Markdown's email-style <a href="#blockquote">blockquoting</a> and multi-paragraph <a href="#list">list items</a>
203work best -- and look better -- when you format them with hard breaks.</p>
204
205<h3 id="header">Headers</h3>
206
207<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>
208
209<p>Setext-style headers are "underlined" using equal signs (for first-level
210headers) and dashes (for second-level headers). For example:</p>
211
212<pre><code>This is an H1
213=============
214
215This is an H2
216-------------
217</code></pre>
218
219<p>Any number of underlining <code>=</code>'s or <code>-</code>'s will work.</p>
220
221<p>Atx-style headers use 1-6 hash characters at the start of the line,
222corresponding to header levels 1-6. For example:</p>
223
224<pre><code># This is an H1
225
226## This is an H2
227
228###### This is an H6
229</code></pre>
230
231<p>Optionally, you may "close" atx-style headers. This is purely
232cosmetic -- you can use this if you think it looks better. The
233closing hashes don't even need to match the number of hashes
234used to open the header. (The number of opening hashes
235determines the header level.) :</p>
236
237<pre><code># This is an H1 #
238
239## This is an H2 ##
240
241### This is an H3 ######
242</code></pre>
243
244<h3 id="blockquote">Blockquotes</h3>
245
246<p>Markdown uses email-style <code>&gt;</code> characters for blockquoting. If you're
247familiar with quoting passages of text in an email message, then you
248know how to create a blockquote in Markdown. It looks best if you hard
249wrap the text and put a <code>&gt;</code> before every line:</p>
250
251<pre><code>&gt; This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
252&gt; consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
253&gt; Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
254&gt;
255&gt; Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
256&gt; id sem consectetuer libero luctus adipiscing.
257</code></pre>
258
259<p>Markdown allows you to be lazy and only put the <code>&gt;</code> before the first
260line of a hard-wrapped paragraph:</p>
261
262<pre><code>&gt; This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
263consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
264Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
265
266&gt; Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
267id sem consectetuer libero luctus adipiscing.
268</code></pre>
269
270<p>Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
271adding additional levels of <code>&gt;</code>:</p>
272
273<pre><code>&gt; This is the first level of quoting.
274&gt;
275&gt; &gt; This is nested blockquote.
276&gt;
277&gt; Back to the first level.
278</code></pre>
279
280<p>Blockquotes can contain other Markdown elements, including headers, lists,
281and code blocks:</p>
282
283<pre><code>&gt; ## This is a header.
284&gt;
285&gt; 1. This is the first list item.
286&gt; 2. This is the second list item.
287&gt;
288&gt; Here's some example code:
289&gt;
290&gt; return shell_exec("echo $input | $markdown_script");
291</code></pre>
292
293<p>Any decent text editor should make email-style quoting easy. For
294example, with BBEdit, you can make a selection and choose Increase
295Quote Level from the Text menu.</p>
296
297<h3 id="list">Lists</h3>
298
299<p>Markdown supports ordered (numbered) and unordered (bulleted) lists.</p>
300
301<p>Unordered lists use asterisks, pluses, and hyphens -- interchangably
302
303<pre><code>* Red
304* Green
305* Blue
306</code></pre>
307
308<p>is equivalent to:</p>
309
310<pre><code>+ Red
311+ Green
312+ Blue
313</code></pre>
314
315<p>and:</p>
316
317<pre><code>- Red
318- Green
319- Blue
320</code></pre>
321
322<p>Ordered lists use numbers followed by periods:</p>
323
324<pre><code>1. Bird
3252. McHale
3263. Parish
327</code></pre>
328
329<p>It's important to note that the actual numbers you use to mark the
330list have no effect on the HTML output Markdown produces. The HTML
331Markdown produces from the above list is:</p>
332
333<pre><code>&lt;ol&gt;
334&lt;li&gt;Bird&lt;/li&gt;
335&lt;li&gt;McHale&lt;/li&gt;
336&lt;li&gt;Parish&lt;/li&gt;
337&lt;/ol&gt;
338</code></pre>
339
340<p>If you instead wrote the list in Markdown like this:</p>
341
342<pre><code>1. Bird
3431. McHale
3441. Parish
345</code></pre>
346
347<p>or even:</p>
348
349<pre><code>3. Bird
3501. McHale
3518. Parish
352</code></pre>
353
354<p>you'd get the exact same HTML output. The point is, if you want to,
355you can use ordinal numbers in your ordered Markdown lists, so that
356the numbers in your source match the numbers in your published HTML.
357But if you want to be lazy, you don't have to.</p>
358
359<p>If you do use lazy list numbering, however, you should still start the
360list with the number 1. At some point in the future, Markdown may support
361starting ordered lists at an arbitrary number.</p>
362
363<p>List markers typically start at the left margin, but may be indented by
364up to three spaces. List markers must be followed by one or more spaces
365or a tab.</p>
366
367<p>To make lists look nice, you can wrap items with hanging indents:</p>
368
369<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
370 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
371 viverra nec, fringilla in, laoreet vitae, risus.
372* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
373 Suspendisse id sem consectetuer libero luctus adipiscing.
374</code></pre>
375
376<p>But if you want to be lazy, you don't have to:</p>
377
378<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
379Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
380viverra nec, fringilla in, laoreet vitae, risus.
381* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
382Suspendisse id sem consectetuer libero luctus adipiscing.
383</code></pre>
384
385<p>If list items are separated by blank lines, Markdown will wrap the
386items in <code>&lt;p&gt;</code> tags in the HTML output. For example, this input:</p>
387
388<pre><code>* Bird
389* Magic
390</code></pre>
391
392<p>will turn into:</p>
393
394<pre><code>&lt;ul&gt;
395&lt;li&gt;Bird&lt;/li&gt;
396&lt;li&gt;Magic&lt;/li&gt;
397&lt;/ul&gt;
398</code></pre>
399
400<p>But this:</p>
401
402<pre><code>* Bird
403
404* Magic
405</code></pre>
406
407<p>will turn into:</p>
408
409<pre><code>&lt;ul&gt;
410&lt;li&gt;&lt;p&gt;Bird&lt;/p&gt;&lt;/li&gt;
411&lt;li&gt;&lt;p&gt;Magic&lt;/p&gt;&lt;/li&gt;
412&lt;/ul&gt;
413</code></pre>
414
415<p>List items may consist of multiple paragraphs. Each subsequent
416paragraph in a list item must be intended by either 4 spaces
417or one tab:</p>
418
419<pre><code>1. This is a list item with two paragraphs. Lorem ipsum dolor
420 sit amet, consectetuer adipiscing elit. Aliquam hendrerit
421 mi posuere lectus.
422
423 Vestibulum enim wisi, viverra nec, fringilla in, laoreet
424 vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
425 sit amet velit.
426
4272. Suspendisse id sem consectetuer libero luctus adipiscing.
428</code></pre>
429
430<p>It looks nice if you indent every line of the subsequent
431paragraphs, but here again, Markdown will allow you to be
432lazy:</p>
433
434<pre><code>* This is a list item with two paragraphs.
435
436 This is the second paragraph in the list item. You're
437only required to indent the first line. Lorem ipsum dolor
438sit amet, consectetuer adipiscing elit.
439
440* Another item in the same list.
441</code></pre>
442
443<p>To put a blockquote within a list item, the blockquote's <code>&gt;</code>
444delimiters need to be indented:</p>
445
446<pre><code>* A list item with a blockquote:
447
448 &gt; This is a blockquote
449 &gt; inside a list item.
450</code></pre>
451
452<p>To put a code block within a list item, the code block needs
453to be indented <em>twice</em> -- 8 spaces or two tabs:</p>
454
455<pre><code>* A list item with a code block:
456
457 &lt;code goes here&gt;
458</code></pre>
459
460<p>It's worth noting that it's possible to trigger an ordered list by
461accident, by writing something like this:</p>
462
463<pre><code>1986. What a great season.
464</code></pre>
465
466<p>In other words, a <em>number-period-space</em> sequence at the beginning of a
467line. To avoid this, you can backslash-escape the period:</p>
468
469<pre><code>1986\. What a great season.
470</code></pre>
471
472<h3 id="precode">Code Blocks</h3>
473
474<p>Pre-formatted code blocks are used for writing about programming or
475markup source code. Rather than forming normal paragraphs, the lines
476of a code block are interpreted literally. Markdown wraps a code block
477in both <code>&lt;pre&gt;</code> and <code>&lt;code&gt;</code> tags.</p>
478
479<p>To produce a code block in Markdown, simply indent every line of the
480block by at least 4 spaces or 1 tab. For example, given this input:</p>
481
482<pre><code>This is a normal paragraph:
483
484 This is a code block.
485</code></pre>
486
487<p>Markdown will generate:</p>
488
489<pre><code>&lt;p&gt;This is a normal paragraph:&lt;/p&gt;
490
491&lt;pre&gt;&lt;code&gt;This is a code block.
492&lt;/code&gt;&lt;/pre&gt;
493</code></pre>
494
495<p>One level of indentation -- 4 spaces or 1 tab -- is removed from each
496line of the code block. For example, this:</p>
497
498<pre><code>Here is an example of AppleScript:
499
500 tell application "Foo"
501 beep
502 end tell
503</code></pre>
504
505<p>will turn into:</p>
506
507<pre><code>&lt;p&gt;Here is an example of AppleScript:&lt;/p&gt;
508
509&lt;pre&gt;&lt;code&gt;tell application "Foo"
510 beep
511end tell
512&lt;/code&gt;&lt;/pre&gt;
513</code></pre>
514
515<p>A code block continues until it reaches a line that is not indented
516(or the end of the article).</p>
517
518<p>Within a code block, ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> and <code>&gt;</code>)
519are automatically converted into HTML entities. This makes it very
520easy to include example HTML source code using Markdown -- just paste
521it and indent it, and Markdown will handle the hassle of encoding the
522ampersands and angle brackets. For example, this:</p>
523
524<pre><code> &lt;div class="footer"&gt;
525 &amp;copy; 2004 Foo Corporation
526 &lt;/div&gt;
527</code></pre>
528
529<p>will turn into:</p>
530
531<pre><code>&lt;pre&gt;&lt;code&gt;&amp;lt;div class="footer"&amp;gt;
532 &amp;amp;copy; 2004 Foo Corporation
533&amp;lt;/div&amp;gt;
534&lt;/code&gt;&lt;/pre&gt;
535</code></pre>
536
537<p>Regular Markdown syntax is not processed within code blocks. E.g.,
538asterisks are just literal asterisks within a code block. This means
539it's also easy to use Markdown to write about Markdown's own syntax.</p>
540
541<h3 id="hr">Horizontal Rules</h3>
542
543<p>You can produce a horizontal rule tag (<code>&lt;hr /&gt;</code>) by placing three or
544more hyphens, asterisks, or underscores on a line by themselves. If you
545wish, you may use spaces between the hyphens or asterisks. Each of the
546following lines will produce a horizontal rule:</p>
547
548<pre><code>* * *
549
550***
551
552*****
553
554- - -
555
556---------------------------------------
557
558_ _ _
559</code></pre>
560
561<hr />
562
563<h2 id="span">Span Elements</h2>
564
565<h3 id="link">Links</h3>
566
567<p>Markdown supports two style of links: <em>inline</em> and <em>reference</em>.</p>
568
569<p>In both styles, the link text is delimited by [square brackets].</p>
570
571<p>To create an inline link, use a set of regular parentheses immediately
572after the link text's closing square bracket. Inside the parentheses,
573put the URL where you want the link to point, along with an <em>optional</em>
574title for the link, surrounded in quotes. For example:</p>
575
576<pre><code>This is [an example](http://example.com/ "Title") inline link.
577
578[This link](http://example.net/) has no title attribute.
579</code></pre>
580
581<p>Will produce:</p>
582
583<pre><code>&lt;p&gt;This is &lt;a href="http://example.com/" title="Title"&gt;
584an example&lt;/a&gt; inline link.&lt;/p&gt;
585
586&lt;p&gt;&lt;a href="http://example.net/"&gt;This link&lt;/a&gt; has no
587title attribute.&lt;/p&gt;
588</code></pre>
589
590<p>If you're referring to a local resource on the same server, you can
591use relative paths:</p>
592
593<pre><code>See my [About](/about/) page for details.
594</code></pre>
595
596<p>Reference-style links use a second set of square brackets, inside
597which you place a label of your choosing to identify the link:</p>
598
599<pre><code>This is [an example][id] reference-style link.
600</code></pre>
601
602<p>You can optionally use a space to separate the sets of brackets:</p>
603
604<pre><code>This is [an example] [id] reference-style link.
605</code></pre>
606
607<p>Then, anywhere in the document, you define your link label like this,
608on a line by itself:</p>
609
610<pre><code>[id]: http://example.com/ "Optional Title Here"
611</code></pre>
612
613<p>That is:</p>
614
615<ul>
616<li>Square brackets containing the link identifier (optionally
617indented from the left margin using up to three spaces);</li>
618<li>followed by a colon;</li>
619<li>followed by one or more spaces (or tabs);</li>
620<li>followed by the URL for the link;</li>
621<li>optionally followed by a title attribute for the link, enclosed
622in double or single quotes.</li>
623</ul>
624
625<p>The link URL may, optionally, be surrounded by angle brackets:</p>
626
627<pre><code>[id]: &lt;http://example.com/&gt; "Optional Title Here"
628</code></pre>
629
630<p>You can put the title attribute on the next line and use extra spaces
631or tabs for padding, which tends to look better with longer URLs:</p>
632
633<pre><code>[id]: http://example.com/longish/path/to/resource/here
634 "Optional Title Here"
635</code></pre>
636
637<p>Link definitions are only used for creating links during Markdown
638processing, and are stripped from your document in the HTML output.</p>
639
640<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>
641
642<pre><code>[link text][a]
643[link text][A]
644</code></pre>
645
646<p>are equivalent.</p>
647
648<p>The <em>implicit link name</em> shortcut allows you to omit the name of the
649link, in which case the link text itself is used as the name.
650Just use an empty set of square brackets -- e.g., to link the word
651"Google" to the google.com web site, you could simply write:</p>
652
653<pre><code>[Google][]
654</code></pre>
655
656<p>And then define the link:</p>
657
658<pre><code>[Google]: http://google.com/
659</code></pre>
660
661<p>Because link names may contain spaces, this shortcut even works for
662multiple words in the link text:</p>
663
664<pre><code>Visit [Daring Fireball][] for more information.
665</code></pre>
666
667<p>And then define the link:</p>
668
669<pre><code>[Daring Fireball]: http://daringfireball.net/
670</code></pre>
671
672<p>Link definitions can be placed anywhere in your Markdown document. I
673tend to put them immediately after each paragraph in which they're
674used, but if you want, you can put them all at the end of your
675document, sort of like footnotes.</p>
676
677<p>Here's an example of reference links in action:</p>
678
679<pre><code>I get 10 times more traffic from [Google] [1] than from
680[Yahoo] [2] or [MSN] [3].
681
682 [1]: http://google.com/ "Google"
683 [2]: http://search.yahoo.com/ "Yahoo Search"
684 [3]: http://search.msn.com/ "MSN Search"
685</code></pre>
686
687<p>Using the implicit link name shortcut, you could instead write:</p>
688
689<pre><code>I get 10 times more traffic from [Google][] than from
690[Yahoo][] or [MSN][].
691
692 [google]: http://google.com/ "Google"
693 [yahoo]: http://search.yahoo.com/ "Yahoo Search"
694 [msn]: http://search.msn.com/ "MSN Search"
695</code></pre>
696
697<p>Both of the above examples will produce the following HTML output:</p>
698
699<pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
700title="Google"&gt;Google&lt;/a&gt; than from
701&lt;a href="http://search.yahoo.com/" title="Yahoo Search"&gt;Yahoo&lt;/a&gt;
702or &lt;a href="http://search.msn.com/" title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
703</code></pre>
704
705<p>For comparison, here is the same paragraph written using
706Markdown's inline link style:</p>
707
708<pre><code>I get 10 times more traffic from [Google](http://google.com/ "Google")
709than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
710[MSN](http://search.msn.com/ "MSN Search").
711</code></pre>
712
713<p>The point of reference-style links is not that they're easier to
714write. The point is that with reference-style links, your document
715source is vastly more readable. Compare the above examples: using
716reference-style links, the paragraph itself is only 81 characters
717long; with inline-style links, it's 176 characters; and as raw HTML,
718it's 234 characters. In the raw HTML, there's more markup than there
719is text.</p>
720
721<p>With Markdown's reference-style links, a source document much more
722closely resembles the final output, as rendered in a browser. By
723allowing you to move the markup-related metadata out of the paragraph,
724you can add links without interrupting the narrative flow of your
725prose.</p>
726
727<h3 id="em">Emphasis</h3>
728
729<p>Markdown treats asterisks (<code>*</code>) and underscores (<code>_</code>) as indicators of
730emphasis. Text wrapped with one <code>*</code> or <code>_</code> will be wrapped with an
731HTML <code>&lt;em&gt;</code> tag; double <code>*</code>'s or <code>_</code>'s will be wrapped with an HTML
732<code>&lt;strong&gt;</code> tag. E.g., this input:</p>
733
734<pre><code>*single asterisks*
735
736_single underscores_
737
738**double asterisks**
739
740__double underscores__
741</code></pre>
742
743<p>will produce:</p>
744
745<pre><code>&lt;em&gt;single asterisks&lt;/em&gt;
746
747&lt;em&gt;single underscores&lt;/em&gt;
748
749&lt;strong&gt;double asterisks&lt;/strong&gt;
750
751&lt;strong&gt;double underscores&lt;/strong&gt;
752</code></pre>
753
754<p>You can use whichever style you prefer; the lone restriction is that
755the same character must be used to open and close an emphasis span.</p>
756
757<p>Emphasis can be used in the middle of a word:</p>
758
759<pre><code>un*fucking*believable
760</code></pre>
761
762<p>But if you surround an <code>*</code> or <code>_</code> with spaces, it'll be treated as a
763literal asterisk or underscore.</p>
764
765<p>To produce a literal asterisk or underscore at a position where it
766would otherwise be used as an emphasis delimiter, you can backslash
767escape it:</p>
768
769<pre><code>\*this text is surrounded by literal asterisks\*
770</code></pre>
771
772<h3 id="code">Code</h3>
773
774<p>To indicate a span of code, wrap it with backtick quotes (<code>`</code>).
775Unlike a pre-formatted code block, a code span indicates code within a
776normal paragraph. For example:</p>
777
778<pre><code>Use the `printf()` function.
779</code></pre>
780
781<p>will produce:</p>
782
783<pre><code>&lt;p&gt;Use the &lt;code&gt;printf()&lt;/code&gt; function.&lt;/p&gt;
784</code></pre>
785
786<p>To include a literal backtick character within a code span, you can use
787multiple backticks as the opening and closing delimiters:</p>
788
789<pre><code>``There is a literal backtick (`) here.``
790</code></pre>
791
792<p>which will produce this:</p>
793
794<pre><code>&lt;p&gt;&lt;code&gt;There is a literal backtick (`) here.&lt;/code&gt;&lt;/p&gt;
795</code></pre>
796
797<p>The backtick delimiters surrounding a code span may include spaces --
798one after the opening, one before the closing. This allows you to place
799literal backtick characters at the beginning or end of a code span:</p>
800
801<pre><code>A single backtick in a code span: `` ` ``
802
803A backtick-delimited string in a code span: `` `foo` ``
804</code></pre>
805
806<p>will produce:</p>
807
808<pre><code>&lt;p&gt;A single backtick in a code span: &lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
809
810&lt;p&gt;A backtick-delimited string in a code span: &lt;code&gt;`foo`&lt;/code&gt;&lt;/p&gt;
811</code></pre>
812
813<p>With a code span, ampersands and angle brackets are encoded as HTML
814entities automatically, which makes it easy to include example HTML
815tags. Markdown will turn this:</p>
816
817<pre><code>Please don't use any `&lt;blink&gt;` tags.
818</code></pre>
819
820<p>into:</p>
821
822<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;
823</code></pre>
824
825<p>You can write this:</p>
826
827<pre><code>`&amp;#8212;` is the decimal-encoded equivalent of `&amp;mdash;`.
828</code></pre>
829
830<p>to produce:</p>
831
832<pre><code>&lt;p&gt;&lt;code&gt;&amp;amp;#8212;&lt;/code&gt; is the decimal-encoded
833equivalent of &lt;code&gt;&amp;amp;mdash;&lt;/code&gt;.&lt;/p&gt;
834</code></pre>
835
836<h3 id="img">Images</h3>
837
838<p>Admittedly, it's fairly difficult to devise a "natural" syntax for
839placing images into a plain text document format.</p>
840
841<p>Markdown uses an image syntax that is intended to resemble the syntax
842for links, allowing for two styles: <em>inline</em> and <em>reference</em>.</p>
843
844<p>Inline image syntax looks like this:</p>
845
846<pre><code>![Alt text](/path/to/img.jpg)
847
848![Alt text](/path/to/img.jpg "Optional title")
849</code></pre>
850
851<p>That is:</p>
852
853<ul>
854<li>An exclamation mark: <code>!</code>;</li>
855<li>followed by a set of square brackets, containing the <code>alt</code>
856attribute text for the image;</li>
857<li>followed by a set of parentheses, containing the URL or path to
858the image, and an optional <code>title</code> attribute enclosed in double
859or single quotes.</li>
860</ul>
861
862<p>Reference-style image syntax looks like this:</p>
863
864<pre><code>![Alt text][id]
865</code></pre>
866
867<p>Where "id" is the name of a defined image reference. Image references
868are defined using syntax identical to link references:</p>
869
870<pre><code>[id]: url/to/image "Optional title attribute"
871</code></pre>
872
873<p>As of this writing, Markdown has no syntax for specifying the
874dimensions of an image; if this is important to you, you can simply
875use regular HTML <code>&lt;img&gt;</code> tags.</p>
876
877<hr />
878
879<h2 id="misc">Miscellaneous</h2>
880
881<h3 id="autolink">Automatic Links</h3>
882
883<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>
884
885<pre><code>&lt;http://example.com/&gt;
886</code></pre>
887
888<p>Markdown will turn this into:</p>
889
890<pre><code>&lt;a href="http://example.com/"&gt;http://example.com/&lt;/a&gt;
891</code></pre>
892
893<p>Automatic links for email addresses work similarly, except that
894Markdown will also perform a bit of randomized decimal and hex
895entity-encoding to help obscure your address from address-harvesting
896spambots. For example, Markdown will turn this:</p>
897
898<pre><code>&lt;address@example.com&gt;
899</code></pre>
900
901<p>into something like this:</p>
902
903<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;
904&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;
905&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;
906&amp;#109;&amp;#x70;&amp;#x6C;e&amp;#x2E;&amp;#99;&amp;#111;&amp;#109;&lt;/a&gt;
907</code></pre>
908
909<p>which will render in a browser as a clickable link to "address@example.com".</p>
910
911<p>(This sort of entity-encoding trick will indeed fool many, if not
912most, address-harvesting bots, but it definitely won't fool all of
913them. It's better than nothing, but an address published in this way
914will probably eventually start receiving spam.)</p>
915
916<h3 id="backslash">Backslash Escapes</h3>
917
918<p>Markdown allows you to use backslash escapes to generate literal
919characters which would otherwise have special meaning in Markdown's
920formatting syntax. For example, if you wanted to surround a word with
921literal asterisks (instead of an HTML <code>&lt;em&gt;</code> tag), you can backslashes
922before the asterisks, like this:</p>
923
924<pre><code>\*literal asterisks\*
925</code></pre>
926
927<p>Markdown provides backslash escapes for the following characters:</p>
928
929<pre><code>\ backslash
930` backtick
931* asterisk
932_ underscore
933{} curly braces
934[] square brackets
935() parentheses
936# hash mark
937+ plus sign
938- minus sign (hyphen)
939. dot
940! exclamation mark
941</code></pre>
  
1Markdown: Syntax
2================
3
4<ul id="ProjectSubmenu">
5 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
6 <li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li>
7 <li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li>
8 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
9 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
10</ul>
11
12
13* [Overview](#overview)
14 * [Philosophy](#philosophy)
15 * [Inline HTML](#html)
16 * [Automatic Escaping for Special Characters](#autoescape)
17* [Block Elements](#block)
18 * [Paragraphs and Line Breaks](#p)
19 * [Headers](#header)
20 * [Blockquotes](#blockquote)
21 * [Lists](#list)
22 * [Code Blocks](#precode)
23 * [Horizontal Rules](#hr)
24* [Span Elements](#span)
25 * [Links](#link)
26 * [Emphasis](#em)
27 * [Code](#code)
28 * [Images](#img)
29* [Miscellaneous](#misc)
30 * [Backslash Escapes](#backslash)
31 * [Automatic Links](#autolink)
32
33
34**Note:** This document is itself written using Markdown; you
35can [see the source for it by adding '.text' to the URL][src].
36
37 [src]: /projects/markdown/syntax.text
38
39* * *
40
41<h2 id="overview">Overview</h2>
42
43<h3 id="philosophy">Philosophy</h3>
44
45Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
46
47Readability, however, is emphasized above all else. A Markdown-formatted
48document should be publishable as-is, as plain text, without looking
49like it's been marked up with tags or formatting instructions. While
50Markdown's syntax has been influenced by several existing text-to-HTML
51filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4],
52[Grutatext] [5], and [EtText] [6] -- the single biggest source of
53inspiration for Markdown's syntax is the format of plain text email.
54
55 [1]: http://docutils.sourceforge.net/mirror/setext.html
56 [2]: http://www.aaronsw.com/2002/atx/
57 [3]: http://textism.com/tools/textile/
58 [4]: http://docutils.sourceforge.net/rst.html
59 [5]: http://www.triptico.com/software/grutatxt.html
60 [6]: http://ettext.taint.org/doc/
61
62To this end, Markdown's syntax is comprised entirely of punctuation
63characters, which punctuation characters have been carefully chosen so
64as to look like what they mean. E.g., asterisks around a word actually
65look like \*emphasis\*. Markdown lists look like, well, lists. Even
66blockquotes look like quoted passages of text, assuming you've ever
67used email.
68
69
70
71<h3 id="html">Inline HTML</h3>
72
73Markdown's syntax is intended for one purpose: to be used as a
74format for *writing* for the web.
75
76Markdown is not a replacement for HTML, or even close to it. Its
77syntax is very small, corresponding only to a very small subset of
78HTML tags. The idea is *not* to create a syntax that makes it easier
79to insert HTML tags. In my opinion, HTML tags are already easy to
80insert. The idea for Markdown is to make it easy to read, write, and
81edit prose. HTML is a *publishing* format; Markdown is a *writing*
82format. Thus, Markdown's formatting syntax only addresses issues that
83can be conveyed in plain text.
84
85For any markup that is not covered by Markdown's syntax, you simply
86use HTML itself. There's no need to preface it or delimit it to
87indicate that you're switching from Markdown to HTML; you just use
88the tags.
89
90The only restrictions are that block-level HTML elements -- e.g. `<div>`,
91`<table>`, `<pre>`, `<p>`, etc. -- must be separated from surrounding
92content by blank lines, and the start and end tags of the block should
93not be indented with tabs or spaces. Markdown is smart enough not
94to add extra (unwanted) `<p>` tags around HTML block-level tags.
95
96For example, to add an HTML table to a Markdown article:
97
98 This is a regular paragraph.
99
100 <table>
101 <tr>
102 <td>Foo</td>
103 </tr>
104 </table>
105
106 This is another regular paragraph.
107
108Note that Markdown formatting syntax is not processed within block-level
109HTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an
110HTML block.
111
112Span-level HTML tags -- e.g. `<span>`, `<cite>`, or `<del>` -- can be
113used anywhere in a Markdown paragraph, list item, or header. If you
114want, you can even use HTML tags instead of Markdown formatting; e.g. if
115you'd prefer to use HTML `<a>` or `<img>` tags instead of Markdown's
116link or image syntax, go right ahead.
117
118Unlike block-level HTML tags, Markdown syntax *is* processed within
119span-level tags.
120
121
122<h3 id="autoescape">Automatic Escaping for Special Characters</h3>
123
124In HTML, there are two characters that demand special treatment: `<`
125and `&`. Left angle brackets are used to start tags; ampersands are
126used to denote HTML entities. If you want to use them as literal
127characters, you must escape them as entities, e.g. `&lt;`, and
128`&amp;`.
129
130Ampersands in particular are bedeviling for web writers. If you want to
131write about 'AT&T', you need to write '`AT&amp;T`'. You even need to
132escape ampersands within URLs. Thus, if you want to link to:
133
134 http://images.google.com/images?num=30&q=larry+bird
135
136you need to encode the URL as:
137
138 http://images.google.com/images?num=30&amp;q=larry+bird
139
140in your anchor tag `href` attribute. Needless to say, this is easy to
141forget, and is probably the single most common source of HTML validation
142errors in otherwise well-marked-up web sites.
143
144Markdown allows you to use these characters naturally, taking care of
145all the necessary escaping for you. If you use an ampersand as part of
146an HTML entity, it remains unchanged; otherwise it will be translated
147into `&amp;`.
148
149So, if you want to include a copyright symbol in your article, you can write:
150
151 &copy;
152
153and Markdown will leave it alone. But if you write:
154
155 AT&T
156
157Markdown will translate it to:
158
159 AT&amp;T
160
161Similarly, because Markdown supports [inline HTML](#html), if you use
162angle brackets as delimiters for HTML tags, Markdown will treat them as
163such. But if you write:
164
165 4 < 5
166
167Markdown will translate it to:
168
169 4 &lt; 5
170
171However, inside Markdown code spans and blocks, angle brackets and
172ampersands are *always* encoded automatically. This makes it easy to use
173Markdown to write about HTML code. (As opposed to raw HTML, which is a
174terrible format for writing about HTML syntax, because every single `<`
175and `&` in your example code needs to be escaped.)
176
177
178* * *
179
180
181<h2 id="block">Block Elements</h2>
182
183
184<h3 id="p">Paragraphs and Line Breaks</h3>
185
186A paragraph is simply one or more consecutive lines of text, separated
187by one or more blank lines. (A blank line is any line that looks like a
188blank line -- a line containing nothing but spaces or tabs is considered
189blank.) Normal paragraphs should not be intended with spaces or tabs.
190
191The implication of the "one or more consecutive lines of text" rule is
192that Markdown supports "hard-wrapped" text paragraphs. This differs
193significantly from most other text-to-HTML formatters (including Movable
194Type's "Convert Line Breaks" option) which translate every line break
195character in a paragraph into a `<br />` tag.
196
197When you *do* want to insert a `<br />` break tag using Markdown, you
198end a line with two or more spaces, then type return.
199
200Yes, this takes a tad more effort to create a `<br />`, but a simplistic
201"every line break is a `<br />`" rule wouldn't work for Markdown.
202Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l]
203work best -- and look better -- when you format them with hard breaks.
204
205 [bq]: #blockquote
206 [l]: #list
207
208
209
210<h3 id="header">Headers</h3>
211
212Markdown supports two styles of headers, [Setext] [1] and [atx] [2].
213
214Setext-style headers are "underlined" using equal signs (for first-level
215headers) and dashes (for second-level headers). For example:
216
217 This is an H1
218 =============
219
220 This is an H2
221 -------------
222
223Any number of underlining `=`'s or `-`'s will work.
224
225Atx-style headers use 1-6 hash characters at the start of the line,
226corresponding to header levels 1-6. For example:
227
228 # This is an H1
229
230 ## This is an H2
231
232 ###### This is an H6
233
234Optionally, you may "close" atx-style headers. This is purely
235cosmetic -- you can use this if you think it looks better. The
236closing hashes don't even need to match the number of hashes
237used to open the header. (The number of opening hashes
238determines the header level.) :
239
240 # This is an H1 #
241
242 ## This is an H2 ##
243
244 ### This is an H3 ######
245
246
247<h3 id="blockquote">Blockquotes</h3>
248
249Markdown uses email-style `>` characters for blockquoting. If you're
250familiar with quoting passages of text in an email message, then you
251know how to create a blockquote in Markdown. It looks best if you hard
252wrap the text and put a `>` before every line:
253
254 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
255 > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
256 > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
257 >
258 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
259 > id sem consectetuer libero luctus adipiscing.
260
261Markdown allows you to be lazy and only put the `>` before the first
262line of a hard-wrapped paragraph:
263
264 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
265 consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
266 Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
267
268 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
269 id sem consectetuer libero luctus adipiscing.
270
271Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
272adding additional levels of `>`:
273
274 > This is the first level of quoting.
275 >
276 > > This is nested blockquote.
277 >
278 > Back to the first level.
279
280Blockquotes can contain other Markdown elements, including headers, lists,
281and code blocks:
282
283 > ## This is a header.
284 >
285 > 1. This is the first list item.
286 > 2. This is the second list item.
287 >
288 > Here's some example code:
289 >
290 > return shell_exec("echo $input | $markdown_script");
291
292Any decent text editor should make email-style quoting easy. For
293example, with BBEdit, you can make a selection and choose Increase
294Quote Level from the Text menu.
295
296
297<h3 id="list">Lists</h3>
298
299Markdown supports ordered (numbered) and unordered (bulleted) lists.
300
301Unordered lists use asterisks, pluses, and hyphens -- interchangably
302
303 * Red
304 * Green
305 * Blue
306
307is equivalent to:
308
309 + Red
310 + Green
311 + Blue
312
313and:
314
315 - Red
316 - Green
317 - Blue
318
319Ordered lists use numbers followed by periods:
320
321 1. Bird
322 2. McHale
323 3. Parish
324
325It's important to note that the actual numbers you use to mark the
326list have no effect on the HTML output Markdown produces. The HTML
327Markdown produces from the above list is:
328
329 <ol>
330 <li>Bird</li>
331 <li>McHale</li>
332 <li>Parish</li>
333 </ol>
334
335If you instead wrote the list in Markdown like this:
336
337 1. Bird
338 1. McHale
339 1. Parish
340
341or even:
342
343 3. Bird
344 1. McHale
345 8. Parish
346
347you'd get the exact same HTML output. The point is, if you want to,
348you can use ordinal numbers in your ordered Markdown lists, so that
349the numbers in your source match the numbers in your published HTML.
350But if you want to be lazy, you don't have to.
351
352If you do use lazy list numbering, however, you should still start the
353list with the number 1. At some point in the future, Markdown may support
354starting ordered lists at an arbitrary number.
355
356List markers typically start at the left margin, but may be indented by
357up to three spaces. List markers must be followed by one or more spaces
358or a tab.
359
360To make lists look nice, you can wrap items with hanging indents:
361
362 * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
363 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
364 viverra nec, fringilla in, laoreet vitae, risus.
365 * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
366 Suspendisse id sem consectetuer libero luctus adipiscing.
367
368But if you want to be lazy, you don't have to:
369
370 * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
371 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
372 viverra nec, fringilla in, laoreet vitae, risus.
373 * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
374 Suspendisse id sem consectetuer libero luctus adipiscing.
375
376If list items are separated by blank lines, Markdown will wrap the
377items in `<p>` tags in the HTML output. For example, this input:
378
379 * Bird
380 * Magic
381
382will turn into:
383
384 <ul>
385 <li>Bird</li>
386 <li>Magic</li>
387 </ul>
388
389But this:
390
391 * Bird
392
393 * Magic
394
395will turn into:
396
397 <ul>
398 <li><p>Bird</p></li>
399 <li><p>Magic</p></li>
400 </ul>
401
402List items may consist of multiple paragraphs. Each subsequent
403paragraph in a list item must be intended by either 4 spaces
404or one tab:
405
406 1. This is a list item with two paragraphs. Lorem ipsum dolor
407 sit amet, consectetuer adipiscing elit. Aliquam hendrerit
408 mi posuere lectus.
409
410 Vestibulum enim wisi, viverra nec, fringilla in, laoreet
411 vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
412 sit amet velit.
413
414 2. Suspendisse id sem consectetuer libero luctus adipiscing.
415
416It looks nice if you indent every line of the subsequent
417paragraphs, but here again, Markdown will allow you to be
418lazy:
419
420 * This is a list item with two paragraphs.
421
422 This is the second paragraph in the list item. You're
423 only required to indent the first line. Lorem ipsum dolor
424 sit amet, consectetuer adipiscing elit.
425
426 * Another item in the same list.
427
428To put a blockquote within a list item, the blockquote's `>`
429delimiters need to be indented:
430
431 * A list item with a blockquote:
432
433 > This is a blockquote
434 > inside a list item.
435
436To put a code block within a list item, the code block needs
437to be indented *twice* -- 8 spaces or two tabs:
438
439 * A list item with a code block:
440
441 <code goes here>
442
443
444It's worth noting that it's possible to trigger an ordered list by
445accident, by writing something like this:
446
447 1986. What a great season.
448
449In other words, a *number-period-space* sequence at the beginning of a
450line. To avoid this, you can backslash-escape the period:
451
452 1986\. What a great season.
453
454
455
456<h3 id="precode">Code Blocks</h3>
457
458Pre-formatted code blocks are used for writing about programming or
459markup source code. Rather than forming normal paragraphs, the lines
460of a code block are interpreted literally. Markdown wraps a code block
461in both `<pre>` and `<code>` tags.
462
463To produce a code block in Markdown, simply indent every line of the
464block by at least 4 spaces or 1 tab. For example, given this input:
465
466 This is a normal paragraph:
467
468 This is a code block.
469
470Markdown will generate:
471
472 <p>This is a normal paragraph:</p>
473
474 <pre><code>This is a code block.
475 </code></pre>
476
477One level of indentation -- 4 spaces or 1 tab -- is removed from each
478line of the code block. For example, this:
479
480 Here is an example of AppleScript:
481
482 tell application "Foo"
483 beep
484 end tell
485
486will turn into:
487
488 <p>Here is an example of AppleScript:</p>
489
490 <pre><code>tell application "Foo"
491 beep
492 end tell
493 </code></pre>
494
495A code block continues until it reaches a line that is not indented
496(or the end of the article).
497
498Within a code block, ampersands (`&`) and angle brackets (`<` and `>`)
499are automatically converted into HTML entities. This makes it very
500easy to include example HTML source code using Markdown -- just paste
501it and indent it, and Markdown will handle the hassle of encoding the
502ampersands and angle brackets. For example, this:
503
504 <div class="footer">
505 &copy; 2004 Foo Corporation
506 </div>
507
508will turn into:
509
510 <pre><code>&lt;div class="footer"&gt;
511 &amp;copy; 2004 Foo Corporation
512 &lt;/div&gt;
513 </code></pre>
514
515Regular Markdown syntax is not processed within code blocks. E.g.,
516asterisks are just literal asterisks within a code block. This means
517it's also easy to use Markdown to write about Markdown's own syntax.
518
519
520
521<h3 id="hr">Horizontal Rules</h3>
522
523You can produce a horizontal rule tag (`<hr />`) by placing three or
524more hyphens, asterisks, or underscores on a line by themselves. If you
525wish, you may use spaces between the hyphens or asterisks. Each of the
526following lines will produce a horizontal rule:
527
528 * * *
529
530 ***
531
532 *****
533
534 - - -
535
536 ---------------------------------------
537
538 _ _ _
539
540
541* * *
542
543<h2 id="span">Span Elements</h2>
544
545<h3 id="link">Links</h3>
546
547Markdown supports two style of links: *inline* and *reference*.
548
549In both styles, the link text is delimited by [square brackets].
550
551To create an inline link, use a set of regular parentheses immediately
552after the link text's closing square bracket. Inside the parentheses,
553put the URL where you want the link to point, along with an *optional*
554title for the link, surrounded in quotes. For example:
555
556 This is [an example](http://example.com/ "Title") inline link.
557
558 [This link](http://example.net/) has no title attribute.
559
560Will produce:
561
562 <p>This is <a href="http://example.com/" title="Title">
563 an example</a> inline link.</p>
564
565 <p><a href="http://example.net/">This link</a> has no
566 title attribute.</p>
567
568If you're referring to a local resource on the same server, you can
569use relative paths:
570
571 See my [About](/about/) page for details.
572
573Reference-style links use a second set of square brackets, inside
574which you place a label of your choosing to identify the link:
575
576 This is [an example][id] reference-style link.
577
578You can optionally use a space to separate the sets of brackets:
579
580 This is [an example] [id] reference-style link.
581
582Then, anywhere in the document, you define your link label like this,
583on a line by itself:
584
585 [id]: http://example.com/ "Optional Title Here"
586
587That is:
588
589* Square brackets containing the link identifier (optionally
590 indented from the left margin using up to three spaces);
591* followed by a colon;
592* followed by one or more spaces (or tabs);
593* followed by the URL for the link;
594* optionally followed by a title attribute for the link, enclosed
595 in double or single quotes.
596
597The link URL may, optionally, be surrounded by angle brackets:
598
599 [id]: <http://example.com/> "Optional Title Here"
600
601You can put the title attribute on the next line and use extra spaces
602or tabs for padding, which tends to look better with longer URLs:
603
604 [id]: http://example.com/longish/path/to/resource/here
605 "Optional Title Here"
606
607Link definitions are only used for creating links during Markdown
608processing, and are stripped from your document in the HTML output.
609
610Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are *not* case sensitive. E.g. these two links:
611
612 [link text][a]
613 [link text][A]
614
615are equivalent.
616
617The *implicit link name* shortcut allows you to omit the name of the
618link, in which case the link text itself is used as the name.
619Just use an empty set of square brackets -- e.g., to link the word
620"Google" to the google.com web site, you could simply write:
621
622 [Google][]
623
624And then define the link:
625
626 [Google]: http://google.com/
627
628Because link names may contain spaces, this shortcut even works for
629multiple words in the link text:
630
631 Visit [Daring Fireball][] for more information.
632
633And then define the link:
634
635 [Daring Fireball]: http://daringfireball.net/
636
637Link definitions can be placed anywhere in your Markdown document. I
638tend to put them immediately after each paragraph in which they're
639used, but if you want, you can put them all at the end of your
640document, sort of like footnotes.
641
642Here's an example of reference links in action:
643
644 I get 10 times more traffic from [Google] [1] than from
645 [Yahoo] [2] or [MSN] [3].
646
647 [1]: http://google.com/ "Google"
648 [2]: http://search.yahoo.com/ "Yahoo Search"
649 [3]: http://search.msn.com/ "MSN Search"
650
651Using the implicit link name shortcut, you could instead write:
652
653 I get 10 times more traffic from [Google][] than from
654 [Yahoo][] or [MSN][].
655
656 [google]: http://google.com/ "Google"
657 [yahoo]: http://search.yahoo.com/ "Yahoo Search"
658 [msn]: http://search.msn.com/ "MSN Search"
659
660Both of the above examples will produce the following HTML output:
661
662 <p>I get 10 times more traffic from <a href="http://google.com/"
663 title="Google">Google</a> than from
664 <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
665 or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
666
667For comparison, here is the same paragraph written using
668Markdown's inline link style:
669
670 I get 10 times more traffic from [Google](http://google.com/ "Google")
671 than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
672 [MSN](http://search.msn.com/ "MSN Search").
673
674The point of reference-style links is not that they're easier to
675write. The point is that with reference-style links, your document
676source is vastly more readable. Compare the above examples: using
677reference-style links, the paragraph itself is only 81 characters
678long; with inline-style links, it's 176 characters; and as raw HTML,
679it's 234 characters. In the raw HTML, there's more markup than there
680is text.
681
682With Markdown's reference-style links, a source document much more
683closely resembles the final output, as rendered in a browser. By
684allowing you to move the markup-related metadata out of the paragraph,
685you can add links without interrupting the narrative flow of your
686prose.
687
688
689<h3 id="em">Emphasis</h3>
690
691Markdown treats asterisks (`*`) and underscores (`_`) as indicators of
692emphasis. Text wrapped with one `*` or `_` will be wrapped with an
693HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML
694`<strong>` tag. E.g., this input:
695
696 *single asterisks*
697
698 _single underscores_
699
700 **double asterisks**
701
702 __double underscores__
703
704will produce:
705
706 <em>single asterisks</em>
707
708 <em>single underscores</em>
709
710 <strong>double asterisks</strong>
711
712 <strong>double underscores</strong>
713
714You can use whichever style you prefer; the lone restriction is that
715the same character must be used to open and close an emphasis span.
716
717Emphasis can be used in the middle of a word:
718
719 un*fucking*believable
720
721But if you surround an `*` or `_` with spaces, it'll be treated as a
722literal asterisk or underscore.
723
724To produce a literal asterisk or underscore at a position where it
725would otherwise be used as an emphasis delimiter, you can backslash
726escape it:
727
728 \*this text is surrounded by literal asterisks\*
729
730
731
732<h3 id="code">Code</h3>
733
734To indicate a span of code, wrap it with backtick quotes (`` ` ``).
735Unlike a pre-formatted code block, a code span indicates code within a
736normal paragraph. For example:
737
738 Use the `printf()` function.
739
740will produce:
741
742 <p>Use the <code>printf()</code> function.</p>
743
744To include a literal backtick character within a code span, you can use
745multiple backticks as the opening and closing delimiters:
746
747 ``There is a literal backtick (`) here.``
748
749which will produce this:
750
751 <p><code>There is a literal backtick (`) here.</code></p>
752
753The backtick delimiters surrounding a code span may include spaces --
754one after the opening, one before the closing. This allows you to place
755literal backtick characters at the beginning or end of a code span:
756
757 A single backtick in a code span: `` ` ``
758
759 A backtick-delimited string in a code span: `` `foo` ``
760
761will produce:
762
763 <p>A single backtick in a code span: <code>`</code></p>
764
765 <p>A backtick-delimited string in a code span: <code>`foo`</code></p>
766
767With a code span, ampersands and angle brackets are encoded as HTML
768entities automatically, which makes it easy to include example HTML
769tags. Markdown will turn this:
770
771 Please don't use any `<blink>` tags.
772
773into:
774
775 <p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>
776
777You can write this:
778
779 `&#8212;` is the decimal-encoded equivalent of `&mdash;`.
780
781to produce:
782
783 <p><code>&amp;#8212;</code> is the decimal-encoded
784 equivalent of <code>&amp;mdash;</code>.</p>
785
786
787
788<h3 id="img">Images</h3>
789
790Admittedly, it's fairly difficult to devise a "natural" syntax for
791placing images into a plain text document format.
792
793Markdown uses an image syntax that is intended to resemble the syntax
794for links, allowing for two styles: *inline* and *reference*.
795
796Inline image syntax looks like this:
797
798 ![Alt text](/path/to/img.jpg)
799
800 ![Alt text](/path/to/img.jpg "Optional title")
801
802That is:
803
804* An exclamation mark: `!`;
805* followed by a set of square brackets, containing the `alt`
806 attribute text for the image;
807* followed by a set of parentheses, containing the URL or path to
808 the image, and an optional `title` attribute enclosed in double
809 or single quotes.
810
811Reference-style image syntax looks like this:
812
813 ![Alt text][id]
814
815Where "id" is the name of a defined image reference. Image references
816are defined using syntax identical to link references:
817
818 [id]: url/to/image "Optional title attribute"
819
820As of this writing, Markdown has no syntax for specifying the
821dimensions of an image; if this is important to you, you can simply
822use regular HTML `<img>` tags.
823
824
825* * *
826
827
828<h2 id="misc">Miscellaneous</h2>
829
830<h3 id="autolink">Automatic Links</h3>
831
832Markdown 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:
833
834 <http://example.com/>
835
836Markdown will turn this into:
837
838 <a href="http://example.com/">http://example.com/</a>
839
840Automatic links for email addresses work similarly, except that
841Markdown will also perform a bit of randomized decimal and hex
842entity-encoding to help obscure your address from address-harvesting
843spambots. For example, Markdown will turn this:
844
845 <address@example.com>
846
847into something like this:
848
849 <a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;
850 &#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;
851 &#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
852 &#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
853
854which will render in a browser as a clickable link to "address@example.com".
855
856(This sort of entity-encoding trick will indeed fool many, if not
857most, address-harvesting bots, but it definitely won't fool all of
858them. It's better than nothing, but an address published in this way
859will probably eventually start receiving spam.)
860
861
862
863<h3 id="backslash">Backslash Escapes</h3>
864
865Markdown allows you to use backslash escapes to generate literal
866characters which would otherwise have special meaning in Markdown's
867formatting syntax. For example, if you wanted to surround a word with
868literal asterisks (instead of an HTML `<em>` tag), you can backslashes
869before the asterisks, like this:
870
871 \*literal asterisks\*
872
873Markdown provides backslash escapes for the following characters:
874
875 \ backslash
876 ` backtick
877 * asterisk
878 _ underscore
879 {} curly braces
880 [] square brackets
881 () parentheses
882 # hash mark
883 + plus sign
884 - minus sign (hyphen)
885 . dot
886 ! exclamation mark
  
1<blockquote>
2 <p>foo</p>
3
4 <blockquote>
5 <p>bar</p>
6 </blockquote>
7
8 <p>foo</p>
9</blockquote>
  
1> foo
2>
3> > bar
4>
5> foo
  
1<h2>Unordered</h2>
2
3<p>Asterisks tight:</p>
4
5<ul>
6<li>asterisk 1</li>
7<li>asterisk 2</li>
8<li>asterisk 3</li>
9</ul>
10
11<p>Asterisks loose:</p>
12
13<ul>
14<li><p>asterisk 1</p></li>
15<li><p>asterisk 2</p></li>
16<li><p>asterisk 3</p></li>
17</ul>
18
19<hr />
20
21<p>Pluses tight:</p>
22
23<ul>
24<li>Plus 1</li>
25<li>Plus 2</li>
26<li>Plus 3</li>
27</ul>
28
29<p>Pluses loose:</p>
30
31<ul>
32<li><p>Plus 1</p></li>
33<li><p>Plus 2</p></li>
34<li><p>Plus 3</p></li>
35</ul>
36
37<hr />
38
39<p>Minuses tight:</p>
40
41<ul>
42<li>Minus 1</li>
43<li>Minus 2</li>
44<li>Minus 3</li>
45</ul>
46
47<p>Minuses loose:</p>
48
49<ul>
50<li><p>Minus 1</p></li>
51<li><p>Minus 2</p></li>
52<li><p>Minus 3</p></li>
53</ul>
54
55<h2>Ordered</h2>
56
57<p>Tight:</p>
58
59<ol>
60<li>First</li>
61<li>Second</li>
62<li>Third</li>
63</ol>
64
65<p>and:</p>
66
67<ol>
68<li>One</li>
69<li>Two</li>
70<li>Three</li>
71</ol>
72
73<p>Loose using tabs:</p>
74
75<ol>
76<li><p>First</p></li>
77<li><p>Second</p></li>
78<li><p>Third</p></li>
79</ol>
80
81<p>and using spaces:</p>
82
83<ol>
84<li><p>One</p></li>
85<li><p>Two</p></li>
86<li><p>Three</p></li>
87</ol>
88
89<p>Multiple paragraphs:</p>
90
91<ol>
92<li><p>Item 1, graf one.</p>
93
94<p>Item 2. graf two. The quick brown fox jumped over the lazy dog's
95back.</p></li>
96<li><p>Item 2.</p></li>
97<li><p>Item 3.</p></li>
98</ol>
99
100<h2>Nested</h2>
101
102<ul>
103<li>Tab
104<ul>
105<li>Tab
106<ul>
107<li>Tab</li>
108</ul></li>
109</ul></li>
110</ul>
111
112<p>Here's another:</p>
113
114<ol>
115<li>First</li>
116<li>Second:
117<ul>
118<li>Fee</li>
119<li>Fie</li>
120<li>Foe</li>
121</ul></li>
122<li>Third</li>
123</ol>
124
125<p>Same thing but with paragraphs:</p>
126
127<ol>
128<li><p>First</p></li>
129<li><p>Second:</p>
130
131<ul>
132<li>Fee</li>
133<li>Fie</li>
134<li>Foe</li>
135</ul></li>
136<li><p>Third</p></li>
137</ol>
  
1## Unordered
2
3Asterisks tight:
4
5* asterisk 1
6* asterisk 2
7* asterisk 3
8
9
10Asterisks loose:
11
12* asterisk 1
13
14* asterisk 2
15
16* asterisk 3
17
18* * *
19
20Pluses tight:
21
22+ Plus 1
23+ Plus 2
24+ Plus 3
25
26
27Pluses loose:
28
29+ Plus 1
30
31+ Plus 2
32
33+ Plus 3
34
35* * *
36
37
38Minuses tight:
39
40- Minus 1
41- Minus 2
42- Minus 3
43
44
45Minuses loose:
46
47- Minus 1
48
49- Minus 2
50
51- Minus 3
52
53
54## Ordered
55
56Tight:
57
581. First
592. Second
603. Third
61
62and:
63
641. One
652. Two
663. Three
67
68
69Loose using tabs:
70
711. First
72
732. Second
74
753. Third
76
77and using spaces:
78
791. One
80
812. Two
82
833. Three
84
85Multiple paragraphs:
86
871. Item 1, graf one.
88
89 Item 2. graf two. The quick brown fox jumped over the lazy dog's
90 back.
91
922. Item 2.
93
943. Item 3.
95
96
97
98## Nested
99
100* Tab
101 * Tab
102 * Tab
103
104Here's another:
105
1061. First
1072. Second:
108 * Fee
109 * Fie
110 * Foe
1113. Third
112
113Same thing but with paragraphs:
114
1151. First
116
1172. Second:
118 * Fee
119 * Fie
120 * Foe
121
1223. Third
  
1<p><strong><em>This is strong and em.</em></strong></p>
2
3<p>So is <strong><em>this</em></strong> word.</p>
4
5<p><strong><em>This is strong and em.</em></strong></p>
6
7<p>So is <strong><em>this</em></strong> word.</p>
  
1***This is strong and em.***
2
3So is ***this*** word.
4
5___This is strong and em.___
6
7So is ___this___ word.
  
1<ul>
2<li><p>this is a list item
3indented with tabs</p></li>
4<li><p>this is a list item
5indented with spaces</p></li>
6</ul>
7
8<p>Code:</p>
9
10<pre><code>this code block is indented by one tab
11</code></pre>
12
13<p>And:</p>
14
15<pre><code> this code block is indented by two tabs
16</code></pre>
17
18<p>And:</p>
19
20<pre><code>+ this is an example list item
21 indented with tabs
22
23+ this is an example list item
24 indented with spaces
25</code></pre>
  
1+ this is a list item
2 indented with tabs
3
4+ this is a list item
5 indented with spaces
6
7Code:
8
9 this code block is indented by one tab
10
11And:
12
13 this code block is indented by two tabs
14
15And:
16
17 + this is an example list item
18 indented with tabs
19
20 + this is an example list item
21 indented with spaces
  
1<blockquote>
2<p>A list within a blockquote:</p>
3<ul>
4<li>asterisk 1</li>
5<li>asterisk 2</li>
6<li>asterisk 3</li>
7</ul>
8</blockquote>
  
1> A list within a blockquote:
2>
3> * asterisk 1
4> * asterisk 2
5> * asterisk 3
  
1
2
3<h1 id="lorem"> Lorem ipsum </h1>
4<p>Dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
5 incididunt ut labore et dolore magna aliqua.
6</p>
7<ul>
8 <li><p class="first_item">Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
9 nisi ut aliquip ex ea commodo consequat.
10</p>
11
12 </li>
13
14 <li><p>Duis aute irure dolor in reprehenderit in voluptate velit esse
15 cillum dolore eu fugiat nulla pariatur2. Excepteur sint occaecat
16 cupidatat non proident, sunt in culpa qui officia deserunt mollit
17 anim id est laborum.
18</p>
19
20 </li>
21</ul>
22<p>Duis aute <strong type="term">irure</strong> dolor in reprehenderit in voluptate
23 velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
24 occaecat cupidatat non proident, sunt in culpa qui officia deserunt
25 mollit anim id est laborum.
26</p>
  
1
2Lorem ipsum {@id=lorem}
3=================================
4
5Dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
6incididunt ut labore et dolore magna aliqua.
7
8* Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
9 nisi ut aliquip ex ea commodo consequat.{@class=first_item}
10
11* Duis aute irure dolor in reprehenderit in voluptate velit esse
12 cillum dolore eu fugiat nulla pariatur2. Excepteur sint occaecat
13 cupidatat non proident, sunt in culpa qui officia deserunt mollit
14 anim id est laborum.
15
16Duis aute **irure{@type=term}** dolor in reprehenderit in voluptate
17velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
18occaecat cupidatat non proident, sunt in culpa qui officia deserunt
19mollit anim id est laborum.
  
1
2<p>Lorem ipsum <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#121;&#117;&#114;&#105;&#64;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#111;&#114;&#103;">&#121;&#117;&#114;&#105;&#64;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#111;&#114;&#103;</a>, etc.
3</p>
4<ul>
5 <li>
6 An email address in a list
7 </li>
8
9 <li>
10 <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#121;&#117;&#114;&#105;&#64;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#111;&#114;&#103;">&#121;&#117;&#114;&#105;&#64;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#111;&#114;&#103;</a>
11 </li>
12
13 <li>
14 Another item.
15 </li>
16</ul>
  
1Lorem ipsum <yuri@domain.org>, etc.
2
3* An email address in a list
4* <yuri@domain.org>
5* Another item.
  
1
2<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
3 tempor incididunt ut labore et dolore magna aliqua<sup><a href="#fn1-903162597" id="fnr1-903162597">1</a></sup>. Ut enim ad minim
4 veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
5 commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
6 velit esse cillum dolore eu fugiat nulla pariatur<sup><a href="#fn2-903162597" id="fnr2-903162597">2</a></sup>. Excepteur sint
7 occaecat cupidatat non proident, sunt in culpa qui officia deserunt
8 mollit anim id est laborum.
9</p>
10<ul>
11 <li>
12 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
13 eiusmod tempor incididunt ut labore et dolore<sup><a href="#fn3-903162597" id="fnr3-903162597">3</a></sup> magna aliqua.
14 </li>
15</ul>
16<p>Duis aute irure dolor in reprehenderit in voluptate
17 velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
18 occaecat cupidatat non proident, sunt in culpa qui officia deserunt
19 mollit anim id est laborum.
20</p>
21
22<div class="footnote"><hr/><ol>
23 <li id="fn1-903162597">
24 Sed ut perspiciatis unde omnis iste natus error sit voluptatem
25 accusantium doloremque laudantium, totam rem aperiam, eaque ipsa
26 quae ab illo inventore veritatis et quasi architecto beatae vitae
27 dicta sunt explicabo.<a href="#fnr1-903162597" class="footnoteBackLink" title="Jump back to footnote 1 in the text">&#8617;</a>
28 </li>
29
30 <li id="fn2-903162597">
31 Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit
32 aut fugit, sed quia consequuntur magni dolores eos qui ratione
33 voluptatem sequi nesciunt. <p> Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet,
34 consectetur, adipisci velit, sed quia non numquam eius modi
35 tempora incidunt ut labore et dolore magnam aliquam quaerat
36 voluptatem. <a href="#fnr2-903162597" class="footnoteBackLink" title="Jump back to footnote 1 in the text">&#8617;</a>
37</p>
38
39 </li>
40
41 <li id="fn3-903162597">
42 Ut enim ad minim veniam, quis nostrud exercitation ullamco
43 laboris nisi ut aliquip ex ea commodo consequat. <a href="#fnr3-903162597" class="footnoteBackLink" title="Jump back to footnote 1 in the text">&#8617;</a>
44 </li>
45</ol>
46</div>
  
1Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
2tempor incididunt ut labore et dolore magna aliqua[^2]. Ut enim ad minim
3veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
4commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
5velit esse cillum dolore eu fugiat nulla pariatur[^1]. Excepteur sint
6occaecat cupidatat non proident, sunt in culpa qui officia deserunt
7mollit anim id est laborum.
8
9[^1]: Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit
10 aut fugit, sed quia consequuntur magni dolores eos qui ratione
11 voluptatem sequi nesciunt.
12
13 Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet,
14 consectetur, adipisci velit, sed quia non numquam eius modi
15 tempora incidunt ut labore et dolore magnam aliquam quaerat
16 voluptatem.
17
18[^2]: Sed ut perspiciatis unde omnis iste natus error sit voluptatem
19 accusantium doloremque laudantium, totam rem aperiam, eaque ipsa
20 quae ab illo inventore veritatis et quasi architecto beatae vitae
21 dicta sunt explicabo.
22
23* Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
24 eiusmod tempor incididunt ut labore et dolore[^foo] magna aliqua.
25
26[^foo]: Ut enim ad minim veniam, quis nostrud exercitation ullamco
27 laboris nisi ut aliquip ex ea commodo consequat.
28
29Duis aute irure dolor in reprehenderit in voluptate
30velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
31occaecat cupidatat non proident, sunt in culpa qui officia deserunt
32mollit anim id est laborum.
  
1<h2>A plain header</h2>
2
3<p>Let's first have a plain header</p>
4
5<h1>An underlined header</h1>
6
7<p>(That's also useful)</p>
8
9<h1>A header with a <a href="http://www.link.com">link</a></h1>
10
11<p>First with a hash</p>
12
13<h2>Another with a <a href="http://www.link.com/">link</a></h2>
14
15<p>This time underlined</p>
  
1## A plain header
2
3Let's first have a plain header
4
5An underlined header
6====================
7
8(That's also useful)
9
10# A header with a [link](http://www.link.com)
11
12First with a hash
13
14Another with a [link][a]
15------------------------
16This time underlined
17
18[a]: http://www.link.com/
  
1[DEFAULT]
2input_ext=.text
3normalize=1
4# comment out next line to run these tests
5#skip=1
6
7[Yuri-Footnotes]
8extensions=footnotes
9skip=1
  
1<p>AT&amp;T has an ampersand in their name.</p>
2
3<p>AT&amp;T is another way to write it.</p>
4
5<p>This &amp; that.</p>
6
7<p>4 &lt; 5.</p>
8
9<p>6 > 5.</p>
10
11<p>Here's a <a href="http://example.com/?foo=1&amp;bar=2">link</a> with an ampersand in the URL.</p>
12
13<p>Here's a link with an amersand in the link text: <a href="http://att.com/" title="AT&amp;T">AT&amp;T</a>.</p>
14
15<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
16
17<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
  
1AT&T has an ampersand in their name.
2
3AT&amp;T is another way to write it.
4
5This & that.
6
74 < 5.
8
96 > 5.
10
11Here's a [link] [1] with an ampersand in the URL.
12
13Here's a link with an amersand in the link text: [AT&T] [2].
14
15Here's an inline [link](/script?foo=1&bar=2).
16
17Here's an inline [link](</script?foo=1&bar=2>).
18
19
20[1]: http://example.com/?foo=1&bar=2
21[2]: http://att.com/ "AT&T"
  
1<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>
2
3<p>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</a></p>
4
5<ul>
6<li>In a list?</li>
7<li><a href="http://example.com/">http://example.com/</a></li>
8<li>It should.</li>
9</ul>
10
11<blockquote>
12 <p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
13</blockquote>
14
15<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
16
17<pre><code>or here: &lt;http://example.com/&gt;
18</code></pre>
  
1Link: <http://example.com/>.
2
3With an ampersand: <http://example.com/?foo=1&bar=2>
4
5* In a list?
6* <http://example.com/>
7* It should.
8
9> Blockquoted: <http://example.com/>
10
11Auto-links should not occur here: `<http://example.com/>`
12
13 or here: <http://example.com/>
  
1<p>These should all get escaped:</p>
2
3<p>Backslash: \</p>
4
5<p>Backtick: `</p>
6
7<p>Asterisk: *</p>
8
9<p>Underscore: _</p>
10
11<p>Left brace: {</p>
12
13<p>Right brace: }</p>
14
15<p>Left bracket: [</p>
16
17<p>Right bracket: ]</p>
18
19<p>Left paren: (</p>
20
21<p>Right paren: )</p>
22
23<p>Greater-than: ></p>
24
25<p>Hash: #</p>
26
27<p>Period: .</p>
28
29<p>Bang: !</p>
30
31<p>Plus: +</p>
32
33<p>Minus: -</p>
34
35<p>These should not, because they occur within a code block:</p>
36
37<pre><code>Backslash: \\
38
39Backtick: \`
40
41Asterisk: \*
42
43Underscore: \_
44
45Left brace: \{
46
47Right brace: \}
48
49Left bracket: \[
50
51Right bracket: \]
52
53Left paren: \(
54
55Right paren: \)
56
57Greater-than: \&gt;
58
59Hash: \#
60
61Period: \.
62
63Bang: \!
64
65Plus: \+
66
67Minus: \-
68</code></pre>
69
70<p>Nor should these, which occur in code spans:</p>
71
72<p>Backslash: <code>\\</code></p>
73
74<p>Backtick: <code>\`</code></p>
75
76<p>Asterisk: <code>\*</code></p>
77
78<p>Underscore: <code>\_</code></p>
79
80<p>Left brace: <code>\{</code></p>
81
82<p>Right brace: <code>\}</code></p>
83
84<p>Left bracket: <code>\[</code></p>
85
86<p>Right bracket: <code>\]</code></p>
87
88<p>Left paren: <code>\(</code></p>
89
90<p>Right paren: <code>\)</code></p>
91
92<p>Greater-than: <code>\&gt;</code></p>
93
94<p>Hash: <code>\#</code></p>
95
96<p>Period: <code>\.</code></p>
97
98<p>Bang: <code>\!</code></p>
99
100<p>Plus: <code>\+</code></p>
101
102<p>Minus: <code>\-</code></p>
103
104
105<p>These should get escaped, even though they're matching pairs for
106other Markdown constructs:</p>
107
108<p>*asterisks*</p>
109
110<p>_underscores_</p>
111
112<p>`backticks`</p>
113
114<p>This is a code span with a literal backslash-backtick sequence: <code>\`</code></p>
115
116<p>This is a tag with unescaped backticks <span attr='`ticks`'>bar</span>.</p>
117
118<p>This is a tag with backslashes <span attr='\\backslashes\\'>bar</span>.</p>
  
1These should all get escaped:
2
3Backslash: \\
4
5Backtick: \`
6
7Asterisk: \*
8
9Underscore: \_
10
11Left brace: \{
12
13Right brace: \}
14
15Left bracket: \[
16
17Right bracket: \]
18
19Left paren: \(
20
21Right paren: \)
22
23Greater-than: \>
24
25Hash: \#
26
27Period: \.
28
29Bang: \!
30
31Plus: \+
32
33Minus: \-
34
35
36
37These should not, because they occur within a code block:
38
39 Backslash: \\
40
41 Backtick: \`
42
43 Asterisk: \*
44
45 Underscore: \_
46
47 Left brace: \{
48
49 Right brace: \}
50
51 Left bracket: \[
52
53 Right bracket: \]
54
55 Left paren: \(
56
57 Right paren: \)
58
59 Greater-than: \>
60
61 Hash: \#
62
63 Period: \.
64
65 Bang: \!
66
67 Plus: \+
68
69 Minus: \-
70
71
72Nor should these, which occur in code spans:
73
74Backslash: `\\`
75
76Backtick: `` \` ``
77
78Asterisk: `\*`
79
80Underscore: `\_`
81
82Left brace: `\{`
83
84Right brace: `\}`
85
86Left bracket: `\[`
87
88Right bracket: `\]`
89
90Left paren: `\(`
91
92Right paren: `\)`
93
94Greater-than: `\>`
95
96Hash: `\#`
97
98Period: `\.`
99
100Bang: `\!`
101
102Plus: `\+`
103
104Minus: `\-`
105
106
107These should get escaped, even though they're matching pairs for
108other Markdown constructs:
109
110\*asterisks\*
111
112\_underscores\_
113
114\`backticks\`
115
116This is a code span with a literal backslash-backtick sequence: `` \` ``
117
118This is a tag with unescaped backticks <span attr='`ticks`'>bar</span>.
119
120This is a tag with backslashes <span attr='\\backslashes\\'>bar</span>.
  
1<blockquote>
2 <p>Example:</p>
3
4<pre><code>sub status {
5 print "working";
6}
7</code></pre>
8
9 <p>Or:</p>
10
11<pre><code>sub status {
12 return "working";
13}
14</code></pre>
15</blockquote>
  
1> Example:
2>
3> sub status {
4> print "working";
5> }
6>
7> Or:
8>
9> sub status {
10> return "working";
11> }
  
1<pre><code>code block on the first line
2</code></pre>
3
4<p>Regular text.</p>
5
6<pre><code>code block indented by spaces
7</code></pre>
8
9<p>Regular text.</p>
10
11<pre><code>the lines in this block
12all contain trailing spaces
13</code></pre>
14
15<p>Regular Text.</p>
16
17<pre><code>code block on the last line
18</code></pre>
  
1 code block on the first line
2
3Regular text.
4
5 code block indented by spaces
6
7Regular text.
8
9 the lines in this block
10 all contain trailing spaces
11
12Regular Text.
13
14 code block on the last line
  
1<p><code>&lt;test a="</code> content of attribute <code>"&gt;</code></p>
2
3<p>Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span></p>
4
5<p>Here's how you put <code>`backticks`</code> in a code span.</p>
  
1`<test a="` content of attribute `">`
2
3Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span>
4
5Here's how you put `` `backticks` `` in a code span.
  
1<p>In Markdown 1.0.0 and earlier. Version
28. This line turns into a list item.
3Because a hard-wrapped line in the
4middle of a paragraph looked like a
5list item.</p>
6
7<p>Here's one with a bullet.
8* criminey.</p>
  
1In Markdown 1.0.0 and earlier. Version
28. This line turns into a list item.
3Because a hard-wrapped line in the
4middle of a paragraph looked like a
5list item.
6
7Here's one with a bullet.
8* criminey.
  
1<p>Dashes:</p>
2
3<hr />
4
5<hr />
6
7<hr />
8
9<hr />
10
11<pre><code>---
12</code></pre>
13
14<hr />
15
16<hr />
17
18<hr />
19
20<hr />
21
22<pre><code>- - -
23</code></pre>
24
25<p>Asterisks:</p>
26
27<hr />
28
29<hr />
30
31<hr />
32
33<hr />
34
35<pre><code>***
36</code></pre>
37
38<hr />
39
40<hr />
41
42<hr />
43
44<hr />
45
46<pre><code>* * *
47</code></pre>
48
49<p>Underscores:</p>
50
51<hr />
52
53<hr />
54
55<hr />
56
57<hr />
58
59<pre><code>___
60</code></pre>
61
62<hr />
63
64<hr />
65
66<hr />
67
68<hr />
69
70<pre><code>_ _ _
71</code></pre>
  
1Dashes:
2
3---
4
5 ---
6
7 ---
8
9 ---
10
11 ---
12
13- - -
14
15 - - -
16
17 - - -
18
19 - - -
20
21 - - -
22
23
24Asterisks:
25
26***
27
28 ***
29
30 ***
31
32 ***
33
34 ***
35
36* * *
37
38 * * *
39
40 * * *
41
42 * * *
43
44 * * *
45
46
47Underscores:
48
49___
50
51 ___
52
53 ___
54
55 ___
56
57 ___
58
59_ _ _
60
61 _ _ _
62
63 _ _ _
64
65 _ _ _
66
67 _ _ _
  
1<p><img src="/path/to/img.jpg" alt="Alt text" title="" /></p>
2
3<p><img src="/path/to/img.jpg" alt="Alt text" title="Optional title" /></p>
4
5<p>Inline within a paragraph: <a href="/url/">alt text</a>.</p>
6
7<p><img src="/url/" alt="alt text" title="title preceded by two spaces" /></p>
8
9<p><img src="/url/" alt="alt text" title="title has spaces afterward" /></p>
10
11<p><img src="/url/" alt="alt text" title="" /></p>
12
13<p><img src="/url/" alt="alt text" title="with a title" />.</p>
14
15<p><img src="" alt="Empty" title="" /></p>
16
17<p><img src="http://example.com/(parens).jpg" alt="this is a stupid URL" title="" /></p>
18
19<p><img src="/url/" alt="alt text" /></p>
20
21<p><img src="/url/" alt="alt text" title="Title here" /></p>
  
1![Alt text](/path/to/img.jpg)
2
3![Alt text](/path/to/img.jpg "Optional title")
4
5Inline within a paragraph: [alt text](/url/).
6
7![alt text](/url/ "title preceded by two spaces")
8
9![alt text](/url/ "title has spaces afterward" )
10
11![alt text](</url/>)
12
13![alt text](</url/> "with a title").
14
15![Empty]()
16
17![this is a stupid URL](http://example.com/(parens).jpg)
18
19
20![alt text][foo]
21
22 [foo]: /url/
23
24![alt text][bar]
25
26 [bar]: /url/ "Title here"
  
1<p>Simple block on one line:</p>
2
3<div>foo</div>
4
5<p>And nested without indentation:</p>
6
7<div>
8<div>
9<div>
10foo
11</div>
12<div style=">"/>
13</div>
14<div>bar</div>
15</div>
16
17<p>And with attributes:</p>
18
19<div>
20 <div id="foo">
21 </div>
22</div>
23
24<p>This was broken in 1.0.2b7:</p>
25
26<div class="inlinepage">
27<div class="toggleableend">
28foo
29</div>
30</div>
  
1Simple block on one line:
2
3<div>foo</div>
4
5And nested without indentation:
6
7<div>
8<div>
9<div>
10foo
11</div>
12<div style=">"/>
13</div>
14<div>bar</div>
15</div>
16
17And with attributes:
18
19<div>
20 <div id="foo">
21 </div>
22</div>
23
24This was broken in 1.0.2b7:
25
26<div class="inlinepage">
27<div class="toggleableend">
28foo
29</div>
30</div>
  
1<p>Here's a simple block:</p>
2
3<div>
4 foo
5</div>
6
7<p>This should be a code block, though:</p>
8
9<pre><code>&lt;div&gt;
10 foo
11&lt;/div&gt;
12</code></pre>
13
14<p>As should this:</p>
15
16<pre><code>&lt;div&gt;foo&lt;/div&gt;
17</code></pre>
18
19<p>Now, nested:</p>
20
21<div>
22 <div>
23 <div>
24 foo
25 </div>
26 </div>
27</div>
28
29<p>This should just be an HTML comment:</p>
30
31<!-- Comment -->
32
33<p>Multiline:</p>
34
35<!--
36Blah
37Blah
38-->
39
40<p>Code block:</p>
41
42<pre><code>&lt;!-- Comment --&gt;
43</code></pre>
44
45<p>Just plain comment, with trailing spaces on the line:</p>
46
47<!-- foo -->
48
49<p>Code:</p>
50
51<pre><code>&lt;hr /&gt;
52</code></pre>
53
54<p>Hr's:</p>
55
56<hr>
57
58<hr/>
59
60<hr />
61
62<hr>
63
64<hr/>
65
66<hr />
67
68<hr class="foo" id="bar" />
69
70<hr class="foo" id="bar"/>
71
72<hr class="foo" id="bar" >
  
1Here's a simple block:
2
3<div>
4 foo
5</div>
6
7This should be a code block, though:
8
9 <div>
10 foo
11 </div>
12
13As should this:
14
15 <div>foo</div>
16
17Now, nested:
18
19<div>
20 <div>
21 <div>
22 foo
23 </div>
24 </div>
25</div>
26
27This should just be an HTML comment:
28
29<!-- Comment -->
30
31Multiline:
32
33<!--
34Blah
35Blah
36-->
37
38Code block:
39
40 <!-- Comment -->
41
42Just plain comment, with trailing spaces on the line:
43
44<!-- foo -->
45
46Code:
47
48 <hr />
49
50Hr's:
51
52<hr>
53
54<hr/>
55
56<hr />
57
58<hr>
59
60<hr/>
61
62<hr />
63
64<hr class="foo" id="bar" />
65
66<hr class="foo" id="bar"/>
67
68<hr class="foo" id="bar" >
  
1<p>Paragraph one.</p>
2
3<!-- This is a simple comment -->
4
5<!--
6 This is another comment.
7-->
8
9<p>Paragraph two.</p>
10
11<!-- one comment block -- -- with two comments -->
12
13<p>The end.</p>
  
1Paragraph one.
2
3<!-- This is a simple comment -->
4
5<!--
6 This is another comment.
7-->
8
9Paragraph two.
10
11<!-- one comment block -- -- with two comments -->
12
13The end.
  
1<p>Just a <a href="/url/">URL</a>.</p>
2
3<p><a href="/url/" title="title">URL and title</a>.</p>
4
5<p><a href="/url/" title="title preceded by two spaces">URL and title</a>.</p>
6
7<p><a href="/url/" title="title preceded by a tab">URL and title</a>.</p>
8
9<p><a href="/url/" title="title has spaces afterward">URL and title</a>.</p>
10
11<p><a href="/url/">URL wrapped in angle brackets</a>.</p>
12
13<p><a href="/url/" title="Here's the title">URL w/ angle brackets + title</a>.</p>
14
15<p><a href="">Empty</a>.</p>
16
17<p><a href="http://en.wikipedia.org/wiki/WIMP_(computing)">With parens in the URL</a></p>
18
19<p>(With outer parens and <a href="/foo(bar)">parens in url</a>)</p>
20
21<p><a href="/foo(bar)" title="and a title">With parens in the URL</a></p>
22
23<p>(With outer parens and <a href="/foo(bar)" title="and a title">parens in url</a>)</p>
  
1Just a [URL](/url/).
2
3[URL and title](/url/ "title").
4
5[URL and title](/url/ "title preceded by two spaces").
6
7[URL and title](/url/ "title preceded by a tab").
8
9[URL and title](/url/ "title has spaces afterward" ).
10
11[URL wrapped in angle brackets](</url/>).
12
13[URL w/ angle brackets + title](</url/> "Here's the title").
14
15[Empty]().
16
17[With parens in the URL](http://en.wikipedia.org/wiki/WIMP_(computing))
18
19(With outer parens and [parens in url](/foo(bar)))
20
21
22[With parens in the URL](/foo(bar) "and a title")
23
24(With outer parens and [parens in url](/foo(bar) "and a title"))
  
1<p>Foo <a href="/url/" title="Title">bar</a>.</p>
2
3<p>Foo <a href="/url/" title="Title">bar</a>.</p>
4
5<p>Foo <a href="/url/" title="Title">bar</a>.</p>
6
7<p>With <a href="/url/">embedded [brackets]</a>.</p>
8
9<p>Indented <a href="/url">once</a>.</p>
10
11<p>Indented <a href="/url">twice</a>.</p>
12
13<p>Indented <a href="/url">thrice</a>.</p>
14
15<p>Indented [four][] times.</p>
16
17<pre><code>[four]: /url
18</code></pre>
19
20<hr />
21
22<p><a href="foo">this</a> should work</p>
23
24<p>So should <a href="foo">this</a>.</p>
25
26<p>And <a href="foo">this</a>.</p>
27
28<p>And <a href="foo">this</a>.</p>
29
30<p>And <a href="foo">this</a>.</p>
31
32<p>But not [that] [].</p>
33
34<p>Nor [that][].</p>
35
36<p>Nor [that].</p>
37
38<p>[Something in brackets like <a href="foo">this</a> should work]</p>
39
40<p>[Same with <a href="foo">this</a>.]</p>
41
42<p>In this case, <a href="/somethingelse/">this</a> points to something else.</p>
43
44<p>Backslashing should suppress [this] and [this].</p>
45
46<hr />
47
48<p>Here's one where the <a href="/url/">link
49breaks</a> across lines.</p>
50
51<p>Here's another where the <a href="/url/">link
52breaks</a> across lines, but with a line-ending space.</p>
  
1Foo [bar] [1].
2
3Foo [bar][1].
4
5Foo [bar]
6[1].
7
8[1]: /url/ "Title"
9
10
11With [embedded [brackets]] [b].
12
13
14Indented [once][].
15
16Indented [twice][].
17
18Indented [thrice][].
19
20Indented [four][] times.
21
22 [once]: /url
23
24 [twice]: /url
25
26 [thrice]: /url
27
28 [four]: /url
29
30
31[b]: /url/
32
33* * *
34
35[this] [this] should work
36
37So should [this][this].
38
39And [this] [].
40
41And [this][].
42
43And [this].
44
45But not [that] [].
46
47Nor [that][].
48
49Nor [that].
50
51[Something in brackets like [this][] should work]
52
53[Same with [this].]
54
55In this case, [this](/somethingelse/) points to something else.
56
57Backslashing should suppress \[this] and [this\].
58
59[this]: foo
60
61
62* * *
63
64Here's one where the [link
65breaks] across lines.
66
67Here's another where the [link
68breaks] across lines, but with a line-ending space.
69
70
71[link breaks]: /url/
  
1<p>This is the <a href="/simple">simple case</a>.</p>
2
3<p>This one has a <a href="/foo">line
4break</a>.</p>
5
6<p>This one has a <a href="/foo">line
7break</a> with a line-ending space.</p>
8
9<p><a href="/that">this</a> and the <a href="/other">other</a></p>
  
1This is the [simple case].
2
3[simple case]: /simple
4
5
6
7This one has a [line
8break].
9
10This one has a [line
11break] with a line-ending space.
12
13[line break]: /foo
14
15
16[this] [that] and the [other]
17
18[this]: /this
19[that]: /that
20[other]: /other
  
1<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
2
3<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
  
1Foo [bar][].
2
3Foo [bar](/url/ "Title with "quotes" inside").
4
5
6 [bar]: /url/ "Title with "quotes" inside"
  
1<h1>Markdown: Basics</h1>
2
3<ul id="ProjectSubmenu">
4 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
5 <li><a class="selected" title="Markdown Basics">Basics</a></li>
6 <li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
7 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
8 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
9</ul>
10
11<h2>Getting the Gist of Markdown's Formatting Syntax</h2>
12
13<p>This page offers a brief overview of what it's like to use Markdown.
14The <a href="/projects/markdown/syntax" title="Markdown Syntax">syntax page</a> provides complete, detailed documentation for
15every feature, but Markdown should be very easy to pick up simply by
16looking at a few examples of it in action. The examples on this page
17are written in a before/after style, showing example syntax and the
18HTML output produced by Markdown.</p>
19
20<p>It's also helpful to simply try Markdown out; the <a href="/projects/markdown/dingus" title="Markdown Dingus">Dingus</a> is a
21web application that allows you type your own Markdown-formatted text
22and translate it to XHTML.</p>
23
24<p><strong>Note:</strong> This document is itself written using Markdown; you
25can <a href="/projects/markdown/basics.text">see the source for it by adding '.text' to the URL</a>.</p>
26
27<h2>Paragraphs, Headers, Blockquotes</h2>
28
29<p>A paragraph is simply one or more consecutive lines of text, separated
30by one or more blank lines. (A blank line is any line that looks like a
31blank line -- a line containing nothing spaces or tabs is considered
32blank.) Normal paragraphs should not be intended with spaces or tabs.</p>
33
34<p>Markdown offers two styles of headers: <em>Setext</em> and <em>atx</em>.
35Setext-style headers for <code>&lt;h1&gt;</code> and <code>&lt;h2&gt;</code> are created by
36"underlining" with equal signs (<code>=</code>) and hyphens (<code>-</code>), respectively.
37To create an atx-style header, you put 1-6 hash marks (<code>#</code>) at the
38beginning of the line -- the number of hashes equals the resulting
39HTML header level.</p>
40
41<p>Blockquotes are indicated using email-style '<code>&gt;</code>' angle brackets.</p>
42
43<p>Markdown:</p>
44
45<pre><code>A First Level Header
46====================
47
48A Second Level Header
49---------------------
50
51Now is the time for all good men to come to
52the aid of their country. This is just a
53regular paragraph.
54
55The quick brown fox jumped over the lazy
56dog's back.
57
58### Header 3
59
60&gt; This is a blockquote.
61&gt;
62&gt; This is the second paragraph in the blockquote.
63&gt;
64&gt; ## This is an H2 in a blockquote
65</code></pre>
66
67<p>Output:</p>
68
69<pre><code>&lt;h1&gt;A First Level Header&lt;/h1&gt;
70
71&lt;h2&gt;A Second Level Header&lt;/h2&gt;
72
73&lt;p&gt;Now is the time for all good men to come to
74the aid of their country. This is just a
75regular paragraph.&lt;/p&gt;
76
77&lt;p&gt;The quick brown fox jumped over the lazy
78dog's back.&lt;/p&gt;
79
80&lt;h3&gt;Header 3&lt;/h3&gt;
81
82&lt;blockquote&gt;
83 &lt;p&gt;This is a blockquote.&lt;/p&gt;
84
85 &lt;p&gt;This is the second paragraph in the blockquote.&lt;/p&gt;
86
87 &lt;h2&gt;This is an H2 in a blockquote&lt;/h2&gt;
88&lt;/blockquote&gt;
89</code></pre>
90
91<h3>Phrase Emphasis</h3>
92
93<p>Markdown uses asterisks and underscores to indicate spans of emphasis.</p>
94
95<p>Markdown:</p>
96
97<pre><code>Some of these words *are emphasized*.
98Some of these words _are emphasized also_.
99
100Use two asterisks for **strong emphasis**.
101Or, if you prefer, __use two underscores instead__.
102</code></pre>
103
104<p>Output:</p>
105
106<pre><code>&lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
107Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
108
109&lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
110Or, if you prefer, &lt;strong&gt;use two underscores instead&lt;/strong&gt;.&lt;/p&gt;
111</code></pre>
112
113<h2>Lists</h2>
114
115<p>Unordered (bulleted) lists use asterisks, pluses, and hyphens (<code>*</code>,
116<code>+</code>, and <code>-</code>) as list markers. These three markers are
117interchangable; this:</p>
118
119<pre><code>* Candy.
120* Gum.
121* Booze.
122</code></pre>
123
124<p>this:</p>
125
126<pre><code>+ Candy.
127+ Gum.
128+ Booze.
129</code></pre>
130
131<p>and this:</p>
132
133<pre><code>- Candy.
134- Gum.
135- Booze.
136</code></pre>
137
138<p>all produce the same output:</p>
139
140<pre><code>&lt;ul&gt;
141&lt;li&gt;Candy.&lt;/li&gt;
142&lt;li&gt;Gum.&lt;/li&gt;
143&lt;li&gt;Booze.&lt;/li&gt;
144&lt;/ul&gt;
145</code></pre>
146
147<p>Ordered (numbered) lists use regular numbers, followed by periods, as
148list markers:</p>
149
150<pre><code>1. Red
1512. Green
1523. Blue
153</code></pre>
154
155<p>Output:</p>
156
157<pre><code>&lt;ol&gt;
158&lt;li&gt;Red&lt;/li&gt;
159&lt;li&gt;Green&lt;/li&gt;
160&lt;li&gt;Blue&lt;/li&gt;
161&lt;/ol&gt;
162</code></pre>
163
164<p>If you put blank lines between items, you'll get <code>&lt;p&gt;</code> tags for the
165list item text. You can create multi-paragraph list items by indenting
166the paragraphs by 4 spaces or 1 tab:</p>
167
168<pre><code>* A list item.
169
170 With multiple paragraphs.
171
172* Another item in the list.
173</code></pre>
174
175<p>Output:</p>
176
177<pre><code>&lt;ul&gt;
178&lt;li&gt;&lt;p&gt;A list item.&lt;/p&gt;
179&lt;p&gt;With multiple paragraphs.&lt;/p&gt;&lt;/li&gt;
180&lt;li&gt;&lt;p&gt;Another item in the list.&lt;/p&gt;&lt;/li&gt;
181&lt;/ul&gt;
182</code></pre>
183
184<h3>Links</h3>
185
186<p>Markdown supports two styles for creating links: <em>inline</em> and
187<em>reference</em>. With both styles, you use square brackets to delimit the
188text you want to turn into a link.</p>
189
190<p>Inline-style links use parentheses immediately after the link text.
191For example:</p>
192
193<pre><code>This is an [example link](http://example.com/).
194</code></pre>
195
196<p>Output:</p>
197
198<pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/"&gt;
199example link&lt;/a&gt;.&lt;/p&gt;
200</code></pre>
201
202<p>Optionally, you may include a title attribute in the parentheses:</p>
203
204<pre><code>This is an [example link](http://example.com/ "With a Title").
205</code></pre>
206
207<p>Output:</p>
208
209<pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/" title="With a Title"&gt;
210example link&lt;/a&gt;.&lt;/p&gt;
211</code></pre>
212
213<p>Reference-style links allow you to refer to your links by names, which
214you define elsewhere in your document:</p>
215
216<pre><code>I get 10 times more traffic from [Google][1] than from
217[Yahoo][2] or [MSN][3].
218
219[1]: http://google.com/ "Google"
220[2]: http://search.yahoo.com/ "Yahoo Search"
221[3]: http://search.msn.com/ "MSN Search"
222</code></pre>
223
224<p>Output:</p>
225
226<pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
227title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
228title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
229title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
230</code></pre>
231
232<p>The title attribute is optional. Link names may contain letters,
233numbers and spaces, but are <em>not</em> case sensitive:</p>
234
235<pre><code>I start my morning with a cup of coffee and
236[The New York Times][NY Times].
237
238[ny times]: http://www.nytimes.com/
239</code></pre>
240
241<p>Output:</p>
242
243<pre><code>&lt;p&gt;I start my morning with a cup of coffee and
244&lt;a href="http://www.nytimes.com/"&gt;The New York Times&lt;/a&gt;.&lt;/p&gt;
245</code></pre>
246
247<h3>Images</h3>
248
249<p>Image syntax is very much like link syntax.</p>
250
251<p>Inline (titles are optional):</p>
252
253<pre><code>![alt text](/path/to/img.jpg "Title")
254</code></pre>
255
256<p>Reference-style:</p>
257
258<pre><code>![alt text][id]
259
260[id]: /path/to/img.jpg "Title"
261</code></pre>
262
263<p>Both of the above examples produce the same output:</p>
264
265<pre><code>&lt;img src="/path/to/img.jpg" alt="alt text" title="Title" /&gt;
266</code></pre>
267
268<h3>Code</h3>
269
270<p>In a regular paragraph, you can create code span by wrapping text in
271backtick quotes. Any ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> or
272<code>&gt;</code>) will automatically be translated into HTML entities. This makes
273it easy to use Markdown to write about HTML example code:</p>
274
275<pre><code>I strongly recommend against using any `&lt;blink&gt;` tags.
276
277I wish SmartyPants used named entities like `&amp;mdash;`
278instead of decimal-encoded entites like `&amp;#8212;`.
279</code></pre>
280
281<p>Output:</p>
282
283<pre><code>&lt;p&gt;I strongly recommend against using any
284&lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
285
286&lt;p&gt;I wish SmartyPants used named entities like
287&lt;code&gt;&amp;amp;mdash;&lt;/code&gt; instead of decimal-encoded
288entites like &lt;code&gt;&amp;amp;#8212;&lt;/code&gt;.&lt;/p&gt;
289</code></pre>
290
291<p>To specify an entire block of pre-formatted code, indent every line of
292the block by 4 spaces or 1 tab. Just like with code spans, <code>&amp;</code>, <code>&lt;</code>,
293and <code>&gt;</code> characters will be escaped automatically.</p>
294
295<p>Markdown:</p>
296
297<pre><code>If you want your page to validate under XHTML 1.0 Strict,
298you've got to put paragraph tags in your blockquotes:
299
300 &lt;blockquote&gt;
301 &lt;p&gt;For example.&lt;/p&gt;
302 &lt;/blockquote&gt;
303</code></pre>
304
305<p>Output:</p>
306
307<pre><code>&lt;p&gt;If you want your page to validate under XHTML 1.0 Strict,
308you've got to put paragraph tags in your blockquotes:&lt;/p&gt;
309
310&lt;pre&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;
311 &amp;lt;p&amp;gt;For example.&amp;lt;/p&amp;gt;
312&amp;lt;/blockquote&amp;gt;
313&lt;/code&gt;&lt;/pre&gt;
314</code></pre>
  
1Markdown: Basics
2================
3
4<ul id="ProjectSubmenu">
5 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
6 <li><a class="selected" title="Markdown Basics">Basics</a></li>
7 <li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
8 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
9 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
10</ul>
11
12
13Getting the Gist of Markdown's Formatting Syntax
14------------------------------------------------
15
16This page offers a brief overview of what it's like to use Markdown.
17The [syntax page] [s] provides complete, detailed documentation for
18every feature, but Markdown should be very easy to pick up simply by
19looking at a few examples of it in action. The examples on this page
20are written in a before/after style, showing example syntax and the
21HTML output produced by Markdown.
22
23It's also helpful to simply try Markdown out; the [Dingus] [d] is a
24web application that allows you type your own Markdown-formatted text
25and translate it to XHTML.
26
27**Note:** This document is itself written using Markdown; you
28can [see the source for it by adding '.text' to the URL] [src].
29
30 [s]: /projects/markdown/syntax "Markdown Syntax"
31 [d]: /projects/markdown/dingus "Markdown Dingus"
32 [src]: /projects/markdown/basics.text
33
34
35## Paragraphs, Headers, Blockquotes ##
36
37A paragraph is simply one or more consecutive lines of text, separated
38by one or more blank lines. (A blank line is any line that looks like a
39blank line -- a line containing nothing spaces or tabs is considered
40blank.) Normal paragraphs should not be intended with spaces or tabs.
41
42Markdown offers two styles of headers: *Setext* and *atx*.
43Setext-style headers for `<h1>` and `<h2>` are created by
44"underlining" with equal signs (`=`) and hyphens (`-`), respectively.
45To create an atx-style header, you put 1-6 hash marks (`#`) at the
46beginning of the line -- the number of hashes equals the resulting
47HTML header level.
48
49Blockquotes are indicated using email-style '`>`' angle brackets.
50
51Markdown:
52
53 A First Level Header
54 ====================
55
56 A Second Level Header
57 ---------------------
58
59 Now is the time for all good men to come to
60 the aid of their country. This is just a
61 regular paragraph.
62
63 The quick brown fox jumped over the lazy
64 dog's back.
65
66 ### Header 3
67
68 > This is a blockquote.
69 >
70 > This is the second paragraph in the blockquote.
71 >
72 > ## This is an H2 in a blockquote
73
74
75Output:
76
77 <h1>A First Level Header</h1>
78
79 <h2>A Second Level Header</h2>
80
81 <p>Now is the time for all good men to come to
82 the aid of their country. This is just a
83 regular paragraph.</p>
84
85 <p>The quick brown fox jumped over the lazy
86 dog's back.</p>
87
88 <h3>Header 3</h3>
89
90 <blockquote>
91 <p>This is a blockquote.</p>
92
93 <p>This is the second paragraph in the blockquote.</p>
94
95 <h2>This is an H2 in a blockquote</h2>
96 </blockquote>
97
98
99
100### Phrase Emphasis ###
101
102Markdown uses asterisks and underscores to indicate spans of emphasis.
103
104Markdown:
105
106 Some of these words *are emphasized*.
107 Some of these words _are emphasized also_.
108
109 Use two asterisks for **strong emphasis**.
110 Or, if you prefer, __use two underscores instead__.
111
112Output:
113
114 <p>Some of these words <em>are emphasized</em>.
115 Some of these words <em>are emphasized also</em>.</p>
116
117 <p>Use two asterisks for <strong>strong emphasis</strong>.
118 Or, if you prefer, <strong>use two underscores instead</strong>.</p>
119
120
121
122## Lists ##
123
124Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
125`+`, and `-`) as list markers. These three markers are
126interchangable; this:
127
128 * Candy.
129 * Gum.
130 * Booze.
131
132this:
133
134 + Candy.
135 + Gum.
136 + Booze.
137
138and this:
139
140 - Candy.
141 - Gum.
142 - Booze.
143
144all produce the same output:
145
146 <ul>
147 <li>Candy.</li>
148 <li>Gum.</li>
149 <li>Booze.</li>
150 </ul>
151
152Ordered (numbered) lists use regular numbers, followed by periods, as
153list markers:
154
155 1. Red
156 2. Green
157 3. Blue
158
159Output:
160
161 <ol>
162 <li>Red</li>
163 <li>Green</li>
164 <li>Blue</li>
165 </ol>
166
167If you put blank lines between items, you'll get `<p>` tags for the
168list item text. You can create multi-paragraph list items by indenting
169the paragraphs by 4 spaces or 1 tab:
170
171 * A list item.
172
173 With multiple paragraphs.
174
175 * Another item in the list.
176
177Output:
178
179 <ul>
180 <li><p>A list item.</p>
181 <p>With multiple paragraphs.</p></li>
182 <li><p>Another item in the list.</p></li>
183 </ul>
184
185
186
187### Links ###
188
189Markdown supports two styles for creating links: *inline* and
190*reference*. With both styles, you use square brackets to delimit the
191text you want to turn into a link.
192
193Inline-style links use parentheses immediately after the link text.
194For example:
195
196 This is an [example link](http://example.com/).
197
198Output:
199
200 <p>This is an <a href="http://example.com/">
201 example link</a>.</p>
202
203Optionally, you may include a title attribute in the parentheses:
204
205 This is an [example link](http://example.com/ "With a Title").
206
207Output:
208
209 <p>This is an <a href="http://example.com/" title="With a Title">
210 example link</a>.</p>
211
212Reference-style links allow you to refer to your links by names, which
213you define elsewhere in your document:
214
215 I get 10 times more traffic from [Google][1] than from
216 [Yahoo][2] or [MSN][3].
217
218 [1]: http://google.com/ "Google"
219 [2]: http://search.yahoo.com/ "Yahoo Search"
220 [3]: http://search.msn.com/ "MSN Search"
221
222Output:
223
224 <p>I get 10 times more traffic from <a href="http://google.com/"
225 title="Google">Google</a> than from <a href="http://search.yahoo.com/"
226 title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
227 title="MSN Search">MSN</a>.</p>
228
229The title attribute is optional. Link names may contain letters,
230numbers and spaces, but are *not* case sensitive:
231
232 I start my morning with a cup of coffee and
233 [The New York Times][NY Times].
234
235 [ny times]: http://www.nytimes.com/
236
237Output:
238
239 <p>I start my morning with a cup of coffee and
240 <a href="http://www.nytimes.com/">The New York Times</a>.</p>
241
242
243### Images ###
244
245Image syntax is very much like link syntax.
246
247Inline (titles are optional):
248
249 ![alt text](/path/to/img.jpg "Title")
250
251Reference-style:
252
253 ![alt text][id]
254
255 [id]: /path/to/img.jpg "Title"
256
257Both of the above examples produce the same output:
258
259 <img src="/path/to/img.jpg" alt="alt text" title="Title" />
260
261
262
263### Code ###
264
265In a regular paragraph, you can create code span by wrapping text in
266backtick quotes. Any ampersands (`&`) and angle brackets (`<` or
267`>`) will automatically be translated into HTML entities. This makes
268it easy to use Markdown to write about HTML example code:
269
270 I strongly recommend against using any `<blink>` tags.
271
272 I wish SmartyPants used named entities like `&mdash;`
273 instead of decimal-encoded entites like `&#8212;`.
274
275Output:
276
277 <p>I strongly recommend against using any
278 <code>&lt;blink&gt;</code> tags.</p>
279
280 <p>I wish SmartyPants used named entities like
281 <code>&amp;mdash;</code> instead of decimal-encoded
282 entites like <code>&amp;#8212;</code>.</p>
283
284
285To specify an entire block of pre-formatted code, indent every line of
286the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`,
287and `>` characters will be escaped automatically.
288
289Markdown:
290
291 If you want your page to validate under XHTML 1.0 Strict,
292 you've got to put paragraph tags in your blockquotes:
293
294 <blockquote>
295 <p>For example.</p>
296 </blockquote>
297
298Output:
299
300 <p>If you want your page to validate under XHTML 1.0 Strict,
301 you've got to put paragraph tags in your blockquotes:</p>
302
303 <pre><code>&lt;blockquote&gt;
304 &lt;p&gt;For example.&lt;/p&gt;
305 &lt;/blockquote&gt;
306 </code></pre>
  
1<h1>Markdown: Syntax</h1>
2
3<ul id="ProjectSubmenu">
4 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
5 <li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li>
6 <li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li>
7 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
8 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
9</ul>
10
11<ul>
12<li><a href="#overview">Overview</a>
13<ul>
14<li><a href="#philosophy">Philosophy</a></li>
15<li><a href="#html">Inline HTML</a></li>
16<li><a href="#autoescape">Automatic Escaping for Special Characters</a></li>
17</ul></li>
18<li><a href="#block">Block Elements</a>
19<ul>
20<li><a href="#p">Paragraphs and Line Breaks</a></li>
21<li><a href="#header">Headers</a></li>
22<li><a href="#blockquote">Blockquotes</a></li>
23<li><a href="#list">Lists</a></li>
24<li><a href="#precode">Code Blocks</a></li>
25<li><a href="#hr">Horizontal Rules</a></li>
26</ul></li>
27<li><a href="#span">Span Elements</a>
28<ul>
29<li><a href="#link">Links</a></li>
30<li><a href="#em">Emphasis</a></li>
31<li><a href="#code">Code</a></li>
32<li><a href="#img">Images</a></li>
33</ul></li>
34<li><a href="#misc">Miscellaneous</a>
35<ul>
36<li><a href="#backslash">Backslash Escapes</a></li>
37<li><a href="#autolink">Automatic Links</a></li>
38</ul></li>
39</ul>
40
41<p><strong>Note:</strong> This document is itself written using Markdown; you
42can <a href="/projects/markdown/syntax.text">see the source for it by adding '.text' to the URL</a>.</p>
43
44<hr />
45
46<h2 id="overview">Overview</h2>
47
48<h3 id="philosophy">Philosophy</h3>
49
50<p>Markdown is intended to be as easy-to-read and easy-to-write as is feasible.</p>
51
52<p>Readability, however, is emphasized above all else. A Markdown-formatted
53document should be publishable as-is, as plain text, without looking
54like it's been marked up with tags or formatting instructions. While
55Markdown's syntax has been influenced by several existing text-to-HTML
56filters -- 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>,
57<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
58inspiration for Markdown's syntax is the format of plain text email.</p>
59
60<p>To this end, Markdown's syntax is comprised entirely of punctuation
61characters, which punctuation characters have been carefully chosen so
62as to look like what they mean. E.g., asterisks around a word actually
63look like *emphasis*. Markdown lists look like, well, lists. Even
64blockquotes look like quoted passages of text, assuming you've ever
65used email.</p>
66
67<h3 id="html">Inline HTML</h3>
68
69<p>Markdown's syntax is intended for one purpose: to be used as a
70format for <em>writing</em> for the web.</p>
71
72<p>Markdown is not a replacement for HTML, or even close to it. Its
73syntax is very small, corresponding only to a very small subset of
74HTML tags. The idea is <em>not</em> to create a syntax that makes it easier
75to insert HTML tags. In my opinion, HTML tags are already easy to
76insert. The idea for Markdown is to make it easy to read, write, and
77edit prose. HTML is a <em>publishing</em> format; Markdown is a <em>writing</em>
78format. Thus, Markdown's formatting syntax only addresses issues that
79can be conveyed in plain text.</p>
80
81<p>For any markup that is not covered by Markdown's syntax, you simply
82use HTML itself. There's no need to preface it or delimit it to
83indicate that you're switching from Markdown to HTML; you just use
84the tags.</p>
85
86<p>The only restrictions are that block-level HTML elements -- e.g. <code>&lt;div&gt;</code>,
87<code>&lt;table&gt;</code>, <code>&lt;pre&gt;</code>, <code>&lt;p&gt;</code>, etc. -- must be separated from surrounding
88content by blank lines, and the start and end tags of the block should
89not be indented with tabs or spaces. Markdown is smart enough not
90to add extra (unwanted) <code>&lt;p&gt;</code> tags around HTML block-level tags.</p>
91
92<p>For example, to add an HTML table to a Markdown article:</p>
93
94<pre><code>This is a regular paragraph.
95
96&lt;table&gt;
97 &lt;tr&gt;
98 &lt;td&gt;Foo&lt;/td&gt;
99 &lt;/tr&gt;
100&lt;/table&gt;
101
102This is another regular paragraph.
103</code></pre>
104
105<p>Note that Markdown formatting syntax is not processed within block-level
106HTML tags. E.g., you can't use Markdown-style <code>*emphasis*</code> inside an
107HTML block.</p>
108
109<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
110used anywhere in a Markdown paragraph, list item, or header. If you
111want, you can even use HTML tags instead of Markdown formatting; e.g. if
112you'd prefer to use HTML <code>&lt;a&gt;</code> or <code>&lt;img&gt;</code> tags instead of Markdown's
113link or image syntax, go right ahead.</p>
114
115<p>Unlike block-level HTML tags, Markdown syntax <em>is</em> processed within
116span-level tags.</p>
117
118<h3 id="autoescape">Automatic Escaping for Special Characters</h3>
119
120<p>In HTML, there are two characters that demand special treatment: <code>&lt;</code>
121and <code>&amp;</code>. Left angle brackets are used to start tags; ampersands are
122used to denote HTML entities. If you want to use them as literal
123characters, you must escape them as entities, e.g. <code>&amp;lt;</code>, and
124<code>&amp;amp;</code>.</p>
125
126<p>Ampersands in particular are bedeviling for web writers. If you want to
127write about 'AT&amp;T', you need to write '<code>AT&amp;amp;T</code>'. You even need to
128escape ampersands within URLs. Thus, if you want to link to:</p>
129
130<pre><code>http://images.google.com/images?num=30&amp;q=larry+bird
131</code></pre>
132
133<p>you need to encode the URL as:</p>
134
135<pre><code>http://images.google.com/images?num=30&amp;amp;q=larry+bird
136</code></pre>
137
138<p>in your anchor tag <code>href</code> attribute. Needless to say, this is easy to
139forget, and is probably the single most common source of HTML validation
140errors in otherwise well-marked-up web sites.</p>
141
142<p>Markdown allows you to use these characters naturally, taking care of
143all the necessary escaping for you. If you use an ampersand as part of
144an HTML entity, it remains unchanged; otherwise it will be translated
145into <code>&amp;amp;</code>.</p>
146
147<p>So, if you want to include a copyright symbol in your article, you can write:</p>
148
149<pre><code>&amp;copy;
150</code></pre>
151
152<p>and Markdown will leave it alone. But if you write:</p>
153
154<pre><code>AT&amp;T
155</code></pre>
156
157<p>Markdown will translate it to:</p>
158
159<pre><code>AT&amp;amp;T
160</code></pre>
161
162<p>Similarly, because Markdown supports <a href="#html">inline HTML</a>, if you use
163angle brackets as delimiters for HTML tags, Markdown will treat them as
164such. But if you write:</p>
165
166<pre><code>4 &lt; 5
167</code></pre>
168
169<p>Markdown will translate it to:</p>
170
171<pre><code>4 &amp;lt; 5
172</code></pre>
173
174<p>However, inside Markdown code spans and blocks, angle brackets and
175ampersands are <em>always</em> encoded automatically. This makes it easy to use
176Markdown to write about HTML code. (As opposed to raw HTML, which is a
177terrible format for writing about HTML syntax, because every single <code>&lt;</code>
178and <code>&amp;</code> in your example code needs to be escaped.)</p>
179
180<hr />
181
182<h2 id="block">Block Elements</h2>
183
184<h3 id="p">Paragraphs and Line Breaks</h3>
185
186<p>A paragraph is simply one or more consecutive lines of text, separated
187by one or more blank lines. (A blank line is any line that looks like a
188blank line -- a line containing nothing but spaces or tabs is considered
189blank.) Normal paragraphs should not be intended with spaces or tabs.</p>
190
191<p>The implication of the "one or more consecutive lines of text" rule is
192that Markdown supports "hard-wrapped" text paragraphs. This differs
193significantly from most other text-to-HTML formatters (including Movable
194Type's "Convert Line Breaks" option) which translate every line break
195character in a paragraph into a <code>&lt;br /&gt;</code> tag.</p>
196
197<p>When you <em>do</em> want to insert a <code>&lt;br /&gt;</code> break tag using Markdown, you
198end a line with two or more spaces, then type return.</p>
199
200<p>Yes, this takes a tad more effort to create a <code>&lt;br /&gt;</code>, but a simplistic
201"every line break is a <code>&lt;br /&gt;</code>" rule wouldn't work for Markdown.
202Markdown's email-style <a href="#blockquote">blockquoting</a> and multi-paragraph <a href="#list">list items</a>
203work best -- and look better -- when you format them with hard breaks.</p>
204
205<h3 id="header">Headers</h3>
206
207<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>
208
209<p>Setext-style headers are "underlined" using equal signs (for first-level
210headers) and dashes (for second-level headers). For example:</p>
211
212<pre><code>This is an H1
213=============
214
215This is an H2
216-------------
217</code></pre>
218
219<p>Any number of underlining <code>=</code>'s or <code>-</code>'s will work.</p>
220
221<p>Atx-style headers use 1-6 hash characters at the start of the line,
222corresponding to header levels 1-6. For example:</p>
223
224<pre><code># This is an H1
225
226## This is an H2
227
228###### This is an H6
229</code></pre>
230
231<p>Optionally, you may "close" atx-style headers. This is purely
232cosmetic -- you can use this if you think it looks better. The
233closing hashes don't even need to match the number of hashes
234used to open the header. (The number of opening hashes
235determines the header level.) :</p>
236
237<pre><code># This is an H1 #
238
239## This is an H2 ##
240
241### This is an H3 ######
242</code></pre>
243
244<h3 id="blockquote">Blockquotes</h3>
245
246<p>Markdown uses email-style <code>&gt;</code> characters for blockquoting. If you're
247familiar with quoting passages of text in an email message, then you
248know how to create a blockquote in Markdown. It looks best if you hard
249wrap the text and put a <code>&gt;</code> before every line:</p>
250
251<pre><code>&gt; This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
252&gt; consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
253&gt; Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
254&gt;
255&gt; Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
256&gt; id sem consectetuer libero luctus adipiscing.
257</code></pre>
258
259<p>Markdown allows you to be lazy and only put the <code>&gt;</code> before the first
260line of a hard-wrapped paragraph:</p>
261
262<pre><code>&gt; This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
263consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
264Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
265
266&gt; Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
267id sem consectetuer libero luctus adipiscing.
268</code></pre>
269
270<p>Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
271adding additional levels of <code>&gt;</code>:</p>
272
273<pre><code>&gt; This is the first level of quoting.
274&gt;
275&gt; &gt; This is nested blockquote.
276&gt;
277&gt; Back to the first level.
278</code></pre>
279
280<p>Blockquotes can contain other Markdown elements, including headers, lists,
281and code blocks:</p>
282
283<pre><code>&gt; ## This is a header.
284&gt;
285&gt; 1. This is the first list item.
286&gt; 2. This is the second list item.
287&gt;
288&gt; Here's some example code:
289&gt;
290&gt; return shell_exec("echo $input | $markdown_script");
291</code></pre>
292
293<p>Any decent text editor should make email-style quoting easy. For
294example, with BBEdit, you can make a selection and choose Increase
295Quote Level from the Text menu.</p>
296
297<h3 id="list">Lists</h3>
298
299<p>Markdown supports ordered (numbered) and unordered (bulleted) lists.</p>
300
301<p>Unordered lists use asterisks, pluses, and hyphens -- interchangably
302
303<pre><code>* Red
304* Green
305* Blue
306</code></pre>
307
308<p>is equivalent to:</p>
309
310<pre><code>+ Red
311+ Green
312+ Blue
313</code></pre>
314
315<p>and:</p>
316
317<pre><code>- Red
318- Green
319- Blue
320</code></pre>
321
322<p>Ordered lists use numbers followed by periods:</p>
323
324<pre><code>1. Bird
3252. McHale
3263. Parish
327</code></pre>
328
329<p>It's important to note that the actual numbers you use to mark the
330list have no effect on the HTML output Markdown produces. The HTML
331Markdown produces from the above list is:</p>
332
333<pre><code>&lt;ol&gt;
334&lt;li&gt;Bird&lt;/li&gt;
335&lt;li&gt;McHale&lt;/li&gt;
336&lt;li&gt;Parish&lt;/li&gt;
337&lt;/ol&gt;
338</code></pre>
339
340<p>If you instead wrote the list in Markdown like this:</p>
341
342<pre><code>1. Bird
3431. McHale
3441. Parish
345</code></pre>
346
347<p>or even:</p>
348
349<pre><code>3. Bird
3501. McHale
3518. Parish
352</code></pre>
353
354<p>you'd get the exact same HTML output. The point is, if you want to,
355you can use ordinal numbers in your ordered Markdown lists, so that
356the numbers in your source match the numbers in your published HTML.
357But if you want to be lazy, you don't have to.</p>
358
359<p>If you do use lazy list numbering, however, you should still start the
360list with the number 1. At some point in the future, Markdown may support
361starting ordered lists at an arbitrary number.</p>
362
363<p>List markers typically start at the left margin, but may be indented by
364up to three spaces. List markers must be followed by one or more spaces
365or a tab.</p>
366
367<p>To make lists look nice, you can wrap items with hanging indents:</p>
368
369<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
370 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
371 viverra nec, fringilla in, laoreet vitae, risus.
372* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
373 Suspendisse id sem consectetuer libero luctus adipiscing.
374</code></pre>
375
376<p>But if you want to be lazy, you don't have to:</p>
377
378<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
379Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
380viverra nec, fringilla in, laoreet vitae, risus.
381* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
382Suspendisse id sem consectetuer libero luctus adipiscing.
383</code></pre>
384
385<p>If list items are separated by blank lines, Markdown will wrap the
386items in <code>&lt;p&gt;</code> tags in the HTML output. For example, this input:</p>
387
388<pre><code>* Bird
389* Magic
390</code></pre>
391
392<p>will turn into:</p>
393
394<pre><code>&lt;ul&gt;
395&lt;li&gt;Bird&lt;/li&gt;
396&lt;li&gt;Magic&lt;/li&gt;
397&lt;/ul&gt;
398</code></pre>
399
400<p>But this:</p>
401
402<pre><code>* Bird
403
404* Magic
405</code></pre>
406
407<p>will turn into:</p>
408
409<pre><code>&lt;ul&gt;
410&lt;li&gt;&lt;p&gt;Bird&lt;/p&gt;&lt;/li&gt;
411&lt;li&gt;&lt;p&gt;Magic&lt;/p&gt;&lt;/li&gt;
412&lt;/ul&gt;
413</code></pre>
414
415<p>List items may consist of multiple paragraphs. Each subsequent
416paragraph in a list item must be intended by either 4 spaces
417or one tab:</p>
418
419<pre><code>1. This is a list item with two paragraphs. Lorem ipsum dolor
420 sit amet, consectetuer adipiscing elit. Aliquam hendrerit
421 mi posuere lectus.
422
423 Vestibulum enim wisi, viverra nec, fringilla in, laoreet
424 vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
425 sit amet velit.
426
4272. Suspendisse id sem consectetuer libero luctus adipiscing.
428</code></pre>
429
430<p>It looks nice if you indent every line of the subsequent
431paragraphs, but here again, Markdown will allow you to be
432lazy:</p>
433
434<pre><code>* This is a list item with two paragraphs.
435
436 This is the second paragraph in the list item. You're
437only required to indent the first line. Lorem ipsum dolor
438sit amet, consectetuer adipiscing elit.
439
440* Another item in the same list.
441</code></pre>
442
443<p>To put a blockquote within a list item, the blockquote's <code>&gt;</code>
444delimiters need to be indented:</p>
445
446<pre><code>* A list item with a blockquote:
447
448 &gt; This is a blockquote
449 &gt; inside a list item.
450</code></pre>
451
452<p>To put a code block within a list item, the code block needs
453to be indented <em>twice</em> -- 8 spaces or two tabs:</p>
454
455<pre><code>* A list item with a code block:
456
457 &lt;code goes here&gt;
458</code></pre>
459
460<p>It's worth noting that it's possible to trigger an ordered list by
461accident, by writing something like this:</p>
462
463<pre><code>1986. What a great season.
464</code></pre>
465
466<p>In other words, a <em>number-period-space</em> sequence at the beginning of a
467line. To avoid this, you can backslash-escape the period:</p>
468
469<pre><code>1986\. What a great season.
470</code></pre>
471
472<h3 id="precode">Code Blocks</h3>
473
474<p>Pre-formatted code blocks are used for writing about programming or
475markup source code. Rather than forming normal paragraphs, the lines
476of a code block are interpreted literally. Markdown wraps a code block
477in both <code>&lt;pre&gt;</code> and <code>&lt;code&gt;</code> tags.</p>
478
479<p>To produce a code block in Markdown, simply indent every line of the
480block by at least 4 spaces or 1 tab. For example, given this input:</p>
481
482<pre><code>This is a normal paragraph:
483
484 This is a code block.
485</code></pre>
486
487<p>Markdown will generate:</p>
488
489<pre><code>&lt;p&gt;This is a normal paragraph:&lt;/p&gt;
490
491&lt;pre&gt;&lt;code&gt;This is a code block.
492&lt;/code&gt;&lt;/pre&gt;
493</code></pre>
494
495<p>One level of indentation -- 4 spaces or 1 tab -- is removed from each
496line of the code block. For example, this:</p>
497
498<pre><code>Here is an example of AppleScript:
499
500 tell application "Foo"
501 beep
502 end tell
503</code></pre>
504
505<p>will turn into:</p>
506
507<pre><code>&lt;p&gt;Here is an example of AppleScript:&lt;/p&gt;
508
509&lt;pre&gt;&lt;code&gt;tell application "Foo"
510 beep
511end tell
512&lt;/code&gt;&lt;/pre&gt;
513</code></pre>
514
515<p>A code block continues until it reaches a line that is not indented
516(or the end of the article).</p>
517
518<p>Within a code block, ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> and <code>&gt;</code>)
519are automatically converted into HTML entities. This makes it very
520easy to include example HTML source code using Markdown -- just paste
521it and indent it, and Markdown will handle the hassle of encoding the
522ampersands and angle brackets. For example, this:</p>
523
524<pre><code> &lt;div class="footer"&gt;
525 &amp;copy; 2004 Foo Corporation
526 &lt;/div&gt;
527</code></pre>
528
529<p>will turn into:</p>
530
531<pre><code>&lt;pre&gt;&lt;code&gt;&amp;lt;div class="footer"&amp;gt;
532 &amp;amp;copy; 2004 Foo Corporation
533&amp;lt;/div&amp;gt;
534&lt;/code&gt;&lt;/pre&gt;
535</code></pre>
536
537<p>Regular Markdown syntax is not processed within code blocks. E.g.,
538asterisks are just literal asterisks within a code block. This means
539it's also easy to use Markdown to write about Markdown's own syntax.</p>
540
541<h3 id="hr">Horizontal Rules</h3>
542
543<p>You can produce a horizontal rule tag (<code>&lt;hr /&gt;</code>) by placing three or
544more hyphens, asterisks, or underscores on a line by themselves. If you
545wish, you may use spaces between the hyphens or asterisks. Each of the
546following lines will produce a horizontal rule:</p>
547
548<pre><code>* * *
549
550***
551
552*****
553
554- - -
555
556---------------------------------------
557
558_ _ _
559</code></pre>
560
561<hr />
562
563<h2 id="span">Span Elements</h2>
564
565<h3 id="link">Links</h3>
566
567<p>Markdown supports two style of links: <em>inline</em> and <em>reference</em>.</p>
568
569<p>In both styles, the link text is delimited by [square brackets].</p>
570
571<p>To create an inline link, use a set of regular parentheses immediately
572after the link text's closing square bracket. Inside the parentheses,
573put the URL where you want the link to point, along with an <em>optional</em>
574title for the link, surrounded in quotes. For example:</p>
575
576<pre><code>This is [an example](http://example.com/ "Title") inline link.
577
578[This link](http://example.net/) has no title attribute.
579</code></pre>
580
581<p>Will produce:</p>
582
583<pre><code>&lt;p&gt;This is &lt;a href="http://example.com/" title="Title"&gt;
584an example&lt;/a&gt; inline link.&lt;/p&gt;
585
586&lt;p&gt;&lt;a href="http://example.net/"&gt;This link&lt;/a&gt; has no
587title attribute.&lt;/p&gt;
588</code></pre>
589
590<p>If you're referring to a local resource on the same server, you can
591use relative paths:</p>
592
593<pre><code>See my [About](/about/) page for details.
594</code></pre>
595
596<p>Reference-style links use a second set of square brackets, inside
597which you place a label of your choosing to identify the link:</p>
598
599<pre><code>This is [an example][id] reference-style link.
600</code></pre>
601
602<p>You can optionally use a space to separate the sets of brackets:</p>
603
604<pre><code>This is [an example] [id] reference-style link.
605</code></pre>
606
607<p>Then, anywhere in the document, you define your link label like this,
608on a line by itself:</p>
609
610<pre><code>[id]: http://example.com/ "Optional Title Here"
611</code></pre>
612
613<p>That is:</p>
614
615<ul>
616<li>Square brackets containing the link identifier (optionally
617indented from the left margin using up to three spaces);</li>
618<li>followed by a colon;</li>
619<li>followed by one or more spaces (or tabs);</li>
620<li>followed by the URL for the link;</li>
621<li>optionally followed by a title attribute for the link, enclosed
622in double or single quotes.</li>
623</ul>
624
625<p>The link URL may, optionally, be surrounded by angle brackets:</p>
626
627<pre><code>[id]: &lt;http://example.com/&gt; "Optional Title Here"
628</code></pre>
629
630<p>You can put the title attribute on the next line and use extra spaces
631or tabs for padding, which tends to look better with longer URLs:</p>
632
633<pre><code>[id]: http://example.com/longish/path/to/resource/here
634 "Optional Title Here"
635</code></pre>
636
637<p>Link definitions are only used for creating links during Markdown
638processing, and are stripped from your document in the HTML output.</p>
639
640<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>
641
642<pre><code>[link text][a]
643[link text][A]
644</code></pre>
645
646<p>are equivalent.</p>
647
648<p>The <em>implicit link name</em> shortcut allows you to omit the name of the
649link, in which case the link text itself is used as the name.
650Just use an empty set of square brackets -- e.g., to link the word
651"Google" to the google.com web site, you could simply write:</p>
652
653<pre><code>[Google][]
654</code></pre>
655
656<p>And then define the link:</p>
657
658<pre><code>[Google]: http://google.com/
659</code></pre>
660
661<p>Because link names may contain spaces, this shortcut even works for
662multiple words in the link text:</p>
663
664<pre><code>Visit [Daring Fireball][] for more information.
665</code></pre>
666
667<p>And then define the link:</p>
668
669<pre><code>[Daring Fireball]: http://daringfireball.net/
670</code></pre>
671
672<p>Link definitions can be placed anywhere in your Markdown document. I
673tend to put them immediately after each paragraph in which they're
674used, but if you want, you can put them all at the end of your
675document, sort of like footnotes.</p>
676
677<p>Here's an example of reference links in action:</p>
678
679<pre><code>I get 10 times more traffic from [Google] [1] than from
680[Yahoo] [2] or [MSN] [3].
681
682 [1]: http://google.com/ "Google"
683 [2]: http://search.yahoo.com/ "Yahoo Search"
684 [3]: http://search.msn.com/ "MSN Search"
685</code></pre>
686
687<p>Using the implicit link name shortcut, you could instead write:</p>
688
689<pre><code>I get 10 times more traffic from [Google][] than from
690[Yahoo][] or [MSN][].
691
692 [google]: http://google.com/ "Google"
693 [yahoo]: http://search.yahoo.com/ "Yahoo Search"
694 [msn]: http://search.msn.com/ "MSN Search"
695</code></pre>
696
697<p>Both of the above examples will produce the following HTML output:</p>
698
699<pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
700title="Google"&gt;Google&lt;/a&gt; than from
701&lt;a href="http://search.yahoo.com/" title="Yahoo Search"&gt;Yahoo&lt;/a&gt;
702or &lt;a href="http://search.msn.com/" title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
703</code></pre>
704
705<p>For comparison, here is the same paragraph written using
706Markdown's inline link style:</p>
707
708<pre><code>I get 10 times more traffic from [Google](http://google.com/ "Google")
709than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
710[MSN](http://search.msn.com/ "MSN Search").
711</code></pre>
712
713<p>The point of reference-style links is not that they're easier to
714write. The point is that with reference-style links, your document
715source is vastly more readable. Compare the above examples: using
716reference-style links, the paragraph itself is only 81 characters
717long; with inline-style links, it's 176 characters; and as raw HTML,
718it's 234 characters. In the raw HTML, there's more markup than there
719is text.</p>
720
721<p>With Markdown's reference-style links, a source document much more
722closely resembles the final output, as rendered in a browser. By
723allowing you to move the markup-related metadata out of the paragraph,
724you can add links without interrupting the narrative flow of your
725prose.</p>
726
727<h3 id="em">Emphasis</h3>
728
729<p>Markdown treats asterisks (<code>*</code>) and underscores (<code>_</code>) as indicators of
730emphasis. Text wrapped with one <code>*</code> or <code>_</code> will be wrapped with an
731HTML <code>&lt;em&gt;</code> tag; double <code>*</code>'s or <code>_</code>'s will be wrapped with an HTML
732<code>&lt;strong&gt;</code> tag. E.g., this input:</p>
733
734<pre><code>*single asterisks*
735
736_single underscores_
737
738**double asterisks**
739
740__double underscores__
741</code></pre>
742
743<p>will produce:</p>
744
745<pre><code>&lt;em&gt;single asterisks&lt;/em&gt;
746
747&lt;em&gt;single underscores&lt;/em&gt;
748
749&lt;strong&gt;double asterisks&lt;/strong&gt;
750
751&lt;strong&gt;double underscores&lt;/strong&gt;
752</code></pre>
753
754<p>You can use whichever style you prefer; the lone restriction is that
755the same character must be used to open and close an emphasis span.</p>
756
757<p>Emphasis can be used in the middle of a word:</p>
758
759<pre><code>un*fucking*believable
760</code></pre>
761
762<p>But if you surround an <code>*</code> or <code>_</code> with spaces, it'll be treated as a
763literal asterisk or underscore.</p>
764
765<p>To produce a literal asterisk or underscore at a position where it
766would otherwise be used as an emphasis delimiter, you can backslash
767escape it:</p>
768
769<pre><code>\*this text is surrounded by literal asterisks\*
770</code></pre>
771
772<h3 id="code">Code</h3>
773
774<p>To indicate a span of code, wrap it with backtick quotes (<code>`</code>).
775Unlike a pre-formatted code block, a code span indicates code within a
776normal paragraph. For example:</p>
777
778<pre><code>Use the `printf()` function.
779</code></pre>
780
781<p>will produce:</p>
782
783<pre><code>&lt;p&gt;Use the &lt;code&gt;printf()&lt;/code&gt; function.&lt;/p&gt;
784</code></pre>
785
786<p>To include a literal backtick character within a code span, you can use
787multiple backticks as the opening and closing delimiters:</p>
788
789<pre><code>``There is a literal backtick (`) here.``
790</code></pre>
791
792<p>which will produce this:</p>
793
794<pre><code>&lt;p&gt;&lt;code&gt;There is a literal backtick (`) here.&lt;/code&gt;&lt;/p&gt;
795</code></pre>
796
797<p>The backtick delimiters surrounding a code span may include spaces --
798one after the opening, one before the closing. This allows you to place
799literal backtick characters at the beginning or end of a code span:</p>
800
801<pre><code>A single backtick in a code span: `` ` ``
802
803A backtick-delimited string in a code span: `` `foo` ``
804</code></pre>
805
806<p>will produce:</p>
807
808<pre><code>&lt;p&gt;A single backtick in a code span: &lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
809
810&lt;p&gt;A backtick-delimited string in a code span: &lt;code&gt;`foo`&lt;/code&gt;&lt;/p&gt;
811</code></pre>
812
813<p>With a code span, ampersands and angle brackets are encoded as HTML
814entities automatically, which makes it easy to include example HTML
815tags. Markdown will turn this:</p>
816
817<pre><code>Please don't use any `&lt;blink&gt;` tags.
818</code></pre>
819
820<p>into:</p>
821
822<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;
823</code></pre>
824
825<p>You can write this:</p>
826
827<pre><code>`&amp;#8212;` is the decimal-encoded equivalent of `&amp;mdash;`.
828</code></pre>
829
830<p>to produce:</p>
831
832<pre><code>&lt;p&gt;&lt;code&gt;&amp;amp;#8212;&lt;/code&gt; is the decimal-encoded
833equivalent of &lt;code&gt;&amp;amp;mdash;&lt;/code&gt;.&lt;/p&gt;
834</code></pre>
835
836<h3 id="img">Images</h3>
837
838<p>Admittedly, it's fairly difficult to devise a "natural" syntax for
839placing images into a plain text document format.</p>
840
841<p>Markdown uses an image syntax that is intended to resemble the syntax
842for links, allowing for two styles: <em>inline</em> and <em>reference</em>.</p>
843
844<p>Inline image syntax looks like this:</p>
845
846<pre><code>![Alt text](/path/to/img.jpg)
847
848![Alt text](/path/to/img.jpg "Optional title")
849</code></pre>
850
851<p>That is:</p>
852
853<ul>
854<li>An exclamation mark: <code>!</code>;</li>
855<li>followed by a set of square brackets, containing the <code>alt</code>
856attribute text for the image;</li>
857<li>followed by a set of parentheses, containing the URL or path to
858the image, and an optional <code>title</code> attribute enclosed in double
859or single quotes.</li>
860</ul>
861
862<p>Reference-style image syntax looks like this:</p>
863
864<pre><code>![Alt text][id]
865</code></pre>
866
867<p>Where "id" is the name of a defined image reference. Image references
868are defined using syntax identical to link references:</p>
869
870<pre><code>[id]: url/to/image "Optional title attribute"
871</code></pre>
872
873<p>As of this writing, Markdown has no syntax for specifying the
874dimensions of an image; if this is important to you, you can simply
875use regular HTML <code>&lt;img&gt;</code> tags.</p>
876
877<hr />
878
879<h2 id="misc">Miscellaneous</h2>
880
881<h3 id="autolink">Automatic Links</h3>
882
883<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>
884
885<pre><code>&lt;http://example.com/&gt;
886</code></pre>
887
888<p>Markdown will turn this into:</p>
889
890<pre><code>&lt;a href="http://example.com/"&gt;http://example.com/&lt;/a&gt;
891</code></pre>
892
893<p>Automatic links for email addresses work similarly, except that
894Markdown will also perform a bit of randomized decimal and hex
895entity-encoding to help obscure your address from address-harvesting
896spambots. For example, Markdown will turn this:</p>
897
898<pre><code>&lt;address@example.com&gt;
899</code></pre>
900
901<p>into something like this:</p>
902
903<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;
904&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;
905&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;
906&amp;#109;&amp;#x70;&amp;#x6C;e&amp;#x2E;&amp;#99;&amp;#111;&amp;#109;&lt;/a&gt;
907</code></pre>
908
909<p>which will render in a browser as a clickable link to "address@example.com".</p>
910
911<p>(This sort of entity-encoding trick will indeed fool many, if not
912most, address-harvesting bots, but it definitely won't fool all of
913them. It's better than nothing, but an address published in this way
914will probably eventually start receiving spam.)</p>
915
916<h3 id="backslash">Backslash Escapes</h3>
917
918<p>Markdown allows you to use backslash escapes to generate literal
919characters which would otherwise have special meaning in Markdown's
920formatting syntax. For example, if you wanted to surround a word with
921literal asterisks (instead of an HTML <code>&lt;em&gt;</code> tag), you can backslashes
922before the asterisks, like this:</p>
923
924<pre><code>\*literal asterisks\*
925</code></pre>
926
927<p>Markdown provides backslash escapes for the following characters:</p>
928
929<pre><code>\ backslash
930` backtick
931* asterisk
932_ underscore
933{} curly braces
934[] square brackets
935() parentheses
936# hash mark
937+ plus sign
938- minus sign (hyphen)
939. dot
940! exclamation mark
941</code></pre>
  
1Markdown: Syntax
2================
3
4<ul id="ProjectSubmenu">
5 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
6 <li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li>
7 <li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li>
8 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
9 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
10</ul>
11
12
13* [Overview](#overview)
14 * [Philosophy](#philosophy)
15 * [Inline HTML](#html)
16 * [Automatic Escaping for Special Characters](#autoescape)
17* [Block Elements](#block)
18 * [Paragraphs and Line Breaks](#p)
19 * [Headers](#header)
20 * [Blockquotes](#blockquote)
21 * [Lists](#list)
22 * [Code Blocks](#precode)
23 * [Horizontal Rules](#hr)
24* [Span Elements](#span)
25 * [Links](#link)
26 * [Emphasis](#em)
27 * [Code](#code)
28 * [Images](#img)
29* [Miscellaneous](#misc)
30 * [Backslash Escapes](#backslash)
31 * [Automatic Links](#autolink)
32
33
34**Note:** This document is itself written using Markdown; you
35can [see the source for it by adding '.text' to the URL][src].
36
37 [src]: /projects/markdown/syntax.text
38
39* * *
40
41<h2 id="overview">Overview</h2>
42
43<h3 id="philosophy">Philosophy</h3>
44
45Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
46
47Readability, however, is emphasized above all else. A Markdown-formatted
48document should be publishable as-is, as plain text, without looking
49like it's been marked up with tags or formatting instructions. While
50Markdown's syntax has been influenced by several existing text-to-HTML
51filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4],
52[Grutatext] [5], and [EtText] [6] -- the single biggest source of
53inspiration for Markdown's syntax is the format of plain text email.
54
55 [1]: http://docutils.sourceforge.net/mirror/setext.html
56 [2]: http://www.aaronsw.com/2002/atx/
57 [3]: http://textism.com/tools/textile/
58 [4]: http://docutils.sourceforge.net/rst.html
59 [5]: http://www.triptico.com/software/grutatxt.html
60 [6]: http://ettext.taint.org/doc/
61
62To this end, Markdown's syntax is comprised entirely of punctuation
63characters, which punctuation characters have been carefully chosen so
64as to look like what they mean. E.g., asterisks around a word actually
65look like \*emphasis\*. Markdown lists look like, well, lists. Even
66blockquotes look like quoted passages of text, assuming you've ever
67used email.
68
69
70
71<h3 id="html">Inline HTML</h3>
72
73Markdown's syntax is intended for one purpose: to be used as a
74format for *writing* for the web.
75
76Markdown is not a replacement for HTML, or even close to it. Its
77syntax is very small, corresponding only to a very small subset of
78HTML tags. The idea is *not* to create a syntax that makes it easier
79to insert HTML tags. In my opinion, HTML tags are already easy to
80insert. The idea for Markdown is to make it easy to read, write, and
81edit prose. HTML is a *publishing* format; Markdown is a *writing*
82format. Thus, Markdown's formatting syntax only addresses issues that
83can be conveyed in plain text.
84
85For any markup that is not covered by Markdown's syntax, you simply
86use HTML itself. There's no need to preface it or delimit it to
87indicate that you're switching from Markdown to HTML; you just use
88the tags.
89
90The only restrictions are that block-level HTML elements -- e.g. `<div>`,
91`<table>`, `<pre>`, `<p>`, etc. -- must be separated from surrounding
92content by blank lines, and the start and end tags of the block should
93not be indented with tabs or spaces. Markdown is smart enough not
94to add extra (unwanted) `<p>` tags around HTML block-level tags.
95
96For example, to add an HTML table to a Markdown article:
97
98 This is a regular paragraph.
99
100 <table>
101 <tr>
102 <td>Foo</td>
103 </tr>
104 </table>
105
106 This is another regular paragraph.
107
108Note that Markdown formatting syntax is not processed within block-level
109HTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an
110HTML block.
111
112Span-level HTML tags -- e.g. `<span>`, `<cite>`, or `<del>` -- can be
113used anywhere in a Markdown paragraph, list item, or header. If you
114want, you can even use HTML tags instead of Markdown formatting; e.g. if
115you'd prefer to use HTML `<a>` or `<img>` tags instead of Markdown's
116link or image syntax, go right ahead.
117
118Unlike block-level HTML tags, Markdown syntax *is* processed within
119span-level tags.
120
121
122<h3 id="autoescape">Automatic Escaping for Special Characters</h3>
123
124In HTML, there are two characters that demand special treatment: `<`
125and `&`. Left angle brackets are used to start tags; ampersands are
126used to denote HTML entities. If you want to use them as literal
127characters, you must escape them as entities, e.g. `&lt;`, and
128`&amp;`.
129
130Ampersands in particular are bedeviling for web writers. If you want to
131write about 'AT&T', you need to write '`AT&amp;T`'. You even need to
132escape ampersands within URLs. Thus, if you want to link to:
133
134 http://images.google.com/images?num=30&q=larry+bird
135
136you need to encode the URL as:
137
138 http://images.google.com/images?num=30&amp;q=larry+bird
139
140in your anchor tag `href` attribute. Needless to say, this is easy to
141forget, and is probably the single most common source of HTML validation
142errors in otherwise well-marked-up web sites.
143
144Markdown allows you to use these characters naturally, taking care of
145all the necessary escaping for you. If you use an ampersand as part of
146an HTML entity, it remains unchanged; otherwise it will be translated
147into `&amp;`.
148
149So, if you want to include a copyright symbol in your article, you can write:
150
151 &copy;
152
153and Markdown will leave it alone. But if you write:
154
155 AT&T
156
157Markdown will translate it to:
158
159 AT&amp;T
160
161Similarly, because Markdown supports [inline HTML](#html), if you use
162angle brackets as delimiters for HTML tags, Markdown will treat them as
163such. But if you write:
164
165 4 < 5
166
167Markdown will translate it to:
168
169 4 &lt; 5
170
171However, inside Markdown code spans and blocks, angle brackets and
172ampersands are *always* encoded automatically. This makes it easy to use
173Markdown to write about HTML code. (As opposed to raw HTML, which is a
174terrible format for writing about HTML syntax, because every single `<`
175and `&` in your example code needs to be escaped.)
176
177
178* * *
179
180
181<h2 id="block">Block Elements</h2>
182
183
184<h3 id="p">Paragraphs and Line Breaks</h3>
185
186A paragraph is simply one or more consecutive lines of text, separated
187by one or more blank lines. (A blank line is any line that looks like a
188blank line -- a line containing nothing but spaces or tabs is considered
189blank.) Normal paragraphs should not be intended with spaces or tabs.
190
191The implication of the "one or more consecutive lines of text" rule is
192that Markdown supports "hard-wrapped" text paragraphs. This differs
193significantly from most other text-to-HTML formatters (including Movable
194Type's "Convert Line Breaks" option) which translate every line break
195character in a paragraph into a `<br />` tag.
196
197When you *do* want to insert a `<br />` break tag using Markdown, you
198end a line with two or more spaces, then type return.
199
200Yes, this takes a tad more effort to create a `<br />`, but a simplistic
201"every line break is a `<br />`" rule wouldn't work for Markdown.
202Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l]
203work best -- and look better -- when you format them with hard breaks.
204
205 [bq]: #blockquote
206 [l]: #list
207
208
209
210<h3 id="header">Headers</h3>
211
212Markdown supports two styles of headers, [Setext] [1] and [atx] [2].
213
214Setext-style headers are "underlined" using equal signs (for first-level
215headers) and dashes (for second-level headers). For example:
216
217 This is an H1
218 =============
219
220 This is an H2
221 -------------
222
223Any number of underlining `=`'s or `-`'s will work.
224
225Atx-style headers use 1-6 hash characters at the start of the line,
226corresponding to header levels 1-6. For example:
227
228 # This is an H1
229
230 ## This is an H2
231
232 ###### This is an H6
233
234Optionally, you may "close" atx-style headers. This is purely
235cosmetic -- you can use this if you think it looks better. The
236closing hashes don't even need to match the number of hashes
237used to open the header. (The number of opening hashes
238determines the header level.) :
239
240 # This is an H1 #
241
242 ## This is an H2 ##
243
244 ### This is an H3 ######
245
246
247<h3 id="blockquote">Blockquotes</h3>
248
249Markdown uses email-style `>` characters for blockquoting. If you're
250familiar with quoting passages of text in an email message, then you
251know how to create a blockquote in Markdown. It looks best if you hard
252wrap the text and put a `>` before every line:
253
254 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
255 > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
256 > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
257 >
258 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
259 > id sem consectetuer libero luctus adipiscing.
260
261Markdown allows you to be lazy and only put the `>` before the first
262line of a hard-wrapped paragraph:
263
264 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
265 consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
266 Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
267
268 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
269 id sem consectetuer libero luctus adipiscing.
270
271Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
272adding additional levels of `>`:
273
274 > This is the first level of quoting.
275 >
276 > > This is nested blockquote.
277 >
278 > Back to the first level.
279
280Blockquotes can contain other Markdown elements, including headers, lists,
281and code blocks:
282
283 > ## This is a header.
284 >
285 > 1. This is the first list item.
286 > 2. This is the second list item.
287 >
288 > Here's some example code:
289 >
290 > return shell_exec("echo $input | $markdown_script");
291
292Any decent text editor should make email-style quoting easy. For
293example, with BBEdit, you can make a selection and choose Increase
294Quote Level from the Text menu.
295
296
297<h3 id="list">Lists</h3>
298
299Markdown supports ordered (numbered) and unordered (bulleted) lists.
300
301Unordered lists use asterisks, pluses, and hyphens -- interchangably
302
303 * Red
304 * Green
305 * Blue
306
307is equivalent to:
308
309 + Red
310 + Green
311 + Blue
312
313and:
314
315 - Red
316 - Green
317 - Blue
318
319Ordered lists use numbers followed by periods:
320
321 1. Bird
322 2. McHale
323 3. Parish
324
325It's important to note that the actual numbers you use to mark the
326list have no effect on the HTML output Markdown produces. The HTML
327Markdown produces from the above list is:
328
329 <ol>
330 <li>Bird</li>
331 <li>McHale</li>
332 <li>Parish</li>
333 </ol>
334
335If you instead wrote the list in Markdown like this:
336
337 1. Bird
338 1. McHale
339 1. Parish
340
341or even:
342
343 3. Bird
344 1. McHale
345 8. Parish
346
347you'd get the exact same HTML output. The point is, if you want to,
348you can use ordinal numbers in your ordered Markdown lists, so that
349the numbers in your source match the numbers in your published HTML.
350But if you want to be lazy, you don't have to.
351
352If you do use lazy list numbering, however, you should still start the
353list with the number 1. At some point in the future, Markdown may support
354starting ordered lists at an arbitrary number.
355
356List markers typically start at the left margin, but may be indented by
357up to three spaces. List markers must be followed by one or more spaces
358or a tab.
359
360To make lists look nice, you can wrap items with hanging indents:
361
362 * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
363 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
364 viverra nec, fringilla in, laoreet vitae, risus.
365 * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
366 Suspendisse id sem consectetuer libero luctus adipiscing.
367
368But if you want to be lazy, you don't have to:
369
370 * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
371 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
372 viverra nec, fringilla in, laoreet vitae, risus.
373 * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
374 Suspendisse id sem consectetuer libero luctus adipiscing.
375
376If list items are separated by blank lines, Markdown will wrap the
377items in `<p>` tags in the HTML output. For example, this input:
378
379 * Bird
380 * Magic
381
382will turn into:
383
384 <ul>
385 <li>Bird</li>
386 <li>Magic</li>
387 </ul>
388
389But this:
390
391 * Bird
392
393 * Magic
394
395will turn into:
396
397 <ul>
398 <li><p>Bird</p></li>
399 <li><p>Magic</p></li>
400 </ul>
401
402List items may consist of multiple paragraphs. Each subsequent
403paragraph in a list item must be intended by either 4 spaces
404or one tab:
405
406 1. This is a list item with two paragraphs. Lorem ipsum dolor
407 sit amet, consectetuer adipiscing elit. Aliquam hendrerit
408 mi posuere lectus.
409
410 Vestibulum enim wisi, viverra nec, fringilla in, laoreet
411 vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
412 sit amet velit.
413
414 2. Suspendisse id sem consectetuer libero luctus adipiscing.
415
416It looks nice if you indent every line of the subsequent
417paragraphs, but here again, Markdown will allow you to be
418lazy:
419
420 * This is a list item with two paragraphs.
421
422 This is the second paragraph in the list item. You're
423 only required to indent the first line. Lorem ipsum dolor
424 sit amet, consectetuer adipiscing elit.
425
426 * Another item in the same list.
427
428To put a blockquote within a list item, the blockquote's `>`
429delimiters need to be indented:
430
431 * A list item with a blockquote:
432
433 > This is a blockquote
434 > inside a list item.
435
436To put a code block within a list item, the code block needs
437to be indented *twice* -- 8 spaces or two tabs:
438
439 * A list item with a code block:
440
441 <code goes here>
442
443
444It's worth noting that it's possible to trigger an ordered list by
445accident, by writing something like this:
446
447 1986. What a great season.
448
449In other words, a *number-period-space* sequence at the beginning of a
450line. To avoid this, you can backslash-escape the period:
451
452 1986\. What a great season.
453
454
455
456<h3 id="precode">Code Blocks</h3>
457
458Pre-formatted code blocks are used for writing about programming or
459markup source code. Rather than forming normal paragraphs, the lines
460of a code block are interpreted literally. Markdown wraps a code block
461in both `<pre>` and `<code>` tags.
462
463To produce a code block in Markdown, simply indent every line of the
464block by at least 4 spaces or 1 tab. For example, given this input:
465
466 This is a normal paragraph:
467
468 This is a code block.
469
470Markdown will generate:
471
472 <p>This is a normal paragraph:</p>
473
474 <pre><code>This is a code block.
475 </code></pre>
476
477One level of indentation -- 4 spaces or 1 tab -- is removed from each
478line of the code block. For example, this:
479
480 Here is an example of AppleScript:
481
482 tell application "Foo"
483 beep
484 end tell
485
486will turn into:
487
488 <p>Here is an example of AppleScript:</p>
489
490 <pre><code>tell application "Foo"
491 beep
492 end tell
493 </code></pre>
494
495A code block continues until it reaches a line that is not indented
496(or the end of the article).
497
498Within a code block, ampersands (`&`) and angle brackets (`<` and `>`)
499are automatically converted into HTML entities. This makes it very
500easy to include example HTML source code using Markdown -- just paste
501it and indent it, and Markdown will handle the hassle of encoding the
502ampersands and angle brackets. For example, this:
503
504 <div class="footer">
505 &copy; 2004 Foo Corporation
506 </div>
507
508will turn into:
509
510 <pre><code>&lt;div class="footer"&gt;
511 &amp;copy; 2004 Foo Corporation
512 &lt;/div&gt;
513 </code></pre>
514
515Regular Markdown syntax is not processed within code blocks. E.g.,
516asterisks are just literal asterisks within a code block. This means
517it's also easy to use Markdown to write about Markdown's own syntax.
518
519
520
521<h3 id="hr">Horizontal Rules</h3>
522
523You can produce a horizontal rule tag (`<hr />`) by placing three or
524more hyphens, asterisks, or underscores on a line by themselves. If you
525wish, you may use spaces between the hyphens or asterisks. Each of the
526following lines will produce a horizontal rule:
527
528 * * *
529
530 ***
531
532 *****
533
534 - - -
535
536 ---------------------------------------
537
538 _ _ _
539
540
541* * *
542
543<h2 id="span">Span Elements</h2>
544
545<h3 id="link">Links</h3>
546
547Markdown supports two style of links: *inline* and *reference*.
548
549In both styles, the link text is delimited by [square brackets].
550
551To create an inline link, use a set of regular parentheses immediately
552after the link text's closing square bracket. Inside the parentheses,
553put the URL where you want the link to point, along with an *optional*
554title for the link, surrounded in quotes. For example:
555
556 This is [an example](http://example.com/ "Title") inline link.
557
558 [This link](http://example.net/) has no title attribute.
559
560Will produce:
561
562 <p>This is <a href="http://example.com/" title="Title">
563 an example</a> inline link.</p>
564
565 <p><a href="http://example.net/">This link</a> has no
566 title attribute.</p>
567
568If you're referring to a local resource on the same server, you can
569use relative paths:
570
571 See my [About](/about/) page for details.
572
573Reference-style links use a second set of square brackets, inside
574which you place a label of your choosing to identify the link:
575
576 This is [an example][id] reference-style link.
577
578You can optionally use a space to separate the sets of brackets:
579
580 This is [an example] [id] reference-style link.
581
582Then, anywhere in the document, you define your link label like this,
583on a line by itself:
584
585 [id]: http://example.com/ "Optional Title Here"
586
587That is:
588
589* Square brackets containing the link identifier (optionally
590 indented from the left margin using up to three spaces);
591* followed by a colon;
592* followed by one or more spaces (or tabs);
593* followed by the URL for the link;
594* optionally followed by a title attribute for the link, enclosed
595 in double or single quotes.
596
597The link URL may, optionally, be surrounded by angle brackets:
598
599 [id]: <http://example.com/> "Optional Title Here"
600
601You can put the title attribute on the next line and use extra spaces
602or tabs for padding, which tends to look better with longer URLs:
603
604 [id]: http://example.com/longish/path/to/resource/here
605 "Optional Title Here"
606
607Link definitions are only used for creating links during Markdown
608processing, and are stripped from your document in the HTML output.
609
610Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are *not* case sensitive. E.g. these two links:
611
612 [link text][a]
613 [link text][A]
614
615are equivalent.
616
617The *implicit link name* shortcut allows you to omit the name of the
618link, in which case the link text itself is used as the name.
619Just use an empty set of square brackets -- e.g., to link the word
620"Google" to the google.com web site, you could simply write:
621
622 [Google][]
623
624And then define the link:
625
626 [Google]: http://google.com/
627
628Because link names may contain spaces, this shortcut even works for
629multiple words in the link text:
630
631 Visit [Daring Fireball][] for more information.
632
633And then define the link:
634
635 [Daring Fireball]: http://daringfireball.net/
636
637Link definitions can be placed anywhere in your Markdown document. I
638tend to put them immediately after each paragraph in which they're
639used, but if you want, you can put them all at the end of your
640document, sort of like footnotes.
641
642Here's an example of reference links in action:
643
644 I get 10 times more traffic from [Google] [1] than from
645 [Yahoo] [2] or [MSN] [3].
646
647 [1]: http://google.com/ "Google"
648 [2]: http://search.yahoo.com/ "Yahoo Search"
649 [3]: http://search.msn.com/ "MSN Search"
650
651Using the implicit link name shortcut, you could instead write:
652
653 I get 10 times more traffic from [Google][] than from
654 [Yahoo][] or [MSN][].
655
656 [google]: http://google.com/ "Google"
657 [yahoo]: http://search.yahoo.com/ "Yahoo Search"
658 [msn]: http://search.msn.com/ "MSN Search"
659
660Both of the above examples will produce the following HTML output:
661
662 <p>I get 10 times more traffic from <a href="http://google.com/"
663 title="Google">Google</a> than from
664 <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
665 or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
666
667For comparison, here is the same paragraph written using
668Markdown's inline link style:
669
670 I get 10 times more traffic from [Google](http://google.com/ "Google")
671 than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
672 [MSN](http://search.msn.com/ "MSN Search").
673
674The point of reference-style links is not that they're easier to
675write. The point is that with reference-style links, your document
676source is vastly more readable. Compare the above examples: using
677reference-style links, the paragraph itself is only 81 characters
678long; with inline-style links, it's 176 characters; and as raw HTML,
679it's 234 characters. In the raw HTML, there's more markup than there
680is text.
681
682With Markdown's reference-style links, a source document much more
683closely resembles the final output, as rendered in a browser. By
684allowing you to move the markup-related metadata out of the paragraph,
685you can add links without interrupting the narrative flow of your
686prose.
687
688
689<h3 id="em">Emphasis</h3>
690
691Markdown treats asterisks (`*`) and underscores (`_`) as indicators of
692emphasis. Text wrapped with one `*` or `_` will be wrapped with an
693HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML
694`<strong>` tag. E.g., this input:
695
696 *single asterisks*
697
698 _single underscores_
699
700 **double asterisks**
701
702 __double underscores__
703
704will produce:
705
706 <em>single asterisks</em>
707
708 <em>single underscores</em>
709
710 <strong>double asterisks</strong>
711
712 <strong>double underscores</strong>
713
714You can use whichever style you prefer; the lone restriction is that
715the same character must be used to open and close an emphasis span.
716
717Emphasis can be used in the middle of a word:
718
719 un*fucking*believable
720
721But if you surround an `*` or `_` with spaces, it'll be treated as a
722literal asterisk or underscore.
723
724To produce a literal asterisk or underscore at a position where it
725would otherwise be used as an emphasis delimiter, you can backslash
726escape it:
727
728 \*this text is surrounded by literal asterisks\*
729
730
731
732<h3 id="code">Code</h3>
733
734To indicate a span of code, wrap it with backtick quotes (`` ` ``).
735Unlike a pre-formatted code block, a code span indicates code within a
736normal paragraph. For example:
737
738 Use the `printf()` function.
739
740will produce:
741
742 <p>Use the <code>printf()</code> function.</p>
743
744To include a literal backtick character within a code span, you can use
745multiple backticks as the opening and closing delimiters:
746
747 ``There is a literal backtick (`) here.``
748
749which will produce this:
750
751 <p><code>There is a literal backtick (`) here.</code></p>
752
753The backtick delimiters surrounding a code span may include spaces --
754one after the opening, one before the closing. This allows you to place
755literal backtick characters at the beginning or end of a code span:
756
757 A single backtick in a code span: `` ` ``
758
759 A backtick-delimited string in a code span: `` `foo` ``
760
761will produce:
762
763 <p>A single backtick in a code span: <code>`</code></p>
764
765 <p>A backtick-delimited string in a code span: <code>`foo`</code></p>
766
767With a code span, ampersands and angle brackets are encoded as HTML
768entities automatically, which makes it easy to include example HTML
769tags. Markdown will turn this:
770
771 Please don't use any `<blink>` tags.
772
773into:
774
775 <p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>
776
777You can write this:
778
779 `&#8212;` is the decimal-encoded equivalent of `&mdash;`.
780
781to produce:
782
783 <p><code>&amp;#8212;</code> is the decimal-encoded
784 equivalent of <code>&amp;mdash;</code>.</p>
785
786
787
788<h3 id="img">Images</h3>
789
790Admittedly, it's fairly difficult to devise a "natural" syntax for
791placing images into a plain text document format.
792
793Markdown uses an image syntax that is intended to resemble the syntax
794for links, allowing for two styles: *inline* and *reference*.
795
796Inline image syntax looks like this:
797
798 ![Alt text](/path/to/img.jpg)
799
800 ![Alt text](/path/to/img.jpg "Optional title")
801
802That is:
803
804* An exclamation mark: `!`;
805* followed by a set of square brackets, containing the `alt`
806 attribute text for the image;
807* followed by a set of parentheses, containing the URL or path to
808 the image, and an optional `title` attribute enclosed in double
809 or single quotes.
810
811Reference-style image syntax looks like this:
812
813 ![Alt text][id]
814
815Where "id" is the name of a defined image reference. Image references
816are defined using syntax identical to link references:
817
818 [id]: url/to/image "Optional title attribute"
819
820As of this writing, Markdown has no syntax for specifying the
821dimensions of an image; if this is important to you, you can simply
822use regular HTML `<img>` tags.
823
824
825* * *
826
827
828<h2 id="misc">Miscellaneous</h2>
829
830<h3 id="autolink">Automatic Links</h3>
831
832Markdown 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:
833
834 <http://example.com/>
835
836Markdown will turn this into:
837
838 <a href="http://example.com/">http://example.com/</a>
839
840Automatic links for email addresses work similarly, except that
841Markdown will also perform a bit of randomized decimal and hex
842entity-encoding to help obscure your address from address-harvesting
843spambots. For example, Markdown will turn this:
844
845 <address@example.com>
846
847into something like this:
848
849 <a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;
850 &#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;
851 &#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
852 &#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
853
854which will render in a browser as a clickable link to "address@example.com".
855
856(This sort of entity-encoding trick will indeed fool many, if not
857most, address-harvesting bots, but it definitely won't fool all of
858them. It's better than nothing, but an address published in this way
859will probably eventually start receiving spam.)
860
861
862
863<h3 id="backslash">Backslash Escapes</h3>
864
865Markdown allows you to use backslash escapes to generate literal
866characters which would otherwise have special meaning in Markdown's
867formatting syntax. For example, if you wanted to surround a word with
868literal asterisks (instead of an HTML `<em>` tag), you can backslashes
869before the asterisks, like this:
870
871 \*literal asterisks\*
872
873Markdown provides backslash escapes for the following characters:
874
875 \ backslash
876 ` backtick
877 * asterisk
878 _ underscore
879 {} curly braces
880 [] square brackets
881 () parentheses
882 # hash mark
883 + plus sign
884 - minus sign (hyphen)
885 . dot
886 ! exclamation mark
  
1<blockquote>
2 <p>foo</p>
3
4 <blockquote>
5 <p>bar</p>
6 </blockquote>
7
8 <p>foo</p>
9</blockquote>
  
1> foo
2>
3> > bar
4>
5> foo
  
1<h2>Unordered</h2>
2
3<p>Asterisks tight:</p>
4
5<ul>
6<li>asterisk 1</li>
7<li>asterisk 2</li>
8<li>asterisk 3</li>
9</ul>
10
11<p>Asterisks loose:</p>
12
13<ul>
14<li><p>asterisk 1</p></li>
15<li><p>asterisk 2</p></li>
16<li><p>asterisk 3</p></li>
17</ul>
18
19<hr />
20
21<p>Pluses tight:</p>
22
23<ul>
24<li>Plus 1</li>
25<li>Plus 2</li>
26<li>Plus 3</li>
27</ul>
28
29<p>Pluses loose:</p>
30
31<ul>
32<li><p>Plus 1</p></li>
33<li><p>Plus 2</p></li>
34<li><p>Plus 3</p></li>
35</ul>
36
37<hr />
38
39<p>Minuses tight:</p>
40
41<ul>
42<li>Minus 1</li>
43<li>Minus 2</li>
44<li>Minus 3</li>
45</ul>
46
47<p>Minuses loose:</p>
48
49<ul>
50<li><p>Minus 1</p></li>
51<li><p>Minus 2</p></li>
52<li><p>Minus 3</p></li>
53</ul>
54
55<h2>Ordered</h2>
56
57<p>Tight:</p>
58
59<ol>
60<li>First</li>
61<li>Second</li>
62<li>Third</li>
63</ol>
64
65<p>and:</p>
66
67<ol>
68<li>One</li>
69<li>Two</li>
70<li>Three</li>
71</ol>
72
73<p>Loose using tabs:</p>
74
75<ol>
76<li><p>First</p></li>
77<li><p>Second</p></li>
78<li><p>Third</p></li>
79</ol>
80
81<p>and using spaces:</p>
82
83<ol>
84<li><p>One</p></li>
85<li><p>Two</p></li>
86<li><p>Three</p></li>
87</ol>
88
89<p>Multiple paragraphs:</p>
90
91<ol>
92<li><p>Item 1, graf one.</p>
93
94<p>Item 2. graf two. The quick brown fox jumped over the lazy dog's
95back.</p></li>
96<li><p>Item 2.</p></li>
97<li><p>Item 3.</p></li>
98</ol>
99
100<h2>Nested</h2>
101
102<ul>
103<li>Tab
104<ul>
105<li>Tab
106<ul>
107<li>Tab</li>
108</ul></li>
109</ul></li>
110</ul>
111
112<p>Here's another:</p>
113
114<ol>
115<li>First</li>
116<li>Second:
117<ul>
118<li>Fee</li>
119<li>Fie</li>
120<li>Foe</li>
121</ul></li>
122<li>Third</li>
123</ol>
124
125<p>Same thing but with paragraphs:</p>
126
127<ol>
128<li><p>First</p></li>
129<li><p>Second:</p>
130
131<ul>
132<li>Fee</li>
133<li>Fie</li>
134<li>Foe</li>
135</ul></li>
136<li><p>Third</p></li>
137</ol>
138
139
140<p>This was an error in Markdown 1.0.1:</p>
141
142<ul>
143<li><p>this</p>
144
145<ul><li>sub</li></ul>
146
147<p>that</p></li>
148</ul>
  
1## Unordered
2
3Asterisks tight:
4
5* asterisk 1
6* asterisk 2
7* asterisk 3
8
9
10Asterisks loose:
11
12* asterisk 1
13
14* asterisk 2
15
16* asterisk 3
17
18* * *
19
20Pluses tight:
21
22+ Plus 1
23+ Plus 2
24+ Plus 3
25
26
27Pluses loose:
28
29+ Plus 1
30
31+ Plus 2
32
33+ Plus 3
34
35* * *
36
37
38Minuses tight:
39
40- Minus 1
41- Minus 2
42- Minus 3
43
44
45Minuses loose:
46
47- Minus 1
48
49- Minus 2
50
51- Minus 3
52
53
54## Ordered
55
56Tight:
57
581. First
592. Second
603. Third
61
62and:
63
641. One
652. Two
663. Three
67
68
69Loose using tabs:
70
711. First
72
732. Second
74
753. Third
76
77and using spaces:
78
791. One
80
812. Two
82
833. Three
84
85Multiple paragraphs:
86
871. Item 1, graf one.
88
89 Item 2. graf two. The quick brown fox jumped over the lazy dog's
90 back.
91
922. Item 2.
93
943. Item 3.
95
96
97
98## Nested
99
100* Tab
101 * Tab
102 * Tab
103
104Here's another:
105
1061. First
1072. Second:
108 * Fee
109 * Fie
110 * Foe
1113. Third
112
113Same thing but with paragraphs:
114
1151. First
116
1172. Second:
118 * Fee
119 * Fie
120 * Foe
121
1223. Third
123
124
125This was an error in Markdown 1.0.1:
126
127* this
128
129 * sub
130
131 that
  
1<p><strong><em>This is strong and em.</em></strong></p>
2
3<p>So is <strong><em>this</em></strong> word.</p>
4
5<p><strong><em>This is strong and em.</em></strong></p>
6
7<p>So is <strong><em>this</em></strong> word.</p>
  
1***This is strong and em.***
2
3So is ***this*** word.
4
5___This is strong and em.___
6
7So is ___this___ word.
  
1<ul>
2<li><p>this is a list item
3indented with tabs</p></li>
4<li><p>this is a list item
5indented with spaces</p></li>
6</ul>
7
8<p>Code:</p>
9
10<pre><code>this code block is indented by one tab
11</code></pre>
12
13<p>And:</p>
14
15<pre><code> this code block is indented by two tabs
16</code></pre>
17
18<p>And:</p>
19
20<pre><code>+ this is an example list item
21 indented with tabs
22
23+ this is an example list item
24 indented with spaces
25</code></pre>
  
1+ this is a list item
2 indented with tabs
3
4+ this is a list item
5 indented with spaces
6
7Code:
8
9 this code block is indented by one tab
10
11And:
12
13 this code block is indented by two tabs
14
15And:
16
17 + this is an example list item
18 indented with tabs
19
20 + this is an example list item
21 indented with spaces
  
1<blockquote>
2<p>A list within a blockquote:</p>
3<ul>
4<li>asterisk 1</li>
5<li>asterisk 2</li>
6<li>asterisk 3</li>
7</ul>
8</blockquote>
  
1> A list within a blockquote:
2>
3> * asterisk 1
4> * asterisk 2
5> * asterisk 3
  
1[DEFAULT]
2input_ext=.text
3normalize=1
4# comment out next line to run these tests
5skip=1
  
1import traceback
2from util import MarkdownSyntaxError
3from nose.plugins import Plugin
4from nose.plugins.errorclass import ErrorClass, ErrorClassPlugin
5
6class Markdown(ErrorClassPlugin):
7 """ Add MarkdownSyntaxError and ensure proper formatting. """
8 mdsyntax = ErrorClass(MarkdownSyntaxError,
9 label='MarkdownSyntaxError',
10 isfailure=True)
11 enabled = True
12
13 def configure(self, options, conf):
14 self.conf = conf
15
16 def addError(self, test, err):
17 """ Ensure other plugins see the error by returning nothing here. """
18 pass
19
20 def formatError(self, test, err):
21 """ Remove unnessecary and unhelpful traceback from error report. """
22 et, ev, tb = err
23 if et.__name__ == 'MarkdownSyntaxError':
24 return et, ev, ''
25 return err
26
27
28def escape(html):
29 """ Escape HTML for display as source within HTML. """
30 html = html.replace('&', '&amp;')
31 html = html.replace('<', '&lt;')
32 html = html.replace('>', '&gt;')
33 return html
34
35
36class HtmlOutput(Plugin):
37 """Output test results as ugly, unstyled html. """
38
39 name = 'html-output'
40 score = 2 # run late
41 enabled = True
42
43 def __init__(self):
44 super(HtmlOutput, self).__init__()
45 self.html = [ '<html><head>',
46 '<title>Test output</title>',
47 '</head><body>' ]
48
49 def configure(self, options, conf):
50 self.conf = conf
51
52 def addSuccess(self, test):
53 self.html.append('<span>ok</span>')
54
55 def addError(self, test, err):
56 err = self.formatErr(err)
57 self.html.append('<span>ERROR</span>')
58 self.html.append('<pre>%s</pre>' % escape(err))
59
60 def addFailure(self, test, err):
61 err = self.formatErr(err)
62 self.html.append('<span>FAIL</span>')
63 self.html.append('<pre>%s</pre>' % escape(err))
64
65 def finalize(self, result):
66 self.html.append('<div>')
67 self.html.append("Ran %d test%s" %
68 (result.testsRun, result.testsRun != 1 and "s"
69or ""))
70 self.html.append('</div>')
71 self.html.append('<div>')
72 if not result.wasSuccessful():
73 self.html.extend(['<span>FAILED (',
74 'failures=%d ' % len(result.failures),
75 'errors=%d' % len(result.errors)])
76 for cls in result.errorClasses.keys():
77 storage, label, isfail = result.errorClasses[cls]
78 if len(storage):
79 self.html.append(' %ss=%d' % (label, len(storage)))
80 self.html.append(')</span>')
81 else:
82 self.html.append('OK')
83 self.html.append('</div></body></html>')
84 f = open('tmp/test-output.html', 'w')
85 for l in self.html:
86 f.write(l)
87 f.close()
88
89 def formatErr(self, err):
90 exctype, value, tb = err
91 return ''.join(traceback.format_exception(exctype, value, tb))
92
93 def startContext(self, ctx):
94 try:
95 n = ctx.__name__
96 except AttributeError:
97 n = str(ctx).replace('<', '').replace('>', '')
98 self.html.extend(['<fieldset>', '<legend>', n, '</legend>'])
99 try:
100 path = ctx.__file__.replace('.pyc', '.py')
101 self.html.extend(['<div>', path, '</div>'])
102 except AttributeError:
103 pass
104
105 def stopContext(self, ctx):
106 self.html.append('</fieldset>')
107
108 def startTest(self, test):
109 self.html.extend([ '<div><span>',
110 test.shortDescription() or str(test),
111 '</span>' ])
112
113 def stopTest(self, test):
114 self.html.append('</div>')
  
1<p>Simple block on one line:</p>
2<p>&lt;div&gt;foo&lt;/div&gt;</p>
3<p>And nested without indentation:</p>
4<p>&lt;div&gt;
5&lt;div&gt;
6&lt;div&gt;
7foo
8&lt;/div&gt;
9&lt;/div&gt;
10&lt;div&gt;bar&lt;/div&gt;
11&lt;/div&gt;</p>
  
1Simple block on one line:
2
3<div>foo</div>
4
5And nested without indentation:
6
7<div>
8<div>
9<div>
10foo
11</div>
12</div>
13<div>bar</div>
14</div>
  
1<p>Paragraph one.</p>
2<p>&lt;!-- This is a simple comment --&gt;</p>
3<p>&lt;!--
4 This is another comment.
5--&gt;</p>
6<p>Paragraph two.</p>
7<p>&lt;!-- one comment block -- -- with two comments --&gt;</p>
8<p>The end.</p>
  
1Paragraph one.
2
3<!-- This is a simple comment -->
4
5<!--
6 This is another comment.
7-->
8
9Paragraph two.
10
11<!-- one comment block -- -- with two comments -->
12
13The end.
  
1<p>Here's a simple block:</p>
2<p>&lt;div&gt;
3 foo
4&lt;/div&gt;</p>
5<p>This should be a code block, though:</p>
6<pre><code>&lt;div&gt;
7 foo
8&lt;/div&gt;
9</code></pre>
10<p>As should this:</p>
11<pre><code>&lt;div&gt;foo&lt;/div&gt;
12</code></pre>
13<p>Now, nested:</p>
14<p>&lt;div&gt;
15 &lt;div&gt;
16 &lt;div&gt;
17 foo
18 &lt;/div&gt;
19 &lt;/div&gt;
20&lt;/div&gt;</p>
21<p>This should just be an HTML comment:</p>
22<p>&lt;!-- Comment --&gt;</p>
23<p>Multiline:</p>
24<p>&lt;!--
25Blah
26Blah
27--&gt;</p>
28<p>Code block:</p>
29<pre><code>&lt;!-- Comment --&gt;
30</code></pre>
31<p>Just plain comment, with trailing spaces on the line:</p>
32<p>&lt;!-- foo --&gt;</p>
33<p>Code:</p>
34<pre><code>&lt;hr /&gt;
35</code></pre>
36<p>Hr's:</p>
37<p>&lt;hr&gt;</p>
38<p>&lt;hr/&gt;</p>
39<p>&lt;hr /&gt;</p>
40<p>&lt;hr&gt;</p>
41<p>&lt;hr/&gt;</p>
42<p>&lt;hr /&gt;</p>
43<p>&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;</p>
44<p>&lt;hr class=&quot;foo&quot; id=&quot;bar&quot;/&gt;</p>
45<p>&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; &gt;</p>
  
1Here's a simple block:
2
3<div>
4 foo
5</div>
6
7This should be a code block, though:
8
9 <div>
10 foo
11 </div>
12
13As should this:
14
15 <div>foo</div>
16
17Now, nested:
18
19<div>
20 <div>
21 <div>
22 foo
23 </div>
24 </div>
25</div>
26
27This should just be an HTML comment:
28
29<!-- Comment -->
30
31Multiline:
32
33<!--
34Blah
35Blah
36-->
37
38Code block:
39
40 <!-- Comment -->
41
42Just plain comment, with trailing spaces on the line:
43
44<!-- foo -->
45
46Code:
47
48 <hr />
49
50Hr's:
51
52<hr>
53
54<hr/>
55
56<hr />
57
58<hr>
59
60<hr/>
61
62<hr />
63
64<hr class="foo" id="bar" />
65
66<hr class="foo" id="bar"/>
67
68<hr class="foo" id="bar" >
  
1<p>Here's a simple block:</p>
2<p></p>
3<p>This should be a code block, though:</p>
4<pre><code>&lt;div&gt;
5 foo
6&lt;/div&gt;
7</code></pre>
8<p>As should this:</p>
9<pre><code>&lt;div&gt;foo&lt;/div&gt;
10</code></pre>
11<p>Now, nested:</p>
12<p></p>
13<p>This should just be an HTML comment:</p>
14<p></p>
15<p>Multiline:</p>
16<p></p>
17<p>Code block:</p>
18<pre><code>&lt;!-- Comment --&gt;
19</code></pre>
20<p>Just plain comment, with trailing spaces on the line:</p>
21<p></p>
22<p>Code:</p>
23<pre><code>&lt;hr /&gt;
24</code></pre>
25<p>Hr's:</p>
26<p></p>
27<p></p>
28<p></p>
29<p></p>
30<p></p>
31<p></p>
32<p></p>
33<p></p>
34<p></p>
  
1Here's a simple block:
2
3<div>
4 foo
5</div>
6
7This should be a code block, though:
8
9 <div>
10 foo
11 </div>
12
13As should this:
14
15 <div>foo</div>
16
17Now, nested:
18
19<div>
20 <div>
21 <div>
22 foo
23 </div>
24 </div>
25</div>
26
27This should just be an HTML comment:
28
29<!-- Comment -->
30
31Multiline:
32
33<!--
34Blah
35Blah
36-->
37
38Code block:
39
40 <!-- Comment -->
41
42Just plain comment, with trailing spaces on the line:
43
44<!-- foo -->
45
46Code:
47
48 <hr />
49
50Hr's:
51
52<hr>
53
54<hr/>
55
56<hr />
57
58<hr>
59
60<hr/>
61
62<hr />
63
64<hr class="foo" id="bar" />
65
66<hr class="foo" id="bar"/>
67
68<hr class="foo" id="bar" >
  
1<p>Here's a simple block:</p>
2<p>[HTML_REMOVED]</p>
3<p>This should be a code block, though:</p>
4<pre><code>&lt;div&gt;
5 foo
6&lt;/div&gt;
7</code></pre>
8<p>As should this:</p>
9<pre><code>&lt;div&gt;foo&lt;/div&gt;
10</code></pre>
11<p>Now, nested:</p>
12<p>[HTML_REMOVED]</p>
13<p>This should just be an HTML comment:</p>
14<p>[HTML_REMOVED]</p>
15<p>Multiline:</p>
16<p>[HTML_REMOVED]</p>
17<p>Code block:</p>
18<pre><code>&lt;!-- Comment --&gt;
19</code></pre>
20<p>Just plain comment, with trailing spaces on the line:</p>
21<p>[HTML_REMOVED]</p>
22<p>Code:</p>
23<pre><code>&lt;hr /&gt;
24</code></pre>
25<p>Hr's:</p>
26<p>[HTML_REMOVED]</p>
27<p>[HTML_REMOVED]</p>
28<p>[HTML_REMOVED]</p>
29<p>[HTML_REMOVED]</p>
30<p>[HTML_REMOVED]</p>
31<p>[HTML_REMOVED]</p>
32<p>[HTML_REMOVED]</p>
33<p>[HTML_REMOVED]</p>
34<p>[HTML_REMOVED]</p>
  
1Here's a simple block:
2
3<div>
4 foo
5</div>
6
7This should be a code block, though:
8
9 <div>
10 foo
11 </div>
12
13As should this:
14
15 <div>foo</div>
16
17Now, nested:
18
19<div>
20 <div>
21 <div>
22 foo
23 </div>
24 </div>
25</div>
26
27This should just be an HTML comment:
28
29<!-- Comment -->
30
31Multiline:
32
33<!--
34Blah
35Blah
36-->
37
38Code block:
39
40 <!-- Comment -->
41
42Just plain comment, with trailing spaces on the line:
43
44<!-- foo -->
45
46Code:
47
48 <hr />
49
50Hr's:
51
52<hr>
53
54<hr/>
55
56<hr />
57
58<hr>
59
60<hr/>
61
62<hr />
63
64<hr class="foo" id="bar" />
65
66<hr class="foo" id="bar"/>
67
68<hr class="foo" id="bar" >
  
1<p>This should be stripped/escaped in safe_mode.</p>
2<p>&lt;script&gt;
3alert(&quot;Hello world!&quot;)
4&lt;/script&gt;</p>
5<p>With blank lines.</p>
6<p>&lt;script&gt;
7
8alert(&quot;Hello world!&quot;)
9
10&lt;/script&gt;</p>
11<p>Now with some weirdness</p>
12<p><code>&lt;script &lt;!--
13alert("Hello world!")
14&lt;/script &lt;&gt;</code> `</p>
15<p>Try another way.</p>
16<p>&lt;script &lt;!--
17alert(&quot;Hello world!&quot;)
18&lt;/script &lt;&gt;
19
20This time with blank lines.
21
22&lt;script &lt;!--
23
24alert(&quot;Hello world!&quot;)
25
26&lt;/script &lt;&gt;
27
28</p>
  
1This should be stripped/escaped in safe_mode.
2
3<script>
4alert("Hello world!")
5</script>
6
7With blank lines.
8
9<script>
10
11alert("Hello world!")
12
13</script>
14
15Now with some weirdness
16
17``<script <!--
18alert("Hello world!")
19</script <>`` `
20
21Try another way.
22
23<script <!--
24alert("Hello world!")
25</script <>
26
27This time with blank lines.
28
29<script <!--
30
31alert("Hello world!")
32
33</script <>
  
1[DEFAULT]
2safe_mode=escape
3
4[remove]
5safe_mode=remove
6
7[replace]
8safe_mode=replace
  
1<p>These links should be unsafe and not allowed in safe_mode</p>
2<p><a href="">link</a>
3<a href="">link</a>
4<a href="">link</a>
5<a href="">link</a>
6<a href="">link</a>
7<a href="">link</a>
8<a href="">link</a>
9<a href="">link</a>
10<a href="">link</a>
11<a href="">link</a>
12<a href="">link</a></p>
13<p><img alt="img" src="" />
14<a href="">ref</a>
15<img alt="imgref" src="" /></p>
16<p>These should work regardless:</p>
17<p><a href="relative/url.html">relative</a>
18<a href="mailto:foo@bar.com">email</a>
19<a href="news:some.news.group.com">news scheme</a>
20<a href="http://example.com">http link</a></p>
  
1These links should be unsafe and not allowed in safe_mode
2
3[link](javascript:alert%28'Hello%20world!'%29)
4[link](vbscript:msgbox%28%22Hello%20world!%22%29)
5[link](livescript:alert%28'Hello%20world!'%29)
6[link](mocha:[code])
7[link](jAvAsCrIpT:alert%28'Hello%20world!'%29)
8[link](ja&#32;vas&#32;cr&#32;ipt:alert%28'Hello%20world!'%29)
9[link](ja&#00032;vas&#32;cr&#32;ipt:alert%28'Hello%20world!'%29)
10[link](ja&#x00020;vas&#32;cr&#32;ipt:alert%28'Hello%20world!'%29)
11[link](ja%09&#x20;%0Avas&#32;cr&#x0a;ipt:alert%28'Hello%20world!'%29)
12[link](ja%20vas%20cr%20ipt:alert%28'Hello%20world!'%29)
13[link](live%20script:alert%28'Hello%20world!'%29)
14
15![img](javascript:alert%29'XSS'%29)
16[ref][]
17![imgref][]
18
19[ref]: javascript:alert%29'XSS'%29
20[imgref]: javascript:alert%29'XSS'%29
21
22These should work regardless:
23
24[relative](relative/url.html)
25[email](mailto:foo@bar.com)
26[news scheme](news:some.news.group.com)
27[http link](http://example.com)
  
1#!/usr/bin/python
2"""
3Python-Markdown Regression Tests
4================================
5
6Tests of the various APIs with the python markdown lib.
7
8"""
9
10import unittest
11from doctest import DocTestSuite
12import os
13import markdown
14
15class TestMarkdownBasics(unittest.TestCase):
16 """ Tests basics of the Markdown class. """
17
18 def setUp(self):
19 """ Create instance of Markdown. """
20 self.md = markdown.Markdown()
21
22 def testBlankInput(self):
23 """ Test blank input. """
24 self.assertEqual(self.md.convert(''), '')
25
26 def testWhitespaceOnly(self):
27 """ Test input of only whitespace. """
28 self.assertEqual(self.md.convert(' '), '')
29
30 def testSimpleInput(self):
31 """ Test simple input. """
32 self.assertEqual(self.md.convert('foo'), '<p>foo</p>')
33
34class TestBlockParser(unittest.TestCase):
35 """ Tests of the BlockParser class. """
36
37 def setUp(self):
38 """ Create instance of BlockParser. """
39 self.parser = markdown.Markdown().parser
40
41 def testParseChunk(self):
42 """ Test BlockParser.parseChunk. """
43 root = markdown.etree.Element("div")
44 text = 'foo'
45 self.parser.parseChunk(root, text)
46 self.assertEqual(markdown.etree.tostring(root), "<div><p>foo</p></div>")
47
48 def testParseDocument(self):
49 """ Test BlockParser.parseDocument. """
50 lines = ['#foo', '', 'bar', '', ' baz']
51 tree = self.parser.parseDocument(lines)
52 self.assert_(isinstance(tree, markdown.etree.ElementTree))
53 self.assert_(markdown.etree.iselement(tree.getroot()))
54 self.assertEqual(markdown.etree.tostring(tree.getroot()),
55 "<div><h1>foo</h1><p>bar</p><pre><code>baz\n</code></pre></div>")
56
57
58class TestBlockParserState(unittest.TestCase):
59 """ Tests of the State class for BlockParser. """
60
61 def setUp(self):
62 self.state = markdown.blockparser.State()
63
64 def testBlankState(self):
65 """ Test State when empty. """
66 self.assertEqual(self.state, [])
67
68 def testSetSate(self):
69 """ Test State.set(). """
70 self.state.set('a_state')
71 self.assertEqual(self.state, ['a_state'])
72 self.state.set('state2')
73 self.assertEqual(self.state, ['a_state', 'state2'])
74
75 def testIsSate(self):
76 """ Test State.isstate(). """
77 self.assertEqual(self.state.isstate('anything'), False)
78 self.state.set('a_state')
79 self.assertEqual(self.state.isstate('a_state'), True)
80 self.state.set('state2')
81 self.assertEqual(self.state.isstate('state2'), True)
82 self.assertEqual(self.state.isstate('a_state'), False)
83 self.assertEqual(self.state.isstate('missing'), False)
84
85 def testReset(self):
86 """ Test State.reset(). """
87 self.state.set('a_state')
88 self.state.reset()
89 self.assertEqual(self.state, [])
90 self.state.set('state1')
91 self.state.set('state2')
92 self.state.reset()
93 self.assertEqual(self.state, ['state1'])
94
95class TestHtmlStash(unittest.TestCase):
96 """ Test Markdown's HtmlStash. """
97
98 def setUp(self):
99 self.stash = markdown.preprocessors.HtmlStash()
100 self.placeholder = self.stash.store('foo')
101
102 def testSimpleStore(self):
103 """ Test HtmlStash.store. """
104 self.assertEqual(self.placeholder,
105 markdown.preprocessors.HTML_PLACEHOLDER % 0)
106 self.assertEqual(self.stash.html_counter, 1)
107 self.assertEqual(self.stash.rawHtmlBlocks, [('foo', False)])
108
109 def testStoreMore(self):
110 """ Test HtmlStash.store with additional blocks. """
111 placeholder = self.stash.store('bar')
112 self.assertEqual(placeholder,
113 markdown.preprocessors.HTML_PLACEHOLDER % 1)
114 self.assertEqual(self.stash.html_counter, 2)
115 self.assertEqual(self.stash.rawHtmlBlocks,
116 [('foo', False), ('bar', False)])
117
118 def testSafeStore(self):
119 """ Test HtmlStash.store with 'safe' html. """
120 self.stash.store('bar', True)
121 self.assertEqual(self.stash.rawHtmlBlocks,
122 [('foo', False), ('bar', True)])
123
124 def testReset(self):
125 """ Test HtmlStash.reset. """
126 self.stash.reset()
127 self.assertEqual(self.stash.html_counter, 0)
128 self.assertEqual(self.stash.rawHtmlBlocks, [])
129
130class TestOrderedDict(unittest.TestCase):
131 """ Test OrderedDict storage class. """
132
133 def setUp(self):
134 self.odict = markdown.odict.OrderedDict()
135 self.odict['first'] = 'This'
136 self.odict['third'] = 'a'
137 self.odict['fourth'] = 'self'
138 self.odict['fifth'] = 'test'
139
140 def testValues(self):
141 """ Test output of OrderedDict.values(). """
142 self.assertEqual(self.odict.values(), ['This', 'a', 'self', 'test'])
143
144 def testKeys(self):
145 """ Test output of OrderedDict.keys(). """
146 self.assertEqual(self.odict.keys(),
147 ['first', 'third', 'fourth', 'fifth'])
148
149 def testItems(self):
150 """ Test output of OrderedDict.items(). """
151 self.assertEqual(self.odict.items(),
152 [('first', 'This'), ('third', 'a'),
153 ('fourth', 'self'), ('fifth', 'test')])
154
155 def testAddBefore(self):
156 """ Test adding an OrderedDict item before a given key. """
157 self.odict.add('second', 'is', '<third')
158 self.assertEqual(self.odict.items(),
159 [('first', 'This'), ('second', 'is'), ('third', 'a'),
160 ('fourth', 'self'), ('fifth', 'test')])
161
162 def testAddAfter(self):
163 """ Test adding an OrderDict item after a given key. """
164 self.odict.add('second', 'is', '>first')
165 self.assertEqual(self.odict.items(),
166 [('first', 'This'), ('second', 'is'), ('third', 'a'),
167 ('fourth', 'self'), ('fifth', 'test')])
168
169 def testAddAfterEnd(self):
170 """ Test adding an OrderedDict item after the last key. """
171 self.odict.add('sixth', '.', '>fifth')
172 self.assertEqual(self.odict.items(),
173 [('first', 'This'), ('third', 'a'),
174 ('fourth', 'self'), ('fifth', 'test'), ('sixth', '.')])
175
176 def testAdd_begin(self):
177 """ Test adding an OrderedDict item using "_begin". """
178 self.odict.add('zero', 'CRAZY', '_begin')
179 self.assertEqual(self.odict.items(),
180 [('zero', 'CRAZY'), ('first', 'This'), ('third', 'a'),
181 ('fourth', 'self'), ('fifth', 'test')])
182
183 def testAdd_end(self):
184 """ Test adding an OrderedDict item using "_end". """
185 self.odict.add('sixth', '.', '_end')
186 self.assertEqual(self.odict.items(),
187 [('first', 'This'), ('third', 'a'),
188 ('fourth', 'self'), ('fifth', 'test'), ('sixth', '.')])
189
190 def testAddBadLocation(self):
191 """ Test Error on bad location in OrderedDict.add(). """
192 self.assertRaises(ValueError, self.odict.add, 'sixth', '.', '<seventh')
193 self.assertRaises(ValueError, self.odict.add, 'second', 'is', 'third')
194
195 def testDeleteItem(self):
196 """ Test deletion of an OrderedDict item. """
197 del self.odict['fourth']
198 self.assertEqual(self.odict.items(),
199 [('first', 'This'), ('third', 'a'), ('fifth', 'test')])
200
201 def testChangeValue(self):
202 """ Test OrderedDict change value. """
203 self.odict['fourth'] = 'CRAZY'
204 self.assertEqual(self.odict.items(),
205 [('first', 'This'), ('third', 'a'),
206 ('fourth', 'CRAZY'), ('fifth', 'test')])
207
208 def testChangeOrder(self):
209 """ Test OrderedDict change order. """
210 self.odict.link('fourth', '<third')
211 self.assertEqual(self.odict.items(),
212 [('first', 'This'), ('fourth', 'self'),
213 ('third', 'a'), ('fifth', 'test')])
  
1from ConfigParser import SafeConfigParser
2
3class MarkdownSyntaxError(Exception):
4 pass
5
6
7class CustomConfigParser(SafeConfigParser):
8 def get(self, section, option):
9 value = SafeConfigParser.get(self, section, option)
10 if option == 'extensions':
11 if len(value.strip()):
12 return value.split(',')
13 else:
14 return []
15 return value
setup.py
(1 / 3)
  
3535 maintainer = 'Waylan Limberg',
3636 maintainer_email = 'waylan [at] gmail.com',
3737 license = 'BSD License',
38 packages = ['markdown', 'markdown.extensions', 'markdown.tests'],
39 package_data = {'': ['tests/*/*.txt', 'tests/*/*.html', 'tests/*/*.cfg',
40 'tests/*/*/*.txt', 'tests/*/*/*.html', 'tests/*/*/*.cfg']},
38 packages = ['markdown', 'markdown.extensions'],
4139 scripts = ['bin/markdown'],
4240 cmdclass = {'install_scripts': md_install_scripts},
4341 classifiers = ['Development Status :: 5 - Production/Stable',
  
1import os
2import markdown
3import codecs
4import difflib
5import nose
6import util
7from plugins import HtmlOutput, Markdown
8try:
9 import tidy
10except ImportError:
11 tidy = None
12
13
14test_dir = os.path.abspath(os.path.dirname(__file__))
15
16def relpath(path, start=test_dir):
17 """ reimplement relpath for python 2.3-2.5 from 2.6 """
18 if not path:
19 raise ValueError('no path secified')
20 start_list = os.path.abspath(start).split(os.path.sep)
21 path_list = os.path.abspath(path).split(os.path.sep)
22 # Work out how much of the filepath is shared by start and path.
23 i = len(os.path.commonprefix([start_list, path_list]))
24 rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:]
25 if not rel_list:
26 return test_dir
27 return os.path.join(*rel_list)
28
29def get_section(file, config):
30 """ Get name of config section for given file. """
31 filename = os.path.basename(file)
32 if config.has_section(filename):
33 return filename
34 else:
35 return 'DEFAULT'
36
37def get_args(file, config):
38 """ Get args to pass to markdown from config for a given file. """
39 args = {}
40 section = get_section(file, config)
41 for key in ['extensions', 'safe_mode', 'output_format']:
42 args[key] = config.get(section, key)
43 return args
44
45def normalize(text):
46 """ Normalize whitespace for a string of html using tidy. """
47 return str(tidy.parseString(text.encode('utf-8'),
48 drop_empty_paras=0,
49 fix_backslash=0,
50 fix_bad_comments=0,
51 fix_uri=0,
52 join_styles=0,
53 lower_literals=0,
54 merge_divs=0,
55 output_xhtml=1,
56 quote_ampersand=0,
57 show_body_only=1,
58 char_encoding='utf8',
59 newline='LF')).decode('string-escape')
60
61class CheckSyntax(object):
62 def __init__(self, description=None):
63 if description:
64 self.description = 'TestSyntax: "%s"' % description
65
66 def __call__(self, file, config):
67 """ Compare expected output to actual output and report result. """
68 cfg_section = get_section(file, config)
69 if config.getboolean(cfg_section, 'skip'):
70 raise nose.plugins.skip.SkipTest, 'Test skipped per config.'
71 input_file = file + config.get(cfg_section, 'input_ext')
72 input = codecs.open(input_file, encoding="utf-8").read()
73 output_file = file + config.get(cfg_section, 'output_ext')
74 expected_output = codecs.open(output_file, encoding="utf-8").read()
75 output = markdown.markdown(input, **get_args(file, config))
76 if tidy and config.getboolean(cfg_section, 'normalize'):
77 # Normalize whitespace before comparing.
78 expected_output = normalize(expected_output)
79 output = normalize(output)
80 elif config.getboolean(cfg_section, 'normalize'):
81 # Tidy is not available. Skip this test.
82 raise nose.plugins.skip.SkipTest, 'Test skipped. Tidy not available in system.'
83 diff = [l for l in difflib.unified_diff(expected_output.splitlines(True),
84 output.splitlines(True),
85 output_file,
86 'actual_output.html',
87 n=3)]
88 if diff:
89 raise util.MarkdownSyntaxError('Output from "%s" failed to match expected '
90 'output.\n\n%s' % (input_file, ''.join(diff)))
91
92def TestSyntax():
93 for dir_name, sub_dirs, files in os.walk(test_dir):
94 # Get dir specific config settings.
95 config = util.CustomConfigParser({'extensions': '',
96 'safe_mode': False,
97 'output_format': 'xhtml1',
98 'normalize': '0',
99 'skip': '0',
100 'input_ext': '.txt',
101 'output_ext': '.html'})
102 config.read(os.path.join(dir_name, 'test.cfg'))
103 # Loop through files and generate tests.
104 for file in files:
105 root, ext = os.path.splitext(file)
106 if ext == config.get(get_section(file, config), 'input_ext'):
107 path = os.path.join(dir_name, root)
108 check_syntax = CheckSyntax(description=relpath(path, test_dir))
109 yield check_syntax, path, config
110
111def run():
112 nose.main(addplugins=[HtmlOutput(), Markdown()])
113
114# Hack to make nose run with extensions. Once extensions can be added from
115# setup.cfg, the below line can be removed.
116# See nose [Issue 271](http://code.google.com/p/python-nose/issues/detail?id=271)
117run()
  
1<p>AT&amp;T has an ampersand in their name.</p>
2<p>AT&amp;T is another way to write it.</p>
3<p>This &amp; that.</p>
4<p>4 &lt; 5.</p>
5<p>6 &gt; 5.</p>
6<p>Here's a <a href="http://example.com/?foo=1&amp;bar=2">link</a> with an ampersand in the URL.</p>
7<p>Here's a link with an amersand in the link text: <a href="http://att.com/" title="AT&amp;T">AT&amp;T</a>.</p>
8<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
9<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
  
1AT&T has an ampersand in their name.
2
3AT&amp;T is another way to write it.
4
5This & that.
6
74 < 5.
8
96 > 5.
10
11Here's a [link] [1] with an ampersand in the URL.
12
13Here's a link with an amersand in the link text: [AT&T] [2].
14
15Here's an inline [link](/script?foo=1&bar=2).
16
17Here's an inline [link](</script?foo=1&bar=2>).
18
19
20[1]: http://example.com/?foo=1&bar=2
21[2]: http://att.com/ "AT&T"
  
1<p><a href="simple link" title="title">link</a>
2<img alt="image" src="http://example.com/image.jpg" />
3<a href="http://example.com/(()((())923)(">link</a>
4<img alt="image" src="link(()))(" /></p>
  
1[link](<simple link> "title")
2![image](<http://example.com/image.jpg>)
3[link](<http://example.com/(()((())923)(>)
4![image](<link(()))(>)
  
1<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>
2<p>Https link: <a href="https://example.com">https://example.com</a></p>
3<p>Ftp link: <a href="ftp://example.com">ftp://example.com</a></p>
4<p>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</a></p>
5<ul>
6<li>In a list?</li>
7<li><a href="http://example.com/">http://example.com/</a></li>
8<li>It should.</li>
9</ul>
10<blockquote>
11<p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
12</blockquote>
13<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
14<pre><code>or here: &lt;http://example.com/&gt;
15</code></pre>
  
1Link: <http://example.com/>.
2
3Https link: <https://example.com>
4
5Ftp link: <ftp://example.com>
6
7With an ampersand: <http://example.com/?foo=1&bar=2>
8
9* In a list?
10* <http://example.com/>
11* It should.
12
13> Blockquoted: <http://example.com/>
14
15Auto-links should not occur here: `<http://example.com/>`
16
17 or here: <http://example.com/>
  
1<p>These should all get escaped:</p>
2<p>Backslash: \</p>
3<p>Backtick: `</p>
4<p>Asterisk: *</p>
5<p>Underscore: _</p>
6<p>Left brace: {</p>
7<p>Right brace: }</p>
8<p>Left bracket: [</p>
9<p>Right bracket: ]</p>
10<p>Left paren: (</p>
11<p>Right paren: )</p>
12<p>Greater-than: &gt;</p>
13<p>Hash: #</p>
14<p>Period: .</p>
15<p>Bang: !</p>
16<p>Plus: +</p>
17<p>Minus: -</p>
18<p>These should not, because they occur within a code block:</p>
19<pre><code>Backslash: \\
20
21Backtick: \`
22
23Asterisk: \*
24
25Underscore: \_
26
27Left brace: \{
28
29Right brace: \}
30
31Left bracket: \[
32
33Right bracket: \]
34
35Left paren: \(
36
37Right paren: \)
38
39Greater-than: \&gt;
40
41Hash: \#
42
43Period: \.
44
45Bang: \!
46
47Plus: \+
48
49Minus: \-
50</code></pre>
51<p>Nor should these, which occur in code spans:</p>
52<p>Backslash: <code>\\</code></p>
53<p>Backtick: <code>\`</code></p>
54<p>Asterisk: <code>\*</code></p>
55<p>Underscore: <code>\_</code></p>
56<p>Left brace: <code>\{</code></p>
57<p>Right brace: <code>\}</code></p>
58<p>Left bracket: <code>\[</code></p>
59<p>Right bracket: <code>\]</code></p>
60<p>Left paren: <code>\(</code></p>
61<p>Right paren: <code>\)</code></p>
62<p>Greater-than: <code>\&gt;</code></p>
63<p>Hash: <code>\#</code></p>
64<p>Period: <code>\.</code></p>
65<p>Bang: <code>\!</code></p>
66<p>Plus: <code>\+</code></p>
67<p>Minus: <code>\-</code></p>
  
1These should all get escaped:
2
3Backslash: \\
4
5Backtick: \`
6
7Asterisk: \*
8
9Underscore: \_
10
11Left brace: \{
12
13Right brace: \}
14
15Left bracket: \[
16
17Right bracket: \]
18
19Left paren: \(
20
21Right paren: \)
22
23Greater-than: \>
24
25Hash: \#
26
27Period: \.
28
29Bang: \!
30
31Plus: \+
32
33Minus: \-
34
35
36
37These should not, because they occur within a code block:
38
39 Backslash: \\
40
41 Backtick: \`
42
43 Asterisk: \*
44
45 Underscore: \_
46
47 Left brace: \{
48
49 Right brace: \}
50
51 Left bracket: \[
52
53 Right bracket: \]
54
55 Left paren: \(
56
57 Right paren: \)
58
59 Greater-than: \>
60
61 Hash: \#
62
63 Period: \.
64
65 Bang: \!
66
67 Plus: \+
68
69 Minus: \-
70
71
72Nor should these, which occur in code spans:
73
74Backslash: `\\`
75
76Backtick: `` \` ``
77
78Asterisk: `\*`
79
80Underscore: `\_`
81
82Left brace: `\{`
83
84Right brace: `\}`
85
86Left bracket: `\[`
87
88Right bracket: `\]`
89
90Left paren: `\(`
91
92Right paren: `\)`
93
94Greater-than: `\>`
95
96Hash: `\#`
97
98Period: `\.`
99
100Bang: `\!`
101
102Plus: `\+`
103
104Minus: `\-`
  
1construction:0.000000:0.000000
2amps-and-angle-encoding:0.070000:131072.000000
3auto-links:0.080000:397312.000000
4backlash-escapes:0.270000:884736.000000
5blockquotes-with-dode-blocks:0.020000:0.000000
6hard-wrapped:0.020000:0.000000
7horizontal-rules:0.180000:135168.000000
8inline-html-advanced:0.070000:0.000000
9inline-html-comments:0.080000:0.000000
10inline-html-simple:0.210000:0.000000
11links-inline:0.140000:0.000000
12links-reference:0.170000:0.000000
13literal-quotes:0.090000:0.000000
14markdown-documentation-basics:0.690000:1806336.000000
15markdown-syntax:3.310000:6696960.000000
16nested-blockquotes:0.200000:0.000000
17ordered-and-unordered-list:0.530000:0.000000
18strong-and-em-together:0.200000:0.000000
19tabs:0.200000:0.000000
20tidyness:0.200000:0.000000
  
1<blockquote>
2<p>Example:</p>
3<pre><code>sub status {
4 print "working";
5}
6</code></pre>
7<p>Or:</p>
8<pre><code>sub status {
9 return "working";
10}
11</code></pre>
12</blockquote>
  
1> Example:
2>
3> sub status {
4> print "working";
5> }
6>
7> Or:
8>
9> sub status {
10> return "working";
11> }
  
1<ul>
2<li>
3<p>A list item with a code block</p>
4<pre><code>Some *code*
5</code></pre>
6</li>
7<li>
8<p>Another list item</p>
9<pre><code>More code
10
11And more code
12</code></pre>
13</li>
14</ul>
  
1* A list item with a code block
2
3 Some *code*
4
5* Another list item
6
7 More code
8
9 And more code
  
1<p>In Markdown 1.0.0 and earlier. Version
28. This line turns into a list item.
3Because a hard-wrapped line in the
4middle of a paragraph looked like a
5list item.</p>
6<p>Here's one with a bullet.
7* criminey.</p>
  
1In Markdown 1.0.0 and earlier. Version
28. This line turns into a list item.
3Because a hard-wrapped line in the
4middle of a paragraph looked like a
5list item.
6
7Here's one with a bullet.
8* criminey.
  
1<p>Dashes:</p>
2<hr />
3<hr />
4<hr />
5<hr />
6<pre><code>---
7</code></pre>
8<hr />
9<hr />
10<hr />
11<hr />
12<pre><code>- - -
13</code></pre>
14<p>Asterisks:</p>
15<hr />
16<hr />
17<hr />
18<hr />
19<pre><code>***
20</code></pre>
21<hr />
22<hr />
23<hr />
24<hr />
25<pre><code>* * *
26</code></pre>
27<p>Underscores:</p>
28<hr />
29<hr />
30<hr />
31<hr />
32<pre><code>___
33</code></pre>
34<hr />
35<hr />
36<hr />
37<hr />
38<pre><code>_ _ _
39</code></pre>
  
1Dashes:
2
3---
4
5 ---
6
7 ---
8
9 ---
10
11 ---
12
13- - -
14
15 - - -
16
17 - - -
18
19 - - -
20
21 - - -
22
23
24Asterisks:
25
26***
27
28 ***
29
30 ***
31
32 ***
33
34 ***
35
36* * *
37
38 * * *
39
40 * * *
41
42 * * *
43
44 * * *
45
46
47Underscores:
48
49___
50
51 ___
52
53 ___
54
55 ___
56
57 ___
58
59_ _ _
60
61 _ _ _
62
63 _ _ _
64
65 _ _ _
66
67 _ _ _
  
1<p>Simple block on one line:</p>
2<div>foo</div>
3
4<p>And nested without indentation:</p>
5<div>
6<div>
7<div>
8foo
9</div>
10</div>
11<div>bar</div>
12</div>
  
1Simple block on one line:
2
3<div>foo</div>
4
5And nested without indentation:
6
7<div>
8<div>
9<div>
10foo
11</div>
12</div>
13<div>bar</div>
14</div>
  
1<p>Paragraph one.</p>
2<!-- This is a simple comment -->
3
4<!--
5 This is another comment.
6-->
7
8<p>Paragraph two.</p>
9<!-- one comment block -- -- with two comments -->
10
11<p>The end.</p>
  
1Paragraph one.
2
3<!-- This is a simple comment -->
4
5<!--
6 This is another comment.
7-->
8
9Paragraph two.
10
11<!-- one comment block -- -- with two comments -->
12
13The end.
  
1<p>Here's a simple block:</p>
2<div>
3 foo
4</div>
5
6<p>This should be a code block, though:</p>
7<pre><code>&lt;div&gt;
8 foo
9&lt;/div&gt;
10</code></pre>
11<p>As should this:</p>
12<pre><code>&lt;div&gt;foo&lt;/div&gt;
13</code></pre>
14<p>Now, nested:</p>
15<div>
16 <div>
17 <div>
18 foo
19 </div>
20 </div>
21</div>
22
23<p>This should just be an HTML comment:</p>
24<!-- Comment -->
25
26<p>Multiline:</p>
27<!--
28Blah
29Blah
30-->
31
32<p>Code block:</p>
33<pre><code>&lt;!-- Comment --&gt;
34</code></pre>
35<p>Just plain comment, with trailing spaces on the line:</p>
36<!-- foo -->
37
38<p>Code:</p>
39<pre><code>&lt;hr /&gt;
40</code></pre>
41<p>Hr's:</p>
42<hr>
43
44<hr/>
45
46<hr />
47
48<hr>
49
50<hr/>
51
52<hr />
53
54<hr class="foo" id="bar" />
55
56<hr class="foo" id="bar"/>
57
58<hr class="foo" id="bar" >
  
1Here's a simple block:
2
3<div>
4 foo
5</div>
6
7This should be a code block, though:
8
9 <div>
10 foo
11 </div>
12
13As should this:
14
15 <div>foo</div>
16
17Now, nested:
18
19<div>
20 <div>
21 <div>
22 foo
23 </div>
24 </div>
25</div>
26
27This should just be an HTML comment:
28
29<!-- Comment -->
30
31Multiline:
32
33<!--
34Blah
35Blah
36-->
37
38Code block:
39
40 <!-- Comment -->
41
42Just plain comment, with trailing spaces on the line:
43
44<!-- foo -->
45
46Code:
47
48 <hr />
49
50Hr's:
51
52<hr>
53
54<hr/>
55
56<hr />
57
58<hr>
59
60<hr/>
61
62<hr />
63
64<hr class="foo" id="bar" />
65
66<hr class="foo" id="bar"/>
67
68<hr class="foo" id="bar" >
  
1<p>Just a <a href="/url/">URL</a>.</p>
2<p><a href="/url/" title="title">URL and title</a>.</p>
3<p><a href="/url/" title="title preceded by two spaces">URL and title</a>.</p>
4<p><a href="/url/" title="title preceded by a tab">URL and title</a>.</p>
5<p><a href="">Empty</a>.</p>
  
1Just a [URL](/url/).
2
3[URL and title](/url/ "title").
4
5[URL and title](/url/ "title preceded by two spaces").
6
7[URL and title](/url/ "title preceded by a tab").
8
9[Empty]().
  
1<p>Foo <a href="/url/" title="Title">bar</a>.</p>
2<p>Foo <a href="/url/" title="Title">bar</a>.</p>
3<p>Foo <a href="/url/" title="Title">bar</a>.</p>
4<p>With <a href="/url/">embedded [brackets]</a>.</p>
5<p>Indented <a href="/url">once</a>.</p>
6<p>Indented <a href="/url">twice</a>.</p>
7<p>Indented <a href="/url">thrice</a>.</p>
8<p>Indented [four][] times.</p>
9<pre><code>[four]: /url
10</code></pre>
  
1Foo [bar] [1].
2
3Foo [bar][1].
4
5Foo [bar]
6[1].
7
8[1]: /url/ "Title"
9
10
11With [embedded [brackets]] [b].
12
13
14Indented [once][].
15
16Indented [twice][].
17
18Indented [thrice][].
19
20Indented [four][] times.
21
22 [once]: /url
23
24 [twice]: /url
25
26 [thrice]: /url
27
28 [four]: /url
29
30
31[b]: /url/
  
1<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
2<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
  
1Foo [bar][].
2
3Foo [bar](/url/ "Title with "quotes" inside").
4
5
6 [bar]: /url/ "Title with "quotes" inside"
  
1<h1>Markdown: Basics</h1>
2<ul id="ProjectSubmenu">
3 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
4 <li><a class="selected" title="Markdown Basics">Basics</a></li>
5 <li><a href="/projects/markdown/syntax" 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<h2>Getting the Gist of Markdown's Formatting Syntax</h2>
11<p>This page offers a brief overview of what it's like to use Markdown.
12The <a href="/projects/markdown/syntax" title="Markdown Syntax">syntax page</a> provides complete, detailed documentation for
13every feature, but Markdown should be very easy to pick up simply by
14looking at a few examples of it in action. The examples on this page
15are written in a before/after style, showing example syntax and the
16HTML output produced by Markdown.</p>
17<p>It's also helpful to simply try Markdown out; the <a href="/projects/markdown/dingus" title="Markdown Dingus">Dingus</a> is a
18web application that allows you type your own Markdown-formatted text
19and translate it to XHTML.</p>
20<p><strong>Note:</strong> This document is itself written using Markdown; you
21can <a href="/projects/markdown/basics.text">see the source for it by adding '.text' to the URL</a>.</p>
22<h2>Paragraphs, Headers, Blockquotes</h2>
23<p>A paragraph is simply one or more consecutive lines of text, separated
24by one or more blank lines. (A blank line is any line that looks like a
25blank line -- a line containing nothing spaces or tabs is considered
26blank.) Normal paragraphs should not be intended with spaces or tabs.</p>
27<p>Markdown offers two styles of headers: <em>Setext</em> and <em>atx</em>.
28Setext-style headers for <code>&lt;h1&gt;</code> and <code>&lt;h2&gt;</code> are created by
29"underlining" with equal signs (<code>=</code>) and hyphens (<code>-</code>), respectively.
30To create an atx-style header, you put 1-6 hash marks (<code>#</code>) at the
31beginning of the line -- the number of hashes equals the resulting
32HTML header level.</p>
33<p>Blockquotes are indicated using email-style '<code>&gt;</code>' angle brackets.</p>
34<p>Markdown:</p>
35<pre><code>A First Level Header
36====================
37
38A Second Level Header
39---------------------
40
41Now is the time for all good men to come to
42the aid of their country. This is just a
43regular paragraph.
44
45The quick brown fox jumped over the lazy
46dog's back.
47
48### Header 3
49
50&gt; This is a blockquote.
51&gt;
52&gt; This is the second paragraph in the blockquote.
53&gt;
54&gt; ## This is an H2 in a blockquote
55</code></pre>
56<p>Output:</p>
57<pre><code>&lt;h1&gt;A First Level Header&lt;/h1&gt;
58
59&lt;h2&gt;A Second Level Header&lt;/h2&gt;
60
61&lt;p&gt;Now is the time for all good men to come to
62the aid of their country. This is just a
63regular paragraph.&lt;/p&gt;
64
65&lt;p&gt;The quick brown fox jumped over the lazy
66dog's back.&lt;/p&gt;
67
68&lt;h3&gt;Header 3&lt;/h3&gt;
69
70&lt;blockquote&gt;
71 &lt;p&gt;This is a blockquote.&lt;/p&gt;
72
73 &lt;p&gt;This is the second paragraph in the blockquote.&lt;/p&gt;
74
75 &lt;h2&gt;This is an H2 in a blockquote&lt;/h2&gt;
76&lt;/blockquote&gt;
77</code></pre>
78<h3>Phrase Emphasis</h3>
79<p>Markdown uses asterisks and underscores to indicate spans of emphasis.</p>
80<p>Markdown:</p>
81<pre><code>Some of these words *are emphasized*.
82Some of these words _are emphasized also_.
83
84Use two asterisks for **strong emphasis**.
85Or, if you prefer, __use two underscores instead__.
86</code></pre>
87<p>Output:</p>
88<pre><code>&lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
89Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
90
91&lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
92Or, if you prefer, &lt;strong&gt;use two underscores instead&lt;/strong&gt;.&lt;/p&gt;
93</code></pre>
94<h2>Lists</h2>
95<p>Unordered (bulleted) lists use asterisks, pluses, and hyphens (<code>*</code>,
96<code>+</code>, and <code>-</code>) as list markers. These three markers are
97interchangable; this:</p>
98<pre><code>* Candy.
99* Gum.
100* Booze.
101</code></pre>
102<p>this:</p>
103<pre><code>+ Candy.
104+ Gum.
105+ Booze.
106</code></pre>
107<p>and this:</p>
108<pre><code>- Candy.
109- Gum.
110- Booze.
111</code></pre>
112<p>all produce the same output:</p>
113<pre><code>&lt;ul&gt;
114&lt;li&gt;Candy.&lt;/li&gt;
115&lt;li&gt;Gum.&lt;/li&gt;
116&lt;li&gt;Booze.&lt;/li&gt;
117&lt;/ul&gt;
118</code></pre>
119<p>Ordered (numbered) lists use regular numbers, followed by periods, as
120list markers:</p>
121<pre><code>1. Red
1222. Green
1233. Blue
124</code></pre>
125<p>Output:</p>
126<pre><code>&lt;ol&gt;
127&lt;li&gt;Red&lt;/li&gt;
128&lt;li&gt;Green&lt;/li&gt;
129&lt;li&gt;Blue&lt;/li&gt;
130&lt;/ol&gt;
131</code></pre>
132<p>If you put blank lines between items, you'll get <code>&lt;p&gt;</code> tags for the
133list item text. You can create multi-paragraph list items by indenting
134the paragraphs by 4 spaces or 1 tab:</p>
135<pre><code>* A list item.
136
137 With multiple paragraphs.
138
139* Another item in the list.
140</code></pre>
141<p>Output:</p>
142<pre><code>&lt;ul&gt;
143&lt;li&gt;&lt;p&gt;A list item.&lt;/p&gt;
144&lt;p&gt;With multiple paragraphs.&lt;/p&gt;&lt;/li&gt;
145&lt;li&gt;&lt;p&gt;Another item in the list.&lt;/p&gt;&lt;/li&gt;
146&lt;/ul&gt;
147</code></pre>
148<h3>Links</h3>
149<p>Markdown supports two styles for creating links: <em>inline</em> and
150<em>reference</em>. With both styles, you use square brackets to delimit the
151text you want to turn into a link.</p>
152<p>Inline-style links use parentheses immediately after the link text.
153For example:</p>
154<pre><code>This is an [example link](http://example.com/).
155</code></pre>
156<p>Output:</p>
157<pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/"&gt;
158example link&lt;/a&gt;.&lt;/p&gt;
159</code></pre>
160<p>Optionally, you may include a title attribute in the parentheses:</p>
161<pre><code>This is an [example link](http://example.com/ "With a Title").
162</code></pre>
163<p>Output:</p>
164<pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/" title="With a Title"&gt;
165example link&lt;/a&gt;.&lt;/p&gt;
166</code></pre>
167<p>Reference-style links allow you to refer to your links by names, which
168you define elsewhere in your document:</p>
169<pre><code>I get 10 times more traffic from [Google][1] than from
170[Yahoo][2] or [MSN][3].
171
172[1]: http://google.com/ "Google"
173[2]: http://search.yahoo.com/ "Yahoo Search"
174[3]: http://search.msn.com/ "MSN Search"
175</code></pre>
176<p>Output:</p>
177<pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
178title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
179title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
180title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
181</code></pre>
182<p>The title attribute is optional. Link names may contain letters,
183numbers and spaces, but are <em>not</em> case sensitive:</p>
184<pre><code>I start my morning with a cup of coffee and
185[The New York Times][NY Times].
186
187[ny times]: http://www.nytimes.com/
188</code></pre>
189<p>Output:</p>
190<pre><code>&lt;p&gt;I start my morning with a cup of coffee and
191&lt;a href="http://www.nytimes.com/"&gt;The New York Times&lt;/a&gt;.&lt;/p&gt;
192</code></pre>
193<h3>Images</h3>
194<p>Image syntax is very much like link syntax.</p>
195<p>Inline (titles are optional):</p>
196<pre><code>![alt text](/path/to/img.jpg "Title")
197</code></pre>
198<p>Reference-style:</p>
199<pre><code>![alt text][id]
200
201[id]: /path/to/img.jpg "Title"
202</code></pre>
203<p>Both of the above examples produce the same output:</p>
204<pre><code>&lt;img src="/path/to/img.jpg" alt="alt text" title="Title" /&gt;
205</code></pre>
206<h3>Code</h3>
207<p>In a regular paragraph, you can create code span by wrapping text in
208backtick quotes. Any ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> or
209<code>&gt;</code>) will automatically be translated into HTML entities. This makes
210it easy to use Markdown to write about HTML example code:</p>
211<pre><code>I strongly recommend against using any `&lt;blink&gt;` tags.
212
213I wish SmartyPants used named entities like `&amp;mdash;`
214instead of decimal-encoded entites like `&amp;#8212;`.
215</code></pre>
216<p>Output:</p>
217<pre><code>&lt;p&gt;I strongly recommend against using any
218&lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
219
220&lt;p&gt;I wish SmartyPants used named entities like
221&lt;code&gt;&amp;amp;mdash;&lt;/code&gt; instead of decimal-encoded
222entites like &lt;code&gt;&amp;amp;#8212;&lt;/code&gt;.&lt;/p&gt;
223</code></pre>
224<p>To specify an entire block of pre-formatted code, indent every line of
225the block by 4 spaces or 1 tab. Just like with code spans, <code>&amp;</code>, <code>&lt;</code>,
226and <code>&gt;</code> characters will be escaped automatically.</p>
227<p>Markdown:</p>
228<pre><code>If you want your page to validate under XHTML 1.0 Strict,
229you've got to put paragraph tags in your blockquotes:
230
231 &lt;blockquote&gt;
232 &lt;p&gt;For example.&lt;/p&gt;
233 &lt;/blockquote&gt;
234</code></pre>
235<p>Output:</p>
236<pre><code>&lt;p&gt;If you want your page to validate under XHTML 1.0 Strict,
237you've got to put paragraph tags in your blockquotes:&lt;/p&gt;
238
239&lt;pre&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;
240 &amp;lt;p&amp;gt;For example.&amp;lt;/p&amp;gt;
241&amp;lt;/blockquote&amp;gt;
242&lt;/code&gt;&lt;/pre&gt;
243</code></pre>
  
1Markdown: Basics
2================
3
4<ul id="ProjectSubmenu">
5 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
6 <li><a class="selected" title="Markdown Basics">Basics</a></li>
7 <li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
8 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
9 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
10</ul>
11
12
13Getting the Gist of Markdown's Formatting Syntax
14------------------------------------------------
15
16This page offers a brief overview of what it's like to use Markdown.
17The [syntax page] [s] provides complete, detailed documentation for
18every feature, but Markdown should be very easy to pick up simply by
19looking at a few examples of it in action. The examples on this page
20are written in a before/after style, showing example syntax and the
21HTML output produced by Markdown.
22
23It's also helpful to simply try Markdown out; the [Dingus] [d] is a
24web application that allows you type your own Markdown-formatted text
25and translate it to XHTML.
26
27**Note:** This document is itself written using Markdown; you
28can [see the source for it by adding '.text' to the URL] [src].
29
30 [s]: /projects/markdown/syntax "Markdown Syntax"
31 [d]: /projects/markdown/dingus "Markdown Dingus"
32 [src]: /projects/markdown/basics.text
33
34
35## Paragraphs, Headers, Blockquotes ##
36
37A paragraph is simply one or more consecutive lines of text, separated
38by one or more blank lines. (A blank line is any line that looks like a
39blank line -- a line containing nothing spaces or tabs is considered
40blank.) Normal paragraphs should not be intended with spaces or tabs.
41
42Markdown offers two styles of headers: *Setext* and *atx*.
43Setext-style headers for `<h1>` and `<h2>` are created by
44"underlining" with equal signs (`=`) and hyphens (`-`), respectively.
45To create an atx-style header, you put 1-6 hash marks (`#`) at the
46beginning of the line -- the number of hashes equals the resulting
47HTML header level.
48
49Blockquotes are indicated using email-style '`>`' angle brackets.
50
51Markdown:
52
53 A First Level Header
54 ====================
55
56 A Second Level Header
57 ---------------------
58
59 Now is the time for all good men to come to
60 the aid of their country. This is just a
61 regular paragraph.
62
63 The quick brown fox jumped over the lazy
64 dog's back.
65
66 ### Header 3
67
68 > This is a blockquote.
69 >
70 > This is the second paragraph in the blockquote.
71 >
72 > ## This is an H2 in a blockquote
73
74
75Output:
76
77 <h1>A First Level Header</h1>
78
79 <h2>A Second Level Header</h2>
80
81 <p>Now is the time for all good men to come to
82 the aid of their country. This is just a
83 regular paragraph.</p>
84
85 <p>The quick brown fox jumped over the lazy
86 dog's back.</p>
87
88 <h3>Header 3</h3>
89
90 <blockquote>
91 <p>This is a blockquote.</p>
92
93 <p>This is the second paragraph in the blockquote.</p>
94
95 <h2>This is an H2 in a blockquote</h2>
96 </blockquote>
97
98
99
100### Phrase Emphasis ###
101
102Markdown uses asterisks and underscores to indicate spans of emphasis.
103
104Markdown:
105
106 Some of these words *are emphasized*.
107 Some of these words _are emphasized also_.
108
109 Use two asterisks for **strong emphasis**.
110 Or, if you prefer, __use two underscores instead__.
111
112Output:
113
114 <p>Some of these words <em>are emphasized</em>.
115 Some of these words <em>are emphasized also</em>.</p>
116
117 <p>Use two asterisks for <strong>strong emphasis</strong>.
118 Or, if you prefer, <strong>use two underscores instead</strong>.</p>
119
120
121
122## Lists ##
123
124Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
125`+`, and `-`) as list markers. These three markers are
126interchangable; this:
127
128 * Candy.
129 * Gum.
130 * Booze.
131
132this:
133
134 + Candy.
135 + Gum.
136 + Booze.
137
138and this:
139
140 - Candy.
141 - Gum.
142 - Booze.
143
144all produce the same output:
145
146 <ul>
147 <li>Candy.</li>
148 <li>Gum.</li>
149 <li>Booze.</li>
150 </ul>
151
152Ordered (numbered) lists use regular numbers, followed by periods, as
153list markers:
154
155 1. Red
156 2. Green
157 3. Blue
158
159Output:
160
161 <ol>
162 <li>Red</li>
163 <li>Green</li>
164 <li>Blue</li>
165 </ol>
166
167If you put blank lines between items, you'll get `<p>` tags for the
168list item text. You can create multi-paragraph list items by indenting
169the paragraphs by 4 spaces or 1 tab:
170
171 * A list item.
172
173 With multiple paragraphs.
174
175 * Another item in the list.
176
177Output:
178
179 <ul>
180 <li><p>A list item.</p>
181 <p>With multiple paragraphs.</p></li>
182 <li><p>Another item in the list.</p></li>
183 </ul>
184
185
186
187### Links ###
188
189Markdown supports two styles for creating links: *inline* and
190*reference*. With both styles, you use square brackets to delimit the
191text you want to turn into a link.
192
193Inline-style links use parentheses immediately after the link text.
194For example:
195
196 This is an [example link](http://example.com/).
197
198Output:
199
200 <p>This is an <a href="http://example.com/">
201 example link</a>.</p>
202
203Optionally, you may include a title attribute in the parentheses:
204
205 This is an [example link](http://example.com/ "With a Title").
206
207Output:
208
209 <p>This is an <a href="http://example.com/" title="With a Title">
210 example link</a>.</p>
211
212Reference-style links allow you to refer to your links by names, which
213you define elsewhere in your document:
214
215 I get 10 times more traffic from [Google][1] than from
216 [Yahoo][2] or [MSN][3].
217
218 [1]: http://google.com/ "Google"
219 [2]: http://search.yahoo.com/ "Yahoo Search"
220 [3]: http://search.msn.com/ "MSN Search"
221
222Output:
223
224 <p>I get 10 times more traffic from <a href="http://google.com/"
225 title="Google">Google</a> than from <a href="http://search.yahoo.com/"
226 title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
227 title="MSN Search">MSN</a>.</p>
228
229The title attribute is optional. Link names may contain letters,
230numbers and spaces, but are *not* case sensitive:
231
232 I start my morning with a cup of coffee and
233 [The New York Times][NY Times].
234
235 [ny times]: http://www.nytimes.com/
236
237Output:
238
239 <p>I start my morning with a cup of coffee and
240 <a href="http://www.nytimes.com/">The New York Times</a>.</p>
241
242
243### Images ###
244
245Image syntax is very much like link syntax.
246
247Inline (titles are optional):
248
249 ![alt text](/path/to/img.jpg "Title")
250
251Reference-style:
252
253 ![alt text][id]
254
255 [id]: /path/to/img.jpg "Title"
256
257Both of the above examples produce the same output:
258
259 <img src="/path/to/img.jpg" alt="alt text" title="Title" />
260
261
262
263### Code ###
264
265In a regular paragraph, you can create code span by wrapping text in
266backtick quotes. Any ampersands (`&`) and angle brackets (`<` or
267`>`) will automatically be translated into HTML entities. This makes
268it easy to use Markdown to write about HTML example code:
269
270 I strongly recommend against using any `<blink>` tags.
271
272 I wish SmartyPants used named entities like `&mdash;`
273 instead of decimal-encoded entites like `&#8212;`.
274
275Output:
276
277 <p>I strongly recommend against using any
278 <code>&lt;blink&gt;</code> tags.</p>
279
280 <p>I wish SmartyPants used named entities like
281 <code>&amp;mdash;</code> instead of decimal-encoded
282 entites like <code>&amp;#8212;</code>.</p>
283
284
285To specify an entire block of pre-formatted code, indent every line of
286the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`,
287and `>` characters will be escaped automatically.
288
289Markdown:
290
291 If you want your page to validate under XHTML 1.0 Strict,
292 you've got to put paragraph tags in your blockquotes:
293
294 <blockquote>
295 <p>For example.</p>
296 </blockquote>
297
298Output:
299
300 <p>If you want your page to validate under XHTML 1.0 Strict,
301 you've got to put paragraph tags in your blockquotes:</p>
302
303 <pre><code>&lt;blockquote&gt;
304 &lt;p&gt;For example.&lt;/p&gt;
305 &lt;/blockquote&gt;
306 </code></pre>
  
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
40can <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
48document should be publishable as-is, as plain text, without looking
49like it's been marked up with tags or formatting instructions. While
50Markdown's syntax has been influenced by several existing text-to-HTML
51filters -- 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
53inspiration 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
55characters, which punctuation characters have been carefully chosen so
56as to look like what they mean. E.g., asterisks around a word actually
57look like *emphasis*. Markdown lists look like, well, lists. Even
58blockquotes look like quoted passages of text, assuming you've ever
59used 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
63format for <em>writing</em> for the web.</p>
64<p>Markdown is not a replacement for HTML, or even close to it. Its
65syntax is very small, corresponding only to a very small subset of
66HTML tags. The idea is <em>not</em> to create a syntax that makes it easier
67to insert HTML tags. In my opinion, HTML tags are already easy to
68insert. The idea for Markdown is to make it easy to read, write, and
69edit prose. HTML is a <em>publishing</em> format; Markdown is a <em>writing</em>
70format. Thus, Markdown's formatting syntax only addresses issues that
71can be conveyed in plain text.</p>
72<p>For any markup that is not covered by Markdown's syntax, you simply
73use HTML itself. There's no need to preface it or delimit it to
74indicate that you're switching from Markdown to HTML; you just use
75the 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
78content by blank lines, and the start and end tags of the block should
79not be indented with tabs or spaces. Markdown is smart enough not
80to 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
90This is another regular paragraph.
91</code></pre>
92<p>Note that Markdown formatting syntax is not processed within block-level
93HTML tags. E.g., you can't use Markdown-style <code>*emphasis*</code> inside an
94HTML 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
96used anywhere in a Markdown paragraph, list item, or header. If you
97want, you can even use HTML tags instead of Markdown formatting; e.g. if
98you'd prefer to use HTML <code>&lt;a&gt;</code> or <code>&lt;img&gt;</code> tags instead of Markdown's
99link or image syntax, go right ahead.</p>
100<p>Unlike block-level HTML tags, Markdown syntax <em>is</em> processed within
101span-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>
105and <code>&amp;</code>. Left angle brackets are used to start tags; ampersands are
106used to denote HTML entities. If you want to use them as literal
107characters, 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
110write about 'AT&amp;T', you need to write '<code>AT&amp;amp;T</code>'. You even need to
111escape 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