ronn 0.5 → 0.6.0

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