maj
This commit is contained in:
@@ -73,10 +73,23 @@ def getText():
|
|||||||
txt = request.form["txt"].strip()
|
txt = request.form["txt"].strip()
|
||||||
|
|
||||||
if txt:
|
if txt:
|
||||||
words = txt.split()
|
# Découpe le texte en lignes de 20 caractères max
|
||||||
word_count = len(words)
|
formatted_text = ""
|
||||||
print(txt)
|
current_line = ""
|
||||||
print(word_count)
|
for word in txt.split():
|
||||||
|
if len(current_line) + len(word) + 1 > 20:
|
||||||
|
formatted_text += current_line.strip() + "\n"
|
||||||
|
current_line = word + " "
|
||||||
|
else:
|
||||||
|
current_line += word + " " # Ajoute le mot à la ligne actuelle
|
||||||
|
|
||||||
|
# Ajoute la dernière ligne si elle n'est pas vide
|
||||||
|
if current_line.strip():
|
||||||
|
formatted_text += current_line.strip()
|
||||||
|
|
||||||
|
print("Original text:", txt)
|
||||||
|
print("Formatted text with line breaks:")
|
||||||
|
print(formatted_text)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print('empty text')
|
print('empty text')
|
||||||
|
|||||||
Reference in New Issue
Block a user