From bc96356df4bb5a18c81bc09e7345092a875acce1 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 1 Oct 2024 22:12:43 -0500 Subject: [PATCH] Enhance wordWrap with HTML tags for line breaks Added HTML tags to the `wordWrap` method to ensure proper line breaks using `
` instead of newline characters. This change improves the rendering of wrapped text in HTML contexts by enclosing the output in `` tags. --- megamek/src/megamek/client/ui/WrapLayout.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/WrapLayout.java b/megamek/src/megamek/client/ui/WrapLayout.java index a1f6507aa7d..10515ff2dbd 100644 --- a/megamek/src/megamek/client/ui/WrapLayout.java +++ b/megamek/src/megamek/client/ui/WrapLayout.java @@ -211,6 +211,7 @@ public static String wordWrap(String input) { public static String wordWrap(String input, int maximumCharacters) { StringTokenizer token = new StringTokenizer(input, " "); StringBuilder output = new StringBuilder(input.length()); + output.append(""); int lineLen = 0; @@ -218,13 +219,14 @@ public static String wordWrap(String input, int maximumCharacters) { String word = token.nextToken(); if (lineLen + word.length() > maximumCharacters) { - output.append('\n'); + output.append("
"); lineLen = 0; } output.append(word).append(' '); lineLen += word.length(); } + output.append(""); return output.toString(); } }