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.

html formatting obscures hierarchy in some cases

See original GitHub issue

Prettier 1.15.2 Playground link

Input:

<h3 class="timeline-title">
  <gg-inline-editable-text
    [value]="file.filename"
    (updateValue)="saveFilename($event)"
    [hasEditAccess]="hasEditAccess">
    <gg-downloadable-file [file]="file"></gg-downloadable-file>
  </gg-inline-editable-text><span *ngIf="file.filepageid !== filepage.filepageid">Moved to: 
    <gg-item-link [apiId]="{type: 'filepages', id: file.filepageid.toString()}"></gg-item-link></span>
</h3>

Output:

<h3 class="timeline-title">
  <gg-inline-editable-text
    [value]="file.filename"
    (updateValue)="saveFilename($event)"
    [hasEditAccess]="hasEditAccess"
  >
    <gg-downloadable-file
      [file]="file"
    ></gg-downloadable-file> </gg-inline-editable-text
  ><span *ngIf="file.filepageid !== filepage.filepageid"
    >Moved to:
    <gg-item-link
      [apiId]="{ type: 'filepages', id: file.filepageid.toString() }"
    ></gg-item-link
  ></span>
</h3>

Expected behavior:

<h3 class="timeline-title">
  <gg-inline-editable-text
    [value]="file.filename"
    (updateValue)="saveFilename($event)"
    [hasEditAccess]="hasEditAccess"
  >
    <gg-downloadable-file
      [file]="file"
    ></gg-downloadable-file>
  </gg-inline-editable-text><span 
      *ngIf="file.filepageid !== filepage.filepageid"
    >Moved to:
    <gg-item-link
      [apiId]="{ type: 'filepages', id: file.filepageid.toString() }"
    ></gg-item-link
  ></span>
</h3>

This is an example from our code. I’ve included a much larger example in the prettier playground link. There are a few things here that members of our team find ugly, but the biggest issue is the indenting of the closing tag of the </gg-inline-editable-text> element. Including it inline after the </gg-downloadable-file> tag makes it hard to see the hierarchy of the file. Inlining elements when everything fits on one line seems sensible, but otherwise, when working with html, being able to see the hierarchy is important.

(Separately, and if there is interest in this, I could open another issue, one team member (the boss) has said he hates the dangling closing > that are alone on a line, and would prefer to see them on the previous line. in his words, “I’ve never seen it done like that in 20+ years.” The dangling >'s don’t bother me, although they aren’t exactly pretty; it would make it hard to see when the tag ends and other content begins if the the > were simply moved to the previous line. But this is in part because there is a single indent width for both the contents of a tag additional content after a closing tag. Perhaps if wrapped attributes were indented to double the standard indentation, those closing >'s could hug the previous line?)

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
karptonitecommented, Nov 27, 2018

@pmattke I think that is because your version would add meaningful whitespace before and after the ng-content tag.

1reaction
paulheisingcommented, Nov 27, 2018

Also occured to me:

Input:

<markdown [class.big-initial]="showBigInitial"><ng-content></ng-content></markdown>

Actual Output:

<markdown [class.big-initial]="showBigInitial"
  ><ng-content></ng-content
></markdown>

Why does it put the closing > of the markdown and the ng-content tag in the next line?

Expected Output would be:

<markdown [class.big-initial]="showBigInitial">
  <ng-content></ng-content>
</markdown>

Read more comments on GitHub >

github_iconTop Results From Across the Web

The stacking context - CSS: Cascading Style Sheets | MDN
Note: The hierarchy of stacking contexts is a subset of the hierarchy of HTML elements because only certain elements create stacking ...
Read more >
9 Visual formatting model - W3C
The visual formatting model does not specify all aspects of formatting (e.g., it does not specify a letter-spacing algorithm). Conforming user agents may...
Read more >
HTML Structural Assumptions by CSS and JavaScript Libraries
Both CSS and JavaScript technologies use the HTML structure to indicate the formatting or JavaScript functionality that should be applied to a particular ......
Read more >
HTML Text Formatting - W3Schools
HTML contains several elements for defining text with a special meaning. Example. This text is bold. This text is italic. This is subscript...
Read more >
How can I convert HTML to Object structure with text and ...
You can use recursion. And this seems a good case for a generator function. As it was not clear which tags should be...
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