diff options
author | Nobuyoshi Nakada <[email protected]> | 2021-03-21 14:36:57 +0900 |
---|---|---|
committer | aycabta <[email protected]> | 2021-04-03 01:22:09 +0900 |
commit | 64b991b0cd98ee8f23266b8cbea0fa34bdaab1ec (patch) | |
tree | 2cfff855380f2f7dabbf9778ab179718c07276d6 /lib/rdoc | |
parent | a6948329f8f89fb390215086fe4a888915fd589e (diff) |
[ruby/rdoc] Links to document texts without "rdoc-ref:" prefix
While links to generated HTML from RDoc file needs to be prefixed
by "rdoc-ref:" currently, in case of explicit references this
seems just redundant.
Also GitHub RDoc support does not work with this prefix.
This patch lets links to such document texts (".rb", ".rdoc" and
".md" now) refer URLs generated by `RDoc::TopLevel#http_url`
without the prefix.
https://github.com/ruby/rdoc/commit/f18b27b69d
Diffstat (limited to 'lib/rdoc')
-rw-r--r-- | lib/rdoc/markup/to_html.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index e2a00bd8a1..8ae4dd4720 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -357,6 +357,10 @@ 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" } + end + text = text.sub %r%^#{scheme}:/*%i, '' text = text.sub %r%^[*\^](\d+)$%, '\1' |