Project

General

Profile

Statistics
| Revision:

root / trunk / scripts / codemirror / mode / markdown / index.html @ 216

History | View | Annotate | Download (9.67 KB)

1
<!doctype html>
2
<html>
3
  <head>
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
    <link rel="stylesheet" href="markdown.css">
10
    <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11
    <link rel="stylesheet" href="../../doc/docs.css">
12
  </head>
13
  <body>
14
    <h1>CodeMirror: Markdown mode</h1>
15

    
16
<!-- source: http://daringfireball.net/projects/markdown/basics.text -->
17
<form><textarea id="code" name="code">
18
Markdown: Basics
19
================
20

    
21
&lt;ul id="ProjectSubmenu"&gt;
22
    &lt;li&gt;&lt;a href="/projects/markdown/" title="Markdown Project Page"&gt;Main&lt;/a&gt;&lt;/li&gt;
23
    &lt;li&gt;&lt;a class="selected" title="Markdown Basics"&gt;Basics&lt;/a&gt;&lt;/li&gt;
24
    &lt;li&gt;&lt;a href="/projects/markdown/syntax" title="Markdown Syntax Documentation"&gt;Syntax&lt;/a&gt;&lt;/li&gt;
25
    &lt;li&gt;&lt;a href="/projects/markdown/license" title="Pricing and License Information"&gt;License&lt;/a&gt;&lt;/li&gt;
26
    &lt;li&gt;&lt;a href="/projects/markdown/dingus" title="Online Markdown Web Form"&gt;Dingus&lt;/a&gt;&lt;/li&gt;
27
&lt;/ul&gt;
28

    
29

    
30
Getting the Gist of Markdown's Formatting Syntax
31
------------------------------------------------
32

    
33
This page offers a brief overview of what it's like to use Markdown.
34
The [syntax page] [s] provides complete, detailed documentation for
35
every feature, but Markdown should be very easy to pick up simply by
36
looking at a few examples of it in action. The examples on this page
37
are written in a before/after style, showing example syntax and the
38
HTML output produced by Markdown.
39

    
40
It's also helpful to simply try Markdown out; the [Dingus] [d] is a
41
web application that allows you type your own Markdown-formatted text
42
and translate it to XHTML.
43

    
44
**Note:** This document is itself written using Markdown; you
45
can [see the source for it by adding '.text' to the URL] [src].
46

    
47
  [s]: /projects/markdown/syntax  "Markdown Syntax"
48
  [d]: /projects/markdown/dingus  "Markdown Dingus"
49
  [src]: /projects/markdown/basics.text
50

    
51

    
52
## Paragraphs, Headers, Blockquotes ##
53

    
54
A paragraph is simply one or more consecutive lines of text, separated
55
by one or more blank lines. (A blank line is any line that looks like
56
a blank line -- a line containing nothing but spaces or tabs is
57
considered blank.) Normal paragraphs should not be indented with
58
spaces or tabs.
59

    
60
Markdown offers two styles of headers: *Setext* and *atx*.
61
Setext-style headers for `&lt;h1&gt;` and `&lt;h2&gt;` are created by
62
"underlining" with equal signs (`=`) and hyphens (`-`), respectively.
63
To create an atx-style header, you put 1-6 hash marks (`#`) at the
64
beginning of the line -- the number of hashes equals the resulting
65
HTML header level.
66

    
67
Blockquotes are indicated using email-style '`&gt;`' angle brackets.
68

    
69
Markdown:
70

    
71
    A First Level Header
72
    ====================
73
    
74
    A Second Level Header
75
    ---------------------
76

    
77
    Now is the time for all good men to come to
78
    the aid of their country. This is just a
79
    regular paragraph.
80

    
81
    The quick brown fox jumped over the lazy
82
    dog's back.
83
    
84
    ### Header 3
85

    
86
    &gt; This is a blockquote.
87
    &gt; 
88
    &gt; This is the second paragraph in the blockquote.
89
    &gt;
90
    &gt; ## This is an H2 in a blockquote
91

    
92

    
93
Output:
94

    
95
    &lt;h1&gt;A First Level Header&lt;/h1&gt;
96
    
