Fix: descriptionHtml2Text function to work if string not starting with "<div>"

This commit is contained in:
Aroy-Art 2023-09-27 19:10:14 +02:00
parent b631c100b1
commit c3b4e8300e
Signed by: Aroy
GPG key ID: 583642324A1D2070

View file

@ -43,14 +43,13 @@ def is_pdf(file_url):
@register.filter
def descriptionHtml2Text(description):
if description.startswith("<div"):
if is_html(description):
cleanHtml = nh3.clean(description)
soup = BeautifulSoup(cleanHtml, "html.parser")
descriptionText = soup.get_text()
text = soup.get_text()
return text
else:
descriptionText = description
return descriptionText
return description
@register.filter