def hash_reference_links(text, hashes, markdown_obj):
def sub(match):<EOL><INDENT>is_img = match.group(<NUM_LIT:1>) != '<STR_LIT>'<EOL>content = match.group(<NUM_LIT:2>)<EOL>ref = match.group(<NUM_LIT:3>).strip().lower()<EOL>if not ref:<EOL><INDENT>ref = content.strip().lower()<EOL><DEDENT>ref = ref.replace('<STR_LIT:\n>', '<STR_LIT:U+0020>')<EOL>if ref not in markdown_obj.references:<EOL><INDENT>link, title = '<STR_LIT>', '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>link, title = markdown_obj.references[ref]<EOL><DEDENT>if title:<EOL><INDENT>title = '<STR_LIT>'.format(title)<EOL><DEDENT>if is_img:<EOL><INDENT>result = '<STR_LIT>'.format(<EOL>link, content, title)<EOL><DEDENT>else:<EOL><INDENT>result = '<STR_LIT>'.format(link,<EOL>markdown_obj.convert(content).replace('<STR_LIT>', '<STR_LIT>').replace('<STR_LIT>', '<STR_LIT>').strip(),<EOL>title)<EOL><DEDENT>hashed = hash_text(result, '<STR_LIT>')<EOL>hashes[hashed] = result<EOL>return hashed<EOL><DEDENT>return re_reference_link.sub(sub, text)<EOL>
Hashes an <a> link or an <img> link.

    This function only converts reference link styles:

        [text here][ref id]
        ![alt text here][ref id]

    For inline style links, see hash_inline_links.

    Reference ids can be defined anywhere in the Markdown text.
    Reference ids can also be omitted, in which case te text in the
    first box is used as the reference id:

        [ref id][]

    This is known as an "implicit link" reference.