def _strip_tags(text: str) -> str:
    """Strip HTML tags and return plain text. Note: HTML entities are unaffected."""
    # A comment could contain a tag, so strip comments first
    while (start := text.find('<!--')) != -1 and (end := text.find('-->', start)) != -1:
        text = text[:start] + text[end + 3 :]

    while (start := text.find('<')) != -1 and (end := text.find('>', start)) != -1:
        text = text[:start] + text[end + 1 :]

    # Collapse whitespace
    text = ' '.join(text.split())
    return text
Strip HTML tags and return plain text. Note: HTML entities are unaffected.
mkdocs/utils/rendering.py