Skip to content

Conversation

@djanowski
Copy link

@djanowski djanowski commented Oct 9, 2025

If you confirm this is a bug, I'll try to find a fix.

 FAIL  test/render.test.js > Render > whitespace
AssertionError: expected '<h1>Hello <span>John</span> , nice to…' to be '<h1>Hello <span>John</span>, nice to …' // Object.is equality

Expected: "<h1>Hello <span>John</span>, nice to meet you!</h1>"
Received: "<h1>Hello <span>John</span> , nice to meet you!</h1>"

 ❯ test/render.test.js:161:31
    159|     );
    160|
    161|     expect(cleanString(html)).toBe("<h1>Hello <span>John</span>, nice to meet you!</h1>");
       |                               ^
    162|   });
    163| })

@djanowski djanowski changed the title Whitespace error Whitespace error when rendering components Oct 9, 2025
@cossssmin
Copy link
Member

Hi, thanks for bringing this up, it's indeed not what you'd expect though not yet sure if it's intentional or not.

I don't know where it's coming from yet, I hope it's posthtml-components and not the PostHTML parser/renderer itself. Would be great to get this fixed, yes 👍

@djanowski
Copy link
Author

@cossssmin Thank you for your quick reply! Turns out the template that I was using (also the stub I added here) does have a newline at the end of the file, but most editors hide this, and it's hard to prevent it. It does seem like a posthtml-components issue, however I doubt that they'll want to trim component source when they read files :(

@cossssmin
Copy link
Member

If you want to work on a PR to posthtml-components I'll be happy to review and get it merged :)

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

Successfully merging this pull request may close these issues.

2 participants