rdiscountwl 1.0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/BUILDING +151 -0
- data/COPYING +33 -0
- data/README.markdown +73 -0
- data/Rakefile +224 -0
- data/bin/rdiscount +13 -0
- data/ext/Csio.c +61 -0
- data/ext/VERSION +1 -0
- data/ext/amalloc.c +135 -0
- data/ext/amalloc.h +29 -0
- data/ext/basename.c +43 -0
- data/ext/blocktags +33 -0
- data/ext/config.h +25 -0
- data/ext/css.c +87 -0
- data/ext/cstring.h +77 -0
- data/ext/docheader.c +49 -0
- data/ext/dumptree.c +151 -0
- data/ext/emmatch.c +188 -0
- data/ext/extconf.rb +49 -0
- data/ext/flags.c +91 -0
- data/ext/generate.c +1865 -0
- data/ext/github_flavoured.c +100 -0
- data/ext/html5.c +22 -0
- data/ext/markdown.c +1361 -0
- data/ext/markdown.h +238 -0
- data/ext/mkdio.c +360 -0
- data/ext/mkdio.h +122 -0
- data/ext/mktags.c +89 -0
- data/ext/pgm_options.c +146 -0
- data/ext/pgm_options.h +9 -0
- data/ext/rdiscount.c +150 -0
- data/ext/resource.c +159 -0
- data/ext/setup.c +39 -0
- data/ext/tags.c +94 -0
- data/ext/tags.h +19 -0
- data/ext/toc.c +114 -0
- data/ext/version.c +13 -0
- data/ext/xml.c +82 -0
- data/ext/xmlpage.c +46 -0
- data/lib/markdown.rb +1 -0
- data/lib/rdiscount.rb +108 -0
- data/man/markdown.7 +1020 -0
- data/man/rdiscount.1 +22 -0
- data/man/rdiscount.1.ronn +24 -0
- data/rdiscount.gemspec +71 -0
- data/test/benchmark.rb +56 -0
- data/test/benchmark.txt +306 -0
- data/test/markdown_test.rb +158 -0
- data/test/rdiscount_test.rb +276 -0
- metadata +99 -0
data/man/rdiscount.1
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
.\" generated with Ronn/v0.6.8
|
2
|
+
.\" http://github.com/rtomayko/ronn/
|
3
|
+
.
|
4
|
+
.TH "RDISCOUNT" "1" "April 2010" "" "RUBY"
|
5
|
+
.
|
6
|
+
.SH "NAME"
|
7
|
+
\fBrdiscount\fR \- humane markup to HTML conversion tool
|
8
|
+
.
|
9
|
+
.SH "SYNOPSIS"
|
10
|
+
\fBrdiscount\fR [\fIfile\fR\.\.\.]
|
11
|
+
.
|
12
|
+
.SH "DESCRIPTION"
|
13
|
+
The \fBrdiscount\fR utility reads one or more markdown(7)\-formatted text \fIfile\fRs and writes HTML to standard output\. With no \fIfile\fR, or when \fIfile\fR is \'\-\', \fBrdiscount\fR reads source text from standard input\.
|
14
|
+
.
|
15
|
+
.SH "RETURN VALUES"
|
16
|
+
The \fBrdiscount\fR utility exits 0 on success, and > 0 if an error occurs\.
|
17
|
+
.
|
18
|
+
.SH "SEE ALSO"
|
19
|
+
markdown(7)
|
20
|
+
.
|
21
|
+
.SH "AUTHOR"
|
22
|
+
Ryan Tomayko \fIhttp://tomayko\.com/about\fR
|
@@ -0,0 +1,24 @@
|
|
1
|
+
rdiscount(1) -- humane markup to HTML conversion tool
|
2
|
+
=====================================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
|
6
|
+
`rdiscount` [<file>...]
|
7
|
+
|
8
|
+
## DESCRIPTION
|
9
|
+
|
10
|
+
The `rdiscount` utility reads one or more markdown(7)-formatted text <file>s and
|
11
|
+
writes HTML to standard output. With no <file>, or when <file> is '-',
|
12
|
+
`rdiscount` reads source text from standard input.
|
13
|
+
|
14
|
+
## RETURN VALUES
|
15
|
+
|
16
|
+
The `rdiscount` utility exits 0 on success, and > 0 if an error occurs.
|
17
|
+
|
18
|
+
## SEE ALSO
|
19
|
+
|
20
|
+
markdown(7)
|
21
|
+
|
22
|
+
## AUTHOR
|
23
|
+
|
24
|
+
Ryan Tomayko <http://tomayko.com/about>
|
data/rdiscount.gemspec
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'rdiscountwl'
|
3
|
+
s.version = '1.0.0.1'
|
4
|
+
s.summary = "Fast Implementation of Gruber's Markdown in C With Latex Support"
|
5
|
+
s.date = '2022-05-07'
|
6
|
+
s.email = 'i@liangsun.org'
|
7
|
+
s.homepage = 'https://github.com/1e0ng/rdiscount'
|
8
|
+
s.authors = ["Ryan Tomayko", "David Loren Parsons", "Andrew White", "David Foster", "Liang Sun"]
|
9
|
+
s.license = "BSD-3-Clause"
|
10
|
+
# = MANIFEST =
|
11
|
+
s.files = %w[
|
12
|
+
BUILDING
|
13
|
+
COPYING
|
14
|
+
README.markdown
|
15
|
+
Rakefile
|
16
|
+
bin/rdiscount
|
17
|
+
discount
|
18
|
+
ext/Csio.c
|
19
|
+
ext/VERSION
|
20
|
+
ext/amalloc.c
|
21
|
+
ext/amalloc.h
|
22
|
+
ext/basename.c
|
23
|
+
ext/blocktags
|
24
|
+
ext/config.h
|
25
|
+
ext/css.c
|
26
|
+
ext/cstring.h
|
27
|
+
ext/docheader.c
|
28
|
+
ext/dumptree.c
|
29
|
+
ext/emmatch.c
|
30
|
+
ext/extconf.rb
|
31
|
+
ext/flags.c
|
32
|
+
ext/generate.c
|
33
|
+
ext/github_flavoured.c
|
34
|
+
ext/html5.c
|
35
|
+
ext/markdown.c
|
36
|
+
ext/markdown.h
|
37
|
+
ext/mkdio.c
|
38
|
+
ext/mkdio.h
|
39
|
+
ext/mktags.c
|
40
|
+
ext/pgm_options.c
|
41
|
+
ext/pgm_options.h
|
42
|
+
ext/rdiscount.c
|
43
|
+
ext/resource.c
|
44
|
+
ext/setup.c
|
45
|
+
ext/tags.c
|
46
|
+
ext/tags.h
|
47
|
+
ext/toc.c
|
48
|
+
ext/version.c
|
49
|
+
ext/xml.c
|
50
|
+
ext/xmlpage.c
|
51
|
+
lib/markdown.rb
|
52
|
+
lib/rdiscount.rb
|
53
|
+
man/markdown.7
|
54
|
+
man/rdiscount.1
|
55
|
+
man/rdiscount.1.ronn
|
56
|
+
rdiscount.gemspec
|
57
|
+
test/benchmark.rb
|
58
|
+
test/benchmark.txt
|
59
|
+
test/markdown_test.rb
|
60
|
+
test/rdiscount_test.rb
|
61
|
+
]
|
62
|
+
# = MANIFEST =
|
63
|
+
s.test_files = ["test/markdown_test.rb", "test/rdiscount_test.rb"]
|
64
|
+
s.extra_rdoc_files = ["COPYING"]
|
65
|
+
s.extensions = ["ext/extconf.rb"]
|
66
|
+
s.executables = ["rdiscount"]
|
67
|
+
s.require_paths = ["lib"]
|
68
|
+
s.rubyforge_project = 'wink'
|
69
|
+
# Ruby 1.9.2 has a known bug in mkmf. Ruby 1.9.3 or later is fine.
|
70
|
+
s.required_ruby_version = '!= 1.9.2'
|
71
|
+
end
|
data/test/benchmark.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
iterations = 100
|
4
|
+
test_file = "#{File.dirname(__FILE__)}/benchmark.txt"
|
5
|
+
implementations = %w[BlueCloth RDiscount Maruku PEGMarkdown]
|
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
ADDED
@@ -0,0 +1,306 @@
|
|
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
|
+

