Implemented text-transform=capitalize

This commit is contained in:
M66B 2024-02-07 08:03:22 +01:00
parent 0853694aa2
commit 3a2130dc3c
1 changed files with 12 additions and 1 deletions

View File

@ -924,7 +924,18 @@ public class HtmlHelper {
String text = tnode.getWholeText(); String text = tnode.getWholeText();
switch (value) { switch (value) {
case "capitalize": case "capitalize":
// TODO: capitalize for (int i = 0; i < text.length(); ) {
int codepoint = text.codePointAt(i);
if (Character.isLetter(codepoint)) {
tnode.text(text.substring(0, i) +
text.substring(i, i + 1).toUpperCase(Locale.ROOT) +
text.substring(i + 1));
break;
} else if (!Character.isWhitespace(codepoint))
break;
else
i += Character.charCount(codepoint);
}
break; break;
case "uppercase": case "uppercase":
tnode.text(text.toUpperCase(Locale.ROOT)); tnode.text(text.toUpperCase(Locale.ROOT));