markdown_documentation_basics.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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. <h2>Getting the Gist of Markdown's Formatting Syntax</h2>
  10. <p>This page offers a brief overview of what it's like to use Markdown.
  11. The <a href="/projects/markdown/syntax" title="Markdown Syntax">syntax page</a> provides complete, detailed documentation for
  12. every feature, but Markdown should be very easy to pick up simply by
  13. looking at a few examples of it in action. The examples on this page
  14. are written in a before/after style, showing example syntax and the
  15. HTML output produced by Markdown.</p>
  16. <p>It's also helpful to simply try Markdown out; the <a href="/projects/markdown/dingus" title="Markdown Dingus">Dingus</a> is a
  17. web application that allows you type your own Markdown-formatted text
  18. and translate it to XHTML.</p>
  19. <p><strong>Note:</strong> This document is itself written using Markdown; you
  20. can <a href="/projects/markdown/basics.text">see the source for it by adding '.text' to the URL</a>.</p>
  21. <h2>Paragraphs, Headers, Blockquotes</h2>
  22. <p>A paragraph is simply one or more consecutive lines of text, separated
  23. by one or more blank lines. (A blank line is any line that looks like a
  24. blank line -- a line containing nothing spaces or tabs is considered
  25. blank.) Normal paragraphs should not be intended with spaces or tabs.</p>
  26. <p>Markdown offers two styles of headers: <em>Setext</em> and <em>atx</em>.
  27. Setext-style headers for <code>&lt;h1&gt;</code> and <code>&lt;h2&gt;</code> are created by
  28. "underlining" with equal signs (<code>=</code>) and hyphens (<code>-</code>), respectively.
  29. To create an atx-style header, you put 1-6 hash marks (<code>#</code>) at the
  30. beginning of the line -- the number of hashes equals the resulting
  31. HTML header level.</p>
  32. <p>Blockquotes are indicated using email-style '<code>&gt;</code>' angle brackets.</p>
  33. <p>Markdown:</p>
  34. <pre><code>A First Level Header
  35. ====================
  36. A Second Level Header
  37. ---------------------
  38. Now is the time for all good men to come to
  39. the aid of their country. This is just a
  40. regular paragraph.
  41. The quick brown fox jumped over the lazy
  42. dog's back.
  43. ### Header 3
  44. &gt; This is a blockquote.
  45. &gt;
  46. &gt; This is the second paragraph in the blockquote.
  47. &gt;
  48. &gt; ## This is an H2 in a blockquote
  49. </code></pre>
  50. <p>Output:</p>
  51. <pre><code>&lt;h1&gt;A First Level Header&lt;/h1&gt;
  52. &lt;h2&gt;A Second Level Header&lt;/h2&gt;
  53. &lt;p&gt;Now is the time for all good men to come to
  54. the aid of their country. This is just a
  55. regular paragraph.&lt;/p&gt;
  56. &lt;p&gt;The quick brown fox jumped over the lazy
  57. dog's back.&lt;/p&gt;
  58. &lt;h3&gt;Header 3&lt;/h3&gt;
  59. &lt;blockquote&gt;
  60. &lt;p&gt;This is a blockquote.&lt;/p&gt;
  61. &lt;p&gt;This is the second paragraph in the blockquote.&lt;/p&gt;
  62. &lt;h2&gt;This is an H2 in a blockquote&lt;/h2&gt;
  63. &lt;/blockquote&gt;
  64. </code></pre>
  65. <h3>Phrase Emphasis</h3>
  66. <p>Markdown uses asterisks and underscores to indicate spans of emphasis.</p>
  67. <p>Markdown:</p>
  68. <pre><code>Some of these words *are emphasized*.
  69. Some of these words _are emphasized also_.
  70. Use two asterisks for **strong emphasis**.
  71. Or, if you prefer, __use two underscores instead__.
  72. </code></pre>
  73. <p>Output:</p>
  74. <pre><code>&lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
  75. Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
  76. &lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
  77. Or, if you prefer, &lt;strong&gt;use two underscores instead&lt;/strong&gt;.&lt;/p&gt;
  78. </code></pre>
  79. <h2>Lists</h2>
  80. <p>Unordered (bulleted) lists use asterisks, pluses, and hyphens (<code>*</code>,
  81. <code>+</code>, and <code>-</code>) as list markers. These three markers are
  82. interchangable; this:</p>
  83. <pre><code>* Candy.
  84. * Gum.
  85. * Booze.
  86. </code></pre>
  87. <p>this:</p>
  88. <pre><code>+ Candy.
  89. + Gum.
  90. + Booze.
  91. </code></pre>
  92. <p>and this:</p>
  93. <pre><code>- Candy.
  94. - Gum.
  95. - Booze.
  96. </code></pre>
  97. <p>all produce the same output:</p>
  98. <pre><code>&lt;ul&gt;
  99. &lt;li&gt;Candy.&lt;/li&gt;
  100. &lt;li&gt;Gum.&lt;/li&gt;
  101. &lt;li&gt;Booze.&lt;/li&gt;
  102. &lt;/ul&gt;
  103. </code></pre>
  104. <p>Ordered (numbered) lists use regular numbers, followed by periods, as
  105. list markers:</p>
  106. <pre><code>1. Red
  107. 2. Green
  108. 3. Blue
  109. </code></pre>
  110. <p>Output:</p>
  111. <pre><code>&lt;ol&gt;
  112. &lt;li&gt;Red&lt;/li&gt;
  113. &lt;li&gt;Green&lt;/li&gt;
  114. &lt;li&gt;Blue&lt;/li&gt;
  115. &lt;/ol&gt;
  116. </code></pre>
  117. <p>If you put blank lines between items, you'll get <code>&lt;p&gt;</code> tags for the
  118. list item text. You can create multi-paragraph list items by indenting
  119. the paragraphs by 4 spaces or 1 tab:</p>
  120. <pre><code>* A list item.
  121. With multiple paragraphs.
  122. * Another item in the list.
  123. </code></pre>
  124. <p>Output:</p>
  125. <pre><code>&lt;ul&gt;
  126. &lt;li&gt;&lt;p&gt;A list item.&lt;/p&gt;
  127. &lt;p&gt;With multiple paragraphs.&lt;/p&gt;&lt;/li&gt;
  128. &lt;li&gt;&lt;p&gt;Another item in the list.&lt;/p&gt;&lt;/li&gt;
  129. &lt;/ul&gt;
  130. </code></pre>
  131. <h3>Links</h3>
  132. <p>Markdown supports two styles for creating links: <em>inline</em> and
  133. <em>reference</em>. With both styles, you use square brackets to delimit the
  134. text you want to turn into a link.</p>
  135. <p>Inline-style links use parentheses immediately after the link text.
  136. For example:</p>
  137. <pre><code>This is an [example link](http://example.com/).
  138. </code></pre>
  139. <p>Output:</p>
  140. <pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/"&gt;
  141. example link&lt;/a&gt;.&lt;/p&gt;
  142. </code></pre>
  143. <p>Optionally, you may include a title attribute in the parentheses:</p>
  144. <pre><code>This is an [example link](http://example.com/ "With a Title").
  145. </code></pre>
  146. <p>Output:</p>
  147. <pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/" title="With a Title"&gt;
  148. example link&lt;/a&gt;.&lt;/p&gt;
  149. </code></pre>
  150. <p>Reference-style links allow you to refer to your links by names, which
  151. you define elsewhere in your document:</p>
  152. <pre><code>I get 10 times more traffic from [Google][1] than from
  153. [Yahoo][2] or [MSN][3].
  154. [1]: http://google.com/ "Google"
  155. [2]: http://search.yahoo.com/ "Yahoo Search"
  156. [3]: http://search.msn.com/ "MSN Search"
  157. </code></pre>
  158. <p>Output:</p>
  159. <pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
  160. title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
  161. title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
  162. title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
  163. </code></pre>
  164. <p>The title attribute is optional. Link names may contain letters,
  165. numbers and spaces, but are <em>not</em> case sensitive:</p>
  166. <pre><code>I start my morning with a cup of coffee and
  167. [The New York Times][NY Times].
  168. [ny times]: http://www.nytimes.com/
  169. </code></pre>
  170. <p>Output:</p>
  171. <pre><code>&lt;p&gt;I start my morning with a cup of coffee and
  172. &lt;a href="http://www.nytimes.com/"&gt;The New York Times&lt;/a&gt;.&lt;/p&gt;
  173. </code></pre>
  174. <h3>Images</h3>
  175. <p>Image syntax is very much like link syntax.</p>
  176. <p>Inline (titles are optional):</p>
  177. <pre><code>![alt text](/path/to/img.jpg "Title")
  178. </code></pre>
  179. <p>Reference-style:</p>
  180. <pre><code>![alt text][id]
  181. [id]: /path/to/img.jpg "Title"
  182. </code></pre>
  183. <p>Both of the above examples produce the same output:</p>
  184. <pre><code>&lt;img src="/path/to/img.jpg" alt="alt text" title="Title" /&gt;
  185. </code></pre>
  186. <h3>Code</h3>
  187. <p>In a regular paragraph, you can create code span by wrapping text in
  188. backtick quotes. Any ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> or
  189. <code>&gt;</code>) will automatically be translated into HTML entities. This makes
  190. it easy to use Markdown to write about HTML example code:</p>
  191. <pre><code>I strongly recommend against using any `&lt;blink&gt;` tags.
  192. I wish SmartyPants used named entities like `&amp;mdash;`
  193. instead of decimal-encoded entites like `&amp;#8212;`.
  194. </code></pre>
  195. <p>Output:</p>
  196. <pre><code>&lt;p&gt;I strongly recommend against using any
  197. &lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
  198. &lt;p&gt;I wish SmartyPants used named entities like
  199. &lt;code&gt;&amp;amp;mdash;&lt;/code&gt; instead of decimal-encoded
  200. entites like &lt;code&gt;&amp;amp;#8212;&lt;/code&gt;.&lt;/p&gt;
  201. </code></pre>
  202. <p>To specify an entire block of pre-formatted code, indent every line of
  203. the block by 4 spaces or 1 tab. Just like with code spans, <code>&amp;</code>, <code>&lt;</code>,
  204. and <code>&gt;</code> characters will be escaped automatically.</p>
  205. <p>Markdown:</p>
  206. <pre><code>If you want your page to validate under XHTML 1.0 Strict,
  207. you've got to put paragraph tags in your blockquotes:
  208. &lt;blockquote&gt;
  209. &lt;p&gt;For example.&lt;/p&gt;
  210. &lt;/blockquote&gt;
  211. </code></pre>
  212. <p>Output:</p>
  213. <pre><code>&lt;p&gt;If you want your page to validate under XHTML 1.0 Strict,
  214. you've got to put paragraph tags in your blockquotes:&lt;/p&gt;
  215. &lt;pre&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;
  216. &amp;lt;p&amp;gt;For example.&amp;lt;/p&amp;gt;
  217. &amp;lt;/blockquote&amp;gt;
  218. &lt;/code&gt;&lt;/pre&gt;
  219. </code></pre>