-
-
Notifications
You must be signed in to change notification settings - Fork 441
HTML void elements (i.e. <input>) are self-closed when .vue documents are formatted #163
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
Comments
This is prettyhtml behavior and it can't not be config, you can check it on https://prettyhtml.netlify.app/. For your needs I suggest you switch to Prettier for formatting. |
Is there a way to cause volar to use prettier instead of prettyhtml? |
What the difference between "switch to Prettier extension" and "use Prettier in Volar". 🤣 I deliberately avoid support Prettier in Volar. If we support Prettier in Volar, we need to provide corresponding VSCode settings for Prettier, that was repetitive and confusing because Prettier extension already have it. |
I guess that's my question. I don't have the prettyhtml extension installed, and I don't have the prettier extension installed. I do have Volar installed, but that's pretty much it for web development. Neither prettier nor prettyhtml is present in my package.json either. I guess I just assumed that it was Volar that was providing it? |
Yes Volar have it: https://github.com/johnsoncodehk/volar/blob/116664aaea819dc5b5933ee686f8bb596812a659/packages/vscode-vue-languageservice/package.json#L14-L21 This is to provide a formatter out of the box, but does not support other Prettier features for user. (Sorry if I misunderstand what you mean.) |
So, is there no way to fix the formatting that prettyhtml does? It's currently formatting HTML incorrectly. |
This is valid in HTML5, see: https://stackoverflow.com/a/3558200
If you think this is a bug and you want this change in Volar but not switch to Prettier, you can open a issue to prettyhtml. |
Ah, ok, I understand, and I was mistaken about HTML5. If I do want to switch volar to Prettier, how do I go about that? |
See: #53 |
If I have a template in a .vue file with an HTML void element (for example, an element like this:)
When I right-click in the editor and choose "Format Document", the element will be changed to this:
... which is incorrect;
input
is an HTML void element, which should not have a closing tag, nor should it be self-closing.The text was updated successfully, but these errors were encountered: