Home | History | Annotate | Download | only in markdown-test
      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.
     12 The <a href="/projects/markdown/syntax" title="Markdown Syntax">syntax page</a> provides complete, detailed documentation for
     13 every feature, but Markdown should be very easy to pick up simply by
     14 looking at a few examples of it in action. The examples on this page
     15 are written in a before/after style, showing example syntax and the
     16 HTML 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
     18 web application that allows you type your own Markdown-formatted text
     19 and translate it to XHTML.</p>
     20 <p><strong>Note:</strong> This document is itself written using Markdown; you
     21 can <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
     24 by one or more blank lines. (A blank line is any line that looks like a
     25 blank line -- a line containing nothing spaces or tabs is considered
     26 blank.) 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>.
     28 Setext-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.
     30 To create an atx-style header, you put 1-6 hash marks (<code>#</code>) at the
     31 beginning of the line -- the number of hashes equals the resulting
     32 HTML 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 
     38 A Second Level Header
     39 ---------------------
     40 
     41 Now is the time for all good men to come to
     42 the aid of their country. This is just a
     43 regular paragraph.
     44 
     45 The quick brown fox jumped over the lazy
     46 dog'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
     62 the aid of their country. This is just a
     63 regular paragraph.&lt;/p&gt;
     64 
     65 &lt;p&gt;The quick brown fox jumped over the lazy
     66 dog'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*.
     82 Some of these words _are emphasized also_.
     83 
     84 Use two asterisks for **strong emphasis**.
     85 Or, 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;.
     89 Some 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;.
     92 Or, 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
     97 interchangable; 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
    120 list markers:</p>
    121 <pre><code>1.  Red
    122 2.  Green
    123 3.  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
    133 list item text. You can create multi-paragraph list items by indenting
    134 the 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
    151 text you want to turn into a link.</p>
    152 <p>Inline-style links use parentheses immediately after the link text.
    153 For 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;
    158 example 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;
    165 example 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
    168 you 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/"
    178 title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
    179 title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
    180 title="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,
    183 numbers 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
    208 backtick 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
    210 it 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 
    213 I wish SmartyPants used named entities like `&amp;mdash;`
    214 instead 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
    222 entites 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
    225 the block by 4 spaces or 1 tab. Just like with code spans, <code>&amp;</code>, <code>&lt;</code>,
    226 and <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,
    229 you'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,
    237 you'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>