-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Astro 3.5.5 compiler regression for whitespace #893
Comments
It's likely caused by #879. While I'm inclined that we're preserving the whitespace as before compacting, which feels like the more correct behaviour, the
So I wonder if my fix isn't actually right. Perhaps @natemoo-re is able to make the call here. |
@bluwy I believe the change you merged is mostly correct! This seems like a case where the element whitespace inside the BLOCK element should be completely removed but whitespace inside the INLINE elements should be preserved. Adjusting this |
I think the part I'm unclear of is how we decide what elements are block vs inline. We can pick their default states but wouldn't users be able to change block->inline & inline->block with CSS? I had |
It also happens for anchors in 3.6 |
Links on the resume page had additional whitespace surrounding `<span>` elements, making the underline on the anchor elements look weird. Similar issue with the `<summary>` elements. Since `@astrojs/[email protected]`, Astro preserves whitespace before compacting; see withastro/compiler#893 for more details and links to other issues. To address this change without refactoring all the HTML onto a single line to avoid creating whitespace-only text nodes inside an inline-formatting context, set the display to `flex`. For information on how whitespace is handled by HTML and CSS, see this article on MDN: https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Whitespace
withastro/compiler#893 Astro is now preserving more white space than before, causes extra spaces in links in particular. This applies some CSS workarounds to hide that white space.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Astro v3.5.5 (or specifically @astrojs/compiler 2.3.1) generates additional whitespace for the same code compared to previous versions, presumably due to different handling of new lines in source code.
For the following example, taken out of astro-paper:
Locking to Astro 3.5.3 and @astrojs/compiler 2.3.0 would give the following breadcrumbs, which I believe is the correct behavior
But the latest Astro 3.5.5 (@astrojs/compiler 2.3.2) generates additional whitespaces around the
<span>
, which can only be removed if I manually format the file where the<a>
and<span>
above are on the same line. The whitespace is visible as 1 character wide, and also shown in the FireFox DevTools.Using Astro 3.5.5 with compiler 2.3.0 works fine, and is my current workaround. This narrows the problem to @astrojs/compiler rather than the astro main package. And the above can be reproduced with a fresh clone of https://github.com/satnaing/astro-paper after running
npm upgrade
, and the workaround can be verified by locking"@astrojs/compiler": "2.3.0"
What's the expected result?
I would expect the old version to be correct, i.e. behavior from @astrojs/compiler 2.3.0 and before. But I don't know much about web dev to be sure if this is a regression or just a previously wrong behavior fixed.
Link to Minimal Reproducible Example
https://github.com/satnaing/astro-paper
Sorry, I'm not able to figure out what's wrong to put it inside a minimal example, and I was hoping devs working on @astrojs/compiler would know from the description above. Also the astro-paper project can also be used to reproduce the issue.
Participation
The text was updated successfully, but these errors were encountered: