Formatter introduces visible whitespace in Astro/HTML templates when is followed by an expression #8919
Unanswered
loic-bellinger
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Biome team,
I’m running into a formatting behavior that changes the rendered output (visible spacing) in an Astro component.
In HTML, whitespace/newlines between inline nodes can render as a space. In Astro/JSX-like templates, when
is used to prevent wrapping around punctuation (e.g. an en dash), a formatter-introduced newline can become an extra visible space (often "NBSP + normal space").I know I can avoid this by switching to CSS (white-space: nowrap, or gap etc.) or by restructuring the markup, but I’m raising it because it’s a surprising footgun: formatting "shouldn't" visually change output in this kind of simple inline text case.
Input (before formatting)
Output (Biome-formatted)
This introduces a newline + indentation whitespace between – and {end …}. In the final HTML/rendered output, it produces an extra visible space (effectively
+ an additional collapsed space), so the date separator spacing changes.Formatting should ideally avoid introducing a newline/whitespace text node in a way that changes rendered output, don't you think?
Beta Was this translation helpful? Give feedback.
All reactions