Js-beautify: Wrap line length, first line not correct

Created on 30 Jan 2017  路  1Comment  路  Source: beautify-web/js-beautify

Description

When you use 4 spaces for indent and have word wrap on 80, the first lines of your paragraphs are not wrapped at the right length.

Input

Same as output, got on issue opend on my Beautify-js addon for Komodo Edit/Ide, a complete test file is also included in the issue.

Expected Output

The code should have looked like this after beautification:

    <section id="intro" class="wrapper style1">
        <div class="container">
            <div class="row">
                <div class="align-center 12u">
                    <header>
                        <h1>
                            You&rsquo;ve come to the right place.
                        </h1>
                        <!--<div class="align-center 8u -2u 12u$(small)">-->
                        <div class="align-center 10u -1u 12u$(small)">
                            <p>
                                Every organization we work with is seeking to
                                communicate a message. We help develop that
                                message and make it come to life! Whether on
                                the web or through print and mail, we partner
                                with our customers to take a simple idea and
                                create a tangible reality.
                            </p>
                            <p> <strong>At Trevett&rsquo;s, we create compelling communication.</strong>
                            </p>
                        </div>
                    </header>
                </div>
            </div>
        </div>
    </section>

Actual Output

    <section id="intro" class="wrapper style1">
        <div class="container">
            <div class="row">
                <div class="align-center 12u">
                    <header>
                        <h1>
                            You&rsquo;ve come to the right place.
                        </h1>
                        <!--<div class="align-center 8u -2u 12u$(small)">-->
                        <div class="align-center 10u -1u 12u$(small)">
                            <p>
                                Every organization we work with is seeking to communicate a message. We help develop
                                that message and make it come to life! Whether on
                                the web or through print and mail, we partner with
                                our customers to take a simple idea and create a
                                tangible reality.
                            </p>
                            <p> <strong>At Trevett&rsquo;s, we create compelling communication.</strong>
                            </p>
                        </div>
                    </header>
                </div>
            </div>
        </div>
    </section>

Environment

OS: Windows 10

Settings

{
    "indent_size": 4,
    "indent_char": " ",
    "indent_level": 0,
    "indent_with_tabs": false,
    "wrap_line_length": 80
}
html bug

Most helpful comment

This is caused formatting of CONTENT during parsing instead of during output production. As a result the initial indent is ignored, resulting in the first line being n+indent_length characters instead of n.

>All comments

This is caused formatting of CONTENT during parsing instead of during output production. As a result the initial indent is ignored, resulting in the first line being n+indent_length characters instead of n.

Was this page helpful?
0 / 5 - 0 ratings