(raw_message: str)
return new_message
1. parse string into a markdown AST
    2. find the HTML nodes
    3. parse HTML nodes into HTML
    4. find comments in HTML
    5. slice out comments from original message
1. parse string into a markdown AST
    2. find the HTML nodes
    3. parse HTML nodes into HTML
    4. find comments in HTML
    5. slice out comments from original message
1 . parse string into a markdown AST 2 . find the HTML nodes 3 . parse HTML nodes into HTML 4 . find comments in HTML 5 . slice out comments from original message
def strip_html_comments_from_markdown(raw_message: str) -> str:
    """
    1. parse string into a markdown AST
    2. find the HTML nodes
    3. parse HTML nodes into HTML
    4. find comments in HTML
    5. slice out comments from original message
    """
    # NOTE(chdsbd): Remove carriage returns so find_html_positions can process
    # html correctly. pulldown-cmark doesn't handle carriage returns well.
    # remark-parse also doesn't handle carriage returns:
    # https://github.com/remarkjs/remark/issues/195#issuecomment-230760892
    message = raw_message.replace("\r", "")
    html_node_positions = find_html_positions(message)
    comment_locations = []
    for html_start, html_end in html_node_positions:
        html_text = message[html_start:html_end]
        html_parser.feed(html_text)
        for comment_start, comment_end in html_parser.comments:
            comment_locations.append(
                (html_start + comment_start, html_start + comment_end)
            )
        html_parser.reset()

    new_message = message
    for comment_start, comment_end in reversed(comment_locations):
        new_message = new_message[:comment_start] + new_message[comment_end:]
    return new_message
def strip_html_comments_from_markdown ( raw_message : str ) -> str : # NOTE(chdsbd): Remove carriage returns so find_html_positions can process # html correctly. pulldown-cmark doesn't handle carriage returns well. # remark-parse also doesn't handle carriage returns: # https://github.com/remarkjs/remark/issues/195#issuecomment-230760892 message = raw_message . replace ( "\r" , "" ) html_node_positions = find_html_positions ( message ) comment_locations = [ ] for html_start , html_end in html_node_positions : html_text = message [ html_start : html_end ] html_parser . feed ( html_text ) for comment_start , comment_end in html_parser . comments : comment_locations . append ( ( html_start + comment_start , html_start + comment_end ) ) html_parser . reset ( ) new_message = message for comment_start , comment_end in reversed ( comment_locations ) : new_message = new_message [ : comment_start ] + new_message [ comment_end : ] return new_message