compiler icon indicating copy to clipboard operation
compiler copied to clipboard

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

Open felixsanz opened this issue 3 years ago • 1 comments

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 avatar Jun 07 '22 10:06 felixsanz

This is a compiler issue, moving to that repo.

natemoo-re avatar Jun 07 '22 14:06 natemoo-re

Finally closed in https://github.com/withastro/compiler/pull/698

natemoo-re avatar Jan 13 '23 20:01 natemoo-re