97
    &lt;h2&gt;A Second Level Header&lt;/h2&gt;
98
    
99
    &lt;p&gt;Now is the time for all good men to come to
100
    the aid of their country. This is just a
101
    regular paragraph.&lt;/p&gt;
102
    
103
    &lt;p&gt;The quick brown fox jumped over the lazy
104
    dog's back.&lt;/p&gt;
105
    
106
    &lt;h3&gt;Header 3&lt;/h3&gt;
107
    
108
    &lt;blockquote&gt;
109
        &lt;p&gt;This is a blockquote.&lt;/p&gt;
110
        
111
        &lt;p&gt;This is the second paragraph in the blockquote.&lt;/p&gt;
112
        
113
        &lt;h2&gt;This is an H2 in a blockquote&lt;/h2&gt;
114
    &lt;/blockquote&gt;
115

    
116

    
117

    
118
### Phrase Emphasis ###
119

    
120
Markdown uses asterisks and underscores to indicate spans of emphasis.
121

    
122
Markdown:
123

    
124
    Some of these words *are emphasized*.
125
    Some of these words _are emphasized also_.
126
    
127
    Use two asterisks for **strong emphasis**.
128
    Or, if you prefer, __use two underscores instead__.
129

    
130
Output:
131

    
132
    &lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
133
    Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
134
    
135
    &lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
136
    Or, if you prefer, &lt;strong&gt;use two underscores instead&lt;/strong&gt;.&lt;/p&gt;
137
   
138

    
139

    
140
## Lists ##
141

    
142
Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
143
`+`, and `-`) as list markers. These three markers are
144
interchangable; this:
145

    
146
    *   Candy.
147
    *   Gum.
148
    *   Booze.
149

    
150
this:
151

    
152
    +   Candy.
153
    +   Gum.
154
    +   Booze.
155

    
156
and this:
157

    
158
    -   Candy.
159
    -   Gum.
160
    -   Booze.
161

    
162
all produce the same output:
163

    
164
    &lt;ul&gt;
165
    &lt;li&gt;Candy.&lt;/li&gt;
166
    &lt;li&gt;Gum.&lt;/li&gt;
167
    &lt;li&gt;Booze.&lt;/li&gt;
168
    &lt;/ul&gt;
169

    
170
Ordered (numbered) lists use regular numbers, followed by periods, as
171
list markers:
172

    
173
    1.  Red
174
    2.  Green
175
    3.  Blue
176

    
177
Output:
178

    
179
    &lt;ol&gt;
180
    &lt;li&gt;Red&lt;/li&gt;
181
    &lt;li&gt;Green&lt;/li&gt;
182
    &lt;li&gt;Blue&lt;/li&gt;
183
    &lt;/ol&gt;
184

    
185
If you put blank lines between items, you'll get `&lt;p&gt;` tags for the
186
list item text. You can create multi-paragraph list items by indenting
187
the paragraphs by 4 spaces or 1 tab:
188

    
189
    *   A list item.
190
    
191
        With multiple paragraphs.
192

    
193
    *   Another item in the list.
194

    
195
Output:
196

    
197
    &lt;ul&gt;
198
    &lt;li&gt;&lt;p&gt;A list item.&lt;/p&gt;
199
    &lt;p&gt;With multiple paragraphs.&lt;/p&gt;&lt;/li&gt;
200
    &lt;li&gt;&lt;p&gt;Another item in the list.&lt;/p&gt;&lt;/li&gt;
201
    &lt;/ul&gt;
202
    
