def markdown_to_text ( body ) : # Turn our input into HTML md = markdown . markdown ( body , extensions = [ 'markdown.extensions.extra' ] ) # Safely parse HTML so that we don't have to parse it ourselves soup = BeautifulSoup ( md , 'html.parser' ) # Return just the text of the parsed HTML return soup . get_text ( )
python html markdown to text
Converts markdown to text .
def markdown_to_text(body):
    """Converts markdown to text.

    Args:
        body: markdown (or plaintext, or maybe HTML) input

    Returns:
        Plaintext with all tags and frills removed
    """
    # Turn our input into HTML
    md = markdown.markdown(body, extensions=[
        'markdown.extensions.extra'
    ])

    # Safely parse HTML so that we don't have to parse it ourselves
    soup = BeautifulSoup(md, 'html.parser')

    # Return just the text of the parsed HTML
    return soup.get_text()