private String replaceNewLines(String inputString) {
        StringBuilder stringBuilder = new StringBuilder(inputString);
        int i = 0;
        boolean isInsideCode = false;
        while (i < stringBuilder.length()) {
            if (i + 3 < stringBuilder.length() &&
                    Objects.equals(stringBuilder.substring(i, i + 3), "```")) {
                isInsideCode = !isInsideCode;   // Is inside a <pre> code section
                i += 3;
            } else if (stringBuilder.charAt(i) == '`') {
                isInsideCode = !isInsideCode;   // Is inside a <code> code section
                i++;
            } else if (!isInsideCode && stringBuilder.charAt(i) == '\n') {
                // Replacing new lines
                stringBuilder.replace(i, i + 1, "<br>");
                i += 4;
            } else {
                i++;
            }
        }
        return stringBuilder.toString();
    }
Replaces new line characters outside code segments with "<br>" tags

@param inputString The string which needs to changed
@return The string with the new lines replaced
modules/siddhi-doc-gen/src/main/java/io/siddhi/doc/gen/core/freemarker/FormatDescriptionMethod.java