Skip to content

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

@felixsanz

Description

@felixsanz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions