Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (9.63 KB)

1 216 soeren
<!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
    <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10
    <link rel="stylesheet" href="../../doc/docs.css">
11
  </head>
12
  <body>
13
    <h1>CodeMirror: Markdown mode</h1>
14
15
<!-- source: http://daringfireball.net/projects/markdown/basics.text -->
16
<form><textarea id="code" name="code">
17
Markdown: Basics
18
================
19
20
&lt;ul id="ProjectSubmenu"&gt;
21
    &lt;li&gt;&lt;a href="/projects/markdown/" title="Markdown Project Page"&gt;Main&lt;/a&gt;&lt;/li&gt;
22
    &lt;li&gt;&lt;a class="selected" title="Markdown Basics"&gt;Basics&lt;/a&gt;&lt;/li&gt;
23
    &lt;li&gt;&lt;a href="/projects/markdown/syntax" title="Markdown Syntax Documentation"&gt;Syntax&lt;/a&gt;&lt;/li&gt;
24
    &lt;li&gt;&lt;a href="/projects/markdown/license" title="Pricing and License Information"&gt;License&lt;/a&gt;&lt;/li&gt;
25
    &lt;li&gt;&lt;a href="/projects/markdown/dingus" title="Online Markdown Web Form"&gt;Dingus&lt;/a&gt;&lt;/li&gt;
26
&lt;/ul&gt;
27
28
29
Getting the Gist of Markdown's Formatting Syntax
30
------------------------------------------------
31
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.
38
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.
42
43
**Note:** This document is itself written using Markdown; you
44
can [see the source for it by adding '.text' to the URL] [src].
45
46
  [s]: /projects/markdown/syntax  "Markdown Syntax"
47
  [d]: /projects/markdown/dingus  "Markdown Dingus"
48
  [src]: /projects/markdown/basics.text
49
50
51
## Paragraphs, Headers, Blockquotes ##
52
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
57
spaces or tabs.
58
59
Markdown offers two styles of headers: *Setext* and *atx*.
60
Setext-style headers for `&lt;h1&gt;` and `&lt;h2&gt;` 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
64
HTML header level.
65
66
Blockquotes are indicated using email-style '`&gt;`' angle brackets.
67
68
Markdown:
69
70
    A First Level Header
71
    ====================
72
73
    A Second Level Header
74
    ---------------------
75
76
    Now is the time for all good men to come to
77
    the aid of their country. This is just a
78
    regular paragraph.
79
80
    The quick brown fox jumped over the lazy
81
    dog's back.
82
83
    ### Header 3
84
85
    &gt; This is a blockquote.
86
    &gt;
87
    &gt; This is the second paragraph in the blockquote.
88
    &gt;
89
    &gt; ## This is an H2 in a blockquote
90
91
92
Output:
93
94
    &lt;h1&gt;A First Level Header&lt;/h1&gt;
95
96
    &lt;h2&gt;A Second Level Header&lt;/h2&gt;
97
98
    &lt;p&gt;Now is the time for all good men to come to
99
    the aid of their country. This is just a
100
    regular paragraph.&lt;/p&gt;
101
102
    &lt;p&gt;The quick brown fox jumped over the lazy
103
    dog's back.&lt;/p&gt;
104
105
    &lt;h3&gt;Header 3&lt;/h3&gt;
106
107
    &lt;blockquote&gt;
108
        &lt;p&gt;This is a blockquote.&lt;/p&gt;
109
110
        &lt;p&gt;This is the second paragraph in the blockquote.&lt;/p&gt;
111
112
        &lt;h2&gt;This is an H2 in a blockquote&lt;/h2&gt;
113
    &lt;/blockquote&gt;
114
115
116
117
### Phrase Emphasis ###
118
119
Markdown uses asterisks and underscores to indicate spans of emphasis.
120
121
Markdown:
122
123
    Some of these words *are emphasized*.
124
    Some of these words _are emphasized also_.
125
126
    Use two asterisks for **strong emphasis**.
127
    Or, if you prefer, __use two underscores instead__.
128
129
Output:
130
131
    &lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
132
    Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
133
134
    &lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
135
    Or, if you prefer, &lt;strong&gt;use two underscores instead&lt;/strong&gt;.&lt;/p&gt;
136
137
138
139
## Lists ##
140
141
Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
142
`+`, and `-`) as list markers. These three markers are
143
interchangable; this:
144
145
    *   Candy.
146
    *   Gum.
147
    *   Booze.
148
149
this:
150
151
    +   Candy.
152
    +   Gum.
153
    +   Booze.
154
155
and this:
156
157
    -   Candy.
158
    -   Gum.
159
    -   Booze.
160
161
all produce the same output:
162
163
    &lt;ul&gt;
164
    &lt;li&gt;Candy.&lt;/li&gt;
165
    &lt;li&gt;Gum.&lt;/li&gt;
166
    &lt;li&gt;Booze.&lt;/li&gt;
167
    &lt;/ul&gt;
168
169
Ordered (numbered) lists use regular numbers, followed by periods, as
170
list markers:
171
172
    1.  Red
173
    2.  Green
174
    3.  Blue
