Skip to content
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

Conversation

hippotastic
Copy link
Contributor

Changes

Testing

  • Updated test cases to reflect the new correct output.
  • Ran all tests locally.
  • Built Astro Docs using the new code without apparent issues.

Docs

  • Just a bugfix.

@changeset-bot
Copy link

changeset-bot bot commented Jun 16, 2022

🦋 Changeset detected

Latest commit: 3a9887d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
astro Patch
@astrojs/markdown-remark Patch

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

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) feat: markdown Related to Markdown (scope) labels Jun 16, 2022
@hippotastic
Copy link
Contributor Author

@natemoo-re PTAL :) The failed Windows test should be a fluke.

Copy link
Member

@natemoo-re natemoo-re left a 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!

@natemoo-re natemoo-re merged commit 05aa724 into withastro:main Jun 17, 2022
@github-actions github-actions bot mentioned this pull request Jun 17, 2022
@hippotastic hippotastic deleted the fix/remove-extra-newlines-around-components branch June 17, 2022 17:11
@ahmed2m
Copy link

ahmed2m commented Nov 2, 2022

I think this bug (or a variation of it) is present now in .astro files?
https://replit.com/@ahmed2m/Astro-spacing-problem#src/pages/index.astro
image

@hippotastic
Copy link
Contributor Author

@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:
https://stackblitz.com/edit/web-platform-hqtn6w?file=index.html

Hope that helps! :)

@ahmed2m
Copy link

ahmed2m commented Nov 4, 2022

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

SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: markdown Related to Markdown (scope) pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 BUG: Using HTML inside markdown produces additional space.
3 participants