private static StringBuilder trim(final StringBuilder input) {
        int length = input.length();
        int breakLength = BREAK.length();

        while (length > 0) {
            if (input.indexOf(BREAK) == 0) {
                input.delete(0, breakLength);
            } else if (length >= breakLength
                    && input.lastIndexOf(BREAK) == length - breakLength) {
                input.delete(length - breakLength, length);
            } else if (Character.isWhitespace(input.charAt(0))) {
                input.deleteCharAt(0);
            } else if (Character.isWhitespace(input.charAt(length - 1))) {
                input.deleteCharAt(length - 1);
            } else {
                break;
            }
            length = input.length();
        }
        return input;
    }
Remove leading and trailing whitespace

@param input
app/src/main/java/com/github/pockethub/android/util/HtmlUtils.java