|
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>
|
@@ -0,0 +1,158 @@
|
|
1
|
+
rootdir = File.dirname(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift "#{rootdir}/lib"
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'markdown'
|
6
|
+
|
7
|
+
MARKDOWN_TEST_DIR = "#{rootdir}/test/MarkdownTest_1.0.3"
|
8
|
+
|
9
|
+
class MarkdownTest < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def test_that_extension_methods_are_present_on_markdown_class
|
12
|
+
assert Markdown.instance_methods.map{|m| m.to_s }.include?('to_html'),
|
13
|
+
"Markdown class should respond to #to_html"
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_that_simple_one_liner_goes_to_html
|
17
|
+
markdown = Markdown.new('Hello World.')
|
18
|
+
assert_respond_to markdown, :to_html
|
19
|
+
assert_equal "<p>Hello World.</p>", markdown.to_html.strip
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_that_inline_markdown_goes_to_html
|
23
|
+
markdown = Markdown.new('_Hello World_!')
|
24
|
+
assert_equal "<p><em>Hello World</em>!</p>", markdown.to_html.strip
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_that_inline_markdown_starts_and_ends_correctly
|
28
|
+
markdown = Markdown.new('_start _ foo_bar bar_baz _ end_ *italic* **bold** <a>_blah_</a>')
|
29
|
+
assert_respond_to markdown, :to_html
|
30
|
+
assert_equal "<p><em>start _ foo_bar bar_baz _ end</em> <em>italic</em> <strong>bold</strong> <a><em>blah</em></a></p>", markdown.to_html.strip
|
31
|
+
|
32
|
+
markdown = Markdown.new("Run 'rake radiant:extensions:rbac_base:migrate'")
|
33
|
+
assert_equal "<p>Run 'rake radiant:extensions:rbac_base:migrate'</p>", markdown.to_html.strip
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_that_filter_html_works
|
37
|
+
markdown = Markdown.new('Through <em>NO</em> <script>DOUBLE NO</script>', :filter_html)
|
38
|
+
assert_equal "<p>Through <em>NO</em> <script>DOUBLE NO</script></p>", markdown.to_html.strip
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_that_bluecloth_restrictions_are_supported
|
42
|
+
markdown = Markdown.new('Hello World.')
|
43
|
+
[:filter_html, :filter_styles].each do |restriction|
|
44
|
+
assert_respond_to markdown, restriction
|
45
|
+
assert_respond_to markdown, "#{restriction}="
|
46
|
+
end
|
47
|
+
assert_not_equal true, markdown.filter_html
|
48
|
+
assert_not_equal true, markdown.filter_styles
|
49
|
+
|
50
|
+
markdown = Markdown.new('Hello World.', :filter_html, :filter_styles)
|
51
|
+
assert_equal true, markdown.filter_html
|
52
|
+
assert_equal true, markdown.filter_styles
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_that_redcloth_attributes_are_supported
|
56
|
+
markdown = Markdown.new('Hello World.')
|
57
|
+
assert_respond_to markdown, :fold_lines
|
58
|
+
assert_respond_to markdown, :fold_lines=
|
59
|
+
assert_not_equal true, markdown.fold_lines
|
60
|
+
|
61
|
+
markdown = Markdown.new('Hello World.', :fold_lines)
|
62
|
+
assert_equal true, markdown.fold_lines
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_that_redcloth_to_html_with_single_arg_is_supported
|
66
|
+
markdown = Markdown.new('Hello World.')
|
67
|
+
assert_nothing_raised(ArgumentError) { markdown.to_html(true) }
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_that_smart_converts_single_quotes_in_words_that_end_in_re
|
71
|
+
markdown = Markdown.new("They're not for sale.", :smart)
|
72
|
+
assert_equal "<p>They’re not for sale.</p>\n", markdown.to_html
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_that_smart_converts_single_quotes_in_words_that_end_in_ll
|
76
|
+
markdown = Markdown.new("Well that'll be the day", :smart)
|
77
|
+
assert_equal "<p>Well that’ll be the day</p>\n", markdown.to_html
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_that_urls_are_not_doubly_escaped
|
81
|
+
markdown = Markdown.new('[Page 2](/search?query=Markdown+Test&page=2)')
|
82
|
+
assert_equal "<p><a href=\"/search?query=Markdown+Test&page=2\">Page 2</a></p>\n", markdown.to_html
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_simple_inline_html
|
86
|
+
markdown = Markdown.new("before\n\n<div>\n foo\n</div>\nafter")
|
87
|
+
assert_equal "<p>before</p>\n\n<div>\n foo\n</div>\n\n\n<p>after</p>\n",
|
88
|
+
markdown.to_html
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_that_html_blocks_do_not_require_their_own_end_tag_line
|
92
|
+
markdown = Markdown.new("Para 1\n\n<div><pre>HTML block\n</pre></div>\n\nPara 2 [Link](#anchor)")
|
93
|
+
assert_equal "<p>Para 1</p>\n\n<div><pre>HTML block\n</pre></div>\n\n\n<p>Para 2 <a href=\"#anchor\">Link</a></p>\n",
|
94
|
+
markdown.to_html
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_filter_html_doesnt_break_two_space_hard_break
|
98
|
+
markdown = Markdown.new("Lorem, \nipsum\n", :filter_html)
|
99
|
+
assert_equal "<p>Lorem,<br/>\nipsum</p>\n",
|
100
|
+
markdown.to_html
|
101
|
+
end
|
102
|
+
|
103
|
+
# This isn't in the spec but is Markdown.pl behavior.
|
104
|
+
def test_block_quotes_preceded_by_spaces
|
105
|
+
markdown = Markdown.new(
|
106
|
+
"A wise man once said:\n\n" +
|
107
|
+
" > Isn't it wonderful just to be alive.\n"
|
108
|
+
)
|
109
|
+
assert_equal "<p>A wise man once said:</p>\n\n" +
|
110
|
+
"<blockquote><p>Isn't it wonderful just to be alive.</p></blockquote>\n",
|
111
|
+
markdown.to_html
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_ul_with_zero_space_indent
|
115
|
+
markdown = Markdown.new("- foo\n\n- bar\n\n baz\n")
|
116
|
+
assert_equal "<ul><li><p>foo</p></li><li><p>bar</p><p>baz</p></li></ul>",
|
117
|
+
markdown.to_html.gsub("\n", "")
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_ul_with_single_space_indent
|
121
|
+
markdown = Markdown.new(" - foo\n\n - bar\n\n baz\n")
|
122
|
+
assert_equal "<ul><li><p>foo</p></li><li><p>bar</p><p>baz</p></li></ul>",
|
123
|
+
markdown.to_html.gsub("\n", "")
|
124
|
+
end
|
125
|
+
|
126
|
+
# http://github.com/davidfstr/rdiscount/issues/#issue/13
|
127
|
+
def test_headings_with_trailing_space
|
128
|
+
text = "The Ant-Sugar Tales \n" +
|
129
|
+
"=================== \n\n" +
|
130
|
+
"By Candice Yellowflower \n"
|
131
|
+
markdown = Markdown.new(text)
|
132
|
+
assert_equal "<h1>The Ant-Sugar Tales </h1>\n\n<p>By Candice Yellowflower</p>\n",
|
133
|
+
markdown.to_html
|
134
|
+
end
|
135
|
+
|
136
|
+
# Build tests for each file in the MarkdownTest test suite
|
137
|
+
|
138
|
+
Dir["#{MARKDOWN_TEST_DIR}/Tests/*.text"].each do |text_file|
|
139
|
+
|
140
|
+
basename = File.basename(text_file).sub(/\.text$/, '')
|
141
|
+
html_file = text_file.sub(/text$/, 'html')
|
142
|
+
method_name = basename.gsub(/[-,()]/, '').gsub(/\s+/, '_').downcase
|
143
|
+
|
144
|
+
define_method "test_#{method_name}" do
|
145
|
+
markdown = Markdown.new(File.read(text_file))
|
146
|
+
actual_html = markdown.to_html
|
147
|
+
assert_not_nil actual_html
|
148
|
+
end
|
149
|
+
|
150
|
+
define_method "test_#{method_name}_smart" do
|
151
|
+
markdown = Markdown.new(File.read(text_file), :smart)
|
152
|
+
actual_html = markdown.to_html
|
153
|
+
assert_not_nil actual_html
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|