Re-enable showmore_regex for Snappy (#389)

* Re-enable showmore_regex for Snappy

* showmore a bit more aggressively
remotes/1693176582716663532/tmp_refs/heads/watchparty
official-techsupport 2022-10-06 09:17:28 +03:00 committed by GitHub
parent b2961c1d99
commit 4e23161f11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -95,8 +95,8 @@ reddit_domain_regex = re.compile("(^|\s|\()https?:\/\/(reddit\.com|(?:(?:[A-z]{2
color_regex = re.compile("[a-z0-9]{6}", flags=re.A)
# lazy match on the {}?, only match if there is trailing stuff
# don't match between nested </p></li> etc, this can break but works for Snappy
showmore_regex = re.compile(r"^(.{3000,}?</p>)(\s*<p>.*)", flags=re.A|re.DOTALL)
# Specifically match Snappy's way of formatting, this might break some losers' comments.
showmore_regex = re.compile(r"^(.{3000,}?</p>(?:</li></ul>)?)(\s*<p>.*)", flags=re.A|re.DOTALL)
search_token_regex = re.compile('"([^"]*)"|(\S+)', flags=re.A)

View File

@ -386,7 +386,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys
if '<pre>' not in sanitized:
sanitized = sanitized.replace('\n','')
if showmore and len(sanitized) > 5000:
if showmore and len(sanitized) > 3500:
sanitized = showmore_regex.sub(r'\1<p><button class="showmore" onclick="showmore()">SHOW MORE</button></p><d class="d-none">\2</d>', sanitized, count=1)
return sanitized.strip()