mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
c80f3f709f
commit
b9ca9169ba
2 changed files with 38 additions and 30 deletions
|
@ -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 =~ /(.*[^#:])@/
|
||||
if name =~ /(.*[^#:])@/
|
||||
text ||= "#{CGI.unescape $'} at <code>#{$1}</code>"
|
||||
code = false
|
||||
else
|
||||
text ||= name
|
||||
end
|
||||
|
||||
text = name unless text
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue