def inline_anchor node
target = node.target
case node.type
when :link
if (text = node.text) == target
text = nil
else
text = text.gsub '"', %[#{ESC_BS}(dq]
end
if target.start_with? 'mailto:'
macro = 'MTO'
target = target[7..-1].sub '@', %[#{ESC_BS}(at]
else
macro = 'URL'
end
%(#{ESC_BS}c#{LF}#{ESC_FS}#{macro} "#{target}" "#{text}" )
when :xref
refid = (node.attr 'refid') || target
node.text || (node.document.references[:ids][refid] || %([#{refid}]))
when :ref, :bibref
''
else
warn %(asciidoctor: WARNING: unknown anchor type: #{node.type.inspect})
end
end