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

Prettier reformat adds unwanted whitespace to HTML #103

Closed
hidde opened this issue Jun 24, 2020 · 3 comments
Closed

Prettier reformat adds unwanted whitespace to HTML #103

hidde opened this issue Jun 24, 2020 · 3 comments

Comments

@hidde
Copy link

hidde commented Jun 24, 2020

Given the following HTML:

<p>Please use <a href="https://en.wikipedia.org/wiki/Markdown">Markdown</a>, 
so that you can use lists, links and code examples.</p>

Actual result

Formatted with prettier-plugin-svelte, my comma is moved to a new line, which introduces whitespace between the link and the comma:

<p>
   Please use
    <a href="https://en.wikipedia.org/wiki/Markdown">Markdown</a>
    , so that you can use lists, links and code examples.
</p>

It prints “Please use Markdown , so”.

Desired result

I'm trying to avoid that whitespace before the comma.

When formatted with the html parser of Prettier, no whitespace is forced (REPL).

Is prettier-plugin-svelte parsing this with something else than the html parser and would it be possible to change that?

@tiffany352
Copy link

Prettier has a config option "htmlWhitespaceSensitivity": "strict" and it seems like it's completely ignored by this tool. I've been having a really hard time with this because it ends up mattering a lot in my case. I may need to stop using prettier entirely until there's a solution for this.

@tiffany352
Copy link

I found out you can use <!-- prettier-ignore --> and it will be respected, which works well enough for me.

@ehrencrona
Copy link
Contributor

ehrencrona commented Aug 10, 2020

I created a pull request that fixes this problem.
This is by the way a duplicate of #24

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 a pull request may close this issue.

3 participants