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.

Children of p are not indented properly in 1.11.0

See original GitHub issue

Description

Children of p are not indented properly in 1.11.0.

Input

The code looked like this before beautification:

<p>
    <ul>
        <li>sadas</li>
    </ul>
</p>

Expected Output

The code should have looked like this after beautification:

<p>
    <ul>
        <li>sadas</li>
    </ul>
</p>

or

<p></p>
<ul>
    <li>sadas</li>
</ul>
<p></p>

Actual Output

The code actually looked like this after beautification:

<p>
<ul>
    <li>sadas</li>
</ul>
</p>

Steps to Reproduce

  1. Beautify code.

Environment

OS: Win, Linux

Settings

Defaults

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bitwisemancommented, Apr 10, 2020

As an added point, not having an option to revert to the old formatting is not just a theoretical point either. The difference can be seen in the rendered html. If you look at this jsfiddle, you can see that CSS that applies to the p element contents does not apply to the ul even though from the text you might think the ul was “inside” the p element.

// css
p {
  background: green;
}

// html
<p>
    Hello
</p>
<p>
    <span>
        Hello again
    </span>
</p>
<p>
    <ul> 
        <li>Hello all!</li>
    </ul>
</p>

By indenting the ul element, the beautifier has been indicating that the ul is a child of the p element, which it absolutely is not.

1reaction
bitwisemancommented, Apr 10, 2020

@HitkoDev I understand that you’re upset at this fix. It produced an unexpected change to your formatting.

I’m sorry, but up until 1.11.0 the elements were not properly nested, they were incorrectly nested in a way that appeared reasonable. Now they are correctly nested in a way that is surprising until you dig into it.

This fix was noted in the change log. The change log doesn’t highlight your scenario, but that is not really surprising given that it’s not valid html.

Understand, if there were any scenario in which this syntax were valid, I’d be in complete agreement with you. I have just spent several hours looking for any scenario in which the input you provided is valid html, but I can’t find one. I was thinking this might be valid in xhtml, but even there it is not: http://xstandard.com/en/articles/xhtml-reference/p/#p-contains . In xhtml, the ul still cannot be a child of the p so the result is the same as in html. (The only scenario I can find is if you are writing plain xml).

The project does follow semantic versioning to the extent that is reasonable in this area.

We use major version to indicate API compatibility. This project has never made API incompatible changes. There are a number of options that have been retained for backward compatibility.

The question then is what is the definition of “backward compatible” when it comes to formatting output? If we say any change to output is not backward compatible" then every change will be a new major version. That would actually less informative for the consumers of this library - they would not know whether a release is API compatible or not.

We use minor versions to indicate significant formatting fixes or added features. We use patch versions to indicate small bug fixes formatting fixes or added options that cannot cause any side effects.

We do not make spurious changes the output, but output for a given input MAY change for minor or patch versions. For changes that fix formatting errors (making the output more accurate), we turn those on by default and may or may not provide the ability to turn them off. We only do this only when the formatting was strictly incorrect. All other changes should be added as formatting options, which must be off by default such that the default formatting of valid input doesn’t change whenever a feature is added.

Best effort is made to handle invalid inputs in a reasonable way as well, but that is not a priority.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NSOutlineView indentation issue - objective c - Stack Overflow
I'm using an NSOutlineView object to represent a file structure and am finding that it will not correctly indent any children which are...
Read more >
HTML Indentation and Spacing - LearnHowToProgram.com
As we see here, when an HTML tag is nested inside another HTML tag, it's indented. There is one exception: we didn't indent...
Read more >
Indent children in sidebar · Issue #50506 · microsoft/vscode
Technically this is indented, because the parent is a folder, and the folder's icon is a collapse/expand arrow. However my mind does not...
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 >
How to Indent HTML Code – And Why it's Important
In this article, I will show you how to properly indent your HTML files and ... The h2 and p elements are children...
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