private static StringBuilder replace(final StringBuilder input,
                                         final String fromStart, final String fromEnd, final String toStart,
                                         final String toEnd) {
        int start = input.indexOf(fromStart);
        if (start == -1) {
            return input;
        }

        final int fromStartLength = fromStart.length();
        final int fromEndLength = fromEnd.length();
        final int toStartLength = toStart.length();
        while (start != -1) {
            input.replace(start, start + fromStartLength, toStart);
            int end = input.indexOf(fromEnd, start + toStartLength);
            if (end != -1) {
                input.replace(end, end + fromEndLength, toEnd);
            }

            start = input.indexOf(fromStart);
        }
        return input;
    }
Format given HTML string so it is ready to be presented in a text view

@param html
@return formatted HTML
app/src/main/java/com/github/pockethub/android/util/HtmlUtils.java