question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lines are not un-indented correctly when attributes are wrapped

See original GitHub issue

Description

Indenting is broken whenever attribute wrapping happens.

Using js-beautify v1.6.8.

Input

The code looked like this before beautification:

<div first second>content</div>
<div>content</div>

Expected Output

The code should have looked like this after beautification:

<div first 
     second>content</div>
<div>content</div>

Actual Output

The code actually looked like this after beautification:

<div first
     second>content</div>
    <div>content</div>

Steps to Reproduce

Beautify the code

Environment

OS: MacOS

Settings

Example:

{
    "wrap_attributes": "force-aligned"
}

Note: wrap_attributes doesn’t have to be set to force-aligned. Any wrapping (excluding “force-expand-multiline”) introduces, including if “auto” caused the wrapping will demonstrate this issue.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:9
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
HookyQRcommented, Feb 10, 2017

Found the problem. Fixing now.

2reactions
chenasrafcommented, Jan 10, 2017

Same here, the code just keeps getting more and more indented up until the last moment. It’s impossible to use this beautifier anymore like this, I have to manually format the code 😕

<nav id="header"
  class="navbar navbar-default">
  <div class="header-container container-fluid">
    <div class="logo-container navbar-header">
      <a ui-sref="stats"
        class="navbar-brand pws-icon pws-pws"></a>
    </div>
    <div class="header-contents collapse navbar-collapse">
      <ul class="tab-list nav navbar-nav">
        <li class="tab tab-prospects"
          ui-sref-active="active">
          <a ui-sref="stats">
            Stats
          </a>
          </li>
          <li class="tab tab-prospects"
            ui-sref-active="active">
            <a ui-sref="upload">
              Importer
            </a>
            </li>
            <li class="tab tab-prospects"
              ui-sref-active="active">
              <a ui-sref="territories">
                Territory Assignment
              </a>
              </li>

      </ul>
    </div>
  </div>
  </nav>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Intellij idea indent on wrap - formatting - Stack Overflow
You have to un-tick the Align attributes in order to have continuation indentation to work. enter image description here.
Read more >
text-indent - CSS: Cascading Style Sheets - MDN Web Docs
Inverts which lines are indented. All lines except the first line will be indented.
Read more >
textwrap — Text wrapping and filling — Python 3.11.1 ...
Counts towards the length of the first line. The empty string is not indented. (default: '' ) String that will be prepended to...
Read more >
CSS text-indent property - W3Schools
The text-indent property specifies the indentation of the first line in a text-block. Note: Negative values are allowed. The first line will be...
Read more >
Topic: html / css for hanging indent (poetry) - WordPress.com
If your paragraph is not wrapped in p-tags, add those, and in the opening p-tag, add the following attribute: style="text-indent: 20px;.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found