-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Remove extra newlines around components in Markdown #3620
Remove extra newlines around components in Markdown #3620
Conversation
🦋 Changeset detectedLatest commit: 3a9887d The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@natemoo-re PTAL :) The failed Windows test should be a fluke. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks as always!
I think this bug (or a variation of it) is present now in .astro files? |
@ahmed2m I don't think that this is a bug. In my opinion, what you're seeing here is regular HTML whitespace handling which doesn't have anything to do with Astro. Your code will lead to the same results without even using Astro, but only plain HTML. Newlines, tabs and spaces are all considered whitespace characters in HTML, and all whitespace characters will be collapsed to one single space (not zero!) by the browser when displaying the page. If you do not want to introduce whitespace into the output, but still wrap lines in your code, you can do something like this: <h2>
Instead, you can add whitespace before the closing bracket of the
<span class="test">span</span
>, which works well!
</h2> See an example here: Hope that helps! :) |
Yeah, I was using JSX for the longest time and it collapses new lines/spaces into nothing that I thought that's like an html thing. My problem is I use the prettier plugin and somehow it ALWAYS formats like jsx, (usually) break lines around tags |
Changes
mdxJsxFlowElement
andmdxJsxTextElement
elements with children in Markdown. These extra newlines caused unwanted whitespace to be introduced into the resulting HTML output.Testing
Docs