maybe bold for html?
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m39s
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m39s
This commit is contained in:
parent
5c77b59b90
commit
45fb517385
@ -57,7 +57,6 @@ public final class ColorUtils {
|
||||
public static String toHTML(@NonNull String input) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
boolean nextIsColor = false; // Is the next char a color code?
|
||||
boolean isBold = false; // Is the text currently bold?
|
||||
|
||||
// Get the leading spaces from the first line
|
||||
int leadingSpaces = 0;
|
||||
@ -71,32 +70,23 @@ public final class ColorUtils {
|
||||
}
|
||||
|
||||
for (char character : input.toCharArray()) {
|
||||
// Found color symbol, next character is the color
|
||||
// Found color symbol, next color is the color
|
||||
if (character == '§') {
|
||||
nextIsColor = true;
|
||||
continue;
|
||||
}
|
||||
if (nextIsColor) { // Map the current color to its hex code
|
||||
String color = COLOR_MAP.getOrDefault(Character.toLowerCase(character), "");
|
||||
builder.append("<span style=\"color:").append(color).append("\">");
|
||||
builder.append("<span style=\"color:").append(color);
|
||||
if (character == 'l') { // Bold
|
||||
builder.append(";font-weight:bold");
|
||||
}
|
||||
builder.append("\">");
|
||||
nextIsColor = false;
|
||||
|
||||
if (character == 'l') { // Start bold
|
||||
builder.append("<span style=\"font-weight: bold;\">");
|
||||
continue;
|
||||
}
|
||||
if (character == 'r') { // Reset formatting
|
||||
builder.append("</span>");
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (character == ' ') { // Preserve space character
|
||||
builder.append(" ");
|
||||
} else {
|
||||
builder.append(character); // Append the char...
|
||||
}
|
||||
}
|
||||
|
||||
// Add leading spaces to the end of the HTML string
|
||||
builder.append(" ".repeat(Math.max(0, leadingSpaces)));
|
||||
|
Loading…
Reference in New Issue
Block a user