def _do_link_patterns(self, text):
        link_from_hash = {}
        for regex, href in self.link_patterns:
            replacements = []
            for match in regex.finditer(text):
                replacements.append((match.span(), match.expand(href)))
            for (start, end), href in reversed(replacements):
                escaped_href = (
                    href.replace('"', '&quot;')  # b/c of attr quote
                        # To avoid markdown <em> and <strong>:
                        .replace('*', g_escape_table['*'])
                        .replace('_', g_escape_table['_']))
                link = '<a href="%s">%s</a>' % (escaped_href, text[start:end])
                hash = md5(link).hexdigest()
                link_from_hash[hash] = link
                text = text[:start] + hash + text[end:]
        for hash, link in link_from_hash.items():
            text = text.replace(hash, link)
        return text
Caveat emptor: there isn't much guarding against link
dataset/ETHPy150Open CollabQ/CollabQ/vendor/markdown/markdown2.py/Markdown._do_link_patterns