mirror of https://gitlab.com/bashrc2/epicyon
				
				
				
			Fix another case where long words were getting through and trashing the UX
							parent
							
								
									8931da1a1f
								
							
						
					
					
						commit
						313a211dde
					
				|  | @ -1113,6 +1113,7 @@ def remove_long_words(content: str, max_word_length: int, | ||||||
|                     content = content[:max_word_length] |                     content = content[:max_word_length] | ||||||
|                 return content |                 return content | ||||||
|     content = content.replace('<p></p>', '<p> </p>') |     content = content.replace('<p></p>', '<p> </p>') | ||||||
|  |     content = content.replace('<br />', '<br>') | ||||||
|     words = content.split(' ') |     words = content.split(' ') | ||||||
|     if not long_words_list: |     if not long_words_list: | ||||||
|         long_words_list: list[str] = [] |         long_words_list: list[str] = [] | ||||||
|  | @ -1169,10 +1170,10 @@ def remove_long_words(content: str, max_word_length: int, | ||||||
|             end_of_line_char = '\n' |             end_of_line_char = '\n' | ||||||
|             if '<br>' in original_word_str: |             if '<br>' in original_word_str: | ||||||
|                 end_of_line_char = '' |                 end_of_line_char = '' | ||||||
|             content = content.replace(word_str, |             new_word_str = \ | ||||||
|                                       word_str[:max_word_length] + |                 word_str[:max_word_length] + end_of_line_char + \ | ||||||
|                                       end_of_line_char + |                 word_str[max_word_length:] | ||||||
|                                       word_str[max_word_length:]) |             content = content.replace(word_str, new_word_str) | ||||||
|         else: |         else: | ||||||
|             content = content.replace(word_str, |             content = content.replace(word_str, | ||||||
|                                       word_str[:max_word_length]) |                                       word_str[:max_word_length]) | ||||||
|  |  | ||||||
							
								
								
									
										61
									
								
								tests.py
								
								
								
								
							
							
						
						
									
										61
									
								
								tests.py
								
								
								
								
							|  | @ -3990,6 +3990,67 @@ def _test_web_links(): | ||||||
|     result_text = remove_long_words(example_text, 40, []) |     result_text = remove_long_words(example_text, 40, []) | ||||||
|     assert result_text == '<p>1. HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA</p>' |     assert result_text == '<p>1. HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA</p>' | ||||||
| 
 | 
 | ||||||
|  |     example_text = \ | ||||||
|  |         '<p>printing it as</p><p>2037140369160192492322925579391203607' + \ | ||||||
|  |         '9180457601678813485162666958812204044214622117979705473511687' + \ | ||||||
|  |         '4592660294244917367332676764786341343508013819160968359130462' + \ | ||||||
|  |         '2042992012189361768911860908296446835744287698513143677144449' + \ | ||||||
|  |         '7938552838757164161177222742794307083740349375668764576182918' + \ | ||||||
|  |         '1191081223077464252347315511376155447223453567674374804815128' + \ | ||||||
|  |         '6735404590608216087337598386531730585596091790505424832645417' + \ | ||||||
|  |         '4535501077237920206100984089409165176752643554839846882599844' + \ | ||||||
|  |         '5923991409873771880931926782681047189948065387778396896132986' + \ | ||||||
|  |         '1506909307742354583410543953848817545579436209308661274911375' + \ | ||||||
|  |         '0279438885690899872309557867300649792692083221832567745997106' + \ | ||||||
|  |         '4361272558974579895067960526717371469973690968110845204652565' + \ | ||||||
|  |         '7587689165458042953094138457672314834155438608636666321168512' + \ | ||||||
|  |         '4252782578218268564249508506018479212668540667664012944414293' + \ | ||||||
|  |         '2330851074677344997595343747355492702171737174875079240941536' + \ | ||||||
|  |         '5577708112608640981357760962144998520758441440673068086203309' + \ | ||||||
|  |         '6319770638261320199660717718939289964587472883312324782316607' + \ | ||||||
|  |         '1967237252667926931453847363561981705896614769576786119378801' + \ | ||||||
|  |         '2882830466910136185864274111171019637988349519287519085606121' + \ | ||||||
|  |         '2522339449147264219612788230902092720858942438882884398008862' + \ | ||||||
|  |         '3971347873853102233621429454276071388173023720330558429380460' + \ | ||||||
|  |         '24463<br />-----<br />135631432782117671533556239831160434454' + \ | ||||||
|  |         '7335460488150228839142323597554809416586757525360501260323585' + \ | ||||||
|  |         '5427725242735144512118460721691926719820293873391318272145617' + \ | ||||||
|  |         '2554791642059210748685514914488339456875132466046368022599988' + \ | ||||||
|  |         '5273244295738339238990530543987019381897315877208424689309203' + \ | ||||||
|  |         '4437647713420965928758468739219412456408063053612145484613397' + \ | ||||||
|  |         '7772016123436107774252651067596615212806590262272555509568180' + \ | ||||||
|  |         '4017509174747230962281596577708797815066474134136273694278897' + \ | ||||||
|  |         '3360027388222852071012491607526037246576762645075722993280572' + \ | ||||||
|  |         '0175203303419048479968580491030484921302651482301409754854835' + \ | ||||||
|  |         '8571983490854257241872545704643626052023136119167363679870698' + \ | ||||||
|  |         '6658596724473374548909147593122088363315605434015319945902182' + \ | ||||||
|  |         '4528805007798699801368901189663857156868661234311411008127692' + \ | ||||||
|  |         '0776737318215252920723091949275668214683758105365336904270751' + \ | ||||||
|  |         '4269780883475016823742824846496720523040081390146960035213499' + \ | ||||||
|  |         '4242397562282441575512596963230050874858503383101416745601160' + \ | ||||||
|  |         '7883569793778503255464751436889383035257241831991489377524576' + \ | ||||||
|  |         '6486902236709319426301135526407141692658938140338022458562435' + \ | ||||||
|  |         '2058492483177210403138206901075955949723649750887887380112918' + \ | ||||||
|  |         '6077468349611419064296645075152353982955366217878670283274959' + \ | ||||||
|  |         '6553942067490556190686268506650055832177364114438608728336525' + \ | ||||||
|  |         '0621382626679227962349526822499666150757963545641335569627420' + \ | ||||||
|  |         '8921258670239960403498282550000556886617270910694586165105339' + \ | ||||||
|  |         '7011099950229146620093059412209127775142890468769710327385614' + \ | ||||||
|  |         '0122556856706927520947510344871870199933577438968706707773791' + \ | ||||||
|  |         '5845161008648178701657616293931863560534070691425550081565559' + \ | ||||||
|  |         '3409676811957993996940903554947847842104284053634021057864830' + \ | ||||||
|  |         '6688290446849712231828336090313297361727030502882056705996134' + \ | ||||||
|  |         '4733039520306167881855566393478866394412600612994195061492943' + \ | ||||||
|  |         '1274728867456552977222295601679486173993905936303907550874137' + \ | ||||||
|  |         '0019675194211557555048425375304</p><p>would have been way more' + \ | ||||||
|  |         ' useful. at least the line count would give a clue about ' + \ | ||||||
|  |         'magnitudes</p>"' | ||||||
|  |     result_text = remove_long_words(example_text, 40, []) | ||||||
|  |     assert len(result_text) < len(example_text) | ||||||
|  |     assert result_text == \ | ||||||
|  |         '<p>printing it as have been way more useful. at least the ' + \ | ||||||
|  |         'line count would give a clue about magnitudes</p>"</p>' | ||||||
|  | 
 | ||||||
|     example_text = \ |     example_text = \ | ||||||
|         '<p>Tox address is 88AB9DED6F9FBEF43E105FB72060A2D89F9B93C74' + \ |         '<p>Tox address is 88AB9DED6F9FBEF43E105FB72060A2D89F9B93C74' + \ | ||||||
|         '4E8C45AB3C5E42C361C837155AFCFD9D448 </p>' |         '4E8C45AB3C5E42C361C837155AFCFD9D448 </p>' | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue