13 lines
319 B
Python
13 lines
319 B
Python
# retoor <retoor@molodetz.nl>
|
|
import re
|
|
|
|
BLANK_LINES = re.compile(r"\n[ \t]*\n(?:[ \t]*\n)+")
|
|
TRAILING = re.compile(r"[ \t]+\n")
|
|
|
|
|
|
def reformat_html(text):
|
|
if "<pre" in text or "<textarea" in text:
|
|
return TRAILING.sub("\n", text)
|
|
text = TRAILING.sub("\n", text)
|
|
return BLANK_LINES.sub("\n\n", text)
|