203

    
204

    
205
### Links ###
206

    
207
Markdown supports two styles for creating links: *inline* and
208
*reference*. With both styles, you use square brackets to delimit the
209
text you want to turn into a link.
210

    
211
Inline-style links use parentheses immediately after the link text.
212
For example:
213

    
214
    This is an [example link](http://example.com/).
215

    
216
Output:
217

    
218
    &lt;p&gt;This is an &lt;a href="http://example.com/"&gt;
219
    example link&lt;/a&gt;.&lt;/p&gt;
220

    
221
Optionally, you may include a title attribute in the parentheses:
222

    
223
    This is an [example link](http://example.com/ "With a Title").
224

    
225
Output:
226

    
227
    &lt;p&gt;This is an &lt;a href="http://example.com/" title="With a Title"&gt;
228
    example link&lt;/a&gt;.&lt;/p&gt;
229

    
230
Reference-style links allow you to refer to your links by names, which
231
you define elsewhere in your document:
232

    
233
    I get 10 times more traffic from [Google][1] than from
234
    [Yahoo][2] or [MSN][3].
235

    
236
    [1]: http://google.com/        "Google"
237
    [2]: http://search.yahoo.com/  "Yahoo Search"
238
    [3]: http://search.msn.com/    "MSN Search"
239

    
240
Output:
241

    
242
    &lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
243
    title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
244
    title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
245
    title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
246

    
247
The title attribute is optional. Link names may contain letters,
248
numbers and spaces, but are *not* case sensitive:
249

    
250
    I start my morning with a cup of coffee and
251
    [The New York Times][NY Times].
252

    
253
    [ny times]: http://www.nytimes.com/
254

    
255
Output:
256

    
257
    &lt;p&gt;I start my morning with a cup of coffee and
258
    &lt;a href="http://www.nytimes.com/"&gt;The New York Times&lt;/a&gt;.&lt;/p&gt;
259

    
260

    
261
### Images ###
262

    
263
Image syntax is very much like link syntax.
264

    
265
Inline (titles are optional):
266

    
267
    ![alt text](/path/to/img.jpg "Title")
268

    
269
Reference-style:
270

    
271
    ![alt text][id]
272

    
273
    [id]: /path/to/img.jpg "Title"
274

    
275
Both of the above examples produce the same output:
276

    
277
    &lt;img src="/path/to/img.jpg" alt="alt text" title="Title" /&gt;
278

    
279

    
280

    
281
### Code ###
282

    
283
In a regular paragraph, you can create code span by wrapping text in
284
backtick quotes. Any ampersands (`&amp;`) and angle brackets (`&lt;` or
285
`&gt;`) will automatically be translated into HTML entities. This makes
286
it easy to use Markdown to write about HTML example code:
287

    
288
    I strongly recommend against using any `&lt;blink&gt;` tags.
289

    
290
    I wish SmartyPants used named entities like `&amp;mdash;`
291
    instead of decimal-encoded entites like `&amp;#8212;`.
292

    
293
Output:
294

    
295
    &lt;p&gt;I strongly recommend against using any
296
    &lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
297
    
298
    &lt;p&gt;I wish SmartyPants used named entities like
299
    &lt;code&gt;&amp;amp;mdash;&lt;/code&gt; instead of decimal-encoded
300
    entites like &lt;code&gt;&amp;amp;#8212;&lt;/code&gt;.&lt;/p&gt;
301

    
302

    
303
To specify an entire block of pre-formatted code, indent every line of
304
the block by 4 spaces or 1 tab. Just like with code spans, `&amp;`, `&lt;`,
305
and `&gt;` characters will be escaped automatically.
306

    
307
Markdown:
308

    
309
    If you want your page to validate under XHTML 1.0 Strict,
310
    you've got to put paragraph tags in your blockquotes:
311

    
312
        &lt;blockquote&gt;
313
            &lt;p&gt;For example.&lt;/p&gt;
314
        &lt;/blockquote&gt;
315

    
316
Output:
317

    
318
    &lt;p&gt;If you want your page to validate under XHTML 1.0 Strict,
319
    you've got to put paragraph tags in your blockquotes:&lt;/p&gt;
320
    
321
    &lt;pre&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;
322
        &amp;lt;p&amp;gt;For example.&amp;lt;/p&amp;gt;
323
    &amp;lt;/blockquote&amp;gt;
324
    &lt;/code&gt;&lt;/pre&gt;
325
</textarea></form>
326

    
327
    <script>
328
      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
329
        mode: 'markdown',
330
        lineNumbers: true,
331
        matchBrackets: true,
332
        theme: "default"
333
      });
334
    </script>
335

    
336
    <p><strong>MIME types defined:</strong> <code>text/x-markdown</code>.</p>
337

    
338
  </body>
339
</html>