markdown_documentation_basics.text 7.9 KB

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