rinku 2.0.0 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/COPYING +2 -0
- data/README.markdown +9 -0
- data/Rakefile +6 -44
- data/ext/rinku/autolink.c +65 -31
- data/ext/rinku/utf8.c +46 -2
- data/ext/rinku/utf8.h +3 -0
- data/lib/rails_rinku.rb +9 -1
- data/lib/rinku.rb +1 -1
- data/rinku.gemspec +5 -4
- data/test/autolink_test.rb +71 -5
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8f7f8c8339abdc0a121db5d557f431d4532fc7f17ac8ae0ceede5b36a8a79235
|
4
|
+
data.tar.gz: b58a5fd614fafbcd87e7402e7cb54646af697ef6e908ed3c533683e8d1128e1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e52f7b000fa28489a04aac17189cc401c863c0c2620f5170c4700b855c233fb6fa8bb8f81ab0c096919311e5aac593b05385ce49d279ed03679cb3c3a405112
|
7
|
+
data.tar.gz: 8b8453c5ff30e0a0b81c54bd8374a84b2ec847b28fd08929f559f97388ddf69cd62e4ced564a834328526df0d41cc21ea3998b1dc453a74d0170eab85647f389
|
data/COPYING
CHANGED
data/README.markdown
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
Rinku does linking
|
2
2
|
==================
|
3
3
|
|
4
|
+
[![Build Status](https://travis-ci.org/vmg/rinku.svg?branch=master)](https://travis-ci.org/vmg/rinku)
|
5
|
+
[![Dependency Status](https://www.versioneye.com/ruby/rinku/badge.svg)](https://www.versioneye.com/ruby/rinku)
|
6
|
+
|
4
7
|
Rinku is a Ruby library that does autolinking.
|
5
8
|
It parses text and turns anything that remotely resembles a link into an HTML link,
|
6
9
|
just like the Ruby on Rails `auto_link` method -- but it's about 20 times faster,
|
@@ -91,6 +94,12 @@ choose to use Rinku instead.
|
|
91
94
|
|
92
95
|
~~~~ruby
|
93
96
|
require 'rails_rinku'
|
97
|
+
include ActionView::Helpers::TextHelper
|
98
|
+
post_body = "Welcome to my new blog at http://www.myblog.com/."
|
99
|
+
auto_link(post_body, :html => { :target => '_blank' }) do |text|
|
100
|
+
truncate(text, :length => 15)
|
101
|
+
end
|
102
|
+
# => "Welcome to my new blog at <a href=\"http://www.myblog.com/\" target=\"_blank\">http://www.m...</a>."
|
94
103
|
~~~~
|
95
104
|
|
96
105
|
The `rails_rinku` package monkeypatches Rails with an `auto_link` method that
|
data/Rakefile
CHANGED
@@ -1,50 +1,12 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'bundler/gem_tasks'
|
3
3
|
require 'rake/extensiontask'
|
4
|
-
require 'digest/md5'
|
5
|
-
|
6
|
-
task :default => :test
|
7
|
-
|
8
|
-
# ==========================================================
|
9
|
-
# Ruby Extension
|
10
|
-
# ==========================================================
|
11
|
-
|
12
|
-
Rake::ExtensionTask.new('rinku')
|
13
|
-
|
14
|
-
# ==========================================================
|
15
|
-
# Testing
|
16
|
-
# ==========================================================
|
17
|
-
|
18
4
|
require 'rake/testtask'
|
19
|
-
Rake::TestTask.new('test') do |t|
|
20
|
-
t.test_files = FileList['test/*_test.rb']
|
21
|
-
t.ruby_opts += ['-rubygems'] if defined? Gem
|
22
|
-
end
|
23
|
-
task 'test' => [:compile]
|
24
5
|
|
25
|
-
|
6
|
+
task default: :test
|
26
7
|
|
27
|
-
|
28
|
-
$spec = eval(File.read('rinku.gemspec'))
|
8
|
+
Rake::ExtensionTask.new('rinku') # defines compile task
|
29
9
|
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
desc 'Build packages'
|
35
|
-
task :package => package('.gem')
|
36
|
-
|
37
|
-
desc 'Build and install as local gem'
|
38
|
-
task :install => package('.gem') do
|
39
|
-
sh "gem install #{package('.gem')}"
|
40
|
-
end
|
41
|
-
|
42
|
-
desc 'Update the gemspec'
|
43
|
-
task :update_gem => file('rinku.gemspec')
|
44
|
-
|
45
|
-
directory 'pkg/'
|
46
|
-
|
47
|
-
file package('.gem') => %w[pkg/ rinku.gemspec] + $spec.files do |f|
|
48
|
-
sh "gem build rinku.gemspec"
|
49
|
-
mv File.basename(f.name), f.name
|
10
|
+
Rake::TestTask.new(test: :compile) do |t|
|
11
|
+
t.test_files = FileList['test/*_test.rb']
|
50
12
|
end
|
data/ext/rinku/autolink.c
CHANGED
@@ -27,6 +27,14 @@
|
|
27
27
|
#define strncasecmp _strnicmp
|
28
28
|
#endif
|
29
29
|
|
30
|
+
static int
|
31
|
+
is_valid_hostchar(const uint8_t *link, size_t link_len)
|
32
|
+
{
|
33
|
+
size_t pos = 0;
|
34
|
+
int32_t ch = utf8proc_next(link, &pos);
|
35
|
+
return !utf8proc_is_space(ch) && !utf8proc_is_punctuation(ch);
|
36
|
+
}
|
37
|
+
|
30
38
|
bool
|
31
39
|
autolink_issafe(const uint8_t *link, size_t link_len)
|
32
40
|
{
|
@@ -52,7 +60,7 @@ autolink_issafe(const uint8_t *link, size_t link_len)
|
|
52
60
|
static bool
|
53
61
|
autolink_delim(const uint8_t *data, struct autolink_pos *link)
|
54
62
|
{
|
55
|
-
|
63
|
+
int32_t cclose, copen = 0;
|
56
64
|
size_t i;
|
57
65
|
|
58
66
|
for (i = link->start; i < link->end; ++i)
|
@@ -88,25 +96,14 @@ autolink_delim(const uint8_t *data, struct autolink_pos *link)
|
|
88
96
|
if (link->end == link->start)
|
89
97
|
return false;
|
90
98
|
|
91
|
-
cclose = data
|
92
|
-
|
93
|
-
switch (cclose) {
|
94
|
-
case '"': copen = '"'; break;
|
95
|
-
case '\'': copen = '\''; break;
|
96
|
-
case ')': copen = '('; break;
|
97
|
-
case ']': copen = '['; break;
|
98
|
-
case '}': copen = '{'; break;
|
99
|
-
}
|
99
|
+
cclose = utf8proc_rewind(data, link->end);
|
100
|
+
copen = utf8proc_open_paren_character(cclose);
|
100
101
|
|
101
102
|
if (copen != 0) {
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
/* Try to close the final punctuation sign in this same line;
|
107
|
-
* if we managed to close it outside of the URL, that means that it's
|
108
|
-
* not part of the URL. If it closes inside the URL, that means it
|
109
|
-
* is part of the URL.
|
103
|
+
/* Try to close the final punctuation sign in this link; if
|
104
|
+
* there's more closing than opening punctuation symbols in the
|
105
|
+
* URL, we conservatively remove one closing punctuation from
|
106
|
+
* the end of the URL.
|
110
107
|
*
|
111
108
|
* Examples:
|
112
109
|
*
|
@@ -117,23 +114,51 @@ autolink_delim(const uint8_t *data, struct autolink_pos *link)
|
|
117
114
|
* => http://www.pokemon.com/Pikachu_(Electric)
|
118
115
|
*
|
119
116
|
* foo http://www.pokemon.com/Pikachu_(Electric)) bar
|
120
|
-
* => http://www.pokemon.com/Pikachu_(Electric)
|
117
|
+
* => http://www.pokemon.com/Pikachu_(Electric)
|
121
118
|
*
|
122
119
|
* (foo http://www.pokemon.com/Pikachu_(Electric)) bar
|
123
|
-
* =>
|
120
|
+
* => http://www.pokemon.com/Pikachu_(Electric)
|
124
121
|
*/
|
125
122
|
|
123
|
+
size_t closing = 0;
|
124
|
+
size_t opening = 0;
|
125
|
+
size_t i = link->start;
|
126
|
+
|
126
127
|
while (i < link->end) {
|
127
|
-
|
128
|
+
int32_t c = utf8proc_next(data, &i);
|
129
|
+
if (c == copen)
|
128
130
|
opening++;
|
129
|
-
else if (
|
131
|
+
else if (c == cclose)
|
130
132
|
closing++;
|
133
|
+
}
|
131
134
|
|
132
|
-
|
135
|
+
if (copen == cclose) {
|
136
|
+
if (opening > 0)
|
137
|
+
utf8proc_back(data, &link->end);
|
133
138
|
}
|
139
|
+
else {
|
140
|
+
if (closing > opening)
|
141
|
+
utf8proc_back(data, &link->end);
|
142
|
+
}
|
143
|
+
}
|
134
144
|
|
135
|
-
|
136
|
-
|
145
|
+
return true;
|
146
|
+
}
|
147
|
+
|
148
|
+
static bool
|
149
|
+
autolink_delim_iter(const uint8_t *data, struct autolink_pos *link)
|
150
|
+
{
|
151
|
+
size_t prev_link_end;
|
152
|
+
int iterations = 0;
|
153
|
+
|
154
|
+
while(link->end != 0) {
|
155
|
+
prev_link_end = link->end;
|
156
|
+
if (!autolink_delim(data, link))
|
157
|
+
return false;
|
158
|
+
if (prev_link_end == link->end || iterations > 5) {
|
159
|
+
break;
|
160
|
+
}
|
161
|
+
iterations++;
|
137
162
|
}
|
138
163
|
|
139
164
|
return true;
|
@@ -143,16 +168,25 @@ static bool
|
|
143
168
|
check_domain(const uint8_t *data, size_t size,
|
144
169
|
struct autolink_pos *link, bool allow_short)
|
145
170
|
{
|
146
|
-
size_t i, np = 0;
|
171
|
+
size_t i, np = 0, uscore1 = 0, uscore2 = 0;
|
147
172
|
|
148
173
|
if (!rinku_isalnum(data[link->start]))
|
149
174
|
return false;
|
150
175
|
|
151
176
|
for (i = link->start + 1; i < size - 1; ++i) {
|
152
|
-
if (data[i] == '
|
153
|
-
|
177
|
+
if (data[i] == '_') {
|
178
|
+
uscore2++;
|
179
|
+
} else if (data[i] == '.') {
|
180
|
+
uscore1 = uscore2;
|
181
|
+
uscore2 = 0;
|
182
|
+
np++;
|
183
|
+
} else if (!is_valid_hostchar(data + i, size - i) && data[i] != '-')
|
184
|
+
break;
|
154
185
|
}
|
155
186
|
|
187
|
+
if (uscore1 > 0 || uscore2 > 0)
|
188
|
+
return false;
|
189
|
+
|
156
190
|
link->end = i;
|
157
191
|
|
158
192
|
if (allow_short) {
|
@@ -198,7 +232,7 @@ autolink__www(
|
|
198
232
|
return false;
|
199
233
|
|
200
234
|
link->end = utf8proc_find_space(data, link->end, size);
|
201
|
-
return
|
235
|
+
return autolink_delim_iter(data, link);
|
202
236
|
}
|
203
237
|
|
204
238
|
bool
|
@@ -244,7 +278,7 @@ autolink__email(
|
|
244
278
|
break;
|
245
279
|
}
|
246
280
|
|
247
|
-
if ((link->end - pos) < 2 || nb != 1 || np == 0)
|
281
|
+
if ((link->end - pos) < 2 || nb != 1 || np == 0 || (np == 1 && data[link->end - 1] == '.'))
|
248
282
|
return false;
|
249
283
|
|
250
284
|
return autolink_delim(data, link);
|
@@ -278,5 +312,5 @@ autolink__url(
|
|
278
312
|
if (!autolink_issafe(data + link->start, size - link->start))
|
279
313
|
return false;
|
280
314
|
|
281
|
-
return
|
315
|
+
return autolink_delim_iter(data, link);
|
282
316
|
}
|
data/ext/rinku/utf8.c
CHANGED
@@ -75,12 +75,38 @@ int32_t utf8proc_next(const uint8_t *str, size_t *pos)
|
|
75
75
|
return read_cp(str + p, length);
|
76
76
|
}
|
77
77
|
|
78
|
+
int32_t utf8proc_back(const uint8_t *str, size_t *pos)
|
79
|
+
{
|
80
|
+
const size_t p = *pos;
|
81
|
+
int8_t length = 0;
|
82
|
+
|
83
|
+
if (!p)
|
84
|
+
return 0x0;
|
85
|
+
|
86
|
+
if ((str[p - 1] & 0x80) == 0x0) {
|
87
|
+
(*pos) -= 1;
|
88
|
+
return str[p - 1];
|
89
|
+
}
|
90
|
+
|
91
|
+
if (p > 1 && utf8proc_utf8class[str[p - 2]] == 2)
|
92
|
+
length = 2;
|
93
|
+
else if (p > 2 && utf8proc_utf8class[str[p - 3]] == 3)
|
94
|
+
length = 3;
|
95
|
+
else if (p > 3 && utf8proc_utf8class[str[p - 4]] == 4)
|
96
|
+
length = 4;
|
97
|
+
|
98
|
+
(*pos) -= length;
|
99
|
+
return read_cp(&str[*pos], length);
|
100
|
+
}
|
101
|
+
|
78
102
|
size_t utf8proc_find_space(const uint8_t *str, size_t pos, size_t size)
|
79
103
|
{
|
80
104
|
while (pos < size) {
|
81
105
|
const size_t last = pos;
|
82
106
|
int32_t uc = utf8proc_next(str, &pos);
|
83
|
-
if (
|
107
|
+
if (uc == 0xFFFD)
|
108
|
+
return size;
|
109
|
+
else if (utf8proc_is_space(uc))
|
84
110
|
return last;
|
85
111
|
}
|
86
112
|
return size;
|
@@ -93,7 +119,7 @@ int32_t utf8proc_rewind(const uint8_t *data, size_t pos)
|
|
93
119
|
if (!pos)
|
94
120
|
return 0x0;
|
95
121
|
|
96
|
-
if ((data[pos - 1] &
|
122
|
+
if ((data[pos - 1] & 0x80) == 0x0)
|
97
123
|
return data[pos - 1];
|
98
124
|
|
99
125
|
if (pos > 1 && utf8proc_utf8class[data[pos - 2]] == 2)
|
@@ -106,6 +132,24 @@ int32_t utf8proc_rewind(const uint8_t *data, size_t pos)
|
|
106
132
|
return read_cp(&data[pos - length], length);
|
107
133
|
}
|
108
134
|
|
135
|
+
int32_t utf8proc_open_paren_character(int32_t cclose)
|
136
|
+
{
|
137
|
+
switch (cclose) {
|
138
|
+
case '"': return '"';
|
139
|
+
case '\'': return '\'';
|
140
|
+
case ')': return '(';
|
141
|
+
case ']': return '[';
|
142
|
+
case '}': return '{';
|
143
|
+
case 65289: return 65288; /* () */
|
144
|
+
case 12305: return 12304; /* 【】 */
|
145
|
+
case 12303: return 12302; /* 『』 */
|
146
|
+
case 12301: return 12300; /* 「」 */
|
147
|
+
case 12299: return 12298; /* 《》 */
|
148
|
+
case 12297: return 12296; /* 〈〉 */
|
149
|
+
}
|
150
|
+
return 0;
|
151
|
+
}
|
152
|
+
|
109
153
|
bool utf8proc_is_space(int32_t uc)
|
110
154
|
{
|
111
155
|
return (uc == 9 || uc == 10 || uc == 12 || uc == 13 ||
|
data/ext/rinku/utf8.h
CHANGED
@@ -26,8 +26,11 @@ bool rinku_isalpha(char c);
|
|
26
26
|
bool rinku_isalnum(char c);
|
27
27
|
|
28
28
|
int32_t utf8proc_rewind(const uint8_t *data, size_t pos);
|
29
|
+
int32_t utf8proc_next(const uint8_t *str, size_t *pos);
|
30
|
+
int32_t utf8proc_back(const uint8_t *data, size_t *pos);
|
29
31
|
size_t utf8proc_find_space(const uint8_t *str, size_t pos, size_t size);
|
30
32
|
|
33
|
+
int32_t utf8proc_open_paren_character(int32_t cclose);
|
31
34
|
bool utf8proc_is_space(int32_t uc);
|
32
35
|
bool utf8proc_is_punctuation(int32_t uc);
|
33
36
|
|
data/lib/rails_rinku.rb
CHANGED
@@ -13,10 +13,18 @@ module RailsRinku
|
|
13
13
|
options.reverse_merge!(:link => :all, :html => {})
|
14
14
|
text = h(text) unless text.html_safe?
|
15
15
|
|
16
|
+
tag_options_method = if Gem::Version.new(Rails.version) >= Gem::Version.new("5.1")
|
17
|
+
# Rails >= 5.1
|
18
|
+
tag_builder.method(:tag_options)
|
19
|
+
else
|
20
|
+
# Rails <= 5.0
|
21
|
+
method(:tag_options)
|
22
|
+
end
|
23
|
+
|
16
24
|
Rinku.auto_link(
|
17
25
|
text,
|
18
26
|
options[:link],
|
19
|
-
|
27
|
+
tag_options_method.call(options[:html]),
|
20
28
|
options[:skip],
|
21
29
|
&block
|
22
30
|
).html_safe
|
data/lib/rinku.rb
CHANGED
data/rinku.gemspec
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
Gem::Specification.new do |s|
|
4
2
|
s.name = 'rinku'
|
5
|
-
s.version = '2.0.
|
3
|
+
s.version = '2.0.6'
|
6
4
|
s.summary = "Mostly autolinking"
|
7
5
|
s.description = <<-EOF
|
8
6
|
A fast and very smart autolinking library that
|
@@ -11,6 +9,7 @@ Gem::Specification.new do |s|
|
|
11
9
|
s.email = 'vicent@github.com'
|
12
10
|
s.homepage = 'https://github.com/vmg/rinku'
|
13
11
|
s.authors = ["Vicent Marti"]
|
12
|
+
s.license = 'ISC'
|
14
13
|
# = MANIFEST =
|
15
14
|
s.files = %w[
|
16
15
|
COPYING
|
@@ -39,5 +38,7 @@ Gem::Specification.new do |s|
|
|
39
38
|
|
40
39
|
s.add_development_dependency "rake"
|
41
40
|
s.add_development_dependency "rake-compiler"
|
42
|
-
s.add_development_dependency "minitest"
|
41
|
+
s.add_development_dependency "minitest", ">= 5.0"
|
42
|
+
|
43
|
+
s.required_ruby_version = '>= 2.0.0'
|
43
44
|
end
|
data/test/autolink_test.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift "#{rootdir}/lib"
|
1
|
+
require 'bundler/setup'
|
2
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
4
3
|
|
5
4
|
require 'minitest/autorun'
|
6
5
|
require 'cgi'
|
@@ -10,7 +9,7 @@ require 'rinku'
|
|
10
9
|
class RinkuAutoLinkTest < Minitest::Test
|
11
10
|
def generate_result(link_text, href = nil)
|
12
11
|
href ||= link_text
|
13
|
-
href = "http://" + href unless href =~ %r{\A\w
|
12
|
+
href = "http://" + href unless href =~ %r{\A(\w+://|mailto:)}
|
14
13
|
%{<a href="#{CGI.escapeHTML href}">#{CGI.escapeHTML link_text}</a>}
|
15
14
|
end
|
16
15
|
|
@@ -28,7 +27,7 @@ class RinkuAutoLinkTest < Minitest::Test
|
|
28
27
|
end
|
29
28
|
|
30
29
|
def test_global_skip_tags
|
31
|
-
|
30
|
+
assert_nil Rinku.skip_tags
|
32
31
|
Rinku.skip_tags = ['pre']
|
33
32
|
assert_equal Rinku.skip_tags, ['pre']
|
34
33
|
|
@@ -363,6 +362,13 @@ This is just a test. <a href="http://www.pokemon.com">http://www.pokemon.com</a>
|
|
363
362
|
assert_linked "email#{NBSP}<a href=\"mailto:#{email_raw}\">#{email_raw}</a>", "email#{NBSP}#{email_raw}"
|
364
363
|
end
|
365
364
|
|
365
|
+
def test_identifies_unicode_spaces
|
366
|
+
assert_linked(
|
367
|
+
%{This is just a test. <a href="http://www.pokemon.com">http://www.pokemon.com</a>\u202F\u2028\u2001},
|
368
|
+
"This is just a test. http://www.pokemon.com\u202F\u2028\u2001"
|
369
|
+
)
|
370
|
+
end
|
371
|
+
|
366
372
|
def test_www_is_case_insensitive
|
367
373
|
url = "www.reddit.com"
|
368
374
|
assert_linked generate_result(url), url
|
@@ -376,4 +382,64 @@ This is just a test. <a href="http://www.pokemon.com">http://www.pokemon.com</a>
|
|
376
382
|
url = "WwW.reddit.CoM"
|
377
383
|
assert_linked generate_result(url), url
|
378
384
|
end
|
385
|
+
|
386
|
+
def test_non_emails_ending_in_periods
|
387
|
+
assert_linked "abc/def@ghi.", "abc/def@ghi."
|
388
|
+
assert_linked "abc/def@ghi. ", "abc/def@ghi. "
|
389
|
+
assert_linked "abc/def@ghi. x", "abc/def@ghi. x"
|
390
|
+
assert_linked "abc/def@ghi.< x", "abc/def@ghi.< x"
|
391
|
+
assert_linked "abc/<a href=\"mailto:def@ghi.x\">def@ghi.x</a>", "abc/def@ghi.x"
|
392
|
+
assert_linked "abc/<a href=\"mailto:def@ghi.x\">def@ghi.x</a>. a", "abc/def@ghi.x. a"
|
393
|
+
end
|
394
|
+
|
395
|
+
def test_urls_with_entities_and_parens
|
396
|
+
assert_linked "<<a href=\"http://www.google.com\">http://www.google.com</a>>", "<http://www.google.com>"
|
397
|
+
|
398
|
+
assert_linked "<<a href=\"http://www.google.com\">http://www.google.com</a>>)", "<http://www.google.com>)"
|
399
|
+
|
400
|
+
# this produces invalid output, but limits how much work we will do
|
401
|
+
assert_linked "<<a href=\"http://www.google.com>\">http://www.google.com></a>)<)<)<)<)<)<)", "<http://www.google.com>)<)<)<)<)<)<)"
|
402
|
+
|
403
|
+
url = "http://pokemon.com/bulbasaur"
|
404
|
+
assert_linked "URL is #{generate_result(url)}.", "URL is #{url}."
|
405
|
+
assert_linked "(URL is #{generate_result(url)}.)", "(URL is #{url}.)"
|
406
|
+
|
407
|
+
url = "www.pokemon.com/bulbasaur"
|
408
|
+
assert_linked "URL is #{generate_result(url)}.", "URL is #{url}."
|
409
|
+
assert_linked "(URL is #{generate_result(url)}.)", "(URL is #{url}.)"
|
410
|
+
|
411
|
+
url = "abc@xyz.com"
|
412
|
+
assert_linked "URL is #{generate_result(url, "mailto:#{url}")}.", "URL is #{url}."
|
413
|
+
assert_linked "(URL is #{generate_result(url, "mailto:#{url}")}.)", "(URL is #{url}.)"
|
414
|
+
end
|
415
|
+
|
416
|
+
def test_urls_with_parens
|
417
|
+
assert_linked "(<a href=\"http://example.com\">http://example.com</a>)", "(http://example.com)"
|
418
|
+
assert_linked "((<a href=\"http://example.com/()\">http://example.com/()</a>))", "((http://example.com/()))"
|
419
|
+
assert_linked "[<a href=\"http://example.com/()\">http://example.com/()</a>]", "[http://example.com/()]"
|
420
|
+
|
421
|
+
assert_linked "(<a href=\"http://example.com/\">http://example.com/</a>)", "(http://example.com/)"
|
422
|
+
assert_linked "【<a href=\"http://example.com/\">http://example.com/</a>】", "【http://example.com/】"
|
423
|
+
assert_linked "『<a href=\"http://example.com/\">http://example.com/</a>』", "『http://example.com/』"
|
424
|
+
assert_linked "「<a href=\"http://example.com/\">http://example.com/</a>」", "「http://example.com/」"
|
425
|
+
assert_linked "《<a href=\"http://example.com/\">http://example.com/</a>》", "《http://example.com/》"
|
426
|
+
assert_linked "〈<a href=\"http://example.com/\">http://example.com/</a>〉", "〈http://example.com/〉"
|
427
|
+
end
|
428
|
+
|
429
|
+
def test_urls_with_quotes
|
430
|
+
assert_linked "'<a href=\"http://example.com\">http://example.com</a>'", "'http://example.com'"
|
431
|
+
assert_linked "\"<a href=\"http://example.com\">http://example.com</a>\"\"", "\"http://example.com\"\""
|
432
|
+
end
|
433
|
+
|
434
|
+
def test_underscore_in_domain
|
435
|
+
assert_linked "http://foo_bar.com", "http://foo_bar.com"
|
436
|
+
end
|
437
|
+
|
438
|
+
def test_underscore_in_subdomain
|
439
|
+
assert_linked "<a href=\"http://foo_bar.xyz.com\">http://foo_bar.xyz.com</a>", "http://foo_bar.xyz.com"
|
440
|
+
end
|
441
|
+
|
442
|
+
def test_regression_84
|
443
|
+
assert_linked "<a href=\"https://www.keepright.atの情報をもとにエラー修正\">https://www.keepright.atの情報をもとにエラー修正</a>", "https://www.keepright.atの情報をもとにエラー修正"
|
444
|
+
end
|
379
445
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rinku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vicent Marti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '5.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '5.0'
|
55
55
|
description: |2
|
56
56
|
A fast and very smart autolinking library that
|
57
57
|
acts as a drop-in replacement for Rails `auto_link`
|
@@ -80,7 +80,8 @@ files:
|
|
80
80
|
- rinku.gemspec
|
81
81
|
- test/autolink_test.rb
|
82
82
|
homepage: https://github.com/vmg/rinku
|
83
|
-
licenses:
|
83
|
+
licenses:
|
84
|
+
- ISC
|
84
85
|
metadata: {}
|
85
86
|
post_install_message:
|
86
87
|
rdoc_options: []
|
@@ -90,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
91
|
requirements:
|
91
92
|
- - ">="
|
92
93
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
94
|
+
version: 2.0.0
|
94
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
96
|
requirements:
|
96
97
|
- - ">="
|
@@ -98,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
99
|
version: '0'
|
99
100
|
requirements: []
|
100
101
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.
|
102
|
+
rubygems_version: 2.7.6
|
102
103
|
signing_key:
|
103
104
|
specification_version: 4
|
104
105
|
summary: Mostly autolinking
|