human
Complete the below
def clean_nl(string):

    ''''This will clean up newlines so that nl2br can properly be called on the
    cleaned text.'
    '''

What is a the Python program you requested?
assistant
#Here is the Python program you requested.
    html_blocks = ['{http://www.w3.org/1999/xhtml}blockquote', '{http://www.w3.org/1999/xhtml}ol', '{http://www.w3.org/1999/xhtml}li', '{http://www.w3.org/1999/xhtml}ul']
    if (not string):
        return string
    def parse_html(tree):
        if (tree.tag in html_blocks):
            if tree.text:
                tree.text = tree.text.lstrip('\n')
                if (not len(tree)):
                    tree.text = tree.text.rstrip('\n')
            if (tree.tail and tree.tail.startswith('\n')):
                tree.tail = tree.tail[1:]
        for child in tree:
            if (tree.tag in html_blocks):
                if child.tail:
                    child.tail = child.tail.rstrip('\n')
            parse_html(child)
        return tree
    parse = parse_html(html5lib.parseFragment(string))
    walker = html5lib.treewalkers.getTreeWalker('etree')
    stream = walker(parse)
    serializer = HTMLSerializer(quote_attr_values=True, omit_optional_tags=False)
    return serializer.render(stream)