forked from rDrama/rDrama
1
0
Fork 0

do the shit I asked @everyone to do

master
Aevann 2023-02-26 12:54:17 +02:00
parent 28ed629647
commit 1beb1bba21
1 changed files with 13 additions and 0 deletions

View File

@ -562,6 +562,19 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys
sanitized = (sanitized[:pos] +
showmore_regex.sub(r'\1<p><button class="showmore">SHOW MORE</button></p><d class="d-none">\2</d>',
sanitized[pos:], count=1))
else:
soup = BeautifulSoup(sanitized, 'lxml')
tags = soup.findChildren(recursive=False)
if len(tags) > 10:
p = soup.new_tag("p")
button = soup.new_tag("button", attrs={"class": "showmore"})
p.append(button)
soup.append(p)
d = soup.new_tag("d", attrs={"class": "d-none"})
soup.append(d)
for tag in tags[10:]:
d.append(tag)
return sanitized.strip()