prettier: [Glimmer] 🐛 Linebreak added around closing tag and text comming just after

Prettier 2.0.5 Playground link

--parser glimmer

Input:

<span>foo</span>bar

Output:

<span>
  foo
</span>
bar

Expected behavior:

<span>foo</span>bar

Formatting with --parser html produces the expected output. See this playground link

When rendered, the browser displays foo bar while it should display foobar

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 17 (10 by maintainers)

Most upvoted comments

@dcyriller amazing work, thank you! once this makes it to the latest prettier, i’ll give it a try over our codebase at LinkedIn

@thorn0 JSX seems to strike a good balance between formatting and correctness; it breaks tags stuffed on one line, for example, without breaking whitespace (<span>hello</span>world). AFAIU, if we follow JSX behavior, we can avoid the complexity of having 3 flags.

I just noticed that my draft PR breaks <span>hello</span>world — is this what you meant? Yeah, that’s no good, I’ll look into it.

thx for the work on this @dcyriller 👍

@mamiller93 No workarounds that i’m aware of. This is still on my radar as that’s one of the blockers for us to start using this internally at LinkedIn. I’ve been caught up with other work stuff and haven’t had time to work on it.

I like the idea of changing the mode of handlebars printer from htmlWhitespaceSensitivity: ignore to strict. It should be a reasonable amount of work (compared to developing the css mode). And it would make Prettier for handlebars much more usable. Also it shouldn’t make the development of a css mode harder.