auto_html 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe9d59c6aaaa2ac3a738aaceeab582872044be2d3983957e6cc3f973023fa10a
4
- data.tar.gz: 4667fc4cd2183f36a8141446050b8ab31abbbdd6ef06ae8bf547fd75a43660db
3
+ metadata.gz: 1c4554b35676a92a446754ad032d363e1f4be41613ae4923f376ddbb8229a334
4
+ data.tar.gz: 32062562a065326482d93d164caa849ff81029eb872ee66d973d435e528f99bb
5
5
  SHA512:
6
- metadata.gz: b091f4972d71693b18ffb2d19ecc9fa9361d4f0787a7a75bc0c9f10aee59b7d3dc346909a741485ef7ce2e82e2c9960e5cc45d8ad38f53a0e4fed8a590bb7f46
7
- data.tar.gz: 4d79645b12e7ff1e7884f460b36c9d95496698780f2854183afdaa719b585d98f328fdb99355dc08949c7696dfb420195c1113b53e751bf0267f77a291bc2dd3
6
+ metadata.gz: f22718875cce1764c67e795badf8dca2596697d22e9cd3b31d08b71a2abfe0d2b1c726eefee905b263ecf7352cb2e12c5a8aae4fbc1808e1169b45e2f350e3a2
7
+ data.tar.gz: ad11106a8df96b900a20df3a0665ec7b9227ba8a92a1728725381d540a11c8df41057dba72feeb9f22fefab82749336038d74c4bd6efa718d263da440eb82452
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # AutoHtml
2
2
 
3
- AutoHtml is a collection of filters that transforms plain text into HTML code.
3
+ AutoHtml is a collection of filters that transforms plain text into HTML code. See [live demo](https://autohtml.rors.org).
4
4
 
5
5
  ## Installation
6
6
 
@@ -7,13 +7,14 @@ require 'rexml/document'
7
7
  module AutoHtml
8
8
  # Link filter
9
9
  class Link
10
- def initialize(target: nil, rel: nil)
10
+ def initialize(target: nil, rel: nil, short_domains: false)
11
11
  @target = target
12
12
  @rel = rel
13
+ @short_domains = short_domains
13
14
  end
14
15
 
15
16
  def call(text)
16
- Rinku.auto_link(text, :all, attributes)
17
+ Rinku.auto_link(text, :all, attributes, nil, flags)
17
18
  end
18
19
 
19
20
  private
@@ -29,5 +30,9 @@ module AutoHtml
29
30
  def target_attr
30
31
  %(target="#{@target}") if @target
31
32
  end
33
+
34
+ def flags
35
+ @short_domains ? Rinku::AUTOLINK_SHORT_DOMAINS : 0
36
+ end
32
37
  end
33
38
  end
@@ -33,6 +33,11 @@ RSpec.describe AutoHtml::Link do
33
33
  expect(result).to eq '<a href="http://www.google.com/#q=nikola+tesla&ct=tesla09&oi=ddle&fp=Xmf0jJ9P_V0">http://www.google.com/#q=nikola+tesla&ct=tesla09&oi=ddle&fp=Xmf0jJ9P_V0</a>'
34
34
  end
35
35
 
36
+ it 'not transforms short domain URL' do
37
+ result = subject.call('http://localhost:3000')
38
+ expect(result).to eq 'http://localhost:3000'
39
+ end
40
+
36
41
  it 'transforms with target options' do
37
42
  filter = described_class.new(target: '_blank')
38
43
  result = filter.call('http://rors.org')
@@ -45,6 +50,12 @@ RSpec.describe AutoHtml::Link do
45
50
  expect(result).to eq '<a href="http://rors.org" rel="nofollow">http://rors.org</a>'
46
51
  end
47
52
 
53
+ it 'transforms with short_domains options' do
54
+ filter = described_class.new(short_domains: true)
55
+ result = filter.call('http://localhost:3000')
56
+ expect(result).to eq '<a href="http://localhost:3000">http://localhost:3000</a>'
57
+ end
58
+
48
59
  it 'transforms with target and rel options' do
49
60
  filter = described_class.new(target: '_blank', rel: 'nofollow')
50
61
  result = filter.call('http://rors.org')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_html
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dejan Simic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-04 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gemoji
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rexml
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.2.5
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.2.5
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rinku
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -154,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
168
  - !ruby/object:Gem::Version
155
169
  version: '0'
156
170
  requirements: []
157
- rubygems_version: 3.2.22
171
+ rubygems_version: 3.2.3
158
172
  signing_key:
159
173
  specification_version: 4
160
174
  summary: Plain text to HTML conversion