Skip to content

Commit 424bd5d

Browse files
committed
Fix links without paths
1 parent caf2346 commit 424bd5d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/rdoc/markup/to_html.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def gen_url url, text
357357
url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
358358
"<img src=\"#{url}\" />"
359359
else
360-
if scheme != 'link' and %r%\A((?!https?:).*/)([^/]+)\.(rb|rdoc|md)(?=\z|#)%i =~ url
360+
if scheme != 'link' and %r%\A((?!https?:)(?:[^/#]*/)*+)([^/#]+)\.(rb|rdoc|md)(?=\z|#)%i =~ url
361361
url = "#$1#{$2.tr('.', '_')}_#$3.html#$'"
362362
end
363363

test/rdoc/test_rdoc_markup_to_html.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,8 @@ def test_gen_url_ssl_image_url
739739
end
740740

741741
def test_gen_url_rdoc_file
742+
assert_equal '<a href="example_rdoc.html">example</a>',
743+
@to.gen_url('example.rdoc', 'example')
742744
assert_equal '<a href="doc/example_rdoc.html">example</a>',
743745
@to.gen_url('doc/example.rdoc', 'example')
744746
assert_equal '<a href="../ex.doc/example_rdoc.html">example</a>',
@@ -750,6 +752,8 @@ def test_gen_url_rdoc_file
750752
end
751753

752754
def test_gen_url_md_file
755+
assert_equal '<a href="example_md.html">example</a>',
756+
@to.gen_url('example.md', 'example')
753757
assert_equal '<a href="doc/example_md.html">example</a>',
754758
@to.gen_url('doc/example.md', 'example')
755759
assert_equal '<a href="../ex.doc/example_md.html">example</a>',
@@ -761,6 +765,8 @@ def test_gen_url_md_file
761765
end
762766

763767
def test_gen_url_rb_file
768+
assert_equal '<a href="example_rb.html">example</a>',
769+
@to.gen_url('example.rb', 'example')
764770
assert_equal '<a href="doc/example_rb.html">example</a>',
765771
@to.gen_url('doc/example.rb', 'example')
766772
assert_equal '<a href="../ex.doc/example_rb.html">example</a>',

0 commit comments

Comments
 (0)