redcarpet 1.17.2 → 2.0.0b
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of redcarpet might be problematic. Click here for more details.
- data/README.markdown +232 -37
- data/Rakefile +13 -15
- data/bin/redcarpet +1 -1
- data/ext/redcarpet/autolink.c +5 -5
- data/ext/redcarpet/autolink.h +7 -4
- data/ext/redcarpet/html.c +83 -71
- data/ext/redcarpet/html.h +14 -5
- data/ext/redcarpet/html_smartypants.c +35 -11
- data/ext/redcarpet/markdown.c +153 -85
- data/ext/redcarpet/markdown.h +6 -10
- data/ext/redcarpet/rc_markdown.c +108 -0
- data/ext/redcarpet/rc_render.c +469 -0
- data/lib/redcarpet.rb +68 -106
- data/redcarpet.gemspec +8 -11
- data/test/redcarpet_test.rb +206 -122
- metadata +17 -18
- data/ext/redcarpet/redcarpet.c +0 -161
- data/lib/markdown.rb +0 -1
- data/test/benchmark.rb +0 -56
- data/test/benchmark.txt +0 -306
- data/test/markdown_test.rb +0 -186
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redcarpet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 11
|
5
|
+
prerelease: 5
|
6
6
|
segments:
|
7
|
-
- 1
|
8
|
-
- 17
|
9
7
|
- 2
|
10
|
-
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
- b
|
11
|
+
version: 2.0.0b
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- "Natacha Port\xC3\xA9"
|
@@ -16,11 +17,11 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2011-
|
20
|
+
date: 2011-08-03 00:00:00 +02:00
|
20
21
|
default_executable:
|
21
22
|
dependencies: []
|
22
23
|
|
23
|
-
description: A fast and
|
24
|
+
description: A fast, safe and extensible Markdown to (X)HTML parser
|
24
25
|
email: vicent@github.com
|
25
26
|
executables:
|
26
27
|
- redcarpet
|
@@ -45,13 +46,10 @@ files:
|
|
45
46
|
- ext/redcarpet/html_smartypants.c
|
46
47
|
- ext/redcarpet/markdown.c
|
47
48
|
- ext/redcarpet/markdown.h
|
48
|
-
- ext/redcarpet/
|
49
|
-
-
|
49
|
+
- ext/redcarpet/rc_markdown.c
|
50
|
+
- ext/redcarpet/rc_render.c
|
50
51
|
- lib/redcarpet.rb
|
51
52
|
- redcarpet.gemspec
|
52
|
-
- test/benchmark.rb
|
53
|
-
- test/benchmark.txt
|
54
|
-
- test/markdown_test.rb
|
55
53
|
- test/redcarpet_test.rb
|
56
54
|
has_rdoc: true
|
57
55
|
homepage: http://github.com/tanoku/redcarpet
|
@@ -74,19 +72,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
73
|
none: false
|
76
74
|
requirements:
|
77
|
-
- - "
|
75
|
+
- - ">"
|
78
76
|
- !ruby/object:Gem::Version
|
79
|
-
hash:
|
77
|
+
hash: 25
|
80
78
|
segments:
|
81
|
-
-
|
82
|
-
|
79
|
+
- 1
|
80
|
+
- 3
|
81
|
+
- 1
|
82
|
+
version: 1.3.1
|
83
83
|
requirements: []
|
84
84
|
|
85
85
|
rubyforge_project:
|
86
86
|
rubygems_version: 1.6.2
|
87
87
|
signing_key:
|
88
88
|
specification_version: 3
|
89
|
-
summary:
|
89
|
+
summary: Markdown that smells nice
|
90
90
|
test_files:
|
91
|
-
- test/markdown_test.rb
|
92
91
|
- test/redcarpet_test.rb
|
data/ext/redcarpet/redcarpet.c
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
#define RSTRING_NOT_MODIFIED
|
2
|
-
|
3
|
-
#include <stdio.h>
|
4
|
-
#include "ruby.h"
|
5
|
-
|
6
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
7
|
-
#include <ruby/encoding.h>
|
8
|
-
#else
|
9
|
-
#define rb_enc_copy(dst, src)
|
10
|
-
#endif
|
11
|
-
|
12
|
-
#include "markdown.h"
|
13
|
-
#include "html.h"
|
14
|
-
|
15
|
-
typedef enum
|
16
|
-
{
|
17
|
-
REDCARPET_RENDER_HTML,
|
18
|
-
REDCARPET_RENDER_TOC
|
19
|
-
} RendererType;
|
20
|
-
|
21
|
-
static VALUE rb_cRedcarpet;
|
22
|
-
|
23
|
-
static void rb_redcarpet__get_flags(VALUE ruby_obj,
|
24
|
-
unsigned int *enabled_extensions_p,
|
25
|
-
unsigned int *render_flags_p)
|
26
|
-
{
|
27
|
-
unsigned int render_flags = HTML_EXPAND_TABS;
|
28
|
-
unsigned int extensions = 0;
|
29
|
-
|
30
|
-
/* filter_html */
|
31
|
-
if (rb_funcall(ruby_obj, rb_intern("filter_html"), 0) == Qtrue)
|
32
|
-
render_flags |= HTML_SKIP_HTML;
|
33
|
-
|
34
|
-
/* no_image */
|
35
|
-
if (rb_funcall(ruby_obj, rb_intern("no_image"), 0) == Qtrue)
|
36
|
-
render_flags |= HTML_SKIP_IMAGES;
|
37
|
-
|
38
|
-
/* no_links */
|
39
|
-
if (rb_funcall(ruby_obj, rb_intern("no_links"), 0) == Qtrue)
|
40
|
-
render_flags |= HTML_SKIP_LINKS;
|
41
|
-
|
42
|
-
/* filter_style */
|
43
|
-
if (rb_funcall(ruby_obj, rb_intern("filter_styles"), 0) == Qtrue)
|
44
|
-
render_flags |= HTML_SKIP_STYLE;
|
45
|
-
|
46
|
-
/* safelink */
|
47
|
-
if (rb_funcall(ruby_obj, rb_intern("safelink"), 0) == Qtrue)
|
48
|
-
render_flags |= HTML_SAFELINK;
|
49
|
-
|
50
|
-
if (rb_funcall(ruby_obj, rb_intern("generate_toc"), 0) == Qtrue)
|
51
|
-
render_flags |= HTML_TOC;
|
52
|
-
|
53
|
-
if (rb_funcall(ruby_obj, rb_intern("hard_wrap"), 0) == Qtrue)
|
54
|
-
render_flags |= HTML_HARD_WRAP;
|
55
|
-
|
56
|
-
if (rb_funcall(ruby_obj, rb_intern("gh_blockcode"), 0) == Qtrue)
|
57
|
-
render_flags |= HTML_GITHUB_BLOCKCODE;
|
58
|
-
|
59
|
-
if (rb_funcall(ruby_obj, rb_intern("xhtml"), 0) == Qtrue)
|
60
|
-
render_flags |= HTML_USE_XHTML;
|
61
|
-
|
62
|
-
/**
|
63
|
-
* Markdown extensions -- all disabled by default
|
64
|
-
*/
|
65
|
-
if (rb_funcall(ruby_obj, rb_intern("no_intraemphasis"), 0) == Qtrue)
|
66
|
-
extensions |= MKDEXT_NO_INTRA_EMPHASIS;
|
67
|
-
|
68
|
-
if (rb_funcall(ruby_obj, rb_intern("tables"), 0) == Qtrue)
|
69
|
-
extensions |= MKDEXT_TABLES;
|
70
|
-
|
71
|
-
if (rb_funcall(ruby_obj, rb_intern("fenced_code"), 0) == Qtrue)
|
72
|
-
extensions |= MKDEXT_FENCED_CODE;
|
73
|
-
|
74
|
-
if (rb_funcall(ruby_obj, rb_intern("autolink"), 0) == Qtrue)
|
75
|
-
extensions |= MKDEXT_AUTOLINK;
|
76
|
-
|
77
|
-
if (rb_funcall(ruby_obj, rb_intern("strikethrough"), 0) == Qtrue)
|
78
|
-
extensions |= MKDEXT_STRIKETHROUGH;
|
79
|
-
|
80
|
-
if (rb_funcall(ruby_obj, rb_intern("lax_htmlblock"), 0) == Qtrue)
|
81
|
-
extensions |= MKDEXT_LAX_HTML_BLOCKS;
|
82
|
-
|
83
|
-
if (rb_funcall(ruby_obj, rb_intern("space_header"), 0) == Qtrue)
|
84
|
-
extensions |= MKDEXT_SPACE_HEADERS;
|
85
|
-
|
86
|
-
*enabled_extensions_p = extensions;
|
87
|
-
*render_flags_p = render_flags;
|
88
|
-
}
|
89
|
-
|
90
|
-
static VALUE rb_redcarpet__render(VALUE self, RendererType render_type)
|
91
|
-
{
|
92
|
-
VALUE text = rb_funcall(self, rb_intern("text"), 0);
|
93
|
-
VALUE result;
|
94
|
-
|
95
|
-
struct buf input_buf, *output_buf;
|
96
|
-
struct mkd_renderer renderer;
|
97
|
-
unsigned int enabled_extensions, render_flags;
|
98
|
-
|
99
|
-
Check_Type(text, T_STRING);
|
100
|
-
|
101
|
-
memset(&input_buf, 0x0, sizeof(struct buf));
|
102
|
-
input_buf.data = RSTRING_PTR(text);
|
103
|
-
input_buf.size = RSTRING_LEN(text);
|
104
|
-
|
105
|
-
output_buf = bufnew(128);
|
106
|
-
bufgrow(output_buf, RSTRING_LEN(text) * 1.2f);
|
107
|
-
|
108
|
-
rb_redcarpet__get_flags(self, &enabled_extensions, &render_flags);
|
109
|
-
|
110
|
-
switch (render_type) {
|
111
|
-
case REDCARPET_RENDER_HTML:
|
112
|
-
upshtml_renderer(&renderer, render_flags);
|
113
|
-
break;
|
114
|
-
|
115
|
-
case REDCARPET_RENDER_TOC:
|
116
|
-
upshtml_toc_renderer(&renderer);
|
117
|
-
break;
|
118
|
-
|
119
|
-
default:
|
120
|
-
return Qnil;
|
121
|
-
}
|
122
|
-
|
123
|
-
ups_markdown(output_buf, &input_buf, &renderer, enabled_extensions);
|
124
|
-
|
125
|
-
if (rb_funcall(self, rb_intern("smart"), 0) == Qtrue) {
|
126
|
-
struct buf *smart_buf = bufnew(128);
|
127
|
-
upshtml_smartypants(smart_buf, output_buf);
|
128
|
-
result = rb_str_new(smart_buf->data, smart_buf->size);
|
129
|
-
bufrelease(smart_buf);
|
130
|
-
} else {
|
131
|
-
result = rb_str_new(output_buf->data, output_buf->size);
|
132
|
-
}
|
133
|
-
|
134
|
-
bufrelease(output_buf);
|
135
|
-
upshtml_free_renderer(&renderer);
|
136
|
-
|
137
|
-
/* force the input encoding */
|
138
|
-
rb_enc_copy(result, text);
|
139
|
-
|
140
|
-
return result;
|
141
|
-
}
|
142
|
-
|
143
|
-
static VALUE
|
144
|
-
rb_redcarpet_toc(int argc, VALUE *argv, VALUE self)
|
145
|
-
{
|
146
|
-
return rb_redcarpet__render(self, REDCARPET_RENDER_TOC);
|
147
|
-
}
|
148
|
-
|
149
|
-
static VALUE
|
150
|
-
rb_redcarpet_to_html(int argc, VALUE *argv, VALUE self)
|
151
|
-
{
|
152
|
-
return rb_redcarpet__render(self, REDCARPET_RENDER_HTML);
|
153
|
-
}
|
154
|
-
|
155
|
-
void Init_redcarpet()
|
156
|
-
{
|
157
|
-
rb_cRedcarpet = rb_define_class("Redcarpet", rb_cObject);
|
158
|
-
rb_define_method(rb_cRedcarpet, "to_html", rb_redcarpet_to_html, -1);
|
159
|
-
rb_define_method(rb_cRedcarpet, "toc_content", rb_redcarpet_toc, -1);
|
160
|
-
}
|
161
|
-
|
data/lib/markdown.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'redcarpet'
|
data/test/benchmark.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
|
-
iterations = 100
|
4
|
-
test_file = "#{File.dirname(__FILE__)}/benchmark.txt"
|
5
|
-
implementations = %w[BlueCloth RDiscount Maruku PEGMarkdown Redcarpet]
|
6
|
-
|
7
|
-
# Attempt to require each implementation and remove any that are not
|
8
|
-
# installed.
|
9
|
-
implementations.reject! do |class_name|
|
10
|
-
begin
|
11
|
-
module_path =
|
12
|
-
if class_name == 'PEGMarkdown'
|
13
|
-
'peg_markdown'
|
14
|
-
else
|
15
|
-
class_name.downcase
|
16
|
-
end
|
17
|
-
require module_path
|
18
|
-
false
|
19
|
-
rescue LoadError => boom
|
20
|
-
module_path.tr! '_', '-'
|
21
|
-
puts "#{class_name} excluded. Try: gem install #{module_path}"
|
22
|
-
true
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Grab actual class objects.
|
27
|
-
implementations.map! { |class_name| Object.const_get(class_name) }
|
28
|
-
|
29
|
-
# The actual benchmark.
|
30
|
-
def benchmark(implementation, text, iterations)
|
31
|
-
start = Time.now
|
32
|
-
iterations.times do |i|
|
33
|
-
implementation.new(text).to_html
|
34
|
-
end
|
35
|
-
Time.now - start
|
36
|
-
end
|
37
|
-
|
38
|
-
# Read test file
|
39
|
-
test_data = File.read(test_file)
|
40
|
-
|
41
|
-
# Prime the pump
|
42
|
-
puts "Spinning up ..."
|
43
|
-
implementations.each { |impl| benchmark(impl, test_data, 1) }
|
44
|
-
|
45
|
-
# Run benchmarks; gather results.
|
46
|
-
puts "Running benchmarks ..."
|
47
|
-
results =
|
48
|
-
implementations.inject([]) do |r,impl|
|
49
|
-
GC.start
|
50
|
-
r << [ impl, benchmark(impl, test_data, iterations) ]
|
51
|
-
end
|
52
|
-
|
53
|
-
puts "Results for #{iterations} iterations:"
|
54
|
-
results.each do |impl,time|
|
55
|
-
printf " %10s %09.06fs total time, %09.06fs average\n", "#{impl}:", time, time / iterations
|
56
|
-
end
|
data/test/benchmark.txt
DELETED
@@ -1,306 +0,0 @@
|
|
1
|
-
Markdown: Basics
|
2
|
-
================
|
3
|
-
|
4
|
-
<ul id="ProjectSubmenu">
|
5
|
-
<li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
|
6
|
-
<li><a class="selected" title="Markdown Basics">Basics</a></li>
|
7
|
-
<li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
|
8
|
-
<li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
|
9
|
-
<li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
|
10
|
-
</ul>
|
11
|
-
|
12
|
-
|
13
|
-
Getting the Gist of Markdown's Formatting Syntax
|
14
|
-
------------------------------------------------
|
15
|
-
|
16
|
-
This page offers a brief overview of what it's like to use Markdown.
|
17
|
-
The [syntax page] [s] provides complete, detailed documentation for
|
18
|
-
every feature, but Markdown should be very easy to pick up simply by
|
19
|
-
looking at a few examples of it in action. The examples on this page
|
20
|
-
are written in a before/after style, showing example syntax and the
|
21
|
-
HTML output produced by Markdown.
|
22
|
-
|
23
|
-
It's also helpful to simply try Markdown out; the [Dingus] [d] is a
|
24
|
-
web application that allows you type your own Markdown-formatted text
|
25
|
-
and translate it to XHTML.
|
26
|
-
|
27
|
-
**Note:** This document is itself written using Markdown; you
|
28
|
-
can [see the source for it by adding '.text' to the URL] [src].
|
29
|
-
|
30
|
-
[s]: /projects/markdown/syntax "Markdown Syntax"
|
31
|
-
[d]: /projects/markdown/dingus "Markdown Dingus"
|
32
|
-
[src]: /projects/markdown/basics.text
|
33
|
-
|
34
|
-
|
35
|
-
## Paragraphs, Headers, Blockquotes ##
|
36
|
-
|
37
|
-
A paragraph is simply one or more consecutive lines of text, separated
|
38
|
-
by one or more blank lines. (A blank line is any line that looks like a
|
39
|
-
blank line -- a line containing nothing spaces or tabs is considered
|
40
|
-
blank.) Normal paragraphs should not be intended with spaces or tabs.
|
41
|
-
|
42
|
-
Markdown offers two styles of headers: *Setext* and *atx*.
|
43
|
-
Setext-style headers for `<h1>` and `<h2>` are created by
|
44
|
-
"underlining" with equal signs (`=`) and hyphens (`-`), respectively.
|
45
|
-
To create an atx-style header, you put 1-6 hash marks (`#`) at the
|
46
|
-
beginning of the line -- the number of hashes equals the resulting
|
47
|
-
HTML header level.
|
48
|
-
|
49
|
-
Blockquotes are indicated using email-style '`>`' angle brackets.
|
50
|
-
|
51
|
-
Markdown:
|
52
|
-
|
53
|
-
A First Level Header
|
54
|
-
====================
|
55
|
-
|
56
|
-
A Second Level Header
|
57
|
-
---------------------
|
58
|
-
|
59
|
-
Now is the time for all good men to come to
|
60
|
-
the aid of their country. This is just a
|
61
|
-
regular paragraph.
|
62
|
-
|
63
|
-
The quick brown fox jumped over the lazy
|
64
|
-
dog's back.
|
65
|
-
|
66
|
-
### Header 3
|
67
|
-
|
68
|
-
> This is a blockquote.
|
69
|
-
>
|
70
|
-
> This is the second paragraph in the blockquote.
|
71
|
-
>
|
72
|
-
> ## This is an H2 in a blockquote
|
73
|
-
|
74
|
-
|
75
|
-
Output:
|
76
|
-
|
77
|
-
<h1>A First Level Header</h1>
|
78
|
-
|
79
|
-
<h2>A Second Level Header</h2>
|
80
|
-
|
81
|
-
<p>Now is the time for all good men to come to
|
82
|
-
the aid of their country. This is just a
|
83
|
-
regular paragraph.</p>
|
84
|
-
|
85
|
-
<p>The quick brown fox jumped over the lazy
|
86
|
-
dog's back.</p>
|
87
|
-
|
88
|
-
<h3>Header 3</h3>
|
89
|
-
|
90
|
-
<blockquote>
|
91
|
-
<p>This is a blockquote.</p>
|
92
|
-
|
93
|
-
<p>This is the second paragraph in the blockquote.</p>
|
94
|
-
|
95
|
-
<h2>This is an H2 in a blockquote</h2>
|
96
|
-
</blockquote>
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
### Phrase Emphasis ###
|
101
|
-
|
102
|
-
Markdown uses asterisks and underscores to indicate spans of emphasis.
|
103
|
-
|
104
|
-
Markdown:
|
105
|
-
|
106
|
-
Some of these words *are emphasized*.
|
107
|
-
Some of these words _are emphasized also_.
|
108
|
-
|
109
|
-
Use two asterisks for **strong emphasis**.
|
110
|
-
Or, if you prefer, __use two underscores instead__.
|
111
|
-
|
112
|
-
Output:
|
113
|
-
|
114
|
-
<p>Some of these words <em>are emphasized</em>.
|
115
|
-
Some of these words <em>are emphasized also</em>.</p>
|
116
|
-
|
117
|
-
<p>Use two asterisks for <strong>strong emphasis</strong>.
|
118
|
-
Or, if you prefer, <strong>use two underscores instead</strong>.</p>
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
## Lists ##
|
123
|
-
|
124
|
-
Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
|
125
|
-
`+`, and `-`) as list markers. These three markers are
|
126
|
-
interchangable; this:
|
127
|
-
|
128
|
-
* Candy.
|
129
|
-
* Gum.
|
130
|
-
* Booze.
|
131
|
-
|
132
|
-
this:
|
133
|
-
|
134
|
-
+ Candy.
|
135
|
-
+ Gum.
|
136
|
-
+ Booze.
|
137
|
-
|
138
|
-
and this:
|
139
|
-
|
140
|
-
- Candy.
|
141
|
-
- Gum.
|
142
|
-
- Booze.
|
143
|
-
|
144
|
-
all produce the same output:
|
145
|
-
|
146
|
-
<ul>
|
147
|
-
<li>Candy.</li>
|
148
|
-
<li>Gum.</li>
|
149
|
-
<li>Booze.</li>
|
150
|
-
</ul>
|
151
|
-
|
152
|
-
Ordered (numbered) lists use regular numbers, followed by periods, as
|
153
|
-
list markers:
|
154
|
-
|
155
|
-
1. Red
|
156
|
-
2. Green
|
157
|
-
3. Blue
|
158
|
-
|
159
|
-
Output:
|
160
|
-
|
161
|
-
<ol>
|
162
|
-
<li>Red</li>
|
163
|
-
<li>Green</li>
|
164
|
-
<li>Blue</li>
|
165
|
-
</ol>
|
166
|
-
|
167
|
-
If you put blank lines between items, you'll get `<p>` tags for the
|
168
|
-
list item text. You can create multi-paragraph list items by indenting
|
169
|
-
the paragraphs by 4 spaces or 1 tab:
|
170
|
-
|
171
|
-
* A list item.
|
172
|
-
|
173
|
-
With multiple paragraphs.
|
174
|
-
|
175
|
-
* Another item in the list.
|
176
|
-
|
177
|
-
Output:
|
178
|
-
|
179
|
-
<ul>
|
180
|
-
<li><p>A list item.</p>
|
181
|
-
<p>With multiple paragraphs.</p></li>
|
182
|
-
<li><p>Another item in the list.</p></li>
|
183
|
-
</ul>
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
### Links ###
|
188
|
-
|
189
|
-
Markdown supports two styles for creating links: *inline* and
|
190
|
-
*reference*. With both styles, you use square brackets to delimit the
|
191
|
-
text you want to turn into a link.
|
192
|
-
|
193
|
-
Inline-style links use parentheses immediately after the link text.
|
194
|
-
For example:
|
195
|
-
|
196
|
-
This is an [example link](http://example.com/).
|
197
|
-
|
198
|
-
Output:
|
199
|
-
|
200
|
-
<p>This is an <a href="http://example.com/">
|
201
|
-
example link</a>.</p>
|
202
|
-
|
203
|
-
Optionally, you may include a title attribute in the parentheses:
|
204
|
-
|
205
|
-
This is an [example link](http://example.com/ "With a Title").
|
206
|
-
|
207
|
-
Output:
|
208
|
-
|
209
|
-
<p>This is an <a href="http://example.com/" title="With a Title">
|
210
|
-
example link</a>.</p>
|
211
|
-
|
212
|
-
Reference-style links allow you to refer to your links by names, which
|
213
|
-
you define elsewhere in your document:
|
214
|
-
|
215
|
-
I get 10 times more traffic from [Google][1] than from
|
216
|
-
[Yahoo][2] or [MSN][3].
|
217
|
-
|
218
|
-
[1]: http://google.com/ "Google"
|
219
|
-
[2]: http://search.yahoo.com/ "Yahoo Search"
|
220
|
-
[3]: http://search.msn.com/ "MSN Search"
|
221
|
-
|
222
|
-
Output:
|
223
|
-
|
224
|
-
<p>I get 10 times more traffic from <a href="http://google.com/"
|
225
|
-
title="Google">Google</a> than from <a href="http://search.yahoo.com/"
|
226
|
-
title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
|
227
|
-
title="MSN Search">MSN</a>.</p>
|
228
|
-
|
229
|
-
The title attribute is optional. Link names may contain letters,
|
230
|
-
numbers and spaces, but are *not* case sensitive:
|
231
|
-
|
232
|
-
I start my morning with a cup of coffee and
|
233
|
-
[The New York Times][NY Times].
|
234
|
-
|
235
|
-
[ny times]: http://www.nytimes.com/
|
236
|
-
|
237
|
-
Output:
|
238
|
-
|
239
|
-
<p>I start my morning with a cup of coffee and
|
240
|
-
<a href="http://www.nytimes.com/">The New York Times</a>.</p>
|
241
|
-
|
242
|
-
|
243
|
-
### Images ###
|
244
|
-
|
245
|
-
Image syntax is very much like link syntax.
|
246
|
-
|
247
|
-
Inline (titles are optional):
|
248
|
-
|
249
|
-
![alt text](/path/to/img.jpg "Title")
|
250
|
-
|
251
|
-
Reference-style:
|
252
|
-
|
253
|
-
![alt text][id]
|
254
|
-
|
255
|
-
[id]: /path/to/img.jpg "Title"
|
256
|
-
|
257
|
-
Both of the above examples produce the same output:
|
258
|
-
|
259
|
-
<img src="/path/to/img.jpg" alt="alt text" title="Title" />
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
### Code ###
|
264
|
-
|
265
|
-
In a regular paragraph, you can create code span by wrapping text in
|
266
|
-
backtick quotes. Any ampersands (`&`) and angle brackets (`<` or
|
267
|
-
`>`) will automatically be translated into HTML entities. This makes
|
268
|
-
it easy to use Markdown to write about HTML example code:
|
269
|
-
|
270
|
-
I strongly recommend against using any `<blink>` tags.
|
271
|
-
|
272
|
-
I wish SmartyPants used named entities like `—`
|
273
|
-
instead of decimal-encoded entites like `—`.
|
274
|
-
|
275
|
-
Output:
|
276
|
-
|
277
|
-
<p>I strongly recommend against using any
|
278
|
-
<code><blink></code> tags.</p>
|
279
|
-
|
280
|
-
<p>I wish SmartyPants used named entities like
|
281
|
-
<code>&mdash;</code> instead of decimal-encoded
|
282
|
-
entites like <code>&#8212;</code>.</p>
|
283
|
-
|
284
|
-
|
285
|
-
To specify an entire block of pre-formatted code, indent every line of
|
286
|
-
the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`,
|
287
|
-
and `>` characters will be escaped automatically.
|
288
|
-
|
289
|
-
Markdown:
|
290
|
-
|
291
|
-
If you want your page to validate under XHTML 1.0 Strict,
|
292
|
-
you've got to put paragraph tags in your blockquotes:
|
293
|
-
|
294
|
-
<blockquote>
|
295
|
-
<p>For example.</p>
|
296
|
-
</blockquote>
|
297
|
-
|
298
|
-
Output:
|
299
|
-
|
300
|
-
<p>If you want your page to validate under XHTML 1.0 Strict,
|
301
|
-
you've got to put paragraph tags in your blockquotes:</p>
|
302
|
-
|
303
|
-
<pre><code><blockquote>
|
304
|
-
<p>For example.</p>
|
305
|
-
</blockquote>
|
306
|
-
</code></pre>
|