1 package eu.svjatoslav.sixth.core.document;
3 import eu.svjatoslav.commons.string.String2;
7 public static final char[] whitespace = new char[]{'\n', '\r', ' ', '\t'};
9 public static String addIndentExceptFirstLine(String input, int indent) {
10 String[] lines = input.split("\\r?\\n");
12 StringBuilder sb = new StringBuilder();
14 if (lines.length >0 ) sb.append(lines[0]);
16 for (int i = 1; i< lines.length; i++) {
18 sb.append(new String2(" ").repeat(indent).toString());
25 public static boolean isBlank(String s){
26 for (char c : s.toCharArray())
27 if (!isWhitespaceChar(c)) return false;
33 * @return line indent in characters or -1 if line is blank or empty
35 public static int getLineIndent(String line){
36 for (int i = 0; i < line.length(); i++) {
37 if (!isWhitespaceChar(line.charAt(i)))
43 public static boolean isWhitespaceChar(char c){
44 for (char whitespaceChar : whitespace)
45 if (whitespaceChar == c) return true;
50 public static String removePrefix(String string, int charsToRemove){
51 String2 s = new String2(string);
52 s.trimPrefix(charsToRemove);