ruby-changes:66690
From: Nobuyoshi <ko1@a...>
Date: Mon, 5 Jul 2021 18:35:34 +0900 (JST)
Subject: [ruby-changes:66690] 3dacc14fd3 (master): [ruby/rdoc] Fix links without paths
https://git.ruby-lang.org/ruby.git/commit/?id=3dacc14fd3 From 3dacc14fd3dded7feda31c195f6bf6c096c91e21 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 1 Jul 2021 05:39:13 +0900 Subject: [ruby/rdoc] Fix links without paths https://github.com/ruby/rdoc/commit/424bd5db4d --- lib/rdoc/markup/to_html.rb | 2 +- test/rdoc/test_rdoc_markup_to_html.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index f3dd96e..d3bb8af 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -357,7 +357,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markup/to_html.rb#L357 url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then "<img src=\"#{url}\" />" else - if scheme != 'link' and %r%\A((?!https?:).*/)([^/]+)\.(rb|rdoc|md)(?=\z|#)%i =~ url + if scheme != 'link' and %r%\A((?!https?:)(?:[^/#]*/)*+)([^/#]+)\.(rb|rdoc|md)(?=\z|#)%i =~ url url = "#$1#{$2.tr('.', '_')}_#$3.html#$'" end diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb index aa36fb7..342cf71 100644 --- a/test/rdoc/test_rdoc_markup_to_html.rb +++ b/test/rdoc/test_rdoc_markup_to_html.rb @@ -739,6 +739,8 @@ EXPECTED https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_markup_to_html.rb#L739 end def test_gen_url_rdoc_file + assert_equal '<a href="example_rdoc.html">example</a>', + @to.gen_url('example.rdoc', 'example') 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>', @@ -750,6 +752,8 @@ EXPECTED https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_markup_to_html.rb#L752 end def test_gen_url_md_file + assert_equal '<a href="example_md.html">example</a>', + @to.gen_url('example.md', 'example') 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>', @@ -761,6 +765,8 @@ EXPECTED https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_markup_to_html.rb#L765 end def test_gen_url_rb_file + assert_equal '<a href="example_rb.html">example</a>', + @to.gen_url('example.rb', 'example') 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>', -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/