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
vscode: bizarre spaces during formatting #64
Comments
The Plugin uses Prettier to format the code. So in the end this is prettier formatting the code that way. Since Prettier is very opinionated and does not have much options, I guess there is not much you can do about this. |
Nope, I need it. But I think we should re-think this formatting issues. Please, don't close. RFC this. Please. |
I think this comes down to user preferences - I for example would want the code to be formatted that way. Since prettier is very opinionated, there are few options to tweak the outcome. Since it also does not break your code, it is more an inconvenience. Would it help you if you could turn off html formatting (related feature request)? Then script/style would be formatted but not html. Replacing prettier with an entirely different formatter is something we don't want to do at the moment. What we could do is add the vscode html formatter as a second option, so you would choose between one of the two. But even if we would add another formatter, then there is always the question whether or not that formatter then does what you want. |
|
Here's the relevant issue for prettier-plugin-svelte - sveltejs/prettier-plugin-svelte#24 (it's labelled as a bug) |
Yeah, the problem is that adding newlines here alters the rendered output by inserting spaces into the output. The first snippet at the top renders in the browser as Standard Prettier HTML formatting does have an HTML whitespace setting to determine how it treats whitespace in HTML, but the Svelte Prettier plugin does not appear to honor that. From my limited exploration, it reimplements a lot of HTML formatting functionality in order to also support Svelte template syntax.
|
if anyone wanted to help to solve this. you can pick what's left with this PR |
Since this is a |
Is there a way to not add spaces in the below html during formatting?
I need this code to stay like this:
It becomes this instead:
From jamesbirtles/svelte-vscode#50.
The text was updated successfully, but these errors were encountered: