Fix random frontend (problem info, lazy load img, comment pagedown)

This commit is contained in:
cuom1999 2024-02-26 14:31:33 -06:00
parent 7bba448ef5
commit 3f53c62d4d
11 changed files with 131 additions and 96 deletions

View file

@ -88,6 +88,7 @@ ALLOWED_ATTRS = [
"frameborder",
"allow",
"allowfullscreen",
"loading",
]
@ -105,11 +106,9 @@ def markdown(value, lazy_load=False):
soup = BeautifulSoup(html, features="html.parser")
for img in soup.findAll("img"):
if img.get("src"):
img["data-src"] = img["src"]
img["src"] = ""
img["loading"] = "lazy"
for img in soup.findAll("iframe"):
if img.get("src"):
img["data-src"] = img["src"]
img["src"] = ""
img["loading"] = "lazy"
html = str(soup)
return '<div class="md-typeset content-description">%s</div>' % html