4
<title>CodeMirror: Markdown mode</title>
5
<link rel="stylesheet" href="../../lib/codemirror.css">
6
<script src="../../lib/codemirror.js"></script>
7
<script src="../xml/xml.js"></script>
8
<script src="markdown.js"></script>
9
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10
<link rel="stylesheet" href="../../doc/docs.css">
13
<h1>CodeMirror: Markdown mode</h1>
15
<!-- source: http://daringfireball.net/projects/markdown/basics.text -->
16
<form><textarea id="code" name="code">
20
<ul id="ProjectSubmenu">
21
<li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
22
<li><a class="selected" title="Markdown Basics">Basics</a></li>
23
<li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
24
<li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
25
<li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
29
Getting the Gist of Markdown's Formatting Syntax
30
------------------------------------------------
32
This page offers a brief overview of what it's like to use Markdown.
33
The [syntax page] [s] provides complete, detailed documentation for
34
every feature, but Markdown should be very easy to pick up simply by
35
looking at a few examples of it in action. The examples on this page
36
are written in a before/after style, showing example syntax and the
37
HTML output produced by Markdown.
39
It's also helpful to simply try Markdown out; the [Dingus] [d] is a
40
web application that allows you type your own Markdown-formatted text
41
and translate it to XHTML.
43
**Note:** This document is itself written using Markdown; you
44
can [see the source for it by adding '.text' to the URL] [src].
46
[s]: /projects/markdown/syntax "Markdown Syntax"
47
[d]: /projects/markdown/dingus "Markdown Dingus"
48
[src]: /projects/markdown/basics.text
51
## Paragraphs, Headers, Blockquotes ##
53
A paragraph is simply one or more consecutive lines of text, separated
54
by one or more blank lines. (A blank line is any line that looks like
55
a blank line -- a line containing nothing but spaces or tabs is
56
considered blank.) Normal paragraphs should not be indented with
59
Markdown offers two styles of headers: *Setext* and *atx*.
60
Setext-style headers for `<h1>` and `<h2>` are created by
61
"underlining" with equal signs (`=`) and hyphens (`-`), respectively.
62
To create an atx-style header, you put 1-6 hash marks (`#`) at the
63
beginning of the line -- the number of hashes equals the resulting
66
Blockquotes are indicated using email-style '`>`' angle brackets.
76
Now is the time for all good men to come to
77
the aid of their country. This is just a
80
The quick brown fox jumped over the lazy
85
> This is a blockquote.
87
> This is the second paragraph in the blockquote.
89
> ## This is an H2 in a blockquote
94
<h1>A First Level Header</h1>
96
<h2>A Second Level Header</h2>
98
<p>Now is the time for all good men to come to
99
the aid of their country. This is just a
100
regular paragraph.</p>
102
<p>The quick brown fox jumped over the lazy
103
dog's back.</p>
105
<h3>Header 3</h3>
108
<p>This is a blockquote.</p>
110
<p>This is the second paragraph in the blockquote.</p>
112
<h2>This is an H2 in a blockquote</h2>
117
### Phrase Emphasis ###
119
Markdown uses asterisks and underscores to indicate spans of emphasis.
123
Some of these words *are emphasized*.
124
Some of these words _are emphasized also_.
126
Use two asterisks for **strong emphasis**.
127
Or, if you prefer, __use two underscores instead__.
131
<p>Some of these words <em>are emphasized</em>.
132
Some of these words <em>are emphasized also</em>.</p>
134
<p>Use two asterisks for <strong>strong emphasis</strong>.
135
Or, if you prefer, <strong>use two underscores instead</strong>.</p>
141
Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
142
`+`, and `-`) as list markers. These three markers are
143
interchangable; this:
161
all produce the same output:
164
<li>Candy.</li>
165
<li>Gum.</li>
166
<li>Booze.</li>
169
Ordered (numbered) lists use regular numbers, followed by periods, as
179
<li>Red</li>
180
<li>Green</li>
181
<li>Blue</li>
184
If you put blank lines between items, you'll get `<p>` tags for the
185
list item text. You can create multi-paragraph list items by indenting
186
the paragraphs by 4 spaces or 1 tab:
190
With multiple paragraphs.
192
* Another item in the list.
197
<li><p>A list item.</p>
198
<p>With multiple paragraphs.</p></li>
199
<li><p>Another item in the list.</p></li>
206
Markdown supports two styles for creating links: *inline* and
207
*reference*. With both styles, you use square brackets to delimit the
208
text you want to turn into a link.
210
Inline-style links use parentheses immediately after the link text.
213
This is an [example link](http://example.com/).
217
<p>This is an <a href="http://example.com/">
218
example link</a>.</p>
220
Optionally, you may include a title attribute in the parentheses:
222
This is an [example link](http://example.com/ "With a Title").
226
<p>This is an <a href="http://example.com/" title="With a Title">
227
example link</a>.</p>
229
Reference-style links allow you to refer to your links by names, which
230
you define elsewhere in your document:
232
I get 10 times more traffic from [Google][1] than from
233
[Yahoo][2] or [MSN][3].
235
[1]: http://google.com/ "Google"
236
[2]: http://search.yahoo.com/ "Yahoo Search"
237
[3]: http://search.msn.com/ "MSN Search"
241
<p>I get 10 times more traffic from <a href="http://google.com/"
242
title="Google">Google</a> than from <a href="http://search.yahoo.com/"
243
title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
244
title="MSN Search">MSN</a>.</p>
246
The title attribute is optional. Link names may contain letters,
247
numbers and spaces, but are *not* case sensitive:
249
I start my morning with a cup of coffee and
250
[The New York Times][NY Times].
252
[ny times]: http://www.nytimes.com/
256
<p>I start my morning with a cup of coffee and
257
<a href="http://www.nytimes.com/">The New York Times</a>.</p>
262
Image syntax is very much like link syntax.
264
Inline (titles are optional):
266
![alt text](/path/to/img.jpg "Title")
272
[id]: /path/to/img.jpg "Title"
274
Both of the above examples produce the same output:
276
<img src="/path/to/img.jpg" alt="alt text" title="Title" />
282
In a regular paragraph, you can create code span by wrapping text in
283
backtick quotes. Any ampersands (`&`) and angle brackets (`<` or
284
`>`) will automatically be translated into HTML entities. This makes
285
it easy to use Markdown to write about HTML example code:
287
I strongly recommend against using any `<blink>` tags.
289
I wish SmartyPants used named entities like `&mdash;`
290
instead of decimal-encoded entites like `&#8212;`.
294
<p>I strongly recommend against using any
295
<code>&lt;blink&gt;</code> tags.</p>
297
<p>I wish SmartyPants used named entities like
298
<code>&amp;mdash;</code> instead of decimal-encoded
299
entites like <code>&amp;#8212;</code>.</p>
302
To specify an entire block of pre-formatted code, indent every line of
303
the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`,
304
and `>` characters will be escaped automatically.
308
If you want your page to validate under XHTML 1.0 Strict,
309
you've got to put paragraph tags in your blockquotes:
312
<p>For example.</p>
317
<p>If you want your page to validate under XHTML 1.0 Strict,
318
you've got to put paragraph tags in your blockquotes:</p>
320
<pre><code>&lt;blockquote&gt;
321
&lt;p&gt;For example.&lt;/p&gt;
322
&lt;/blockquote&gt;
323
</code></pre>
327
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
335
<p><strong>MIME types defined:</strong> <code>text/x-markdown</code>.</p>