mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/rdoc] Fix for explicit http link
https://github.com/ruby/rdoc/commit/caf234665c
This commit is contained in:
parent
7c8aa0a5d2
commit
f88a9097a4
2 changed files with 8 additions and 8 deletions
|
@ -357,8 +357,8 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|||
url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
|
||||
"<img src=\"#{url}\" />"
|
||||
else
|
||||
if scheme != 'link' and %r%\A([./]*+)(.*?\.)(rb|rdoc|md)(?=\z|#)%i =~ url
|
||||
url = "#$1#{$2.tr('.', '_')}#$3.html#{$'}"
|
||||
if scheme != 'link' and %r%\A((?!https?:).*/)([^/]+)\.(rb|rdoc|md)(?=\z|#)%i =~ url
|
||||
url = "#$1#{$2.tr('.', '_')}_#$3.html#$'"
|
||||
end
|
||||
|
||||
text = text.sub %r%^#{scheme}:/*%i, ''
|
||||
|
|
|
@ -741,33 +741,33 @@ EXPECTED
|
|||
def test_gen_url_rdoc_file
|
||||
assert_equal '<a href="doc/example_rdoc.html">example</a>',
|
||||
@to.gen_url('doc/example.rdoc', 'example')
|
||||
assert_equal '<a href="../ex_doc/example_rdoc.html">example</a>',
|
||||
assert_equal '<a href="../ex.doc/example_rdoc.html">example</a>',
|
||||
@to.gen_url('../ex.doc/example.rdoc', 'example')
|
||||
assert_equal '<a href="doc/example_rdoc.html#label-one">example</a>',
|
||||
@to.gen_url('doc/example.rdoc#label-one', 'example')
|
||||
assert_equal '<a href="../ex_doc/example_rdoc.html#label-two">example</a>',
|
||||
assert_equal '<a href="../ex.doc/example_rdoc.html#label-two">example</a>',
|
||||
@to.gen_url('../ex.doc/example.rdoc#label-two', 'example')
|
||||
end
|
||||
|
||||
def test_gen_url_md_file
|
||||
assert_equal '<a href="doc/example_md.html">example</a>',
|
||||
@to.gen_url('doc/example.md', 'example')
|
||||
assert_equal '<a href="../ex_doc/example_md.html">example</a>',
|
||||
assert_equal '<a href="../ex.doc/example_md.html">example</a>',
|
||||
@to.gen_url('../ex.doc/example.md', 'example')
|
||||
assert_equal '<a href="doc/example_md.html#label-one">example</a>',
|
||||
@to.gen_url('doc/example.md#label-one', 'example')
|
||||
assert_equal '<a href="../ex_doc/example_md.html#label-two">example</a>',
|
||||
assert_equal '<a href="../ex.doc/example_md.html#label-two">example</a>',
|
||||
@to.gen_url('../ex.doc/example.md#label-two', 'example')
|
||||
end
|
||||
|
||||
def test_gen_url_rb_file
|
||||
assert_equal '<a href="doc/example_rb.html">example</a>',
|
||||
@to.gen_url('doc/example.rb', 'example')
|
||||
assert_equal '<a href="../ex_doc/example_rb.html">example</a>',
|
||||
assert_equal '<a href="../ex.doc/example_rb.html">example</a>',
|
||||
@to.gen_url('../ex.doc/example.rb', 'example')
|
||||
assert_equal '<a href="doc/example_rb.html#label-one">example</a>',
|
||||
@to.gen_url('doc/example.rb#label-one', 'example')
|
||||
assert_equal '<a href="../ex_doc/example_rb.html#label-two">example</a>',
|
||||
assert_equal '<a href="../ex.doc/example_rb.html#label-two">example</a>',
|
||||
@to.gen_url('../ex.doc/example.rb#label-two', 'example')
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue