moredown 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/moredown.rb +8 -1
  3. data/test/moredown_test.rb +10 -2
  4. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -100,7 +100,14 @@ class Moredown < RDiscount
100
100
 
101
101
  # remap relative urls
102
102
  if @base_url
103
- html.gsub!('"/images/', "\"#{@base_url}/images/")
103
+ html.gsub!(/<img src="(.*?)"/) do |match|
104
+ if $1.include? '://'
105
+ url = $1
106
+ else
107
+ url = "#{@base_url.chomp('/')}/#{$1}"
108
+ end
109
+ "<img src=\"#{url}\""
110
+ end
104
111
  html.gsub!('<a href="/', "<a href=\"#{@base_url}/")
105
112
  end
106
113
 
@@ -107,8 +107,16 @@ TEXT
107
107
  end
108
108
 
109
109
  def test_base_url
110
- text = "![Image](/images/test.jpg)"
111
- html = "<p><img src=\"http://www.example.com/images/test.jpg\" alt=\"Image\" /></p>\n"
110
+ text = "![Image](test.jpg)"
111
+ html = "<p><img src=\"http://www.example.com/test.jpg\" alt=\"Image\" /></p>\n"
112
+ assert_equal html, Moredown.text_to_html(text, :base_url => 'http://www.example.com')
113
+
114
+ text = "![Image](test.jpg)"
115
+ html = "<p><img src=\"http://www.example.com/test.jpg\" alt=\"Image\" /></p>\n"
116
+ assert_equal html, Moredown.text_to_html(text, :base_url => 'http://www.example.com/')
117
+
118
+ text = "![Image](http://icanhascheezburger.files.wordpress.com/2009/11/funny-pictures-cat-wishes-for-cheeseburger.jpg)"
119
+ html = "<p><img src=\"http://icanhascheezburger.files.wordpress.com/2009/11/funny-pictures-cat-wishes-for-cheeseburger.jpg\" alt=\"Image\" /></p>\n"
112
120
  assert_equal html, Moredown.text_to_html(text, :base_url => 'http://www.example.com')
113
121
  end
114
122
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moredown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hoad
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-11-07 00:00:00 +10:00
14
+ date: 2009-11-28 00:00:00 +10:00
15
15
  default_executable: rdiscount
16
16
  dependencies: []
17
17