public AsciiDocData appendAdjustingSpace()

in log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/processor/AsciiDocData.java [80:98]


    public AsciiDocData appendAdjustingSpace(final CharSequence text) {
        final String normalized = WHITESPACE_SEQUENCE.matcher(text).replaceAll(SPACE);
        if (!normalized.isEmpty()) {
            final StringBuilder currentLine = getCurrentLine();
            // Last char of current line or space
            final char lineLastChar = isEmpty(currentLine) ? SPACE_CHAR : currentLine.charAt(currentLine.length() - 1);
            // First char of test
            final char textFirstChar = normalized.charAt(0);
            if (lineLastChar == SPACE_CHAR && textFirstChar == SPACE_CHAR) {
                // Merge spaces
                currentLine.append(normalized, 1, normalized.length());
            } else if (lineLastChar == CODE_CHAR && Character.isAlphabetic(textFirstChar)) {
                currentLine.append(SPACE_CHAR).append(normalized);
            } else {
                currentLine.append(normalized);
            }
        }
        return this;
    }