diff --git a/files/assets/js/bottom.js b/files/assets/js/bottom.js index 1ad3486d1..b03c8115b 100644 --- a/files/assets/js/bottom.js +++ b/files/assets/js/bottom.js @@ -112,6 +112,12 @@ if (reload_page) { } function register_new_elements(e) { + for (const element of document.getElementsByClassName('showmore')) { + element.onclick = () => { + showmore(element) + }; + } + const onclick = e.querySelectorAll('[data-onclick]'); for (const element of onclick) { element.onclick = ()=>{execute(element, 'onclick')}; diff --git a/files/assets/js/core.js b/files/assets/js/core.js index f8cf9ef6a..ebc45c1c1 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -282,12 +282,6 @@ function showmore(t) { t.innerHTML = 'SHOW LESS' } -for (const element of document.getElementsByClassName('showmore')) { - element.onclick = () => { - showmore(element) - }; -} - function formatDate(d) { let year = d.getFullYear(); let monthAbbr = d.toLocaleDateString('en-us', {month: 'short'}); diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 298008721..da002b784 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -107,7 +107,7 @@ color_regex = re.compile("[a-f0-9]{6}", flags=re.A) # lazy match on the {}?, only match if there is trailing stuff # Specifically match Snappy's way of formatting, this might break some losers' comments. -showmore_regex = re.compile(r"^(.{3000,}?

(?:)?)(\s*

.*)", flags=re.A|re.DOTALL) +showmore_regex = re.compile(r"^((.{3000,}?|(.*?<.*?){10,})?<\/p>(?:<\/li><\/ul>)?)(\s*

.*)", flags=re.A|re.DOTALL) search_token_regex = re.compile('"([^"]*)"|(\S+)', flags=re.A) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 9a63802c6..81586b76a 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -410,8 +410,8 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys if '

' not in sanitized and not sidebar:
 		sanitized = sanitized.replace('\n','')
 
-	if showmore and len(sanitized) > 3500:
-		sanitized = showmore_regex.sub(r'\1

\2', sanitized, count=1) + if showmore and len(sanitized) > 3500 or sanitized.count('<') > 15: + sanitized = showmore_regex.sub(r'\1

\4', sanitized, count=1) return sanitized.strip()