r"""
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         Look &amp; click
    ...         <a href="https://example.com">here</a>
    ...     </body></html>''', preserve_urls=True)
    'Look & click here (https://example.com)'
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         Look &amp; click
    ...         <a href="https://example.com?timestamp=1234">here</a>
    ...     </body></html>''', preserve_urls=True)
    'Look & click here (https://example.com?timestamp=1234)'
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         Look &#38; click here
    ...     </body></html>''', preserve_urls=True)
    'Look & click here'
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         Look &amp; click on
    ...         <a href="https://example.com">https://example.com</a>
    ...     </body></html>''', preserve_urls=True)
    'Look & click on https://example.com'
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         I'm here, <br> click
    ...         <a href="https://example.com">me</a>
    ...     </body></html>''', preserve_urls=True)
    "I'm here,\nclick me (https://example.com)"
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         I'm here, <br/> click
    ...         <a href="https://example.com">me</a>
    ...     </body></html>''', preserve_urls=True)
    "I'm here,\nclick me (https://example.com)"
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         I'm here, <br/> click
    ...         <a href="https://example.com">me</a>
    ...     </body></html>''')
    "I'm here,\nclick me"
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         <p>I'm here!</p>
    ...         <p>Click <a href="https://example.com">me</a></p>
    ...     </body></html>''', preserve_urls=True)
    "I'm here!\nClick me (https://example.com)\n"
    >>> convert_html_to_text(
    ...     '''
    ...     <html>
    ...         <head>
    ...             <title>I'm here</title>
    ...         </head>
    ...         <body>
    ...             <p>I'm here!</p>
    ...             <p>Click <a href="https://example.com">me</a></p>
    ...         </body>
    ...     </html>''', preserve_urls=True)
    "I'm here!\nClick me (https://example.com)\n"

def convert_html_to_text(value, preserve_urls=False):
    r"""
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         Look &amp; click
    ...         <a href="https://example.com">here</a>
    ...     </body></html>''', preserve_urls=True)
    'Look & click here (https://example.com)'
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         Look &amp; click
    ...         <a href="https://example.com?timestamp=1234">here</a>
    ...     </body></html>''', preserve_urls=True)
    'Look & click here (https://example.com?timestamp=1234)'
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         Look &#38; click here
    ...     </body></html>''', preserve_urls=True)
    'Look & click here'
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         Look &amp; click on
    ...         <a href="https://example.com">https://example.com</a>
    ...     </body></html>''', preserve_urls=True)
    'Look & click on https://example.com'
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         I'm here, <br> click
    ...         <a href="https://example.com">me</a>
    ...     </body></html>''', preserve_urls=True)
    "I'm here,\nclick me (https://example.com)"
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         I'm here, <br/> click
    ...         <a href="https://example.com">me</a>
    ...     </body></html>''', preserve_urls=True)
    "I'm here,\nclick me (https://example.com)"
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         I'm here, <br/> click
    ...         <a href="https://example.com">me</a>
    ...     </body></html>''')
    "I'm here,\nclick me"
    >>> convert_html_to_text(
    ...     '''
    ...     <html><body>
    ...         <p>I'm here!</p>
    ...         <p>Click <a href="https://example.com">me</a></p>
    ...     </body></html>''', preserve_urls=True)
    "I'm here!\nClick me (https://example.com)\n"
    >>> convert_html_to_text(
    ...     '''
    ...     <html>
    ...         <head>
    ...             <title>I'm here</title>
    ...         </head>
    ...         <body>
    ...             <p>I'm here!</p>
    ...             <p>Click <a href="https://example.com">me</a></p>
    ...         </body>
    ...     </html>''', preserve_urls=True)
    "I'm here!\nClick me (https://example.com)\n"
    """
    s = MLStripper(preserve_urls=preserve_urls)
    s.feed(value)
    s.close()
    return s.get_data()