test/html-formatter.spec.js
/**
     * Inserted on one indented line if shorter than the character limit.
     * Otherwise, each attribute is inserted on a new line further indented 2 levels.
     */
Inserted on one indented line if shorter than the character limit.
Otherwise, each attribute is inserted on a new line further indented 2 levels.
Inserted on one indented line if shorter than the character limit . Otherwise each attribute is inserted on a new line further indented 2 levels .
insertOpeningTag(openingTag, html, indentLevel) {
        const tagName = HtmlFormatter.getTagName(openingTag);
        const attributes = openingTag
            .slice(openingTag.indexOf(tagName) + tagName.length, openingTag.lastIndexOf(">"))
            .match(HTML_REG_EXP.ATTRIBUTE);
        const oneLineOpeningTag = attributes ? `<${tagName} ${attributes.join(" ")}>` : `<${tagName}>`;
        if (this.shorterThanCharacterLimit(oneLineOpeningTag, indentLevel)) {
            return this.insertIndentedLine(oneLineOpeningTag, html, indentLevel);
        }
        const htmlWithTagName = this.insertIndentedLine(`<${tagName}`, html, indentLevel);
        const htmlWithAttributes = attributes.reduce((html, attribute) => this.insertIndentedLine(attribute, html, indentLevel + 2), htmlWithTagName);
        return this.insertIndentedLine(">", htmlWithAttributes, indentLevel);
    }
insertOpeningTag ( openingTag , html , indentLevel ) { const tagName = HtmlFormatter . getTagName ( openingTag ) ; const attributes = openingTag . slice ( openingTag . indexOf ( tagName ) + tagName . length , openingTag . lastIndexOf ( ">" ) ) . match ( HTML_REG_EXP . ATTRIBUTE ) ; const oneLineOpeningTag = attributes ? ` ${ tagName } ${ attributes . join ( " " ) } ` : ` ${ tagName } ` ; if ( this . shorterThanCharacterLimit ( oneLineOpeningTag , indentLevel ) ) { return this . insertIndentedLine ( oneLineOpeningTag , html , indentLevel ) ; } const htmlWithTagName = this . insertIndentedLine ( ` ${ tagName } ` , html , indentLevel ) ; const htmlWithAttributes = attributes . reduce ( ( html , attribute ) => this . insertIndentedLine ( attribute , html , indentLevel + 2 ) , htmlWithTagName ) ; return this . insertIndentedLine ( ">" , htmlWithAttributes , indentLevel ) ; }
Inserted on one indented line if shorter than the character limit.
Inserted on one indented line if shorter than the character limit .