mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/rdoc] Allow a label in a link to another document text
https://github.com/ruby/rdoc/commit/85bb2d33bb
This commit is contained in:
parent
46ab28d6c9
commit
7c8aa0a5d2
2 changed files with 14 additions and 2 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 /\.(?:rb|rdoc|md)\z/i =~ url
|
||||
url = url.sub(%r%\A([./]*)(.*)\z%) { "#$1#{$2.tr('.', '_')}.html" }
|
||||
if scheme != 'link' and %r%\A([./]*+)(.*?\.)(rb|rdoc|md)(?=\z|#)%i =~ url
|
||||
url = "#$1#{$2.tr('.', '_')}#$3.html#{$'}"
|
||||
end
|
||||
|
||||
text = text.sub %r%^#{scheme}:/*%i, ''
|
||||
|
|
|
@ -743,6 +743,10 @@ EXPECTED
|
|||
@to.gen_url('doc/example.rdoc', 'example')
|
||||
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>',
|
||||
@to.gen_url('../ex.doc/example.rdoc#label-two', 'example')
|
||||
end
|
||||
|
||||
def test_gen_url_md_file
|
||||
|
@ -750,6 +754,10 @@ EXPECTED
|
|||
@to.gen_url('doc/example.md', 'example')
|
||||
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>',
|
||||
@to.gen_url('../ex.doc/example.md#label-two', 'example')
|
||||
end
|
||||
|
||||
def test_gen_url_rb_file
|
||||
|
@ -757,6 +765,10 @@ EXPECTED
|
|||
@to.gen_url('doc/example.rb', 'example')
|
||||
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>',
|
||||
@to.gen_url('../ex.doc/example.rb#label-two', 'example')
|
||||
end
|
||||
|
||||
def test_handle_regexp_HYPERLINK_link
|
||||
|
|
Loading…
Reference in a new issue