def resolve_links(text)
code_tags = 0
text.gsub(/<(\/)?(pre|code|tt)|\{(\S+?)(?:\s(.*?\S))?\}(?=[\W<]|.+<\/|$)/m) do |str|
closed, tag, name, title, match = $1, $2, $3, $4, $&
if tag
code_tags += (closed ? -1 : 1)
next str
end
next str unless code_tags == 0
next(match) if name[0,1] == '|'
if object.is_a?(String)
object
else
link = linkify(name, title)
if link == name || link == title
match = /(.+)?(\{#{Regexp.quote name}(?:\s.*?)?\})(.+)?/.match(text)
file = (@file ? @file : object.file) || '(unknown)'
line = (@file ? 1 : (object.docstring.line_range ? object.docstring.line_range.first : 1)) + (match ? $`.count("\n") : 0)
log.warn "In file `#{file}':#{line}: Cannot resolve link to #{name} from text" + (match ? ":" : ".")
log.warn((match[1] ? '...' : '') + match[2].gsub("\n","") + (match[3] ? '...' : '')) if match
end
link
end
end
end