diff --git a/plotter-app/app.py b/plotter-app/app.py index cc70b0a..ce14f47 100644 --- a/plotter-app/app.py +++ b/plotter-app/app.py @@ -73,10 +73,23 @@ def getText(): txt = request.form["txt"].strip() if txt: - words = txt.split() - word_count = len(words) - print(txt) - print(word_count) + # Découpe le texte en lignes de 20 caractères max + formatted_text = "" + current_line = "" + 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: print('empty text')