def METHOD_NAME(std_domain, env, fromdocname, builder, typ, target, node, contnode):
    if not node.get('refkeepformat'):
        # redirect to original implementation to make it safer
        return self.original(std_domain, env, fromdocname, builder, typ, target, node, contnode)
    # directly reference to document by source name; can be absolute or relative
    from sphinx.domains.std import docname_join, make_refnode
    refdoc = node.get('refdoc', fromdocname)
    docname = docname_join(refdoc, node['reftarget'])
    if docname not in env.all_docs:
        return None
    else:
        innernode = node[0]  # no astext here, to keep literal intact
        return make_refnode(builder, fromdocname, docname, None, innernode)