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

🐛 BUG: Astro components convert last newline character (trailing newline at end-of-file) into a space #422

Closed
1 task
felixsanz opened this issue Jun 7, 2022 · 2 comments

Comments

@felixsanz
Copy link

felixsanz commented Jun 7, 2022

What version of astro are you using?

v1.0.0-beta.40

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

Astro components are not POSIX compliant because if you add a new empty line at the end of the file, it gets converted to a space.

This code (Foo.astro):

<>foo</>(\n, new line)
(EOF, empty line)

1654598376

If you call it like <p><Foo /></p>, the result is <p>foo </p> (with an ending space that affects the html render).

POSIX define a line as:

3.206 Line
A sequence of zero or more non- <newline> characters plus a terminating character.

So astro components should let you finish the file with an empty new line. Astro maybe needs to call trim() internally so it gets deleted and not converted into a space.

Link to Minimal Reproducible Example

https://codesandbox.io/s/withered-breeze-9t904k?file=/src/pages/index.astro

Participation

  • I am willing to submit a pull request for this issue.
@felixsanz felixsanz changed the title 🐛 BUG: 🐛 BUG: Astro components convert last newline character (trailing newline at end-of-file) into a space Jun 7, 2022
@natemoo-re
Copy link
Member

This is a compiler issue, moving to that repo.

@natemoo-re natemoo-re transferred this issue from withastro/astro Jun 7, 2022
@natemoo-re
Copy link
Member

Finally closed in #698

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants