govspeak 1.2.2 → 1.2.3

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.
@@ -1,3 +1,3 @@
1
1
  module Govspeak
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
@@ -27,13 +27,15 @@ EOF
27
27
  end
28
28
 
29
29
  def add_link(el, href, title, alt_text = nil)
30
- begin
31
- host = URI.parse(href).host
32
- unless host.nil? || (@document_domains.compact.include?(host))
33
- el.attr['rel'] = 'external'
30
+ if el.type == :a
31
+ begin
32
+ host = URI.parse(href).host
33
+ unless host.nil? || (@document_domains.compact.include?(host))
34
+ el.attr['rel'] = 'external'
35
+ end
36
+ rescue URI::InvalidURIError, URI::InvalidComponentError
37
+ # it's safe to ignore these very *specific* exceptions
34
38
  end
35
- rescue URI::InvalidURIError, URI::InvalidComponentError
36
- # it's safe to ignore these very *specific* exceptions
37
39
  end
38
40
  super
39
41
  end
@@ -221,6 +221,10 @@ Teston
221
221
  assert_html_output '<p>Text before <a rel="external" href="http://www.google.com">an external link</a> and text afterwards</p>'
222
222
  end
223
223
 
224
+ test_given_govspeak "![image with external url](http://www.example.com/image.jpg)" do
225
+ assert_html_output '<p><img src="http://www.example.com/image.jpg" alt="image with external url" /></p>'
226
+ end
227
+
224
228
  test "should be able to override default 'document_domains' option" do
225
229
  html = Govspeak::Document.new("[internal link](http://www.not-external.com)", document_domains: %w(www.not-external.com)).to_html
226
230
  refute html.include?('rel="external"'), "should not consider www.not-external.com as an external url"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: govspeak
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.2
5
+ version: 1.2.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Griffiths
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2012-11-01 00:00:00 Z
14
+ date: 2012-11-08 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: kramdown
@@ -130,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
- hash: 1267404848853148486
133
+ hash: 3197416977865926476
134
134
  segments:
135
135
  - 0
136
136
  version: "0"
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  requirements:
140
140
  - - ">="
141
141
  - !ruby/object:Gem::Version
142
- hash: 1267404848853148486
142
+ hash: 3197416977865926476
143
143
  segments:
144
144
  - 0
145
145
  version: "0"