def sub_inline_xrefs(text, found = nil)
if (!found || found[:macroish]) || text.include?('<<')
text = text.gsub(XrefInlineMacroRx) {
m = $~
if m[0].start_with? '\\'
next m[0][1..-1]
end
if ::RUBY_ENGINE_OPAL
m[1] = nil if m[1] == ''
end
if m[1]
id, reftext = m[1].split(',', 2).map {|it| it.strip }
id = id.sub(DoubleQuotedRx, '\2')
reftext = if reftext.nil_or_empty?
nil
else
reftext.sub(DoubleQuotedMultiRx, '\2')
end
else
id = m[2]
reftext = m[3] unless m[3].nil_or_empty?
end
if id.include? '#'
path, fragment = id.split('#')
else
path = nil
fragment = id
end
if path
path = Helpers.rootname(path)
if @document.attributes['docname'] == path || @document.references[:includes].include?(path)
refid = fragment
path = nil
target = %(##{fragment})
else
refid = fragment ? %(
path = "#{@document.attributes['relfileprefix']}#{path}#{@document.attributes.fetch 'outfilesuffix', '.html'}"
target = fragment ? %(
end
else
if !(@document.references[:ids].has_key? fragment) &&
((fragment.include? ' ') || fragment.downcase != fragment) &&
(resolved_id = RUBY_MIN_VERSION_1_9 ? (@document.references[:ids].key fragment) : (@document.references[:ids].index fragment))
fragment = resolved_id
end
refid = fragment
target = %(##{fragment})
end
Inline.new(self, :anchor, reftext, :type => :xref, :target => target, :attributes => {'path' => path, 'fragment' => fragment, 'refid' => refid}).convert
}
end
text
end