tartan 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +144 -11
- data/lib/markdown.yml +9 -7
- data/lib/symbolize.rb +0 -3
- data/test/MarkdownTest_1.0/Markdown Documentation - Basics.out +316 -0
- data/test/MarkdownTest_1.0/Markdown Documentation - Syntax.out +947 -0
- data/test/MarkdownTest_1.0/run-markdown.rb +3 -3
- data/test/harder/test-markdown-harder.rb +1 -1
- data/test/test-markdown.yml +48 -1
- data/test/test-readme-example.rb +144 -5
- data/test/test-regexp.rb +42 -0
- metadata +6 -2
data/README
CHANGED
@@ -14,7 +14,7 @@ following benefits:
|
|
14
14
|
2. allows layering and extension of parsing rules
|
15
15
|
3. allows multiple output formats from the same syntax specification
|
16
16
|
|
17
|
-
The current implementation of Tartan is in Ruby and includes a full Markdown
|
17
|
+
The current implementation of Tartan is in Ruby and includes a full Markdown[http://daringfireball.net/projects/markdown/]
|
18
18
|
parser (described in YAML). The format of the parsing specification has been
|
19
19
|
created with an eye to having a language independent definition of wiki (and
|
20
20
|
possibly other) mark-ups. That's a lofty goal, and Tartan hasn't quite gotten
|
@@ -24,9 +24,10 @@ something more than just convert wiki text directly into HTML.
|
|
24
24
|
|
25
25
|
== Usage
|
26
26
|
|
27
|
-
So, really all you want to do is generate HTML from Markdown text. Here's
|
27
|
+
So, really all you want to do is generate HTML from Markdown[http://daringfireball.net/projects/markdown/] text. Here's
|
28
28
|
how you do it:
|
29
29
|
|
30
|
+
# require 'rubygems' # if you are pulling Tartan in as a gem
|
30
31
|
require 'tartan_markdown'
|
31
32
|
|
32
33
|
html = TartanMarkdown.new("* howdy\n* doody").to_html
|
@@ -43,9 +44,9 @@ called in the same way on the instance of the parser object.
|
|
43
44
|
|
44
45
|
You can add parsing syntax to existing parsers. This is done by building up a set of parsers specifications that work together.
|
45
46
|
|
46
|
-
In the Tartan distribution you have a specification for Markdown and you also
|
47
|
+
In the Tartan distribution you have a specification for Markdown[http://daringfireball.net/projects/markdown/] and you also
|
47
48
|
have a specification for table mark-up. You can combine them by creating a new
|
48
|
-
class that layers the tables onto the Markdown definition as follows in a file
|
49
|
+
class that layers the tables onto the Markdown[http://daringfireball.net/projects/markdown/] definition as follows in a file
|
49
50
|
called <tt>tartan_markdown_tables.rb</tt>:
|
50
51
|
|
51
52
|
require 'tartan_markdown_def'
|
@@ -58,7 +59,6 @@ called <tt>tartan_markdown_tables.rb</tt>:
|
|
58
59
|
|
59
60
|
In another file you could use this new parser:
|
60
61
|
|
61
|
-
|
62
62
|
require 'tartan_markdown_tables'
|
63
63
|
|
64
64
|
html = TartanMarkdownTables.new("[|*happy*||**days**|]").to_html
|
@@ -68,7 +68,7 @@ In another file you could use this new parser:
|
|
68
68
|
|
69
69
|
== The Parsing Specification
|
70
70
|
|
71
|
-
|
71
|
+
Each specific parser (Markdown[http://daringfireball.net/projects/markdown/] to HTML, Textile to HTML, your wiki to xml, etc.) needs a parsing specification to tell Tartan how to convert the text into HTML (or what ever other format you need).
|
72
72
|
|
73
73
|
=== Overall Structure
|
74
74
|
|
@@ -91,19 +91,19 @@ list of parsing rules. The base context defaults to <tt>block</tt>; that is, the
|
|
91
91
|
The following is a simple parsing rule to match paragraphs and mark them up in HTML:
|
92
92
|
|
93
93
|
title: paragraph
|
94
|
-
match:
|
94
|
+
match: /(^[^\n]+$\n)*^[^\n]+$/m
|
95
95
|
html:
|
96
96
|
start_mark: <p>
|
97
97
|
end_mark: </p>
|
98
98
|
|
99
99
|
A paragraph, in this case, is any grouping of non blank lines.
|
100
100
|
|
101
|
-
The parser will repetitively apply the <tt>match</tt> regular expression and if it matches, the <tt>html</tt> output sub-rule will put <tt><p></tt
|
101
|
+
The parser will repetitively apply the <tt>match</tt> regular expression and if it matches, the <tt>html</tt> output sub-rule will put the <tt>start_mark</tt>, <tt><p></tt>, and the <tt>end_mark</tt>, <tt></p></tt>, around the text that is matched as a paragraph.
|
102
102
|
|
103
103
|
If we wanted to also mark off blocks of code that are indented by say 2 or more spaces at the beginning of the line, we could use the following rule:
|
104
104
|
|
105
105
|
title: code
|
106
|
-
match:
|
106
|
+
match: /(^[ ]{2,}\S.+?$\n)+^[ ]{2,}\S.+?$/m
|
107
107
|
html:
|
108
108
|
start_mark: <pre><code>
|
109
109
|
end_mark: </code></pre>
|
@@ -112,7 +112,7 @@ When we want to add the <tt>code</tt> rule, the ordering becomes important. If
|
|
112
112
|
|
113
113
|
block:
|
114
114
|
- title: code
|
115
|
-
match:
|
115
|
+
match: /(^[ ]{2,}\S.+?$\n)+^[ ]{2,}\S.+?$/m
|
116
116
|
html:
|
117
117
|
start_mark: <pre><code>
|
118
118
|
end_mark: </code></pre>
|
@@ -122,9 +122,142 @@ When we want to add the <tt>code</tt> rule, the ordering becomes important. If
|
|
122
122
|
start_mark: <p>
|
123
123
|
end_mark: </p>
|
124
124
|
|
125
|
+
Now, lets say we want to be able to mark-up text with emphasis (HTML <tt><em></tt>) and strong emphasis (HTML <tt><strong></tt>) in paragraph text, but not code. We'll use an asterisk (*) around text we want to have emphasis and a double asterisk around text we want to have strong emphasis (**). Note that we don't want this to happen in text in a code block.
|
126
|
+
|
127
|
+
To do this, we set up a new parsing context for paragraph body text and "point" the parser to the context when it recognizes a paragraph.
|
128
|
+
|
129
|
+
First, we create the paragraph parsing context:
|
130
|
+
|
131
|
+
paragraph:
|
132
|
+
- title: strong
|
133
|
+
match: /\*\*(.*?)\*\*/
|
134
|
+
html:
|
135
|
+
replace: <strong>\1</strong>
|
136
|
+
|
137
|
+
- rescan
|
138
|
+
|
139
|
+
- title: emphasis
|
140
|
+
match: /\*(.*?)\*/
|
141
|
+
html:
|
142
|
+
replace: <em>\1</em>
|
143
|
+
|
144
|
+
The <tt>rescan</tt> directive between the <tt>strong</tt> and <tt>emphasis</tt> rules tells the parser to "start over". This is needed because otherwise the <tt>strong</tt> rule would "claim" all the text it matched and the <tt>emphasis</tt> rule wouldn't have a chance to parse any of it. This would come into play if we had a paragraph such as:
|
145
|
+
|
146
|
+
Now listen to this **I want *you* to really hear me**.
|
147
|
+
|
148
|
+
This should get marked up as:
|
149
|
+
|
150
|
+
<p>Now listen to this <strong>I want <em>you<em> to really hear me</strong>.</p>
|
151
|
+
|
152
|
+
but we would get the following without the rescan:
|
153
|
+
|
154
|
+
<p>Now listen to this <strong>I want *you* to really hear me</strong>.</p>
|
155
|
+
|
156
|
+
You might also note that the ordering here, again, is important. If we leave out the <tt>rescan</tt>, we would get the following output instead:
|
157
|
+
|
158
|
+
<p>Now listen to this <em></em>I want <em>you</em> to really hear me<em></em>.</p>
|
159
|
+
|
160
|
+
Now, we also need to modify the paragraph rule in the <tt>block</tt> context to use the new <tt>paragraph</tt> context:
|
161
|
+
|
162
|
+
# . . .
|
163
|
+
- title: paragraph
|
164
|
+
match: /(^[^\n]+$\n)*^[^\n]+$/m
|
165
|
+
subparse: paragraph
|
166
|
+
html:
|
167
|
+
start_mark: <p>
|
168
|
+
end_mark: </p>
|
169
|
+
# . . .
|
170
|
+
|
171
|
+
To do this we use the <tt>subparse</tt> directive to tell the parser that the contents of the paragraph should be parsed by the <tt>paragraph</tt> context.
|
172
|
+
|
173
|
+
==== Creating a Mix-in
|
174
|
+
|
175
|
+
It's possible to mix-in or layer a parsing specification with a base parser. This allows you to add additional markup or change the markup of an existing syntax. You could use this to add table mark-up to Markdown[http://daringfireball.net/projects/markdown/] (in fact, this mix-in to Markdown is available as part of the Tartan code distribution).
|
176
|
+
|
177
|
+
To show how this works, we'll look at how to specify and then add character element markup to the parser example we've been working with. We want to turn things like "<", "&" and "->" into "<", "&" and "→".
|
178
|
+
|
179
|
+
We want these transformation to be done in the context of parsing paragraphs, so we'll only want to add to the <tt>paragraph</tt> context in our previous example.
|
180
|
+
|
181
|
+
So, to add this syntax parsing, you would create the following specification:
|
182
|
+
|
183
|
+
paragraph:
|
184
|
+
- rescan
|
185
|
+
- title: amp
|
186
|
+
match: /&/
|
187
|
+
html:
|
188
|
+
replace: '&'
|
189
|
+
rescan: true
|
190
|
+
- title: rightArrow
|
191
|
+
match: /->/
|
192
|
+
html:
|
193
|
+
replace: '→'
|
194
|
+
rescan: true
|
195
|
+
- title: lessThan
|
196
|
+
match: /</
|
197
|
+
html:
|
198
|
+
replace: '<'
|
199
|
+
rescan: true
|
200
|
+
- title: greaterThan
|
201
|
+
match: />/
|
202
|
+
html:
|
203
|
+
replace: '>'
|
204
|
+
|
205
|
+
That's it for the mix-in specification. Now we add these to the previous set. We didn't touch on file naming of specifications before, but now we need to. Let's say that we put the previous specification in a file called <tt>example-parser.yml</tt> and we put the new spec in <tt>entities.yml</tt>. To combine them, we would create a new Ruby class like this:
|
206
|
+
|
207
|
+
class ExampleParserWithEntities < Tartan
|
208
|
+
yaml "example-parser.yml"
|
209
|
+
yaml "entities.yml"
|
210
|
+
end
|
211
|
+
|
212
|
+
By default, the rules of a mix-in are added to the end of any given context. So, the effective resulting specification once the two sets of rules are combined would be:
|
213
|
+
block:
|
214
|
+
- title: code
|
215
|
+
match: /(^[ ]{2,}\S.+?$\n)+^[ ]{2,}\S.+?$/m
|
216
|
+
html:
|
217
|
+
start_mark: <pre><code>
|
218
|
+
end_mark: </code></pre>
|
219
|
+
- title: paragraph
|
220
|
+
match: /(^[^\n]+$\n)*^[^\n]+$/m
|
221
|
+
subparse: paragraph
|
222
|
+
html:
|
223
|
+
start_mark: <p>
|
224
|
+
end_mark: </p>
|
225
|
+
paragraph:
|
226
|
+
- title: emphasis
|
227
|
+
match: /\*(.*?)\*/
|
228
|
+
html:
|
229
|
+
replace: <em>\1</em>
|
230
|
+
- rescan
|
231
|
+
- title: amp
|
232
|
+
match: /&/
|
233
|
+
html:
|
234
|
+
replace: '&'
|
235
|
+
rescan: true
|
236
|
+
- title: rightArrow
|
237
|
+
match: /->/
|
238
|
+
html:
|
239
|
+
replace: '→'
|
240
|
+
rescan: true
|
241
|
+
- title: lessThan
|
242
|
+
match: /</
|
243
|
+
html:
|
244
|
+
replace: '<'
|
245
|
+
rescan: true
|
246
|
+
- title: greaterThan
|
247
|
+
match: />/
|
248
|
+
html:
|
249
|
+
replace: '>'
|
250
|
+
|
251
|
+
==== Going Further
|
252
|
+
|
253
|
+
Honestly, this brief tutorial just provides you with the basics of Tartan. If you want to know more, for now, the best thing is to look at the Markdown[http://daringfireball.net/projects/markdown/] and table extension specification in the code. That will show you a real-world example of how to create a base parser and a mix-in.
|
254
|
+
|
255
|
+
There will be additional documentation to follow. In particular a reference guide that covers all the parser rule directives one at a time.
|
256
|
+
|
257
|
+
If you need some help in getting Tartan to work for your project, please don't hesitate to post to the Tartan help-form[http://rubyforge.org/forum/forum.php?forum_id=8042] or write me directly at mailto:bitherder@rubyforge.org.
|
125
258
|
|
126
259
|
== The Name
|
127
260
|
|
128
261
|
Tartan is intended to weave together different parsing elements. It's intended
|
129
|
-
to be an alternative of both RedCloth[http:www.redcloth.org/] and BlueCloth. Tartan is a kind of cloth
|
262
|
+
to be an alternative of both RedCloth[http:www.redcloth.org/] and BlueCloth[http://www.deveiate.org/projects/BlueCloth]. Tartan is a kind of cloth
|
130
263
|
that weaves different colors together in an interesting pattern.
|
data/lib/markdown.yml
CHANGED
@@ -51,7 +51,8 @@ span:
|
|
51
51
|
(?:span|cite|del|em|strong|dfn|code|samp|kbd|var|abbr
|
52
52
|
|acronym|b|i|font|a|img|object|tt|big|small|strike|s|u
|
53
53
|
|sup|sub|q)
|
54
|
-
|
54
|
+
(:?\s+[^\s>][^>]*?)?
|
55
|
+
>/x
|
55
56
|
html:
|
56
57
|
start_mark: ''
|
57
58
|
end_mark: ''
|
@@ -79,13 +80,14 @@ span:
|
|
79
80
|
replace: '<'
|
80
81
|
|
81
82
|
- title: gt
|
82
|
-
match:
|
83
|
+
match: />/
|
83
84
|
html:
|
84
85
|
replace: '>'
|
85
86
|
|
86
87
|
- title: backslash_escapes
|
87
88
|
shelve: true
|
88
|
-
match: /\\([\\\`\*\_\{\}\[\]\(\)\>\#\.\!\+\-])/
|
89
|
+
# match: /\\([\\\`\*\_\{\}\[\]\(\)\>\#\.\!\+\-])/
|
90
|
+
match: /\\([-\[\]\\`*_{}()>#.!+])/ # `
|
89
91
|
html:
|
90
92
|
replace: '\1'
|
91
93
|
|
@@ -187,7 +189,7 @@ back_smarties:
|
|
187
189
|
replace: '<'
|
188
190
|
|
189
191
|
- title: gt
|
190
|
-
match: '
|
192
|
+
match: '/>/'
|
191
193
|
html:
|
192
194
|
replace: '>'
|
193
195
|
|
@@ -245,7 +247,7 @@ block:
|
|
245
247
|
end_mark: '</h2>'
|
246
248
|
|
247
249
|
- title: hash_header
|
248
|
-
match: '/^(
|
250
|
+
match: '/^(#{1,6})\s*([^#\s][^#]*?)(?:\s*\#+)?\s*?$/'
|
249
251
|
subparse:
|
250
252
|
context: span
|
251
253
|
match_group: 2
|
@@ -301,12 +303,12 @@ block:
|
|
301
303
|
context: listSpaced
|
302
304
|
match_group: 3
|
303
305
|
html:
|
304
|
-
start_mark: "<ul>\n"
|
306
|
+
start_mark: "\\1\\2<ul>\n"
|
305
307
|
end_mark: "\n</ul>"
|
306
308
|
|
307
309
|
- title: bulletListClose
|
308
310
|
match: >
|
309
|
-
/ (?:\A(\s*)
|
311
|
+
/ (?:\A(\s*)|(\n\n))
|
310
312
|
([-*+](?:[ ]+|\t)[^\n]+(:?\n[ \t]*[^\s][^\n]*)*)/xm
|
311
313
|
subparse:
|
312
314
|
context: listClose
|
data/lib/symbolize.rb
CHANGED
@@ -0,0 +1,316 @@
|
|
1
|
+
<h1>Markdown: Basics</h1>
|
2
|
+
|
3
|
+
<ul id="ProjectSubmenu">
|
4
|
+
<li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
|
5
|
+
<li><a class="selected" title="Markdown Basics">Basics</a></li>
|
6
|
+
<li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
|
7
|
+
<li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
|
8
|
+
<li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
|
9
|
+
</ul>
|
10
|
+
|
11
|
+
<h2>Getting the Gist of Markdown's Formatting Syntax</h2>
|
12
|
+
|
13
|
+
<p>This page offers a brief overview of what it's like to use Markdown.
|
14
|
+
The <a href="/projects/markdown/syntax" title="Markdown Syntax">syntax page</a> provides complete, detailed documentation for
|
15
|
+
every feature, but Markdown should be very easy to pick up simply by
|
16
|
+
looking at a few examples of it in action. The examples on this page
|
17
|
+
are written in a before/after style, showing example syntax and the
|
18
|
+
HTML output produced by Markdown.</p>
|
19
|
+
|
20
|
+
<p>It's also helpful to simply try Markdown out; the <a href="/projects/markdown/dingus" title="Markdown Dingus">Dingus</a> is a
|
21
|
+
web application that allows you type your own Markdown-formatted text
|
22
|
+
and translate it to XHTML.</p>
|
23
|
+
|
24
|
+
<p><strong>Note:</strong> This document is itself written using Markdown; you
|
25
|
+
can <a href="/projects/markdown/basics.text">see the source for it by adding '.text' to the URL</a>.</p>
|
26
|
+
|
27
|
+
|
28
|
+
<h2>Paragraphs, Headers, Blockquotes</h2>
|
29
|
+
|
30
|
+
<p>A paragraph is simply one or more consecutive lines of text, separated
|
31
|
+
by one or more blank lines. (A blank line is any line that looks like a
|
32
|
+
blank line -- a line containing nothing spaces or tabs is considered
|
33
|
+
blank.) Normal paragraphs should not be intended with spaces or tabs.</p>
|
34
|
+
|
35
|
+
<p>Markdown offers two styles of headers: <em>Setext</em> and <em>atx</em>.
|
36
|
+
Setext-style headers for <code><h1></code> and <code><h2></code> are created by
|
37
|
+
"underlining" with equal signs (<code>=</code>) and hyphens (<code>-</code>), respectively.
|
38
|
+
To create an atx-style header, you put 1-6 hash marks (<code>#</code>) at the
|
39
|
+
beginning of the line -- the number of hashes equals the resulting
|
40
|
+
HTML header level.</p>
|
41
|
+
|
42
|
+
<p>Blockquotes are indicated using email-style '<code>></code>' angle brackets.</p>
|
43
|
+
|
44
|
+
<p>Markdown:</p>
|
45
|
+
|
46
|
+
<pre><code>A First Level Header
|
47
|
+
====================
|
48
|
+
|
49
|
+
A Second Level Header
|
50
|
+
---------------------
|
51
|
+
|
52
|
+
Now is the time for all good men to come to
|
53
|
+
the aid of their country. This is just a
|
54
|
+
regular paragraph.
|
55
|
+
|
56
|
+
The quick brown fox jumped over the lazy
|
57
|
+
dog's back.
|
58
|
+
|
59
|
+
### Header 3
|
60
|
+
|
61
|
+
> This is a blockquote.
|
62
|
+
>
|
63
|
+
> This is the second paragraph in the blockquote.
|
64
|
+
>
|
65
|
+
> ## This is an H2 in a blockquote
|
66
|
+
</code></pre>
|
67
|
+
|
68
|
+
<p>Output:</p>
|
69
|
+
|
70
|
+
<pre><code><h1>A First Level Header</h1>
|
71
|
+
|
72
|
+
<h2>A Second Level Header</h2>
|
73
|
+
|
74
|
+
<p>Now is the time for all good men to come to
|
75
|
+
the aid of their country. This is just a
|
76
|
+
regular paragraph.</p>
|
77
|
+
|
78
|
+
<p>The quick brown fox jumped over the lazy
|
79
|
+
dog's back.</p>
|
80
|
+
|
81
|
+
<h3>Header 3</h3>
|
82
|
+
|
83
|
+
<blockquote>
|
84
|
+
<p>This is a blockquote.</p>
|
85
|
+
|
86
|
+
<p>This is the second paragraph in the blockquote.</p>
|
87
|
+
|
88
|
+
<h2>This is an H2 in a blockquote</h2>
|
89
|
+
</blockquote>
|
90
|
+
</code></pre>
|
91
|
+
|
92
|
+
<h3>Phrase Emphasis</h3>
|
93
|
+
|
94
|
+
<p>Markdown uses asterisks and underscores to indicate spans of emphasis.</p>
|
95
|
+
|
96
|
+
<p>Markdown:</p>
|
97
|
+
|
98
|
+
<pre><code>Some of these words *are emphasized*.
|
99
|
+
Some of these words _are emphasized also_.
|
100
|
+
|
101
|
+
Use two asterisks for **strong emphasis**.
|
102
|
+
Or, if you prefer, __use two underscores instead__.
|
103
|
+
</code></pre>
|
104
|
+
|
105
|
+
<p>Output:</p>
|
106
|
+
|
107
|
+
<pre><code><p>Some of these words <em>are emphasized</em>.
|
108
|
+
Some of these words <em>are emphasized also</em>.</p>
|
109
|
+
|
110
|
+
<p>Use two asterisks for <strong>strong emphasis</strong>.
|
111
|
+
Or, if you prefer, <strong>use two underscores instead</strong>.</p>
|
112
|
+
</code></pre>
|
113
|
+
|
114
|
+
<h2>Lists</h2>
|
115
|
+
|
116
|
+
<p>Unordered (bulleted) lists use asterisks, pluses, and hyphens (<code>*</code>,
|
117
|
+
<code>+</code>, and <code>-</code>) as list markers. These three markers are
|
118
|
+
interchangable; this:</p>
|
119
|
+
|
120
|
+
<pre><code>* Candy.
|
121
|
+
* Gum.
|
122
|
+
* Booze.
|
123
|
+
</code></pre>
|
124
|
+
|
125
|
+
<p>this:</p>
|
126
|
+
|
127
|
+
<pre><code>+ Candy.
|
128
|
+
+ Gum.
|
129
|
+
+ Booze.
|
130
|
+
</code></pre>
|
131
|
+
|
132
|
+
<p>and this:</p>
|
133
|
+
|
134
|
+
<pre><code>- Candy.
|
135
|
+
- Gum.
|
136
|
+
- Booze.
|
137
|
+
</code></pre>
|
138
|
+
|
139
|
+
<p>all produce the same output:</p>
|
140
|
+
|
141
|
+
<pre><code><ul>
|
142
|
+
<li>Candy.</li>
|
143
|
+
<li>Gum.</li>
|
144
|
+
<li>Booze.</li>
|
145
|
+
</ul>
|
146
|
+
</code></pre>
|
147
|
+
|
148
|
+
<p>Ordered (numbered) lists use regular numbers, followed by periods, as
|
149
|
+
list markers:</p>
|
150
|
+
|
151
|
+
<pre><code>1. Red
|
152
|
+
2. Green
|
153
|
+
3. Blue
|
154
|
+
</code></pre>
|
155
|
+
|
156
|
+
<p>Output:</p>
|
157
|
+
|
158
|
+
<pre><code><ol>
|
159
|
+
<li>Red</li>
|
160
|
+
<li>Green</li>
|
161
|
+
<li>Blue</li>
|
162
|
+
</ol>
|
163
|
+
</code></pre>
|
164
|
+
|
165
|
+
<p>If you put blank lines between items, you'll get <code><p></code> tags for the
|
166
|
+
list item text. You can create multi-paragraph list items by indenting
|
167
|
+
the paragraphs by 4 spaces or 1 tab:</p>
|
168
|
+
|
169
|
+
<pre><code>* A list item.
|
170
|
+
|
171
|
+
With multiple paragraphs.
|
172
|
+
|
173
|
+
* Another item in the list.
|
174
|
+
</code></pre>
|
175
|
+
|
176
|
+
<p>Output:</p>
|
177
|
+
|
178
|
+
<pre><code><ul>
|
179
|
+
<li><p>A list item.</p>
|
180
|
+
<p>With multiple paragraphs.</p></li>
|
181
|
+
<li><p>Another item in the list.</p></li>
|
182
|
+
</ul>
|
183
|
+
|
184
|
+
</code></pre>
|
185
|
+
|
186
|
+
<h3>Links</h3>
|
187
|
+
|
188
|
+
<p>Markdown supports two styles for creating links: <em>inline</em> and
|
189
|
+
<em>reference</em>. With both styles, you use square brackets to delimit the
|
190
|
+
text you want to turn into a link.</p>
|
191
|
+
|
192
|
+
<p>Inline-style links use parentheses immediately after the link text.
|
193
|
+
For example:</p>
|
194
|
+
|
195
|
+
<pre><code>This is an [example link](http://example.com/).
|
196
|
+
</code></pre>
|
197
|
+
|
198
|
+
<p>Output:</p>
|
199
|
+
|
200
|
+
<pre><code><p>This is an <a href="http://example.com/">
|
201
|
+
example link</a>.</p>
|
202
|
+
</code></pre>
|
203
|
+
|
204
|
+
<p>Optionally, you may include a title attribute in the parentheses:</p>
|
205
|
+
|
206
|
+
<pre><code>This is an [example link](http://example.com/ "With a Title").
|
207
|
+
</code></pre>
|
208
|
+
|
209
|
+
<p>Output:</p>
|
210
|
+
|
211
|
+
<pre><code><p>This is an <a href="http://example.com/" title="With a Title">
|
212
|
+
example link</a>.</p>
|
213
|
+
</code></pre>
|
214
|
+
|
215
|
+
<p>Reference-style links allow you to refer to your links by names, which
|
216
|
+
you define elsewhere in your document:</p>
|
217
|
+
|
218
|
+
<pre><code>I get 10 times more traffic from [Google][1] than from
|
219
|
+
[Yahoo][2] or [MSN][3].
|
220
|
+
|
221
|
+
[1]: http://google.com/ "Google"
|
222
|
+
[2]: http://search.yahoo.com/ "Yahoo Search"
|
223
|
+
[3]: http://search.msn.com/ "MSN Search"
|
224
|
+
</code></pre>
|
225
|
+
|
226
|
+
<p>Output:</p>
|
227
|
+
|
228
|
+
<pre><code><p>I get 10 times more traffic from <a href="http://google.com/"
|
229
|
+
title="Google">Google</a> than from <a href="http://search.yahoo.com/"
|
230
|
+
title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
|
231
|
+
title="MSN Search">MSN</a>.</p>
|
232
|
+
</code></pre>
|
233
|
+
|
234
|
+
<p>The title attribute is optional. Link names may contain letters,
|
235
|
+
numbers and spaces, but are <em>not</em> case sensitive:</p>
|
236
|
+
|
237
|
+
<pre><code>I start my morning with a cup of coffee and
|
238
|
+
[The New York Times][NY Times].
|
239
|
+
|
240
|
+
[ny times]: http://www.nytimes.com/
|
241
|
+
</code></pre>
|
242
|
+
|
243
|
+
<p>Output:</p>
|
244
|
+
|
245
|
+
<pre><code><p>I start my morning with a cup of coffee and
|
246
|
+
<a href="http://www.nytimes.com/">The New York Times</a>.</p>
|
247
|
+
</code></pre>
|
248
|
+
|
249
|
+
<h3>Images</h3>
|
250
|
+
|
251
|
+
<p>Image syntax is very much like link syntax.</p>
|
252
|
+
|
253
|
+
<p>Inline (titles are optional):</p>
|
254
|
+
|
255
|
+
<pre><code>![alt text](/path/to/img.jpg "Title")
|
256
|
+
</code></pre>
|
257
|
+
|
258
|
+
<p>Reference-style:</p>
|
259
|
+
|
260
|
+
<pre><code>![alt text][id]
|
261
|
+
|
262
|
+
[id]: /path/to/img.jpg "Title"
|
263
|
+
</code></pre>
|
264
|
+
|
265
|
+
<p>Both of the above examples produce the same output:</p>
|
266
|
+
|
267
|
+
<pre><code><img src="/path/to/img.jpg" alt="alt text" title="Title" />
|
268
|
+
</code></pre>
|
269
|
+
|
270
|
+
<h3>Code</h3>
|
271
|
+
|
272
|
+
<p>In a regular paragraph, you can create code span by wrapping text in
|
273
|
+
backtick quotes. Any ampersands (<code>&</code>) and angle brackets (<code><</code> or
|
274
|
+
<code>></code>) will automatically be translated into HTML entities. This makes
|
275
|
+
it easy to use Markdown to write about HTML example code:</p>
|
276
|
+
|
277
|
+
<pre><code>I strongly recommend against using any `<blink>` tags.
|
278
|
+
|
279
|
+
I wish SmartyPants used named entities like `&mdash;`
|
280
|
+
instead of decimal-encoded entites like `&#8212;`.
|
281
|
+
</code></pre>
|
282
|
+
|
283
|
+
<p>Output:</p>
|
284
|
+
|
285
|
+
<pre><code><p>I strongly recommend against using any
|
286
|
+
<code>&lt;blink&gt;</code> tags.</p>
|
287
|
+
|
288
|
+
<p>I wish SmartyPants used named entities like
|
289
|
+
<code>&amp;mdash;</code> instead of decimal-encoded
|
290
|
+
entites like <code>&amp;#8212;</code>.</p>
|
291
|
+
</code></pre>
|
292
|
+
|
293
|
+
<p>To specify an entire block of pre-formatted code, indent every line of
|
294
|
+
the block by 4 spaces or 1 tab. Just like with code spans, <code>&</code>, <code><</code>,
|
295
|
+
and <code>></code> characters will be escaped automatically.</p>
|
296
|
+
|
297
|
+
<p>Markdown:</p>
|
298
|
+
|
299
|
+
<pre><code>If you want your page to validate under XHTML 1.0 Strict,
|
300
|
+
you've got to put paragraph tags in your blockquotes:
|
301
|
+
|
302
|
+
<blockquote>
|
303
|
+
<p>For example.</p>
|
304
|
+
</blockquote>
|
305
|
+
</code></pre>
|
306
|
+
|
307
|
+
<p>Output:</p>
|
308
|
+
|
309
|
+
<pre><code><p>If you want your page to validate under XHTML 1.0 Strict,
|
310
|
+
you've got to put paragraph tags in your blockquotes:</p>
|
311
|
+
|
312
|
+
<pre><code>&lt;blockquote&gt;
|
313
|
+
&lt;p&gt;For example.&lt;/p&gt;
|
314
|
+
&lt;/blockquote&gt;
|
315
|
+
</code></pre>
|
316
|
+
</code></pre>
|