maybe bold for html?
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m55s
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m55s
This commit is contained in:
parent
375a8cc2e6
commit
2be48c7c30
@ -46,10 +46,18 @@ public final class ColorUtils {
|
||||
return STRIP_COLOR_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given input
|
||||
* into HTML.
|
||||
*
|
||||
* @param input the input to convert
|
||||
* @return the HTML converted input
|
||||
*/
|
||||
@NonNull
|
||||
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;
|
||||
@ -74,6 +82,19 @@ public final class ColorUtils {
|
||||
nextIsColor = false;
|
||||
continue;
|
||||
}
|
||||
if (character == 'l') { // Start bold
|
||||
isBold = true;
|
||||
builder.append("<b>");
|
||||
continue;
|
||||
}
|
||||
if (character == 'r') { // Reset formatting
|
||||
if (isBold) {
|
||||
builder.append("</b>");
|
||||
isBold = false;
|
||||
}
|
||||
builder.append("</span>");
|
||||
continue;
|
||||
}
|
||||
if (character == ' ') { // Preserve space character
|
||||
builder.append(" ");
|
||||
} else {
|
||||
@ -86,4 +107,5 @@ public final class ColorUtils {
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user