rdiscount_wm 3.0.0.0

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.
@@ -0,0 +1,267 @@
1
+ # encoding: utf-8
2
+ rootdir = File.dirname(File.dirname(__FILE__))
3
+ $LOAD_PATH.unshift "#{rootdir}/lib"
4
+
5
+ require 'test/unit'
6
+ require 'rdiscount'
7
+
8
+ class RDiscountTest < Test::Unit::TestCase
9
+ def test_that_version_looks_valid
10
+ if not /^[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?$/ =~ RDiscount::VERSION
11
+ assert false, 'Expected RDiscount::VERSION to be a 3 or 4 component version string but found ' + RDiscount::VERSION.to_s
12
+ end
13
+ end
14
+
15
+ def test_that_discount_does_not_blow_up_with_weird_formatting_case
16
+ text = (<<-TEXT).gsub(/^ {4}/, '').rstrip
17
+ 1. some text
18
+
19
+ 1.
20
+ TEXT
21
+ RDiscount.new(text).to_html
22
+ end
23
+
24
+ def test_that_smart_converts_double_quotes_to_curly_quotes
25
+ rd = RDiscount.new(%("Quoted text"), :smart)
26
+ assert_equal %(<p>&ldquo;Quoted text&rdquo;</p>\n), rd.to_html
27
+ end
28
+
29
+ def test_that_smart_converts_double_quotes_to_curly_quotes_before_a_heading
30
+ rd = RDiscount.new(%("Quoted text"\n\n# Heading), :smart)
31
+ assert_equal %(<p>&ldquo;Quoted text&rdquo;</p>\n\n<h1>Heading</h1>\n), rd.to_html
32
+ end
33
+
34
+ def test_that_smart_converts_double_quotes_to_curly_quotes_after_a_heading
35
+ rd = RDiscount.new(%(# Heading\n\n"Quoted text"), :smart)
36
+ assert_equal %(<h1>Heading</h1>\n\n<p>&ldquo;Quoted text&rdquo;</p>\n), rd.to_html
37
+ end
38
+
39
+ def test_that_smart_gives_ve_suffix_a_rsquo
40
+ rd = RDiscount.new("I've been meaning to tell you ..", :smart)
41
+ assert_equal "<p>I&rsquo;ve been meaning to tell you ..</p>\n", rd.to_html
42
+ end
43
+
44
+ def test_that_smart_gives_m_suffix_a_rsquo
45
+ rd = RDiscount.new("I'm not kidding", :smart)
46
+ assert_equal "<p>I&rsquo;m not kidding</p>\n", rd.to_html
47
+ end
48
+
49
+ def test_that_smart_gives_d_suffix_a_rsquo
50
+ rd = RDiscount.new("what'd you say?", :smart)
51
+ assert_equal "<p>what&rsquo;d you say?</p>\n", rd.to_html
52
+ end
53
+
54
+ def test_that_generate_toc_sets_toc_ids
55
+ rd = RDiscount.new("# Level 1\n\n## Level 2", :generate_toc)
56
+ assert rd.generate_toc
57
+ assert_equal %(<a name="Level.1"></a>\n<h1>Level 1</h1>\n\n<a name="Level.2"></a>\n<h2>Level 2</h2>\n), rd.to_html
58
+ end
59
+
60
+ def test_should_get_the_generated_toc
61
+ rd = RDiscount.new("# Level 1\n\n## Level 2", :generate_toc)
62
+ exp = %(<ul>\n <li><a href=\"#Level.1\">Level 1</a>\n <ul>\n <li><a href=\"#Level.2\">Level 2</a></li>\n </ul>\n </li>\n</ul>)
63
+ assert_equal exp, rd.toc_content.strip
64
+ end
65
+
66
+ def test_toc_should_escape_apostropes
67
+ rd = RDiscount.new("# A'B\n\n## C", :generate_toc)
68
+ exp = %(<ul>\n <li><a href=\"#A.B\">A'B</a>\n <ul>\n <li><a href=\"#C\">C</a></li>\n </ul>\n </li>\n</ul>)
69
+ assert_equal exp, rd.toc_content.strip
70
+ end
71
+
72
+ def test_toc_should_escape_question_marks
73
+ rd = RDiscount.new("# A?B\n\n## C", :generate_toc)
74
+ exp = %(<ul>\n <li><a href=\"#A.B\">A?B</a>\n <ul>\n <li><a href=\"#C\">C</a></li>\n </ul>\n </li>\n</ul>)
75
+ assert_equal exp, rd.toc_content.strip
76
+ end
77
+
78
+ if "".respond_to?(:encoding)
79
+ def test_should_return_string_in_same_encoding_as_input
80
+ input = "Yogācāra"
81
+ output = RDiscount.new(input).to_html
82
+ assert_equal input.encoding.name, output.encoding.name
83
+ end
84
+ end
85
+
86
+ def test_that_no_image_flag_works
87
+ rd = RDiscount.new(%(![dust mite](http://dust.mite/image.png) <img src="image.png" />), :no_image)
88
+ assert rd.to_html !~ /<img/
89
+ end
90
+
91
+ def test_that_no_links_flag_works
92
+ rd = RDiscount.new(%([This link](http://example.net/) <a href="links.html">links</a>), :no_links)
93
+ assert rd.to_html !~ /<a /
94
+ end
95
+
96
+ def test_that_no_tables_flag_works
97
+ rd = RDiscount.new(<<EOS, :no_tables)
98
+ aaa | bbbb
99
+ -----|------
100
+ hello|sailor
101
+ EOS
102
+ assert rd.to_html !~ /<table/
103
+ end
104
+
105
+ def test_that_strict_flag_works
106
+ rd = RDiscount.new("foo_bar_baz", :strict)
107
+ assert_equal "<p>foo<em>bar</em>baz</p>\n", rd.to_html
108
+ end
109
+
110
+ def test_that_autolink_flag_works
111
+ rd = RDiscount.new("http://github.com/davidfstr/rdiscount", :autolink)
112
+ assert_equal "<p><a href=\"http://github.com/davidfstr/rdiscount\">http://github.com/davidfstr/rdiscount</a></p>\n", rd.to_html
113
+ end
114
+
115
+ def test_that_safelink_flag_works
116
+ rd = RDiscount.new("[IRC](irc://chat.freenode.org/#freenode)", :safelink)
117
+ assert_equal "<p>[IRC](irc://chat.freenode.org/#freenode)</p>\n", rd.to_html
118
+ end
119
+
120
+ def test_that_no_pseudo_protocols_flag_works
121
+ rd = RDiscount.new("[foo](id:bar)", :no_pseudo_protocols)
122
+ assert_equal "<p>[foo](id:bar)</p>\n", rd.to_html
123
+ end
124
+
125
+ def test_that_no_superscript_flag_works
126
+ rd = RDiscount.new("A^B", :no_superscript)
127
+ assert_equal "<p>A^B</p>\n", rd.to_html
128
+
129
+ rd = RDiscount.new("A^B")
130
+ assert_equal "<p>A<sup>B</sup></p>\n", rd.to_html
131
+ end
132
+
133
+ def test_that_no_strikethrough_flag_works
134
+ rd = RDiscount.new("~~A~~", :no_strikethrough)
135
+ assert_equal "<p>~~A~~</p>\n", rd.to_html
136
+
137
+ rd = RDiscount.new("~~A~~")
138
+ assert_equal "<p><del>A</del></p>\n", rd.to_html
139
+ end
140
+
141
+ def test_that_tags_can_have_dashes_and_underscores
142
+ if RDiscount::VERSION.start_with? "2.0.7"
143
+ # Skip test for 2.0.7.x series due to upstream behavioral change in
144
+ # Discount 2.0.7. This test can be fixed in Discount 2.1.5 using the
145
+ # WITH_GITHUB_TAGS compile-time flag.
146
+ return
147
+ end
148
+ rd = RDiscount.new("foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b>")
149
+ assert_equal "<p>foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b></p>\n", rd.to_html
150
+ end
151
+
152
+ def test_that_footnotes_flag_works
153
+ rd = RDiscount.new(<<EOS, :footnotes)
154
+ Obtuse text.[^1]
155
+
156
+ [^1]: Clarification
157
+ EOS
158
+ assert rd.to_html.include?('<a href="#fn:1" rel="footnote">1</a>')
159
+ end
160
+
161
+ def test_that_unicode_urls_encoded_correctly
162
+ rd = RDiscount.new("[Test](http://example.com/ß)")
163
+ assert_equal "<p><a href=\"http://example.com/%C3%9F\">Test</a></p>\n", rd.to_html
164
+ end
165
+
166
+ def test_that_dashes_encoded_correctly
167
+ rd = RDiscount.new("A--B", :smart)
168
+ assert_equal "<p>A&ndash;B</p>\n", rd.to_html
169
+
170
+ rd = RDiscount.new("A---B", :smart)
171
+ assert_equal "<p>A&mdash;B</p>\n", rd.to_html
172
+ end
173
+
174
+ def test_that_superscripts_can_be_escaped
175
+ rd = RDiscount.new("A\\^B")
176
+ assert_equal "<p>A^B</p>\n", rd.to_html
177
+
178
+ rd = RDiscount.new("A^B")
179
+ assert_equal "<p>A<sup>B</sup></p>\n", rd.to_html
180
+ end
181
+
182
+ def test_that_style_tag_is_not_filtered_by_default
183
+ rd = RDiscount.new("Hello<style>p { margin: 5px; }</style>")
184
+ assert_equal "<p>Hello<style>p { margin: 5px; }</style></p>\n", rd.to_html
185
+ end
186
+
187
+ def test_that_tables_can_have_leading_and_trailing_pipes
188
+ rd = RDiscount.new(<<EOS)
189
+ | A | B |
190
+ |---|---|
191
+ | C | D |
192
+ EOS
193
+ assert_equal "<table>\n<thead>\n<tr>\n<th> A </th>\n<th> B </th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td> C </td>\n<td> D </td>\n</tr>\n</tbody>\n</table>\n\n", rd.to_html
194
+ end
195
+
196
+ def test_that_gfm_code_blocks_work
197
+ rd = RDiscount.new(<<EOS)
198
+ ```
199
+ line 1
200
+
201
+ line 2
202
+ ```
203
+ EOS
204
+ assert_equal "<pre><code>line 1\n\nline 2\n</code></pre>\n", rd.to_html
205
+ end
206
+
207
+ def test_that_gfm_code_blocks_work_with_language
208
+ rd = RDiscount.new(<<EOS)
209
+ ```ruby
210
+ line 1
211
+
212
+ line 2
213
+ ```
214
+ EOS
215
+ assert_equal "<pre><code class=\"ruby\">line 1\n\nline 2\n</code></pre>\n", rd.to_html
216
+ end
217
+
218
+ def test_that_pandoc_code_blocks_work
219
+ rd = RDiscount.new(<<EOS)
220
+ ~~~
221
+ line 1
222
+
223
+ line 2
224
+ ~~~
225
+ EOS
226
+ assert_equal "<pre><code>line 1\n\nline 2\n</code></pre>\n", rd.to_html
227
+ end
228
+
229
+ def test_that_discount_definition_lists_work
230
+ rd = RDiscount.new(<<EOS)
231
+ =tag1=
232
+ =tag2=
233
+ data.
234
+ EOS
235
+ assert_equal <<EOS, rd.to_html
236
+ <dl>
237
+ <dt>tag1</dt>
238
+ <dt>tag2</dt>
239
+ <dd>data.</dd>
240
+ </dl>
241
+ EOS
242
+ end
243
+
244
+ def test_that_extra_definition_lists_work
245
+ rd = RDiscount.new(<<EOS)
246
+ tag1
247
+ : data
248
+ EOS
249
+ assert_equal <<EOS, rd.to_html
250
+ <dl>
251
+ <dt>tag1</dt>
252
+ <dd>data</dd>
253
+ </dl>
254
+ EOS
255
+ end
256
+
257
+ def test_that_emphasis_beside_international_characters_detected
258
+ rd = RDiscount.new(%(*foo ä bar*))
259
+ assert_equal %(<p><em>foo ä bar</em></p>\n), rd.to_html
260
+
261
+ rd = RDiscount.new(%(*ä foobar*))
262
+ assert_equal %(<p><em>ä foobar</em></p>\n), rd.to_html
263
+
264
+ rd = RDiscount.new(%(*foobar ä*))
265
+ assert_equal %(<p><em>foobar ä</em></p>\n), rd.to_html
266
+ end
267
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rdiscount_wm
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Tomayko
8
+ - David Loren Parsons
9
+ - Andrew White
10
+ - David Foster
11
+ - Liang Sun
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2014-04-15 00:00:00.000000000 Z
16
+ dependencies: []
17
+ description:
18
+ email: i@liangsun.org
19
+ executables:
20
+ - rdiscount
21
+ extensions:
22
+ - ext/extconf.rb
23
+ extra_rdoc_files:
24
+ - COPYING
25
+ files:
26
+ - BUILDING
27
+ - COPYING
28
+ - README.markdown
29
+ - Rakefile
30
+ - bin/rdiscount
31
+ - ext/Csio.c
32
+ - ext/VERSION
33
+ - ext/amalloc.c
34
+ - ext/amalloc.h
35
+ - ext/basename.c
36
+ - ext/blocktags
37
+ - ext/config.h
38
+ - ext/css.c
39
+ - ext/cstring.h
40
+ - ext/docheader.c
41
+ - ext/dumptree.c
42
+ - ext/emmatch.c
43
+ - ext/extconf.rb
44
+ - ext/flags.c
45
+ - ext/generate.c
46
+ - ext/github_flavoured.c
47
+ - ext/html5.c
48
+ - ext/markdown.c
49
+ - ext/markdown.h
50
+ - ext/mkdio.c
51
+ - ext/mkdio.h
52
+ - ext/mktags.c
53
+ - ext/pgm_options.c
54
+ - ext/pgm_options.h
55
+ - ext/rdiscount.c
56
+ - ext/resource.c
57
+ - ext/setup.c
58
+ - ext/tags.c
59
+ - ext/tags.h
60
+ - ext/toc.c
61
+ - ext/version.c
62
+ - ext/xml.c
63
+ - ext/xmlpage.c
64
+ - lib/markdown.rb
65
+ - lib/rdiscount_wm.rb
66
+ - man/markdown.7
67
+ - man/rdiscount.1
68
+ - man/rdiscount.1.ronn
69
+ - rdiscount_wm.gemspec
70
+ - test/benchmark.rb
71
+ - test/benchmark.txt
72
+ - test/markdown_test.rb
73
+ - test/rdiscount_test.rb
74
+ homepage: https://github.com/liangsun/rdiscount
75
+ licenses:
76
+ - BSD
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '!='
85
+ - !ruby/object:Gem::Version
86
+ version: 1.9.2
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project: wink
94
+ rubygems_version: 2.0.0
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Fast Implementation of Gruber's Markdown in C With Math(LaTex, MathJax) Support
98
+ test_files:
99
+ - test/markdown_test.rb
100
+ - test/rdiscount_test.rb