diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-29 06:23:21 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-29 06:23:21 +0000 |
commit | b9ca9169ba7c71a507fb3d4bcd6373c9c23edc7f (patch) | |
tree | 57d0acdb6bbc29d4f499608effbf1697cf18c677 /lib | |
parent | c80f3f709fc94dac52726b5d9a2f486e6c3be745 (diff) | |
download | ruby-b9ca9169ba7c71a507fb3d4bcd6373c9c23edc7f.tar.gz |
Mark up code inside link text as <code>
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rdoc/markup/to_html_crossref.rb | 22 |
1 files changed, 15 insertions, 7 deletions
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 <code>#{$1}</code>" + 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 = "<code>#{text}</code>" + end + if path =~ /#/ then path << "-label-#{label}" elsif ref.sections and |