-
Notifications
You must be signed in to change notification settings - Fork 97
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
Configure whitespace-sensitive tags #28
Comments
Hey @awmottaz, I've begun work on fixing this issue in #41. Unfortunately, the ability to define custom component tags to be treated as preformatted looks to be a bit difficult due to how Prettier validates options (see prettier/prettier#6151). However, any vanilla HTML tag can be configured as preformatted (as you can see in my Pull Request). |
It is a major issue for me write now, I am not able to format the code without breaking typography and other elements. |
- Maintain whitespace and newlines as-in inside `<pre>` tags - Also consider attribute values (with one exception: the class attribute) to be pre-formatted. Do not add or remove line breaks there. #28
There are really two issues mentioned here: Whitespace should not be changed inside
|
+1 for not adding a list of tags that are whitespace-sensitive. You could also a css-styling to tags to preserve whitespaces - what then? Things like |
@dummdidumm I just tested applying That's a bit problematic. We could invent some other way of signaling "do not format", e.g. |
I think it's possible but we would have to jump through some hoops. Inside |
I would be happy with a magic comment to disable Prettier's whitespace formatting. I like the "disable"/"enable" semantics from ESLint for things like this, e.g. <!-- prettier-disable whitespace -->
<CodeSnippet lang="js">const foo = () => {
return 42
}</CodeSnippet>
<!-- prettier-enable whitespace --> |
I'm against adding anything that is not adhering to the prettier standards. There is a |
@dummdidumm Works! I have to look at the |
The |
Related to #24, whitespace-sensitive tags should not be modified on format. For example, this
becomes this
I would also like to be able to configure custom tags to follow the same rules as the
<pre>
tag. For example, if I configure theCodeSnippet
tag to be whitespace-sensitive, this should not change after formatting:The text was updated successfully, but these errors were encountered: