def br2_br1(content): content = re.sub('<br>(\s+)<br>', '', content) content = re.sub(r"(<br>)\1+", r"\1", content) content = re.sub("<br>", '<br><br>', content) return content