175
176
Output:
177
178
    &lt;ol&gt;
179
    &lt;li&gt;Red&lt;/li&gt;
180
    &lt;li&gt;Green&lt;/li&gt;
181
    &lt;li&gt;Blue&lt;/li&gt;
182
    &lt;/ol&gt;
183
184
If you put blank lines between items, you'll get `&lt;p&gt;` 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:
187
188
    *   A list item.
189
190
        With multiple paragraphs.
191
192
    *   Another item in the list.
193
194
Output:
195
196
    &lt;ul&gt;
197
    &lt;li&gt;&lt;p&gt;A list item.&lt;/p&gt;
198
    &lt;p&gt;With multiple paragraphs.&lt;/p&gt;&lt;/li&gt;
199
    &lt;li&gt;&lt;p&gt;Another item in the list.&lt;/p&gt;&lt;/li&gt;
200
    &lt;/ul&gt;
201
202
203
204
### Links ###
205
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.
209
210
Inline-style links use parentheses immediately after the link text.
211
For example:
212
213
    This is an [example link](http://example.com/).
214
215
Output:
216
217
    &lt;p&gt;This is an &lt;a href="http://example.com/"&gt;
218
    example link&lt;/a&gt;.&lt;/p&gt;
219
220
Optionally, you may include a title attribute in the parentheses:
221
222
    This is an [example link](http://example.com/ "With a Title").
223
224
Output:
225
226
    &lt;p&gt;This is an &lt;a href="http://example.com/" title="With a Title"&gt;
227
    example link&lt;/a&gt;.&lt;/p&gt;
228
229
Reference-style links allow you to refer to your links by names, which
230
you define elsewhere in your document:
231
232
    I get 10 times more traffic from [Google][1] than from
233
    [Yahoo][2] or [MSN][3].
234
235
    [1]: http://google.com/        "Google"
236
    [2]: http://search.yahoo.com/  "Yahoo Search"
237
    [3]: http://search.msn.com/    "MSN Search"
238
239
Output:
240
241
    &lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
242
    title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
243
    title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
244
    title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
245
246
The title attribute is optional. Link names may contain letters,
247
numbers and spaces, but are *not* case sensitive:
248
249
    I start my morning with a cup of coffee and
250
    [The New York Times][NY Times].
251
252
    [ny times]: http://www.nytimes.com/
253
254
Output:
255
256
    &lt;p&gt;I start my morning with a cup of coffee and
257
    &lt;a href="http://www.nytimes.com/"&gt;The New York Times&lt;/a&gt;.&lt;/p&gt;
258
259
260
### Images ###
261
262
Image syntax is very much like link syntax.
263
264
Inline (titles are optional):
265
266
    ![alt text](/path/to/img.jpg "Title")
267
268
Reference-style:
269
270
    ![alt text][id]
271
272
    [id]: /path/to/img.jpg "Title"
273
274
Both of the above examples produce the same output:
275
276
    &lt;img src="/path/to/img.jpg" alt="alt text" title="Title" /&gt;
277
278
279
280
### Code ###
281
282
In a regular paragraph, you can create code span by wrapping text in
283
backtick quotes. Any ampersands (`&amp;`) and angle brackets (`&lt;` or
284
`&gt;`) will automatically be translated into HTML entities. This makes
285
it easy to use Markdown to write about HTML example code:
286
287
    I strongly recommend against using any `&lt;blink&gt;` tags.
288
289
    I wish SmartyPants used named entities like `&amp;mdash;`
290
    instead of decimal-encoded entites like `&amp;#8212;`.
291
292
Output:
293
294
    &lt;p&gt;I strongly recommend against using any
295
    &lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
296
297
    &lt;p&gt;I wish SmartyPants used named entities like
298
    &lt;code&gt;&amp;amp;mdash;&lt;/code&gt; instead of decimal-encoded
299
    entites like &lt;code&gt;&amp;amp;#8212;&lt;/code&gt;.&lt;/p&gt;
300
301
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, `&amp;`, `&lt;`,
304
and `&gt;` characters will be escaped automatically.
305
306
Markdown:
307
308
    If you want your page to validate under XHTML 1.0 Strict,
309
    you've got to put paragraph tags in your blockquotes:
310
311
        &lt;blockquote&gt;
312
            &lt;p&gt;For example.&lt;/p&gt;
313
        &lt;/blockquote&gt;
314
315
Output:
316
317
    &lt;p&gt;If you want your page to validate under XHTML 1.0 Strict,
318
    you've got to put paragraph tags in your blockquotes:&lt;/p&gt;
319
320
    &lt;pre&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;
321
        &amp;lt;p&amp;gt;For example.&amp;lt;/p&amp;gt;
322
    &amp;lt;/blockquote&amp;gt;
323
    &lt;/code&gt;&lt;/pre&gt;
324
</textarea></form>
325
326
    <script>
327
      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
328
        mode: 'markdown',
329
        lineNumbers: true,
330
        matchBrackets: true,
331
        theme: "default"
332
      });
333
    </script>
334
335
    <p><strong>MIME types defined:</strong> <code>text/x-markdown</code>.</p>
336
337
  </body>
338
</html>