anchored 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -13
- data/lib/anchored/linker.rb +1 -1
- data/lib/anchored/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a8df9e706f1afaa992478a748bce0c8c2515df6
|
4
|
+
data.tar.gz: d02ddf11e4a900bec073e1a54893d26480cf52ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45e933df222c21524faf39f7bbca4f036bb704f2d814471b3d18925cf087a1da0ae9b42bfedaec948db5478013d30960de1cc2527d96af9a2096ae67403dbfbf
|
7
|
+
data.tar.gz: 712b65345b0094efabc15875b3c287b3de8a040fd02421e2c8acf2149f915dec60aed5d1b98ebd91ec8860ffcba17b340078f26a183031312d59e70a970cb2a2
|
data/README.md
CHANGED
@@ -26,30 +26,33 @@ $ gem install anchored
|
|
26
26
|
|
27
27
|
## Usage
|
28
28
|
|
29
|
-
|
30
|
-
require "anchored"
|
29
|
+
#### Pass-through
|
31
30
|
|
31
|
+
```ruby
|
32
32
|
Anchored::Linker.auto_link("text")
|
33
|
-
=> "text"
|
34
|
-
|
35
|
-
|
36
|
-
# Wrap URLs in anchors:
|
33
|
+
# => "text"
|
34
|
+
```
|
37
35
|
|
38
|
-
|
39
|
-
=> "hello <a href='http://www.google.com'>www.google.com</a>."
|
36
|
+
#### Wrap URLs in anchors:
|
40
37
|
|
38
|
+
```ruby
|
39
|
+
Anchored::Linker.auto_link("hello www.example.com.")
|
40
|
+
# => "hello <a href='http://www.example.com'>www.example.com</a>."
|
41
|
+
```
|
41
42
|
|
42
|
-
|
43
|
+
#### Set anchor attributes. Alter the link text with a block:
|
43
44
|
|
44
|
-
|
45
|
+
```ruby
|
46
|
+
text = "Welcome to http://www.example.com/."
|
45
47
|
Anchored::Linker.auto_link(text, target: "_blank") do |text|
|
46
48
|
text[0...12] + "..."
|
47
49
|
end
|
48
|
-
# => "Welcome to <a href=\"http://www.
|
49
|
-
|
50
|
+
# => "Welcome to <a href=\"http://www.example.com/\" target=\"_blank\">http://exampl...</a>."
|
51
|
+
```
|
50
52
|
|
51
|
-
|
53
|
+
#### Remove the target attribute when a URL matches a domain:
|
52
54
|
|
55
|
+
```ruby
|
53
56
|
text = "Hello http://www.example.com/."
|
54
57
|
Anchored::Linker.auto_link(text, target: "_blank", domain: "example.com")
|
55
58
|
# => "Hello <a href=\"http://www.example.com/\">http://example.com</a>."
|
data/lib/anchored/linker.rb
CHANGED
@@ -28,7 +28,7 @@ module Anchored
|
|
28
28
|
# regexps for determining context, used high-volume
|
29
29
|
AUTO_LINK_CRE = [/<[^>]+$/, /^[^>]*>/, /<a\b.*?>/i, /<\/a>/i].freeze
|
30
30
|
|
31
|
-
PUNCTUATION_RE = /[^\p{Word}
|
31
|
+
PUNCTUATION_RE = /[^\p{Word}\/=&]$/
|
32
32
|
|
33
33
|
BRACKETS = { "]" => "[", ")" => "(", "}" => "{" }.freeze
|
34
34
|
|
data/lib/anchored/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anchored
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tee Parham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
101
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.6.
|
102
|
+
rubygems_version: 2.6.14
|
103
103
|
signing_key:
|
104
104
|
specification_version: 4
|
105
105
|
summary: Ruby auto linker
|