human
Complete this python program:
def linkify(text, callbacks=DEFAULT_CALLBACKS, skip_pre=False, parse_email=False, tokenizer=HTMLSanitizer):
assistant
#Here is the Python program you requested.

    """Convert URL-like strings in an HTML fragment to links.
    linkify() converts strings that look like URLs or domain names in a
    blob of text that may be an HTML fragment to links, while preserving
    (a) links already in the string, (b) urls found in attributes, and
    (c) email addresses.
    """
    text = force_unicode(text)
    if (not text):
        return u''
    parser = html5lib.HTMLParser(tokenizer=tokenizer)
    forest = parser.parseFragment(text)
    _seen = set([])
    def replace_nodes(tree, new_frag, node, index=0):
        u"\n                                Doesn't    really    replace    nodes,    but    inserts    the    nodes    contained    in\n                                new_frag    into    the    treee    at    position    index    and    returns    the    number\n                                of    nodes    inserted.\n                                If    node    is    passed    in,    it    is    removed    from    the    tree\n                                "
        count = 0
        new_tree = parser.parseFragment(new_frag)
        if new_tree.text:
            if (index == 0):
                tree.text = (tree.text or u'')
                tree.text += new_tree.text
            else:
                tree[(index - 1)].tail = (tree[(index - 1)].tail or u'')
                tree[(index - 1)].tail += new_tree.text
        for n in new_tree:
            if (n.tag == ETREE_TAG(u'a')):
                _seen.add(n)
            tree.insert((index + count), n)
            count += 1
        if (node is not None):
            tree.remove(node)
        return count
    def strip_wrapping_parentheses(fragment):
        u'Strips    wrapping    parentheses.\n\n                                Returns    a    tuple    of    the    following    format::\n\n                                                (string    stripped    from    wrapping    parentheses,\n                                                    count    of    stripped    opening    parentheses,\n                                                    count    of    stripped    closing    parentheses)\n                                '
        opening_parentheses = closing_parentheses = 0
        for char in fragment:
            if (char == u'('):
                opening_parentheses += 1
            else:
               ...