From b8372aa02e5b4048585f09b2f85b91d9538e3162 Mon Sep 17 00:00:00 2001
From: Bob Mottram
' not in content: # handle a single very long string with no spaces content_str = content.replace('
', '').replace(r'<\p>', '') if '://' not in content_str: @@ -1068,6 +1068,7 @@ def remove_long_words(content: str, max_word_length: int, if word_str not in long_words_list: long_words_list.append(word_str) for word_str in long_words_list: + original_word_str = word_str if word_str.startswith('
'): word_str = word_str.replace('
', '')
if word_str.startswith('<'):
@@ -1112,8 +1113,12 @@ def remove_long_words(content: str, max_word_length: int,
if '/' in word_str:
continue
if len(word_str[max_word_length:]) < max_word_length:
+ end_of_line_char = '\n'
+ if '
' in original_word_str:
+ end_of_line_char = ''
content = content.replace(word_str,
- word_str[:max_word_length] + '\n' +
+ word_str[:max_word_length] +
+ end_of_line_char +
word_str[max_word_length:])
else:
content = content.replace(word_str,
diff --git a/tests.py b/tests.py
index ac71ea35c..3db486be6 100644
--- a/tests.py
+++ b/tests.py
@@ -8644,6 +8644,32 @@ def _test_check_individual_post_content():
print(content5)
assert content5 == content
+ content = "
D-A-N-G-E-R-O-U-S
A-N-I-M-A-L
D-A-N-G-E-R-O-U-S
A-N-I-M-A-L