Fix: descriptionHtml2Text function to work if string not starting with "<div>"
This commit is contained in:
parent
b631c100b1
commit
c3b4e8300e
1 changed files with 4 additions and 5 deletions
|
@ -43,14 +43,13 @@ def is_pdf(file_url):
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def descriptionHtml2Text(description):
|
def descriptionHtml2Text(description):
|
||||||
if description.startswith("<div"):
|
if is_html(description):
|
||||||
cleanHtml = nh3.clean(description)
|
cleanHtml = nh3.clean(description)
|
||||||
soup = BeautifulSoup(cleanHtml, "html.parser")
|
soup = BeautifulSoup(cleanHtml, "html.parser")
|
||||||
descriptionText = soup.get_text()
|
text = soup.get_text()
|
||||||
|
return text
|
||||||
else:
|
else:
|
||||||
descriptionText = description
|
return description
|
||||||
|
|
||||||
return descriptionText
|
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
|
|
Loading…
Reference in a new issue