From 123cee6372de7943c44b299dec1cf28a4282be2d Mon Sep 17 00:00:00 2001 From: official-techsupport Date: Tue, 24 Jan 2023 03:56:14 +0000 Subject: [PATCH] fix an edge case in showmore (when many long paragraphs) (#93) $subj Co-authored-by: official-techsupport Reviewed-on: https://fsdfsd.net/rDrama/rDrama/pulls/93 Co-authored-by: official-techsupport Co-committed-by: official-techsupport --- files/helpers/sanitize.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index ef95632a0..e59314ef5 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -428,13 +428,14 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys if showmore: # Insert a show more button if the text is too long or has too many paragraphs + CHARLIMIT = 3000 pos = 0 for _ in range(20): pos = sanitized.find('

', pos + 4) if pos < 0: break - if pos < 0 and len(sanitized) > 3000: - pos = 2500 + if (pos < 0 and len(sanitized) > CHARLIMIT) or pos > CHARLIMIT: + pos = CHARLIMIT - 500 if pos >= 0: sanitized = (sanitized[:pos] + showmore_regex.sub(r'\1

\2',