ronn 0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,75 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv='content-type' value='text/html;charset=utf8'>
5
+ <meta name='generator' value='Ronn/v#{Ronn::VERSION}'>
6
+ <title>#{name}(#{section})#{tagline ? " -- " + tagline : ''}</title>
7
+ <style type='text/css'>
8
+ body {margin:0}
9
+ #man, #man code, #man pre, #man tt, #man kbd, #man samp {
10
+ font-family:consolas,monospace;
11
+ font-size:16px;
12
+ line-height:1.3;
13
+ color:#343331;
14
+ background:#fff; }
15
+ #man { max-width:89ex; text-align:justify; margin:0 25px 25px 25px }
16
+ #man h1, #man h2, #man h3 { color:#232221;clear:left }
17
+ #man h1 { font-size:28px; margin:15px 0 30px 0; text-align:center }
18
+ #man h2 { font-size:18px; margin-bottom:0; margin-top:10px; line-height:1.3; }
19
+ #man h3 { font-size:16px; margin:0 0 0 4ex; }
20
+ #man p, #man ul, #man ol, #man dl, #man pre { margin:0 0 18px 0; }
21
+ #man pre {
22
+ color:#333231;
23
+ background:#edeceb;
24
+ padding:5px 7px;
25
+ margin:0px 0 20px 0;
26
+ border-left:2ex solid #ddd}
27
+ #man pre + h2, #man pre + h3 {
28
+ margin-top:22px;
29
+ }
30
+ #man h2 + pre, #man h3 + pre {
31
+ margin-top:5px;
32
+ }
33
+ #man > p, #man > ul, #man > ol, #man > dl, #man > pre { margin-left:8ex; }
34
+ #man dt { margin:0; clear:left }
35
+ #man dt.flush { float:left; width:8ex }
36
+ #man dd { margin:0 0 0 9ex }
37
+ #man code, #man strong, #man b { font-weight:bold; color:#131211; }
38
+ #man pre code { font-weight:normal; color:#232221; background:inherit }
39
+ #man em, var, u {
40
+ font-style:normal; color:#333231; border-bottom:1px solid #999; }
41
+ #man h1.man-title { display:none; }
42
+ #man ol.man, #man ol.man li { margin:2px 0 10px 0; padding:0;
43
+ float:left; width:33%; list-style-type:none;
44
+ text-transform:uppercase; font-size:18px; color:#999;
45
+ letter-spacing:1px;}
46
+ #man ol.man { width:100%; }
47
+ #man ol.man li.tl { text-align:left }
48
+ #man ol.man li.tc { text-align:center;letter-spacing:4px }
49
+ #man ol.man li.tr { text-align:right }
50
+ #man ol.man a { color:#999 }
51
+ #man ol.man a:hover { color:#333231 }
52
+ </style>
53
+ </head>
54
+ <body>
55
+ <div id='man'>
56
+
57
+ <h1 class='man-title'>#{name}(#{section})</h1>
58
+
59
+ <ol class='head man'>
60
+ <li class='tl'>#{name if section}#{"("+section+")" if name and section}</li>
61
+ <li class='tc'>#{manual}</li>
62
+ <li class='tr'>#{name if section}#{"("+section+")" if name and section}</li>
63
+ </ol>
64
+
65
+ #{html}
66
+
67
+ <ol class='foot man'>
68
+ <li class='tl'>#{organization}</li>
69
+ <li class='tc'>#{date.strftime('%B %Y')}</li>
70
+ <li class='tr'>#{name if section}#{"("+section+")" if name and section}</li>
71
+ </ol>
72
+
73
+ </div>
74
+ </body>
75
+ </html>
@@ -0,0 +1,197 @@
1
+ require 'hpricot'
2
+
3
+ module Ronn
4
+ class RoffFilter
5
+ # Convert Ronn HTML to roff.
6
+ def initialize(html, name, section, tagline, manual=nil, version=nil, date=nil)
7
+ @buf = []
8
+ title_heading name, section, tagline, manual, version, date
9
+ html = Hpricot(html)
10
+ block_filter(html)
11
+ write "\n"
12
+ end
13
+
14
+ def to_s
15
+ @buf.join.gsub(/\s+$/, '')
16
+ end
17
+
18
+ protected
19
+ def previous(node)
20
+ if node.respond_to?(:previous)
21
+ prev = node.previous
22
+ prev = prev.previous until prev.nil? || prev.elem?
23
+ prev
24
+ end
25
+ end
26
+
27
+ def title_heading(name, section, tagline, manual, version, date)
28
+ comment "generated with Ronn/v#{Ronn::VERSION}"
29
+ comment "http://github.com/rtomayko/ronn/"
30
+ macro "TH", %["#{escape(name.upcase)}" "#{section}" "#{date.strftime('%B %Y')}" "#{version}" "#{manual}"]
31
+ end
32
+
33
+ def block_filter(node)
34
+ if node.kind_of?(Array) || node.kind_of?(Hpricot::Elements)
35
+ node.each { |ch| block_filter(ch) }
36
+
37
+ elsif node.doc?
38
+ block_filter(node.children)
39
+
40
+ elsif node.text?
41
+ return if node.to_html =~ /^\s*$/m
42
+ warn "unexpected text: %p", node
43
+
44
+ elsif node.elem?
45
+ case node.name
46
+ when 'h2'
47
+ macro "SH", quote(escape(node.html))
48
+ when 'h3'
49
+ macro "SS", quote(escape(node.html))
50
+
51
+ when 'p'
52
+ prev = previous(node)
53
+ if prev && %w[dd li].include?(node.parent.name)
54
+ macro "IP"
55
+ elsif prev && !%w[h1 h2 h3].include?(prev.name)
56
+ macro "P"
57
+ end
58
+ inline_filter(node.children)
59
+
60
+ when 'pre'
61
+ prev = previous(node)
62
+ indent = prev.nil? || !%w[h1 h2 h3].include?(prev.name)
63
+ macro "IP", %w["" 4] if indent
64
+ macro "nf"
65
+ write "\n"
66
+ inline_filter(node.search('code > *'))
67
+ macro "fi"
68
+ macro "IP", %w["" 0] if indent
69
+
70
+ when 'dl'
71
+ macro "TP"
72
+ block_filter(node.children)
73
+ when 'dt'
74
+ prev = previous(node)
75
+ macro "TP" unless prev.nil?
76
+ inline_filter(node.children)
77
+ write "\n"
78
+ when 'dd'
79
+ if node.search('p').any?
80
+ block_filter(node.children)
81
+ else
82
+ inline_filter(node.children)
83
+ end
84
+ write "\n"
85
+
86
+ # when 'ol'
87
+ # macro "IP", '1.'
88
+ # block_filter(node.children)
89
+ when 'ul'
90
+ block_filter(node.children)
91
+ macro "IP", %w["" 0]
92
+ when 'li'
93
+ case node.parent.name
94
+ when 'ul'
95
+ macro "IP", %w["\(bu" 4]
96
+ end
97
+ if node.search('p|ol|ul|dl|div').any?
98
+ block_filter(node.children)
99
+ else
100
+ inline_filter(node.children)
101
+ end
102
+ write "\n"
103
+
104
+ else
105
+ warn "unrecognized block tag: %p", node.name
106
+ end
107
+
108
+ else
109
+ fail "unexpected node: #{node.inspect}"
110
+ end
111
+ end
112
+
113
+ def inline_filter(node)
114
+ if node.kind_of?(Array) || node.kind_of?(Hpricot::Elements)
115
+ node.each { |ch| inline_filter(ch) }
116
+
117
+ elsif node.text?
118
+ prev = previous(node)
119
+ text = node.to_html.dup
120
+ text.sub!(/^\n+/m, '') if prev && prev.name == 'br'
121
+ if node.previous.nil? && node.next
122
+ text.sub!(/\n+$/m, '')
123
+ else
124
+ text.sub!(/\n+$/m, ' ')
125
+ end
126
+ write escape(text)
127
+
128
+ elsif node.elem?
129
+ case node.name
130
+ when 'code'
131
+ write '\fB'
132
+ inline_filter(node.children)
133
+ write '\fR'
134
+
135
+ when 'b', 'strong', 'kbd', 'samp'
136
+ write '\fB'
137
+ inline_filter(node.children)
138
+ write '\fR'
139
+
140
+ when 'var', 'em', 'i', 'u'
141
+ write '\fI'
142
+ inline_filter(node.children)
143
+ write '\fR'
144
+
145
+ when 'br'
146
+ macro 'br'
147
+ when 'a'
148
+ write '\fI'
149
+ inline_filter(node.children)
150
+ write '\fR'
151
+ else
152
+ warn "unrecognized inline tag: %p", node.name
153
+ end
154
+
155
+ else
156
+ fail "unexpected node: #{node.inspect}"
157
+ end
158
+ end
159
+
160
+ def macro(name, value=nil)
161
+ writeln ".\n.#{[name, value].compact.join(' ')}"
162
+ end
163
+
164
+ def escape(text)
165
+ text.
166
+ gsub(/[\\-]/) { |m| "\\#{m}" }.
167
+ gsub('&nbsp;', ' ').
168
+ gsub('&lt;', '<').
169
+ gsub('&gt;', '>').
170
+ gsub('&amp;', '&')
171
+ end
172
+
173
+ def quote(text)
174
+ "\"#{text}\""
175
+ end
176
+
177
+ # write text to output buffer
178
+ def write(text)
179
+ @buf << text unless text.nil? || text.empty?
180
+ end
181
+
182
+ # write text to output buffer on a new line.
183
+ def writeln(text)
184
+ write "\n" if @buf.last && @buf.last[-1] != ?\n
185
+ write text
186
+ write "\n"
187
+ end
188
+
189
+ def comment(text)
190
+ writeln %[.\\" #{text}]
191
+ end
192
+
193
+ def warn(text, *args)
194
+ $stderr.puts "warn: #{text}" % args
195
+ end
196
+ end
197
+ end
@@ -0,0 +1,1513 @@
1
+ .\" generated with Ronn/v0.3
2
+ .\" http://github.com/rtomayko/ronn/
3
+ .
4
+ .TH "MARKDOWN" "5" "March 2010" "Ryan Tomayko" "Ronn Manual"
5
+ .
6
+ .SH "NAME"
7
+ \fBmarkdown\fR \-\- humane markup syntax
8
+ .
9
+ .SH "SYNOPSIS"
10
+ .
11
+ .nf
12
+ # Header 1 #
13
+ ## Header 2 ##
14
+ ### Header 3 ### (Hashes on right are optional)
15
+ #### Header 4 ####
16
+ ##### Header 5 #####
17
+ This is a paragraph, which is text surrounded by whitespace.
18
+ Paragraphs can be on one line (or many), and can drone on for
19
+ hours.
20
+ [Reference style links][1] and [inline links](http://example.com)
21
+ [1]: http://example.com "Title is optional"
22
+ Inline markup like _italics_, **bold**, and `code()`.
23
+ ![picture alt](/images/photo.jpeg "Title is optional")
24
+ > Blockquotes are like quoted text in email replies
25
+ >> And, they can be nested
26
+ code blocks are for preformatted
27
+ text and must be indented with four spaces
28
+ * Bullet lists are easy too
29
+ * You can
30
+ * even
31
+ * nest them
32
+ \- Another one
33
+ + Another one
34
+ .
35
+ .fi
36
+ .
37
+ .SH "DESCRIPTION"
38
+ .
39
+ .SS "Philosophy"
40
+ Markdown is intended to be as easy\-to\-read and easy\-to\-write as is feasible.
41
+ .
42
+ .P
43
+ Readability, however, is emphasized above all else. A Markdown\-formatted
44
+ document should be publishable as\-is, as plain text, without looking
45
+ like it's been marked up with tags or formatting instructions. While
46
+ Markdown's syntax has been influenced by several existing text\-to\-HTML
47
+ filters \-\- including \fISetext\fR, \fIatx\fR, \fITextile\fR, \fIreStructuredText\fR, \fIGrutatext\fR, and \fIEtText\fR \-\- the single biggest source of
48
+ inspiration for Markdown's syntax is the format of plain text email.
49
+ .
50
+ .P
51
+ To this end, Markdown's syntax is comprised entirely of punctuation
52
+ characters, which punctuation characters have been carefully chosen so
53
+ as to look like what they mean. E.g., asterisks around a word actually
54
+ look like *emphasis*. Markdown lists look like, well, lists. Even
55
+ blockquotes look like quoted passages of text, assuming you've ever
56
+ used email.
57
+ .
58
+ .SS "Inline HTML"
59
+ Markdown's syntax is intended for one purpose: to be used as a
60
+ format for \fIwriting\fR for the web.
61
+ .
62
+ .P
63
+ Markdown is not a replacement for HTML, or even close to it. Its
64
+ syntax is very small, corresponding only to a very small subset of
65
+ HTML tags. The idea is \fInot\fR to create a syntax that makes it easier
66
+ to insert HTML tags. In my opinion, HTML tags are already easy to
67
+ insert. The idea for Markdown is to make it easy to read, write, and
68
+ edit prose. HTML is a \fIpublishing\fR format; Markdown is a \fIwriting\fR
69
+ format. Thus, Markdown's formatting syntax only addresses issues that
70
+ can be conveyed in plain text.
71
+ .
72
+ .P
73
+ For any markup that is not covered by Markdown's syntax, you simply
74
+ use HTML itself. There's no need to preface it or delimit it to
75
+ indicate that you're switching from Markdown to HTML; you just use
76
+ the tags.
77
+ .
78
+ .P
79
+ The only restrictions are that block\-level HTML elements \-\- e.g. \fB<div>\fR, \fB<table>\fR, \fB<pre>\fR, \fB<p>\fR, etc. \-\- must be separated from surrounding
80
+ content by blank lines, and the start and end tags of the block should
81
+ not be indented with tabs or spaces. Markdown is smart enough not
82
+ to add extra (unwanted) \fB<p>\fR tags around HTML block\-level tags.
83
+ .
84
+ .P
85
+ For example, to add an HTML table to a Markdown article:
86
+ .
87
+ .IP "" 4
88
+ .
89
+ .nf
90
+ This is a regular paragraph.
91
+ <table>
92
+ <tr>
93
+ <td>Foo</td>
94
+ </tr>
95
+ </table>
96
+ This is another regular paragraph.
97
+ .
98
+ .fi
99
+ .
100
+ .IP "" 0
101
+ .
102
+ .P
103
+ Note that Markdown formatting syntax is not processed within block\-level
104
+ HTML tags. E.g., you can't use Markdown\-style \fB*emphasis*\fR inside an
105
+ HTML block.
106
+ .
107
+ .P
108
+ Span\-level HTML tags \-\- e.g. \fB<span>\fR, \fB<cite>\fR, or \fB<del>\fR \-\- can be
109
+ used anywhere in a Markdown paragraph, list item, or header. If you
110
+ want, you can even use HTML tags instead of Markdown formatting; e.g. if
111
+ you'd prefer to use HTML \fB<a>\fR or \fB<img>\fR tags instead of Markdown's
112
+ link or image syntax, go right ahead.
113
+ .
114
+ .P
115
+ Unlike block\-level HTML tags, Markdown syntax \fIis\fR processed within
116
+ span\-level tags.
117
+ .
118
+ .SS "Automatic Escaping for Special Characters"
119
+ In HTML, there are two characters that demand special treatment: \fB<\fR
120
+ and \fB&\fR. Left angle brackets are used to start tags; ampersands are
121
+ used to denote HTML entities. If you want to use them as literal
122
+ characters, you must escape them as entities, e.g. \fB&lt;\fR, and \fB&amp;\fR.
123
+ .
124
+ .P
125
+ Ampersands in particular are bedeviling for web writers. If you want to
126
+ write about 'AT&T', you need to write '\fBAT&amp;T\fR'. You even need to
127
+ escape ampersands within URLs. Thus, if you want to link to:
128
+ .
129
+ .IP "" 4
130
+ .
131
+ .nf
132
+ http://images.google.com/images?num=30&q=larry+bird
133
+ .
134
+ .fi
135
+ .
136
+ .IP "" 0
137
+ .
138
+ .P
139
+ you need to encode the URL as:
140
+ .
141
+ .IP "" 4
142
+ .
143
+ .nf
144
+ http://images.google.com/images?num=30&amp;q=larry+bird
145
+ .
146
+ .fi
147
+ .
148
+ .IP "" 0
149
+ .
150
+ .P
151
+ in your anchor tag \fBhref\fR attribute. Needless to say, this is easy to
152
+ forget, and is probably the single most common source of HTML validation
153
+ errors in otherwise well\-marked\-up web sites.
154
+ .
155
+ .P
156
+ Markdown allows you to use these characters naturally, taking care of
157
+ all the necessary escaping for you. If you use an ampersand as part of
158
+ an HTML entity, it remains unchanged; otherwise it will be translated
159
+ into \fB&amp;\fR.
160
+ .
161
+ .P
162
+ So, if you want to include a copyright symbol in your article, you can write:
163
+ .
164
+ .IP "" 4
165
+ .
166
+ .nf
167
+ &copy;
168
+ .
169
+ .fi
170
+ .
171
+ .IP "" 0
172
+ .
173
+ .P
174
+ and Markdown will leave it alone. But if you write:
175
+ .
176
+ .IP "" 4
177
+ .
178
+ .nf
179
+ AT&T
180
+ .
181
+ .fi
182
+ .
183
+ .IP "" 0
184
+ .
185
+ .P
186
+ Markdown will translate it to:
187
+ .
188
+ .IP "" 4
189
+ .
190
+ .nf
191
+ AT&amp;T
192
+ .
193
+ .fi
194
+ .
195
+ .IP "" 0
196
+ .
197
+ .P
198
+ Similarly, because Markdown supports \fIinline HTML\fR, if you use
199
+ angle brackets as delimiters for HTML tags, Markdown will treat them as
200
+ such. But if you write:
201
+ .
202
+ .IP "" 4
203
+ .
204
+ .nf
205
+ 4 < 5
206
+ .
207
+ .fi
208
+ .
209
+ .IP "" 0
210
+ .
211
+ .P
212
+ Markdown will translate it to:
213
+ .
214
+ .IP "" 4
215
+ .
216
+ .nf
217
+ 4 &lt; 5
218
+ .
219
+ .fi
220
+ .
221
+ .IP "" 0
222
+ .
223
+ .P
224
+ However, inside Markdown code spans and blocks, angle brackets and
225
+ ampersands are \fIalways\fR encoded automatically. This makes it easy to use
226
+ Markdown to write about HTML code. (As opposed to raw HTML, which is a
227
+ terrible format for writing about HTML syntax, because every single \fB<\fR
228
+ and \fB&\fR in your example code needs to be escaped.)
229
+ .
230
+ .SH "BLOCK ELEMENTS"
231
+ .
232
+ .SS "Paragraphs and Line Breaks"
233
+ A paragraph is simply one or more consecutive lines of text, separated
234
+ by one or more blank lines. (A blank line is any line that looks like a
235
+ blank line \-\- a line containing nothing but spaces or tabs is considered
236
+ blank.) Normal paragraphs should not be indented with spaces or tabs.
237
+ .
238
+ .P
239
+ The implication of the "one or more consecutive lines of text" rule is
240
+ that Markdown supports "hard\-wrapped" text paragraphs. This differs
241
+ significantly from most other text\-to\-HTML formatters (including Movable
242
+ Type's "Convert Line Breaks" option) which translate every line break
243
+ character in a paragraph into a \fB<br />\fR tag.
244
+ .
245
+ .P
246
+ When you \fIdo\fR want to insert a \fB<br />\fR break tag using Markdown, you
247
+ end a line with two or more spaces, then type return.
248
+ .
249
+ .P
250
+ Yes, this takes a tad more effort to create a \fB<br />\fR, but a simplistic
251
+ "every line break is a \fB<br />\fR" rule wouldn't work for Markdown.
252
+ Markdown's email\-style \fIblockquoting\fR and multi\-paragraph \fIlist items\fR
253
+ work best \-\- and look better \-\- when you format them with hard breaks.
254
+ .
255
+ .SS "Headers"
256
+ Markdown supports two styles of headers, \fISetext\fR and \fIatx\fR.
257
+ .
258
+ .P
259
+ Setext\-style headers are "underlined" using equal signs (for first\-level
260
+ headers) and dashes (for second\-level headers). For example:
261
+ .
262
+ .IP "" 4
263
+ .
264
+ .nf
265
+ This is an H1
266
+ =============
267
+ This is an H2
268
+ \-\-\-\-\-\-\-\-\-\-\-\-\-
269
+ .
270
+ .fi
271
+ .
272
+ .IP "" 0
273
+ .
274
+ .P
275
+ Any number of underlining \fB=\fR's or \fB\-\fR's will work.
276
+ .
277
+ .P
278
+ Atx\-style headers use 1\-6 hash characters at the start of the line,
279
+ corresponding to header levels 1\-6. For example:
280
+ .
281
+ .IP "" 4
282
+ .
283
+ .nf
284
+ # This is an H1
285
+ ## This is an H2
286
+ ###### This is an H6
287
+ .
288
+ .fi
289
+ .
290
+ .IP "" 0
291
+ .
292
+ .P
293
+ Optionally, you may "close" atx\-style headers. This is purely
294
+ cosmetic \-\- you can use this if you think it looks better. The
295
+ closing hashes don't even need to match the number of hashes
296
+ used to open the header. (The number of opening hashes
297
+ determines the header level.) :
298
+ .
299
+ .IP "" 4
300
+ .
301
+ .nf
302
+ # This is an H1 #
303
+ ## This is an H2 ##
304
+ ### This is an H3 ######
305
+ .
306
+ .fi
307
+ .
308
+ .IP "" 0
309
+ .
310
+ .SS "Blockquotes"
311
+ Markdown uses email\-style \fB>\fR characters for blockquoting. If you're
312
+ familiar with quoting passages of text in an email message, then you
313
+ know how to create a blockquote in Markdown. It looks best if you hard
314
+ wrap the text and put a \fB>\fR before every line:
315
+ .
316
+ .IP "" 4
317
+ .
318
+ .nf
319
+ > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
320
+ > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
321
+ > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
322
+ >
323
+ > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
324
+ > id sem consectetuer libero luctus adipiscing.
325
+ .
326
+ .fi
327
+ .
328
+ .IP "" 0
329
+ .
330
+ .P
331
+ Markdown allows you to be lazy and only put the \fB>\fR before the first
332
+ line of a hard\-wrapped paragraph:
333
+ .
334
+ .IP "" 4
335
+ .
336
+ .nf
337
+ > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
338
+ consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
339
+ Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
340
+ > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
341
+ id sem consectetuer libero luctus adipiscing.
342
+ .
343
+ .fi
344
+ .
345
+ .IP "" 0
346
+ .
347
+ .P
348
+ Blockquotes can be nested (i.e. a blockquote\-in\-a\-blockquote) by
349
+ adding additional levels of \fB>\fR:
350
+ .
351
+ .IP "" 4
352
+ .
353
+ .nf
354
+ > This is the first level of quoting.
355
+ >
356
+ > > This is nested blockquote.
357
+ >
358
+ > Back to the first level.
359
+ .
360
+ .fi
361
+ .
362
+ .IP "" 0
363
+ .
364
+ .P
365
+ Blockquotes can contain other Markdown elements, including headers, lists,
366
+ and code blocks:
367
+ .
368
+ .IP "" 4
369
+ .
370
+ .nf
371
+ > ## This is a header.
372
+ >
373
+ > 1. This is the first list item.
374
+ > 2. This is the second list item.
375
+ >
376
+ > Here's some example code:
377
+ >
378
+ > return shell_exec("echo $input | $markdown_script");
379
+ .
380
+ .fi
381
+ .
382
+ .IP "" 0
383
+ .
384
+ .P
385
+ Any decent text editor should make email\-style quoting easy. For
386
+ example, with BBEdit, you can make a selection and choose Increase
387
+ Quote Level from the Text menu.
388
+ .
389
+ .SS "Lists"
390
+ Markdown supports ordered (numbered) and unordered (bulleted) lists.
391
+ .
392
+ .P
393
+ Unordered lists use asterisks, pluses, and hyphens \-\- interchangably
394
+ \-\- as list markers:
395
+ .
396
+ .IP "" 4
397
+ .
398
+ .nf
399
+ * Red
400
+ * Green
401
+ * Blue
402
+ .
403
+ .fi
404
+ .
405
+ .IP "" 0
406
+ .
407
+ .P
408
+ is equivalent to:
409
+ .
410
+ .IP "" 4
411
+ .
412
+ .nf
413
+ + Red
414
+ + Green
415
+ + Blue
416
+ .
417
+ .fi
418
+ .
419
+ .IP "" 0
420
+ .
421
+ .P
422
+ and:
423
+ .
424
+ .IP "" 4
425
+ .
426
+ .nf
427
+ \- Red
428
+ \- Green
429
+ \- Blue
430
+ .
431
+ .fi
432
+ .
433
+ .IP "" 0
434
+ .
435
+ .P
436
+ Ordered lists use numbers followed by periods:
437
+ .
438
+ .IP "" 4
439
+ .
440
+ .nf
441
+ 1. Bird
442
+ 2. McHale
443
+ 3. Parish
444
+ .
445
+ .fi
446
+ .
447
+ .IP "" 0
448
+ .
449
+ .P
450
+ It's important to note that the actual numbers you use to mark the
451
+ list have no effect on the HTML output Markdown produces. The HTML
452
+ Markdown produces from the above list is:
453
+ .
454
+ .IP "" 4
455
+ .
456
+ .nf
457
+ <ol>
458
+ <li>Bird</li>
459
+ <li>McHale</li>
460
+ <li>Parish</li>
461
+ </ol>
462
+ .
463
+ .fi
464
+ .
465
+ .IP "" 0
466
+ .
467
+ .P
468
+ If you instead wrote the list in Markdown like this:
469
+ .
470
+ .IP "" 4
471
+ .
472
+ .nf
473
+ 1. Bird
474
+ 1. McHale
475
+ 1. Parish
476
+ .
477
+ .fi
478
+ .
479
+ .IP "" 0
480
+ .
481
+ .P
482
+ or even:
483
+ .
484
+ .IP "" 4
485
+ .
486
+ .nf
487
+ 3. Bird
488
+ 1. McHale
489
+ 8. Parish
490
+ .
491
+ .fi
492
+ .
493
+ .IP "" 0
494
+ .
495
+ .P
496
+ you'd get the exact same HTML output. The point is, if you want to,
497
+ you can use ordinal numbers in your ordered Markdown lists, so that
498
+ the numbers in your source match the numbers in your published HTML.
499
+ But if you want to be lazy, you don't have to.
500
+ .
501
+ .P
502
+ If you do use lazy list numbering, however, you should still start the
503
+ list with the number 1. At some point in the future, Markdown may support
504
+ starting ordered lists at an arbitrary number.
505
+ .
506
+ .P
507
+ List markers typically start at the left margin, but may be indented by
508
+ up to three spaces. List markers must be followed by one or more spaces
509
+ or a tab.
510
+ .
511
+ .P
512
+ To make lists look nice, you can wrap items with hanging indents:
513
+ .
514
+ .IP "" 4
515
+ .
516
+ .nf
517
+ * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
518
+ Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
519
+ viverra nec, fringilla in, laoreet vitae, risus.
520
+ * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
521
+ Suspendisse id sem consectetuer libero luctus adipiscing.
522
+ .
523
+ .fi
524
+ .
525
+ .IP "" 0
526
+ .
527
+ .P
528
+ But if you want to be lazy, you don't have to:
529
+ .
530
+ .IP "" 4
531
+ .
532
+ .nf
533
+ * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
534
+ Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
535
+ viverra nec, fringilla in, laoreet vitae, risus.
536
+ * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
537
+ Suspendisse id sem consectetuer libero luctus adipiscing.
538
+ .
539
+ .fi
540
+ .
541
+ .IP "" 0
542
+ .
543
+ .P
544
+ If list items are separated by blank lines, Markdown will wrap the
545
+ items in \fB<p>\fR tags in the HTML output. For example, this input:
546
+ .
547
+ .IP "" 4
548
+ .
549
+ .nf
550
+ * Bird
551
+ * Magic
552
+ .
553
+ .fi
554
+ .
555
+ .IP "" 0
556
+ .
557
+ .P
558
+ will turn into:
559
+ .
560
+ .IP "" 4
561
+ .
562
+ .nf
563
+ <ul>
564
+ <li>Bird</li>
565
+ <li>Magic</li>
566
+ </ul>
567
+ .
568
+ .fi
569
+ .
570
+ .IP "" 0
571
+ .
572
+ .P
573
+ But this:
574
+ .
575
+ .IP "" 4
576
+ .
577
+ .nf
578
+ * Bird
579
+ * Magic
580
+ .
581
+ .fi
582
+ .
583
+ .IP "" 0
584
+ .
585
+ .P
586
+ will turn into:
587
+ .
588
+ .IP "" 4
589
+ .
590
+ .nf
591
+ <ul>
592
+ <li><p>Bird</p></li>
593
+ <li><p>Magic</p></li>
594
+ </ul>
595
+ .
596
+ .fi
597
+ .
598
+ .IP "" 0
599
+ .
600
+ .P
601
+ List items may consist of multiple paragraphs. Each subsequent
602
+ paragraph in a list item must be indented by either 4 spaces
603
+ or one tab:
604
+ .
605
+ .IP "" 4
606
+ .
607
+ .nf
608
+ 1. This is a list item with two paragraphs. Lorem ipsum dolor
609
+ sit amet, consectetuer adipiscing elit. Aliquam hendrerit
610
+ mi posuere lectus.
611
+ Vestibulum enim wisi, viverra nec, fringilla in, laoreet
612
+ vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
613
+ sit amet velit.
614
+ 2. Suspendisse id sem consectetuer libero luctus adipiscing.
615
+ .
616
+ .fi
617
+ .
618
+ .IP "" 0
619
+ .
620
+ .P
621
+ It looks nice if you indent every line of the subsequent
622
+ paragraphs, but here again, Markdown will allow you to be
623
+ lazy:
624
+ .
625
+ .IP "" 4
626
+ .
627
+ .nf
628
+ * This is a list item with two paragraphs.
629
+ This is the second paragraph in the list item. You're
630
+ only required to indent the first line. Lorem ipsum dolor
631
+ sit amet, consectetuer adipiscing elit.
632
+ * Another item in the same list.
633
+ .
634
+ .fi
635
+ .
636
+ .IP "" 0
637
+ .
638
+ .P
639
+ To put a blockquote within a list item, the blockquote's \fB>\fR
640
+ delimiters need to be indented:
641
+ .
642
+ .IP "" 4
643
+ .
644
+ .nf
645
+ * A list item with a blockquote:
646
+ > This is a blockquote
647
+ > inside a list item.
648
+ .
649
+ .fi
650
+ .
651
+ .IP "" 0
652
+ .
653
+ .P
654
+ To put a code block within a list item, the code block needs
655
+ to be indented \fItwice\fR \-\- 8 spaces or two tabs:
656
+ .
657
+ .IP "" 4
658
+ .
659
+ .nf
660
+ * A list item with a code block:
661
+ <code goes here>
662
+ .
663
+ .fi
664
+ .
665
+ .IP "" 0
666
+ .
667
+ .P
668
+ It's worth noting that it's possible to trigger an ordered list by
669
+ accident, by writing something like this:
670
+ .
671
+ .IP "" 4
672
+ .
673
+ .nf
674
+ 1986. What a great season.
675
+ .
676
+ .fi
677
+ .
678
+ .IP "" 0
679
+ .
680
+ .P
681
+ In other words, a \fInumber\-period\-space\fR sequence at the beginning of a
682
+ line. To avoid this, you can backslash\-escape the period:
683
+ .
684
+ .IP "" 4
685
+ .
686
+ .nf
687
+ 1986\\. What a great season.
688
+ .
689
+ .fi
690
+ .
691
+ .IP "" 0
692
+ .
693
+ .SS "Code Blocks"
694
+ Pre\-formatted code blocks are used for writing about programming or
695
+ markup source code. Rather than forming normal paragraphs, the lines
696
+ of a code block are interpreted literally. Markdown wraps a code block
697
+ in both \fB<pre>\fR and \fB<code>\fR tags.
698
+ .
699
+ .P
700
+ To produce a code block in Markdown, simply indent every line of the
701
+ block by at least 4 spaces or 1 tab. For example, given this input:
702
+ .
703
+ .IP "" 4
704
+ .
705
+ .nf
706
+ This is a normal paragraph:
707
+ This is a code block.
708
+ .
709
+ .fi
710
+ .
711
+ .IP "" 0
712
+ .
713
+ .P
714
+ Markdown will generate:
715
+ .
716
+ .IP "" 4
717
+ .
718
+ .nf
719
+ <p>This is a normal paragraph:</p>
720
+ <pre><code>This is a code block.
721
+ </code></pre>
722
+ .
723
+ .fi
724
+ .
725
+ .IP "" 0
726
+ .
727
+ .P
728
+ One level of indentation \-\- 4 spaces or 1 tab \-\- is removed from each
729
+ line of the code block. For example, this:
730
+ .
731
+ .IP "" 4
732
+ .
733
+ .nf
734
+ Here is an example of AppleScript:
735
+ tell application "Foo"
736
+ beep
737
+ end tell
738
+ .
739
+ .fi
740
+ .
741
+ .IP "" 0
742
+ .
743
+ .P
744
+ will turn into:
745
+ .
746
+ .IP "" 4
747
+ .
748
+ .nf
749
+ <p>Here is an example of AppleScript:</p>
750
+ <pre><code>tell application "Foo"
751
+ beep
752
+ end tell
753
+ </code></pre>
754
+ .
755
+ .fi
756
+ .
757
+ .IP "" 0
758
+ .
759
+ .P
760
+ A code block continues until it reaches a line that is not indented
761
+ (or the end of the article).
762
+ .
763
+ .P
764
+ Within a code block, ampersands (\fB&\fR) and angle brackets (\fB<\fR and \fB>\fR)
765
+ are automatically converted into HTML entities. This makes it very
766
+ easy to include example HTML source code using Markdown \-\- just paste
767
+ it and indent it, and Markdown will handle the hassle of encoding the
768
+ ampersands and angle brackets. For example, this:
769
+ .
770
+ .IP "" 4
771
+ .
772
+ .nf
773
+ <div class="footer">
774
+ &copy; 2004 Foo Corporation
775
+ </div>
776
+ .
777
+ .fi
778
+ .
779
+ .IP "" 0
780
+ .
781
+ .P
782
+ will turn into:
783
+ .
784
+ .IP "" 4
785
+ .
786
+ .nf
787
+ <pre><code>&lt;div class="footer"&gt;
788
+ &amp;copy; 2004 Foo Corporation
789
+ &lt;/div&gt;
790
+ </code></pre>
791
+ .
792
+ .fi
793
+ .
794
+ .IP "" 0
795
+ .
796
+ .P
797
+ Regular Markdown syntax is not processed within code blocks. E.g.,
798
+ asterisks are just literal asterisks within a code block. This means
799
+ it's also easy to use Markdown to write about Markdown's own syntax.
800
+ .
801
+ .SS "Horizontal Rules"
802
+ You can produce a horizontal rule tag (\fB<hr />\fR) by placing three or
803
+ more hyphens, asterisks, or underscores on a line by themselves. If you
804
+ wish, you may use spaces between the hyphens or asterisks. Each of the
805
+ following lines will produce a horizontal rule:
806
+ .
807
+ .IP "" 4
808
+ .
809
+ .nf
810
+ * * *
811
+ ***
812
+ *****
813
+ \- \- \-
814
+ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
815
+ .
816
+ .fi
817
+ .
818
+ .IP "" 0
819
+ .
820
+ .SH "SPAN ELEMENTS"
821
+ .
822
+ .SS "Links"
823
+ Markdown supports two style of links: \fIinline\fR and \fIreference\fR.
824
+ .
825
+ .P
826
+ In both styles, the link text is delimited by [square brackets].
827
+ .
828
+ .P
829
+ To create an inline link, use a set of regular parentheses immediately
830
+ after the link text's closing square bracket. Inside the parentheses,
831
+ put the URL where you want the link to point, along with an \fIoptional\fR
832
+ title for the link, surrounded in quotes. For example:
833
+ .
834
+ .IP "" 4
835
+ .
836
+ .nf
837
+ This is [an example](http://example.com/ "Title") inline link.
838
+ [This link](http://example.net/) has no title attribute.
839
+ .
840
+ .fi
841
+ .
842
+ .IP "" 0
843
+ .
844
+ .P
845
+ Will produce:
846
+ .
847
+ .IP "" 4
848
+ .
849
+ .nf
850
+ <p>This is <a href="http://example.com/" title="Title">
851
+ an example</a> inline link.</p>
852
+ <p><a href="http://example.net/">This link</a> has no
853
+ title attribute.</p>
854
+ .
855
+ .fi
856
+ .
857
+ .IP "" 0
858
+ .
859
+ .P
860
+ If you're referring to a local resource on the same server, you can
861
+ use relative paths:
862
+ .
863
+ .IP "" 4
864
+ .
865
+ .nf
866
+ See my [About](/about/) page for details.
867
+ .
868
+ .fi
869
+ .
870
+ .IP "" 0
871
+ .
872
+ .P
873
+ Reference\-style links use a second set of square brackets, inside
874
+ which you place a label of your choosing to identify the link:
875
+ .
876
+ .IP "" 4
877
+ .
878
+ .nf
879
+ This is [an example][id] reference\-style link.
880
+ .
881
+ .fi
882
+ .
883
+ .IP "" 0
884
+ .
885
+ .P
886
+ You can optionally use a space to separate the sets of brackets:
887
+ .
888
+ .IP "" 4
889
+ .
890
+ .nf
891
+ This is [an example] [id] reference\-style link.
892
+ .
893
+ .fi
894
+ .
895
+ .IP "" 0
896
+ .
897
+ .P
898
+ Then, anywhere in the document, you define your link label like this,
899
+ on a line by itself:
900
+ .
901
+ .IP "" 4
902
+ .
903
+ .nf
904
+ [id]: http://example.com/ "Optional Title Here"
905
+ .
906
+ .fi
907
+ .
908
+ .IP "" 0
909
+ .
910
+ .P
911
+ That is:
912
+ .
913
+ .IP "\(bu" 4
914
+ Square brackets containing the link identifier (optionally
915
+ indented from the left margin using up to three spaces);
916
+ .
917
+ .IP "\(bu" 4
918
+ followed by a colon;
919
+ .
920
+ .IP "\(bu" 4
921
+ followed by one or more spaces (or tabs);
922
+ .
923
+ .IP "\(bu" 4
924
+ followed by the URL for the link;
925
+ .
926
+ .IP "\(bu" 4
927
+ optionally followed by a title attribute for the link, enclosed
928
+ in double or single quotes, or enclosed in parentheses.
929
+ .
930
+ .IP "" 0
931
+ .
932
+ .P
933
+ The following three link definitions are equivalent:
934
+ .
935
+ .IP "" 4
936
+ .
937
+ .nf
938
+ [foo]: http://example.com/ "Optional Title Here"
939
+ [foo]: http://example.com/ 'Optional Title Here'
940
+ [foo]: http://example.com/ (Optional Title Here)
941
+ .
942
+ .fi
943
+ .
944
+ .IP "" 0
945
+ .
946
+ .P
947
+ \fBNote:\fR There is a known bug in Markdown.pl 1.0.1 which prevents
948
+ single quotes from being used to delimit link titles.
949
+ .
950
+ .P
951
+ The link URL may, optionally, be surrounded by angle brackets:
952
+ .
953
+ .IP "" 4
954
+ .
955
+ .nf
956
+ [id]: <http://example.com/> "Optional Title Here"
957
+ .
958
+ .fi
959
+ .
960
+ .IP "" 0
961
+ .
962
+ .P
963
+ You can put the title attribute on the next line and use extra spaces
964
+ or tabs for padding, which tends to look better with longer URLs:
965
+ .
966
+ .IP "" 4
967
+ .
968
+ .nf
969
+ [id]: http://example.com/longish/path/to/resource/here
970
+ "Optional Title Here"
971
+ .
972
+ .fi
973
+ .
974
+ .IP "" 0
975
+ .
976
+ .P
977
+ Link definitions are only used for creating links during Markdown
978
+ processing, and are stripped from your document in the HTML output.
979
+ .
980
+ .P
981
+ Link definition names may consist of letters, numbers, spaces, and
982
+ punctuation \-\- but they are \fInot\fR case sensitive. E.g. these two
983
+ links:
984
+ .
985
+ .IP "" 4
986
+ .
987
+ .nf
988
+ [link text][a]
989
+ [link text][A]
990
+ .
991
+ .fi
992
+ .
993
+ .IP "" 0
994
+ .
995
+ .P
996
+ are equivalent.
997
+ .
998
+ .P
999
+ The \fIimplicit link name\fR shortcut allows you to omit the name of the
1000
+ link, in which case the link text itself is used as the name.
1001
+ Just use an empty set of square brackets \-\- e.g., to link the word
1002
+ "Google" to the google.com web site, you could simply write:
1003
+ .
1004
+ .IP "" 4
1005
+ .
1006
+ .nf
1007
+ [Google][]
1008
+ .
1009
+ .fi
1010
+ .
1011
+ .IP "" 0
1012
+ .
1013
+ .P
1014
+ And then define the link:
1015
+ .
1016
+ .IP "" 4
1017
+ .
1018
+ .nf
1019
+ [Google]: http://google.com/
1020
+ .
1021
+ .fi
1022
+ .
1023
+ .IP "" 0
1024
+ .
1025
+ .P
1026
+ Because link names may contain spaces, this shortcut even works for
1027
+ multiple words in the link text:
1028
+ .
1029
+ .IP "" 4
1030
+ .
1031
+ .nf
1032
+ Visit [Daring Fireball][] for more information.
1033
+ .
1034
+ .fi
1035
+ .
1036
+ .IP "" 0
1037
+ .
1038
+ .P
1039
+ And then define the link:
1040
+ .
1041
+ .IP "" 4
1042
+ .
1043
+ .nf
1044
+ [Daring Fireball]: http://daringfireball.net/
1045
+ .
1046
+ .fi
1047
+ .
1048
+ .IP "" 0
1049
+ .
1050
+ .P
1051
+ Link definitions can be placed anywhere in your Markdown document. I
1052
+ tend to put them immediately after each paragraph in which they're
1053
+ used, but if you want, you can put them all at the end of your
1054
+ document, sort of like footnotes.
1055
+ .
1056
+ .P
1057
+ Here's an example of reference links in action:
1058
+ .
1059
+ .IP "" 4
1060
+ .
1061
+ .nf
1062
+ I get 10 times more traffic from [Google] [1] than from
1063
+ [Yahoo] [2] or [MSN] [3].
1064
+ [1]: http://google.com/ "Google"
1065
+ [2]: http://search.yahoo.com/ "Yahoo Search"
1066
+ [3]: http://search.msn.com/ "MSN Search"
1067
+ .
1068
+ .fi
1069
+ .
1070
+ .IP "" 0
1071
+ .
1072
+ .P
1073
+ Using the implicit link name shortcut, you could instead write:
1074
+ .
1075
+ .IP "" 4
1076
+ .
1077
+ .nf
1078
+ I get 10 times more traffic from [Google][] than from
1079
+ [Yahoo][] or [MSN][].
1080
+ [google]: http://google.com/ "Google"
1081
+ [yahoo]: http://search.yahoo.com/ "Yahoo Search"
1082
+ [msn]: http://search.msn.com/ "MSN Search"
1083
+ .
1084
+ .fi
1085
+ .
1086
+ .IP "" 0
1087
+ .
1088
+ .P
1089
+ Both of the above examples will produce the following HTML output:
1090
+ .
1091
+ .IP "" 4
1092
+ .
1093
+ .nf
1094
+ <p>I get 10 times more traffic from <a href="http://google.com/"
1095
+ title="Google">Google</a> than from
1096
+ <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
1097
+ or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
1098
+ .
1099
+ .fi
1100
+ .
1101
+ .IP "" 0
1102
+ .
1103
+ .P
1104
+ For comparison, here is the same paragraph written using
1105
+ Markdown's inline link style:
1106
+ .
1107
+ .IP "" 4
1108
+ .
1109
+ .nf
1110
+ I get 10 times more traffic from [Google](http://google.com/ "Google")
1111
+ than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
1112
+ [MSN](http://search.msn.com/ "MSN Search").
1113
+ .
1114
+ .fi
1115
+ .
1116
+ .IP "" 0
1117
+ .
1118
+ .P
1119
+ The point of reference\-style links is not that they're easier to
1120
+ write. The point is that with reference\-style links, your document
1121
+ source is vastly more readable. Compare the above examples: using
1122
+ reference\-style links, the paragraph itself is only 81 characters
1123
+ long; with inline\-style links, it's 176 characters; and as raw HTML,
1124
+ it's 234 characters. In the raw HTML, there's more markup than there
1125
+ is text.
1126
+ .
1127
+ .P
1128
+ With Markdown's reference\-style links, a source document much more
1129
+ closely resembles the final output, as rendered in a browser. By
1130
+ allowing you to move the markup\-related metadata out of the paragraph,
1131
+ you can add links without interrupting the narrative flow of your
1132
+ prose.
1133
+ .
1134
+ .SS "Emphasis"
1135
+ Markdown treats asterisks (\fB*\fR) and underscores (\fB_\fR) as indicators of
1136
+ emphasis. Text wrapped with one \fB*\fR or \fB_\fR will be wrapped with an
1137
+ HTML \fB<em>\fR tag; double \fB*\fR's or \fB_\fR's will be wrapped with an HTML \fB<strong>\fR tag. E.g., this input:
1138
+ .
1139
+ .IP "" 4
1140
+ .
1141
+ .nf
1142
+ *single asterisks*
1143
+ _single underscores_
1144
+ **double asterisks**
1145
+ __double underscores__
1146
+ .
1147
+ .fi
1148
+ .
1149
+ .IP "" 0
1150
+ .
1151
+ .P
1152
+ will produce:
1153
+ .
1154
+ .IP "" 4
1155
+ .
1156
+ .nf
1157
+ <em>single asterisks</em>
1158
+ <em>single underscores</em>
1159
+ <strong>double asterisks</strong>
1160
+ <strong>double underscores</strong>
1161
+ .
1162
+ .fi
1163
+ .
1164
+ .IP "" 0
1165
+ .
1166
+ .P
1167
+ You can use whichever style you prefer; the lone restriction is that
1168
+ the same character must be used to open and close an emphasis span.
1169
+ .
1170
+ .P
1171
+ Emphasis can be used in the middle of a word:
1172
+ .
1173
+ .IP "" 4
1174
+ .
1175
+ .nf
1176
+ un*frigging*believable
1177
+ .
1178
+ .fi
1179
+ .
1180
+ .IP "" 0
1181
+ .
1182
+ .P
1183
+ But if you surround an \fB*\fR or \fB_\fR with spaces, it'll be treated as a
1184
+ literal asterisk or underscore.
1185
+ .
1186
+ .P
1187
+ To produce a literal asterisk or underscore at a position where it
1188
+ would otherwise be used as an emphasis delimiter, you can backslash
1189
+ escape it:
1190
+ .
1191
+ .IP "" 4
1192
+ .
1193
+ .nf
1194
+ \\*this text is surrounded by literal asterisks\\*
1195
+ .
1196
+ .fi
1197
+ .
1198
+ .IP "" 0
1199
+ .
1200
+ .SS "Code"
1201
+ To indicate a span of code, wrap it with backtick quotes (\fB`\fR).
1202
+ Unlike a pre\-formatted code block, a code span indicates code within a
1203
+ normal paragraph. For example:
1204
+ .
1205
+ .IP "" 4
1206
+ .
1207
+ .nf
1208
+ Use the `printf()` function.
1209
+ .
1210
+ .fi
1211
+ .
1212
+ .IP "" 0
1213
+ .
1214
+ .P
1215
+ will produce:
1216
+ .
1217
+ .IP "" 4
1218
+ .
1219
+ .nf
1220
+ <p>Use the <code>printf()</code> function.</p>
1221
+ .
1222
+ .fi
1223
+ .
1224
+ .IP "" 0
1225
+ .
1226
+ .P
1227
+ To include a literal backtick character within a code span, you can use
1228
+ multiple backticks as the opening and closing delimiters:
1229
+ .
1230
+ .IP "" 4
1231
+ .
1232
+ .nf
1233
+ ``There is a literal backtick (`) here.``
1234
+ .
1235
+ .fi
1236
+ .
1237
+ .IP "" 0
1238
+ .
1239
+ .P
1240
+ which will produce this:
1241
+ .
1242
+ .IP "" 4
1243
+ .
1244
+ .nf
1245
+ <p><code>There is a literal backtick (`) here.</code></p>
1246
+ .
1247
+ .fi
1248
+ .
1249
+ .IP "" 0
1250
+ .
1251
+ .P
1252
+ The backtick delimiters surrounding a code span may include spaces \-\-
1253
+ one after the opening, one before the closing. This allows you to place
1254
+ literal backtick characters at the beginning or end of a code span:
1255
+ .
1256
+ .IP "" 4
1257
+ .
1258
+ .nf
1259
+ A single backtick in a code span: `` ` ``
1260
+ A backtick\-delimited string in a code span: `` `foo` ``
1261
+ .
1262
+ .fi
1263
+ .
1264
+ .IP "" 0
1265
+ .
1266
+ .P
1267
+ will produce:
1268
+ .
1269
+ .IP "" 4
1270
+ .
1271
+ .nf
1272
+ <p>A single backtick in a code span: <code>`</code></p>
1273
+ <p>A backtick\-delimited string in a code span: <code>`foo`</code></p>
1274
+ .
1275
+ .fi
1276
+ .
1277
+ .IP "" 0
1278
+ .
1279
+ .P
1280
+ With a code span, ampersands and angle brackets are encoded as HTML
1281
+ entities automatically, which makes it easy to include example HTML
1282
+ tags. Markdown will turn this:
1283
+ .
1284
+ .IP "" 4
1285
+ .
1286
+ .nf
1287
+ Please don't use any `<blink>` tags.
1288
+ .
1289
+ .fi
1290
+ .
1291
+ .IP "" 0
1292
+ .
1293
+ .P
1294
+ into:
1295
+ .
1296
+ .IP "" 4
1297
+ .
1298
+ .nf
1299
+ <p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>
1300
+ .
1301
+ .fi
1302
+ .
1303
+ .IP "" 0
1304
+ .
1305
+ .P
1306
+ You can write this:
1307
+ .
1308
+ .IP "" 4
1309
+ .
1310
+ .nf
1311
+ `&#8212;` is the decimal\-encoded equivalent of `&mdash;`.
1312
+ .
1313
+ .fi
1314
+ .
1315
+ .IP "" 0
1316
+ .
1317
+ .P
1318
+ to produce:
1319
+ .
1320
+ .IP "" 4
1321
+ .
1322
+ .nf
1323
+ <p><code>&amp;#8212;</code> is the decimal\-encoded
1324
+ equivalent of <code>&amp;mdash;</code>.</p>
1325
+ .
1326
+ .fi
1327
+ .
1328
+ .IP "" 0
1329
+ .
1330
+ .SS "Images"
1331
+ Admittedly, it's fairly difficult to devise a "natural" syntax for
1332
+ placing images into a plain text document format.
1333
+ .
1334
+ .P
1335
+ Markdown uses an image syntax that is intended to resemble the syntax
1336
+ for links, allowing for two styles: \fIinline\fR and \fIreference\fR.
1337
+ .
1338
+ .P
1339
+ Inline image syntax looks like this:
1340
+ .
1341
+ .IP "" 4
1342
+ .
1343
+ .nf
1344
+ ![Alt text](/path/to/img.jpg)
1345
+ ![Alt text](/path/to/img.jpg "Optional title")
1346
+ .
1347
+ .fi
1348
+ .
1349
+ .IP "" 0
1350
+ .
1351
+ .P
1352
+ That is:
1353
+ .
1354
+ .IP "\(bu" 4
1355
+ An exclamation mark: \fB!\fR;
1356
+ .
1357
+ .IP "\(bu" 4
1358
+ followed by a set of square brackets, containing the \fBalt\fR
1359
+ attribute text for the image;
1360
+ .
1361
+ .IP "\(bu" 4
1362
+ followed by a set of parentheses, containing the URL or path to
1363
+ the image, and an optional \fBtitle\fR attribute enclosed in double
1364
+ or single quotes.
1365
+ .
1366
+ .IP "" 0
1367
+ .
1368
+ .P
1369
+ Reference\-style image syntax looks like this:
1370
+ .
1371
+ .IP "" 4
1372
+ .
1373
+ .nf
1374
+ ![Alt text][id]
1375
+ .
1376
+ .fi
1377
+ .
1378
+ .IP "" 0
1379
+ .
1380
+ .P
1381
+ Where "id" is the name of a defined image reference. Image references
1382
+ are defined using syntax identical to link references:
1383
+ .
1384
+ .IP "" 4
1385
+ .
1386
+ .nf
1387
+ [id]: url/to/image "Optional title attribute"
1388
+ .
1389
+ .fi
1390
+ .
1391
+ .IP "" 0
1392
+ .
1393
+ .P
1394
+ As of this writing, Markdown has no syntax for specifying the
1395
+ dimensions of an image; if this is important to you, you can simply
1396
+ use regular HTML \fB<img>\fR tags.
1397
+ .
1398
+ .SH "MISCELLANEOUS"
1399
+ .
1400
+ .SS "Automatic Links"
1401
+ Markdown supports a shortcut style for creating "automatic" links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this:
1402
+ .
1403
+ .IP "" 4
1404
+ .
1405
+ .nf
1406
+ <http://example.com/>
1407
+ .
1408
+ .fi
1409
+ .
1410
+ .IP "" 0
1411
+ .
1412
+ .P
1413
+ Markdown will turn this into:
1414
+ .
1415
+ .IP "" 4
1416
+ .
1417
+ .nf
1418
+ <a href="http://example.com/">http://example.com/</a>
1419
+ .
1420
+ .fi
1421
+ .
1422
+ .IP "" 0
1423
+ .
1424
+ .P
1425
+ Automatic links for email addresses work similarly, except that
1426
+ Markdown will also perform a bit of randomized decimal and hex
1427
+ entity\-encoding to help obscure your address from address\-harvesting
1428
+ spambots. For example, Markdown will turn this:
1429
+ .
1430
+ .IP "" 4
1431
+ .
1432
+ .nf
1433
+ <address@example.com>
1434
+ .
1435
+ .fi
1436
+ .
1437
+ .IP "" 0
1438
+ .
1439
+ .P
1440
+ into something like this:
1441
+ .
1442
+ .IP "" 4
1443
+ .
1444
+ .nf
1445
+ <a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;
1446
+ &#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;
1447
+ &#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
1448
+ &#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
1449
+ .
1450
+ .fi
1451
+ .
1452
+ .IP "" 0
1453
+ .
1454
+ .P
1455
+ which will render in a browser as a clickable link to "address@example.com".
1456
+ .
1457
+ .P
1458
+ (This sort of entity\-encoding trick will indeed fool many, if not
1459
+ most, address\-harvesting bots, but it definitely won't fool all of
1460
+ them. It's better than nothing, but an address published in this way
1461
+ will probably eventually start receiving spam.)
1462
+ .
1463
+ .SS "Backslash Escapes"
1464
+ Markdown allows you to use backslash escapes to generate literal
1465
+ characters which would otherwise have special meaning in Markdown's
1466
+ formatting syntax. For example, if you wanted to surround a word
1467
+ with literal asterisks (instead of an HTML \fB<em>\fR tag), you can use
1468
+ backslashes before the asterisks, like this:
1469
+ .
1470
+ .IP "" 4
1471
+ .
1472
+ .nf
1473
+ \\*literal asterisks\\*
1474
+ .
1475
+ .fi
1476
+ .
1477
+ .IP "" 0
1478
+ .
1479
+ .P
1480
+ Markdown provides backslash escapes for the following characters:
1481
+ .
1482
+ .IP "" 4
1483
+ .
1484
+ .nf
1485
+ \\ backslash
1486
+ ` backtick
1487
+ * asterisk
1488
+ _ underscore
1489
+ {} curly braces
1490
+ [] square brackets
1491
+ () parentheses
1492
+ # hash mark
1493
+ + plus sign
1494
+ \- minus sign (hyphen)
1495
+ . dot
1496
+ ! exclamation mark
1497
+ .
1498
+ .fi
1499
+ .
1500
+ .IP "" 0
1501
+ .
1502
+ .SH "AUTHOR"
1503
+ Markdown was created by John Gruber.
1504
+ .
1505
+ .P
1506
+ Manual page by Ryan Tomayko. It's pretty much a direct copy of the\fIMarkdown Syntax Reference\fR,
1507
+ also by John Gruber.
1508
+ .
1509
+ .SH "SEE ALSO"
1510
+ ronn(5)
1511
+ .
1512
+ .br
1513
+ \fIhttp://daringfireball.net/projects/markdown/\fR