From b9ca9169ba7c71a507fb3d4bcd6373c9c23edc7f Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 29 Oct 2018 06:23:21 +0000 Subject: Mark up code inside link text as Merged https://github.com/ruby/rdoc/pull/660 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/markup/to_html_crossref.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/rdoc/markup/to_html_crossref.rb b/lib/rdoc/markup/to_html_crossref.rb index 6020263799..2fbddeb83b 100644 --- a/lib/rdoc/markup/to_html_crossref.rb +++ b/lib/rdoc/markup/to_html_crossref.rb @@ -49,16 +49,19 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml # Creates a link to the reference +name+ if the name exists. If +text+ is # given it is used as the link text, otherwise +name+ is used. - def cross_reference name, text = nil + def cross_reference name, text = nil, code = true lookup = name name = name[1..-1] unless @show_hash if name[0, 1] == '#' - name = "#{CGI.unescape $'} at #{$1}" if name =~ /(.*[^#:])@/ - - text = name unless text + if name =~ /(.*[^#:])@/ + text ||= "#{CGI.unescape $'} at #{$1}" + code = false + else + text ||= name + end - link lookup, text + link lookup, text, code end ## @@ -119,13 +122,14 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml def gen_url url, text return super unless url =~ /\Ardoc-ref:/ - cross_reference $', text + name = $' + cross_reference name, text, name == text end ## # Creates an HTML link to +name+ with the given +text+. - def link name, text + def link name, text, code = true if name =~ /(.*[^#:])@/ then name = $1 label = $' @@ -139,6 +143,10 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml else path = ref.as_href @from_path + if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref) + text = "#{text}" + end + if path =~ /#/ then path << "-label-#{label}" elsif ref.sections and -- cgit v1.2.3