INNER CODE UNIT · Python
clean_release_notes
sameerasw/essentials · .github/scripts/clean_release_notes.py:14
def clean_release_notes(raw: str) -> str:
text = re.sub(r"<img\b[^>]*\/?>", "", raw, flags=re.IGNORECASE)
text = re.sub(r"<a\b[^>]*>\s*</a>", "", text, flags=re.IGNORECASE)
text = re.sub(r"^[-\*_]{3,}\s*$", "", text, flags=re.MULTILINE)
text = re.sub(r"</?(?:details|summary|h[1-6]|p|div|span|align)\b[^>]*>", "", text, flags=re.IGNORECASE)
text = re.sub(r"!\[.*?\]\(.*?\)", "", text)
def convert_md_link(match):
return f'<a href="{match.group(2)}">{match.group(1)}</a>'
text = re.sub(r"\[(.*?)\]\((.*?)\)", convert_md_link, text)
text = re.sub(r"\*\*(.*?)\*\*", r"<b>\1</b>", text)
cleaned_lines = []
in_quote = False
quote_buf = []
for line in text.splitlines():