index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <!doctype html>
  2. <title>CodeMirror: Markdown mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="../../addon/edit/continuelist.js"></script>
  8. <script src="../xml/xml.js"></script>
  9. <script src="markdown.js"></script>
  10. <style type="text/css">
  11. .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
  12. .cm-s-default .cm-trailing-space-a:before,
  13. .cm-s-default .cm-trailing-space-b:before {position: absolute; content: "\00B7"; color: #777;}
  14. .cm-s-default .cm-trailing-space-new-line:before {position: absolute; content: "\21B5"; color: #777;}
  15. </style>
  16. <div id=nav>
  17. <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
  18. <ul>
  19. <li><a href="../../index.html">Home</a>
  20. <li><a href="../../doc/manual.html">Manual</a>
  21. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  22. </ul>
  23. <ul>
  24. <li><a href="../index.html">Language modes</a>
  25. <li><a class=active href="#">Markdown</a>
  26. </ul>
  27. </div>
  28. <article>
  29. <h2>Markdown mode</h2>
  30. <form><textarea id="code" name="code">
  31. Markdown: Basics
  32. ================
  33. &lt;ul id="ProjectSubmenu"&gt;
  34. &lt;li&gt;&lt;a href="/projects/markdown/" title="Markdown Project Page"&gt;Main&lt;/a&gt;&lt;/li&gt;
  35. &lt;li&gt;&lt;a class="selected" title="Markdown Basics"&gt;Basics&lt;/a&gt;&lt;/li&gt;
  36. &lt;li&gt;&lt;a href="/projects/markdown/syntax" title="Markdown Syntax Documentation"&gt;Syntax&lt;/a&gt;&lt;/li&gt;
  37. &lt;li&gt;&lt;a href="/projects/markdown/license" title="Pricing and License Information"&gt;License&lt;/a&gt;&lt;/li&gt;
  38. &lt;li&gt;&lt;a href="/projects/markdown/dingus" title="Online Markdown Web Form"&gt;Dingus&lt;/a&gt;&lt;/li&gt;
  39. &lt;/ul&gt;
  40. Getting the Gist of Markdown's Formatting Syntax
  41. ------------------------------------------------
  42. This page offers a brief overview of what it's like to use Markdown.
  43. The [syntax page] [s] provides complete, detailed documentation for
  44. every feature, but Markdown should be very easy to pick up simply by
  45. looking at a few examples of it in action. The examples on this page
  46. are written in a before/after style, showing example syntax and the
  47. HTML output produced by Markdown.
  48. It's also helpful to simply try Markdown out; the [Dingus] [d] is a
  49. web application that allows you type your own Markdown-formatted text
  50. and translate it to XHTML.
  51. **Note:** This document is itself written using Markdown; you
  52. can [see the source for it by adding '.text' to the URL] [src].
  53. [s]: /projects/markdown/syntax "Markdown Syntax"
  54. [d]: /projects/markdown/dingus "Markdown Dingus"
  55. [src]: /projects/markdown/basics.text
  56. ## Paragraphs, Headers, Blockquotes ##
  57. A paragraph is simply one or more consecutive lines of text, separated
  58. by one or more blank lines. (A blank line is any line that looks like
  59. a blank line -- a line containing nothing but spaces or tabs is
  60. considered blank.) Normal paragraphs should not be indented with
  61. spaces or tabs.
  62. Markdown offers two styles of headers: *Setext* and *atx*.
  63. Setext-style headers for `&lt;h1&gt;` and `&lt;h2&gt;` are created by
  64. "underlining" with equal signs (`=`) and hyphens (`-`), respectively.
  65. To create an atx-style header, you put 1-6 hash marks (`#`) at the
  66. beginning of the line -- the number of hashes equals the resulting
  67. HTML header level.
  68. Blockquotes are indicated using email-style '`&gt;`' angle brackets.
  69. Markdown:
  70. A First Level Header
  71. ====================
  72. A Second Level Header
  73. ---------------------
  74. Now is the time for all good men to come to
  75. the aid of their country. This is just a
  76. regular paragraph.
  77. The quick brown fox jumped over the lazy
  78. dog's back.
  79. ### Header 3
  80. &gt; This is a blockquote.
  81. &gt;
  82. &gt; This is the second paragraph in the blockquote.
  83. &gt;
  84. &gt; ## This is an H2 in a blockquote
  85. Output:
  86. &lt;h1&gt;A First Level Header&lt;/h1&gt;
  87. &lt;h2&gt;A Second Level Header&lt;/h2&gt;
  88. &lt;p&gt;Now is the time for all good men to come to
  89. the aid of their country. This is just a
  90. regular paragraph.&lt;/p&gt;
  91. &lt;p&gt;The quick brown fox jumped over the lazy
  92. dog's back.&lt;/p&gt;
  93. &lt;h3&gt;Header 3&lt;/h3&gt;
  94. &lt;blockquote&gt;
  95. &lt;p&gt;This is a blockquote.&lt;/p&gt;
  96. &lt;p&gt;This is the second paragraph in the blockquote.&lt;/p&gt;
  97. &lt;h2&gt;This is an H2 in a blockquote&lt;/h2&gt;
  98. &lt;/blockquote&gt;
  99. ### Phrase Emphasis ###
  100. Markdown uses asterisks and underscores to indicate spans of emphasis.
  101. Markdown:
  102. Some of these words *are emphasized*.
  103. Some of these words _are emphasized also_.
  104. Use two asterisks for **strong emphasis**.
  105. Or, if you prefer, __use two underscores instead__.
  106. Output:
  107. &lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
  108. Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
  109. &lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
  110. Or, if you prefer, &lt;strong&gt;use two underscores instead&lt;/strong&gt;.&lt;/p&gt;
  111. ## Lists ##
  112. Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
  113. `+`, and `-`) as list markers. These three markers are
  114. interchangable; this:
  115. * Candy.
  116. * Gum.
  117. * Booze.
  118. this:
  119. + Candy.
  120. + Gum.
  121. + Booze.
  122. and this:
  123. - Candy.
  124. - Gum.
  125. - Booze.
  126. all produce the same output:
  127. &lt;ul&gt;
  128. &lt;li&gt;Candy.&lt;/li&gt;
  129. &lt;li&gt;Gum.&lt;/li&gt;
  130. &lt;li&gt;Booze.&lt;/li&gt;
  131. &lt;/ul&gt;
  132. Ordered (numbered) lists use regular numbers, followed by periods, as
  133. list markers:
  134. 1. Red
  135. 2. Green
  136. 3. Blue
  137. Output:
  138. &lt;ol&gt;
  139. &lt;li&gt;Red&lt;/li&gt;
  140. &lt;li&gt;Green&lt;/li&gt;
  141. &lt;li&gt;Blue&lt;/li&gt;
  142. &lt;/ol&gt;
  143. If you put blank lines between items, you'll get `&lt;p&gt;` tags for the
  144. list item text. You can create multi-paragraph list items by indenting
  145. the paragraphs by 4 spaces or 1 tab:
  146. * A list item.
  147. With multiple paragraphs.
  148. * Another item in the list.
  149. Output:
  150. &lt;ul&gt;
  151. &lt;li&gt;&lt;p&gt;A list item.&lt;/p&gt;
  152. &lt;p&gt;With multiple paragraphs.&lt;/p&gt;&lt;/li&gt;
  153. &lt;li&gt;&lt;p&gt;Another item in the list.&lt;/p&gt;&lt;/li&gt;
  154. &lt;/ul&gt;
  155. ### Links ###
  156. Markdown supports two styles for creating links: *inline* and
  157. *reference*. With both styles, you use square brackets to delimit the
  158. text you want to turn into a link.
  159. Inline-style links use parentheses immediately after the link text.
  160. For example:
  161. This is an [example link](http://example.com/).
  162. Output:
  163. &lt;p&gt;This is an &lt;a href="http://example.com/"&gt;
  164. example link&lt;/a&gt;.&lt;/p&gt;
  165. Optionally, you may include a title attribute in the parentheses:
  166. This is an [example link](http://example.com/ "With a Title").
  167. Output:
  168. &lt;p&gt;This is an &lt;a href="http://example.com/" title="With a Title"&gt;
  169. example link&lt;/a&gt;.&lt;/p&gt;
  170. Reference-style links allow you to refer to your links by names, which
  171. you define elsewhere in your document:
  172. I get 10 times more traffic from [Google][1] than from
  173. [Yahoo][2] or [MSN][3].
  174. [1]: http://google.com/ "Google"
  175. [2]: http://search.yahoo.com/ "Yahoo Search"
  176. [3]: http://search.msn.com/ "MSN Search"
  177. Output:
  178. &lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
  179. title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
  180. title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
  181. title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
  182. The title attribute is optional. Link names may contain letters,
  183. numbers and spaces, but are *not* case sensitive:
  184. I start my morning with a cup of coffee and
  185. [The New York Times][NY Times].
  186. [ny times]: http://www.nytimes.com/
  187. Output:
  188. &lt;p&gt;I start my morning with a cup of coffee and
  189. &lt;a href="http://www.nytimes.com/"&gt;The New York Times&lt;/a&gt;.&lt;/p&gt;
  190. ### Images ###
  191. Image syntax is very much like link syntax.
  192. Inline (titles are optional):
  193. ![alt text](/path/to/img.jpg "Title")
  194. Reference-style:
  195. ![alt text][id]
  196. [id]: /path/to/img.jpg "Title"
  197. Both of the above examples produce the same output:
  198. &lt;img src="/path/to/img.jpg" alt="alt text" title="Title" /&gt;
  199. ### Code ###
  200. In a regular paragraph, you can create code span by wrapping text in
  201. backtick quotes. Any ampersands (`&amp;`) and angle brackets (`&lt;` or
  202. `&gt;`) will automatically be translated into HTML entities. This makes
  203. it easy to use Markdown to write about HTML example code:
  204. I strongly recommend against using any `&lt;blink&gt;` tags.
  205. I wish SmartyPants used named entities like `&amp;mdash;`
  206. instead of decimal-encoded entites like `&amp;#8212;`.
  207. Output:
  208. &lt;p&gt;I strongly recommend against using any
  209. &lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
  210. &lt;p&gt;I wish SmartyPants used named entities like
  211. &lt;code&gt;&amp;amp;mdash;&lt;/code&gt; instead of decimal-encoded
  212. entites like &lt;code&gt;&amp;amp;#8212;&lt;/code&gt;.&lt;/p&gt;
  213. To specify an entire block of pre-formatted code, indent every line of
  214. the block by 4 spaces or 1 tab. Just like with code spans, `&amp;`, `&lt;`,
  215. and `&gt;` characters will be escaped automatically.
  216. Markdown:
  217. If you want your page to validate under XHTML 1.0 Strict,
  218. you've got to put paragraph tags in your blockquotes:
  219. &lt;blockquote&gt;
  220. &lt;p&gt;For example.&lt;/p&gt;
  221. &lt;/blockquote&gt;
  222. Output:
  223. &lt;p&gt;If you want your page to validate under XHTML 1.0 Strict,
  224. you've got to put paragraph tags in your blockquotes:&lt;/p&gt;
  225. &lt;pre&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;
  226. &amp;lt;p&amp;gt;For example.&amp;lt;/p&amp;gt;
  227. &amp;lt;/blockquote&amp;gt;
  228. &lt;/code&gt;&lt;/pre&gt;
  229. ## Fenced code blocks (and syntax highlighting)
  230. ```javascript
  231. for (var i = 0; i < items.length; i++) {
  232. console.log(items[i], i); // log them
  233. }
  234. ```
  235. </textarea></form>
  236. <script>
  237. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  238. mode: 'markdown',
  239. lineNumbers: true,
  240. theme: "default",
  241. extraKeys: {"Enter": "newlineAndIndentContinueMarkdownList"}
  242. });
  243. </script>
  244. <p>If you also want support <code>strikethrough</code>, <code>emoji</code> and few other goodies, check out <a href="../gfm/index.html">Github-Flavored Markdown mode</a>.</p>
  245. <p>Optionally depends on other modes for properly highlighted code blocks,
  246. and XML mode for properly highlighted inline XML blocks.</p>
  247. <p>Markdown mode supports these options:</p>
  248. <ul>
  249. <li>
  250. <d1>
  251. <dt><code>highlightFormatting: boolean</code></dt>
  252. <dd>Whether to separately highlight markdown meta characterts (<code>*[]()</code>etc.) (default: <code>false</code>).</dd>
  253. </d1>
  254. </li>
  255. <li>
  256. <d1>
  257. <dt><code>maxBlockquoteDepth: boolean</code></dt>
  258. <dd>Maximum allowed blockquote nesting (default: <code>0</code> - infinite nesting).</dd>
  259. </d1>
  260. </li>
  261. <li>
  262. <d1>
  263. <dt><code>xml: boolean</code></dt>
  264. <dd>Whether to highlight inline XML (default: <code>true</code>).</dd>
  265. </d1>
  266. </li>
  267. <li>
  268. <d1>
  269. <dt><code>fencedCodeBlockHighlighting: boolean</code></dt>
  270. <dd>Whether to syntax-highlight fenced code blocks, if given mode is included (default: <code>true</code>).</dd>
  271. </d1>
  272. </li>
  273. <li>
  274. <d1>
  275. <dt><code>tokenTypeOverrides: Object</code></dt>
  276. <dd>When you want ot override default token type names (e.g. <code>{code: "code"}</code>).</dd>
  277. </d1>
  278. </li>
  279. <li>
  280. <d1>
  281. <dt><code>allowAtxHeaderWithoutSpace: boolean</code></dt>
  282. <dd>Allow lazy headers without whitespace between hashtag and text (default: <code>false</code>).</dd>
  283. </d1>
  284. </li>
  285. </ul>
  286. <p><strong>MIME types defined:</strong> <code>text/x-markdown</code>.</p>
  287. <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#markdown_*">normal</a>, <a href="../../test/index.html#verbose,markdown_*">verbose</a>.</p>
  288. </article>