Skip to content

Commit 1bd8e50

Browse files
floehopperdrbrain
authored andcommitted
Allow an image URL using SSL to be converted into an img HTML tag.
I want to display the Travis CI build status image from my README.rdoc [1] file on Github. Travis CI suggest [2] that I should use an image served over SSL, but as it stands I can't seem to get rdoc to generate an `img` tag for an SSL image URL. [1] https://github.com/floehopper/mocha/blob/master/README.rdoc [2] http://about.travis-ci.org/docs/user/status-images/#using-ssl-enabled-status-images-on-github
1 parent 961085d commit 1bd8e50

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/rdoc/markup/to_html.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def gen_url(url, text)
254254
end
255255
end
256256

257-
if (type == "http" or type == "link") and
257+
if (type == "http" or type == "https" or type == "link") and
258258
url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
259259
"<img src=\"#{url}\" />"
260260
else

test/test_rdoc_markup_to_html.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ def test_gen_url
306306
@to.gen_url('link:example', 'example')
307307
end
308308

309+
def test_gem_url_image_url
310+
assert_equal '<img src="http://example.com/image.png" />', @to.gen_url('http://example.com/image.png', 'ignored')
311+
end
312+
313+
def test_gem_url_ssl_image_url
314+
assert_equal '<img src="https://example.com/image.png" />', @to.gen_url('https://example.com/image.png', 'ignored')
315+
end
316+
309317
def test_handle_special_HYPERLINK_link
310318
special = RDoc::Markup::Special.new 0, 'link:README.txt'
311319

0 commit comments

Comments
 (0)