5 <title>CodeMirror: Markdown mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/continuelist.js"></script>
9 <script src="../xml/xml.js"></script>
10 <script src="markdown.js"></script>
11 <style type="text/css">
12 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
13 .cm-s-default .cm-trailing-space-a:before,
14 .cm-s-default .cm-trailing-space-b:before {position: absolute; content: "\00B7"; color: #777;}
15 .cm-s-default .cm-trailing-space-new-line:before {position: absolute; content: "\21B5"; color: #777;}
17 <link rel="stylesheet" href="../../doc/docs.css">
20 <h1>CodeMirror: Markdown mode</h1>
22 <!-- source: http://daringfireball.net/projects/markdown/basics.text -->
23 <form><textarea id="code" name="code">
27 <ul id="ProjectSubmenu">
28 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
29 <li><a class="selected" title="Markdown Basics">Basics</a></li>
30 <li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
31 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
32 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
36 Getting the Gist of Markdown's Formatting Syntax
37 ------------------------------------------------
39 This page offers a brief overview of what it's like to use Markdown.
40 The [syntax page] [s] provides complete, detailed documentation for
41 every feature, but Markdown should be very easy to pick up simply by
42 looking at a few examples of it in action. The examples on this page
43 are written in a before/after style, showing example syntax and the
44 HTML output produced by Markdown.
46 It's also helpful to simply try Markdown out; the [Dingus] [d] is a
47 web application that allows you type your own Markdown-formatted text
48 and translate it to XHTML.
50 **Note:** This document is itself written using Markdown; you
51 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
58 ## Paragraphs, Headers, Blockquotes ##
60 A paragraph is simply one or more consecutive lines of text, separated
61 by one or more blank lines. (A blank line is any line that looks like
62 a blank line -- a line containing nothing but spaces or tabs is
63 considered blank.) Normal paragraphs should not be indented with
66 Markdown offers two styles of headers: *Setext* and *atx*.
67 Setext-style headers for `<h1>` and `<h2>` are created by
68 "underlining" with equal signs (`=`) and hyphens (`-`), respectively.
69 To create an atx-style header, you put 1-6 hash marks (`#`) at the
70 beginning of the line -- the number of hashes equals the resulting
73 Blockquotes are indicated using email-style '`>`' angle brackets.
83 Now is the time for all good men to come to
84 the aid of their country. This is just a
87 The quick brown fox jumped over the lazy
92 > This is a blockquote.
94 > This is the second paragraph in the blockquote.
96 > ## This is an H2 in a blockquote
101 <h1>A First Level Header</h1>
103 <h2>A Second Level Header</h2>
105 <p>Now is the time for all good men to come to
106 the aid of their country. This is just a
107 regular paragraph.</p>
109 <p>The quick brown fox jumped over the lazy
110 dog's back.</p>
112 <h3>Header 3</h3>
115 <p>This is a blockquote.</p>
117 <p>This is the second paragraph in the blockquote.</p>
119 <h2>This is an H2 in a blockquote</h2>
124 ### Phrase Emphasis ###
126 Markdown uses asterisks and underscores to indicate spans of emphasis.
130 Some of these words *are emphasized*.
131 Some of these words _are emphasized also_.
133 Use two asterisks for **strong emphasis**.
134 Or, if you prefer, __use two underscores instead__.
138 <p>Some of these words <em>are emphasized</em>.
139 Some of these words <em>are emphasized also</em>.</p>
141 <p>Use two asterisks for <strong>strong emphasis</strong>.
142 Or, if you prefer, <strong>use two underscores instead</strong>.</p>
148 Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
149 `+`, and `-`) as list markers. These three markers are
150 interchangable; this:
168 all produce the same output:
171 <li>Candy.</li>
172 <li>Gum.</li>
173 <li>Booze.</li>
176 Ordered (numbered) lists use regular numbers, followed by periods, as
186 <li>Red</li>
187 <li>Green</li>
188 <li>Blue</li>
191 If you put blank lines between items, you'll get `<p>` tags for the
192 list item text. You can create multi-paragraph list items by indenting
193 the paragraphs by 4 spaces or 1 tab:
197 With multiple paragraphs.
199 * Another item in the list.
204 <li><p>A list item.</p>
205 <p>With multiple paragraphs.</p></li>
206 <li><p>Another item in the list.</p></li>
213 Markdown supports two styles for creating links: *inline* and
214 *reference*. With both styles, you use square brackets to delimit the
215 text you want to turn into a link.
217 Inline-style links use parentheses immediately after the link text.
220 This is an [example link](http://example.com/).
224 <p>This is an <a href="http://example.com/">
225 example link</a>.</p>
227 Optionally, you may include a title attribute in the parentheses:
229 This is an [example link](http://example.com/ "With a Title").
233 <p>This is an <a href="http://example.com/" title="With a Title">
234 example link</a>.</p>
236 Reference-style links allow you to refer to your links by names, which
237 you define elsewhere in your document:
239 I get 10 times more traffic from [Google][1] than from
240 [Yahoo][2] or [MSN][3].
242 [1]: http://google.com/ "Google"
243 [2]: http://search.yahoo.com/ "Yahoo Search"
244 [3]: http://search.msn.com/ "MSN Search"
248 <p>I get 10 times more traffic from <a href="http://google.com/"
249 title="Google">Google</a> than from <a href="http://search.yahoo.com/"
250 title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
251 title="MSN Search">MSN</a>.</p>
253 The title attribute is optional. Link names may contain letters,
254 numbers and spaces, but are *not* case sensitive:
256 I start my morning with a cup of coffee and
257 [The New York Times][NY Times].
259 [ny times]: http://www.nytimes.com/
263 <p>I start my morning with a cup of coffee and
264 <a href="http://www.nytimes.com/">The New York Times</a>.</p>
269 Image syntax is very much like link syntax.
271 Inline (titles are optional):
273 ![alt text](/path/to/img.jpg "Title")
279 [id]: /path/to/img.jpg "Title"
281 Both of the above examples produce the same output:
283 <img src="/path/to/img.jpg" alt="alt text" title="Title" />
289 In a regular paragraph, you can create code span by wrapping text in
290 backtick quotes. Any ampersands (`&`) and angle brackets (`<` or
291 `>`) will automatically be translated into HTML entities. This makes
292 it easy to use Markdown to write about HTML example code:
294 I strongly recommend against using any `<blink>` tags.
296 I wish SmartyPants used named entities like `&mdash;`
297 instead of decimal-encoded entites like `&#8212;`.
301 <p>I strongly recommend against using any
302 <code>&lt;blink&gt;</code> tags.</p>
304 <p>I wish SmartyPants used named entities like
305 <code>&amp;mdash;</code> instead of decimal-encoded
306 entites like <code>&amp;#8212;</code>.</p>
309 To specify an entire block of pre-formatted code, indent every line of
310 the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`,
311 and `>` characters will be escaped automatically.
315 If you want your page to validate under XHTML 1.0 Strict,
316 you've got to put paragraph tags in your blockquotes:
319 <p>For example.</p>
324 <p>If you want your page to validate under XHTML 1.0 Strict,
325 you've got to put paragraph tags in your blockquotes:</p>
327 <pre><code>&lt;blockquote&gt;
328 &lt;p&gt;For example.&lt;/p&gt;
329 &lt;/blockquote&gt;
330 </code></pre>
334 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
338 extraKeys: {"Enter": "newlineAndIndentContinueMarkdownList"}
342 <p>Optionally depends on the XML mode for properly highlighted inline XML blocks.</p>
344 <p><strong>MIME types defined:</strong> <code>text/x-markdown</code>.</p>
346 <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#markdown_*">normal</a>, <a href="../../test/index.html#verbose,markdown_*">verbose</a>.</p>