rdiscount 2.0.7.3 → 2.1.6
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.
- data/BUILDING +4 -3
- data/COPYING +25 -44
- data/Rakefile +4 -0
- data/ext/Csio.c +1 -1
- data/ext/VERSION +1 -1
- data/ext/blocktags +33 -0
- data/ext/config.h +6 -0
- data/ext/cstring.h +2 -2
- data/ext/flags.c +1 -0
- data/ext/generate.c +146 -64
- data/ext/github_flavoured.c +100 -0
- data/ext/html5.c +0 -2
- data/ext/markdown.c +229 -136
- data/ext/markdown.h +40 -3
- data/ext/mkdio.c +25 -28
- data/ext/mkdio.h +9 -2
- data/ext/mktags.c +89 -0
- data/ext/pgm_options.c +138 -0
- data/ext/pgm_options.h +9 -0
- data/ext/rdiscount.c +52 -52
- data/ext/setup.c +1 -9
- data/ext/tags.c +34 -66
- data/ext/toc.c +21 -10
- data/ext/version.c +9 -1
- data/lib/rdiscount.rb +7 -1
- data/rdiscount.gemspec +7 -2
- data/test/rdiscount_test.rb +86 -1
- metadata +7 -2
data/test/rdiscount_test.rb
CHANGED
@@ -6,6 +6,12 @@ require 'test/unit'
|
|
6
6
|
require 'rdiscount'
|
7
7
|
|
8
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
|
+
|
9
15
|
def test_that_discount_does_not_blow_up_with_weird_formatting_case
|
10
16
|
text = (<<-TEXT).gsub(/^ {4}/, '').rstrip
|
11
17
|
1. some text
|
@@ -53,7 +59,19 @@ class RDiscountTest < Test::Unit::TestCase
|
|
53
59
|
|
54
60
|
def test_should_get_the_generated_toc
|
55
61
|
rd = RDiscount.new("# Level 1\n\n## Level 2", :generate_toc)
|
56
|
-
exp = %(<ul>\n <li><a href
|
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>)
|
57
75
|
assert_equal exp, rd.toc_content.strip
|
58
76
|
end
|
59
77
|
|
@@ -103,6 +121,22 @@ EOS
|
|
103
121
|
rd = RDiscount.new("[foo](id:bar)", :no_pseudo_protocols)
|
104
122
|
assert_equal "<p>[foo](id:bar)</p>\n", rd.to_html
|
105
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
|
106
140
|
|
107
141
|
def test_that_tags_can_have_dashes_and_underscores
|
108
142
|
if RDiscount::VERSION.start_with? "2.0.7"
|
@@ -128,5 +162,56 @@ EOS
|
|
128
162
|
rd = RDiscount.new("[Test](http://example.com/ß)")
|
129
163
|
assert_equal "<p><a href=\"http://example.com/%C3%9F\">Test</a></p>\n", rd.to_html
|
130
164
|
end
|
165
|
+
|
166
|
+
def test_that_dashes_encoded_correctly
|
167
|
+
rd = RDiscount.new("A--B", :smart)
|
168
|
+
assert_equal "<p>A–B</p>\n", rd.to_html
|
169
|
+
|
170
|
+
rd = RDiscount.new("A---B", :smart)
|
171
|
+
assert_equal "<p>A—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
|
131
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_pandoc_code_blocks_work
|
208
|
+
rd = RDiscount.new(<<EOS)
|
209
|
+
~~~
|
210
|
+
line 1
|
211
|
+
|
212
|
+
line 2
|
213
|
+
~~~
|
214
|
+
EOS
|
215
|
+
assert_equal "<pre><code>line 1\n\nline 2\n</code></pre>\n", rd.to_html
|
216
|
+
end
|
132
217
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdiscount
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-05-
|
15
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
16
16
|
dependencies: []
|
17
17
|
description:
|
18
18
|
email: davidfstr@gmail.com
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- ext/amalloc.c
|
34
34
|
- ext/amalloc.h
|
35
35
|
- ext/basename.c
|
36
|
+
- ext/blocktags
|
36
37
|
- ext/config.h
|
37
38
|
- ext/css.c
|
38
39
|
- ext/cstring.h
|
@@ -42,11 +43,15 @@ files:
|
|
42
43
|
- ext/extconf.rb
|
43
44
|
- ext/flags.c
|
44
45
|
- ext/generate.c
|
46
|
+
- ext/github_flavoured.c
|
45
47
|
- ext/html5.c
|
46
48
|
- ext/markdown.c
|
47
49
|
- ext/markdown.h
|
48
50
|
- ext/mkdio.c
|
49
51
|
- ext/mkdio.h
|
52
|
+
- ext/mktags.c
|
53
|
+
- ext/pgm_options.c
|
54
|
+
- ext/pgm_options.h
|
50
55
|
- ext/rdiscount.c
|
51
56
|
- ext/resource.c
|
52
57
|
- ext/setup.c
|