def strip_html_entities(text): text = text if text else "" text = text.replace("<br>", "\n") text = text.replace("&", "&") text = text.replace(" ", " ") return mark_safe(text)