test/html-formatter.js
/**
     * Inserted on one indented line if shorter than the character limit.
     * Otherwise, insert paragraphs (delimited by empty new lines) which wrap at the character limit.
     */
Inserted on one indented line if shorter than the character limit.
Otherwise, insert paragraphs (delimited by empty new lines) which wrap at the character limit.
Inserted on one indented line if shorter than the character limit . Otherwise insert paragraphs ( delimited by empty new lines ) which wrap at the character limit .
insertTextNode(content, html, indentLevel) {
        const oneLineText = HtmlFormatter.normalizeWhitespace(content);
        if (this.shorterThanCharacterLimit(oneLineText, indentLevel)) {
            return this.insertIndentedLine(oneLineText, html, indentLevel);
        }
        const formattedContent = content
            .split(HTML_REG_EXP.PARAGRAPH_DELIMITER)
            .map(paragraph => {
            return paragraph
                .split(HTML_REG_EXP.WHITESPACE)
                .reduce((indentedParagraph, word) => {
                const lastLineTrimmed = HtmlFormatter.getLastLineTrimmed(indentedParagraph);
                const indentedWord = (lastLineTrimmed === "" ? "" : " ") + word;
                if (this.shorterThanCharacterLimit(lastLineTrimmed + indentedWord, indentLevel)) {
                    return indentedParagraph + indentedWord;
                }
                return this.insertIndentedLine(word, indentedParagraph, indentLevel);
            }, this.insertIndentedLine("", "", indentLevel));
        })
            .join("\n")
            .trim();
        return this.insertIndentedLine(formattedContent, html, indentLevel);
    }
insertTextNode ( content , html , indentLevel ) { const oneLineText = HtmlFormatter . normalizeWhitespace ( content ) ; if ( this . shorterThanCharacterLimit ( oneLineText , indentLevel ) ) { return this . insertIndentedLine ( oneLineText , html , indentLevel ) ; } const formattedContent = content . split ( HTML_REG_EXP . PARAGRAPH_DELIMITER ) . map ( paragraph => { return paragraph . split ( HTML_REG_EXP . WHITESPACE ) . reduce ( ( indentedParagraph , word ) => { const lastLineTrimmed = HtmlFormatter . getLastLineTrimmed ( indentedParagraph ) ; const indentedWord = ( lastLineTrimmed === "" ? "" : " " ) + word ; if ( this . shorterThanCharacterLimit ( lastLineTrimmed + indentedWord , indentLevel ) ) { return indentedParagraph + indentedWord ; } return this . insertIndentedLine ( word , indentedParagraph , indentLevel ) ; } , this . insertIndentedLine ( "" , "" , indentLevel ) ) ; } ) . join ( "\n" ) . trim ( ) ; return this . insertIndentedLine ( formattedContent , html , indentLevel ) ; }
Inserted on one indented line if shorter than the character limit.
Inserted on one indented line if shorter than the character limit .