add 'repl' and 'sep' arguments to text.replace_html()

pull/359/head
Mike Fährmann 5 years ago
parent 8d1ae9b715
commit 1740086d8a
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -36,12 +36,15 @@ def clean_xml(xmldata, repl=""):
return xmldata
def remove_html(txt):
def remove_html(txt, repl=" ", sep=" "):
"""Remove html-tags from a string"""
try:
return " ".join(re.sub("<[^>]+>", " ", txt).split())
txt = re.sub("<[^>]+>", repl, txt)
except TypeError:
return ""
if sep:
return sep.join(txt.split())
return txt.strip()
def split_html(txt, sep=None):

Loading…
Cancel
Save