capybara/virtualenv/lib/python2.7/site-packages/lxml/html/diff.py
def locate_unbalanced_end(unbalanced_end, pre_delete, post_delete):
    """ like locate_unbalanced_start, except handling end tags and
    possibly moving the point earlier in the document.  """
    while 1:
        if not unbalanced_end:
            # Success
            break
        finding = unbalanced_end[-1]
        finding_name = finding.split()[0].strip('<>/')
        if not pre_delete:
            break
        next = pre_delete[-1]
        if next is DEL_END or not next.startswith('</'):
            # A word or a start tag
            break
        name = next.split()[0].strip('<>/')
        if name == 'ins' or name == 'del':
            # Can't move into an insert or delete
            break
        if name == finding_name:
            unbalanced_end.pop()
            post_delete.insert(0, pre_delete.pop())
        else:
            # Found a tag that doesn't match
            break
def locate_unbalanced_end(unbalanced_end, pre_delete, post_delete):
    while 1:
        if not unbalanced_end:
            # Success
            break
        finding = unbalanced_end[-1]
        finding_name = finding.split()[0].strip('<>/')
        if not pre_delete:
            break
        next = pre_delete[-1]
        if next is DEL_END or not next.startswith('</'):
            # A word or a start tag
            break
        name = next.split()[0].strip('<>/')
        if name == 'ins' or name == 'del':
            # Can't move into an insert or delete
            break
        if name == finding_name:
            unbalanced_end.pop()
            post_delete.insert(0, pre_delete.pop())
        else:
            # Found a tag that doesn't match
            break
def locate_unbalanced_end ( unbalanced_end , pre_delete , post_delete ) : while 1 : if not unbalanced_end : # Success break finding = unbalanced_end [ - 1 ] finding_name = finding . split ( ) [ 0 ] . strip ( '<>/' ) if not pre_delete : break next = pre_delete [ - 1 ] if next is DEL_END or not next . startswith ( '</' ) : # A word or a start tag break name = next . split ( ) [ 0 ] . strip ( '<>/' ) if name == 'ins' or name == 'del' : # Can't move into an insert or delete break if name == finding_name : unbalanced_end . pop ( ) post_delete . insert ( 0 , pre_delete . pop ( ) ) else : # Found a tag that doesn't match break
like locate_unbalanced_start, except handling end tags and
    possibly moving the point earlier in the document.
like locate_unbalanced_start except handling end tags and possibly moving the point earlier in the document .