-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Wrap and align html attributes when line reaches wrap-line-length #1285
Comments
+1, me and my team need the same feature, and it seems to be the same feature as requested here: #1262 I played with the source code a bit and have some implementation that seems to work: a new option for "wrap_attributes" - "aligned" which doesn't force the attrs to wrap unless the line length is reached, and aligns them properly when the line is wrapped. Can something like this work, @bitwiseman? If so, we could discuss the details or I can open a PR. (But to be honest, I am not exactly an open source expert and a bit confused about the tests and python version and whatnot). Well, html beautifier doesn't exist in python so maybe it's not an issue :) So guidance is appreciated! |
@cheerypick Yeah, you don't need to worry about the python version for HTML beautifier changes - there is no python implementation for that module yet. For testing, make sure you can run the build and it works locally. Then update test/data/html/tests.js. When you run the build again, it will regenerate the runnable tests from that data file. You can see an example of this in #1158 . If you want to try some simple tests first, cool. If you can make sense of the way that the Whatever the case feel free to start a PR whenever you like and we can discuss there. Thanks again. (If you would be willing to update CONTRIBUTING.md with any additional instructions you feel are needed, that would also be appreciated but not required.) |
@cheerypick - Also, thanks for noting the duplicate. Please continue this discussion in #1262. |
A side note on this: I was actually looking for the combination of those two settings, but now like the proposed example. What I need is that VSCode leaves attributes alone, and when the element becomes longer than 120, it will allign the attributes on new lines, so what I would want is the following:
to:
Notice the second input, where it should leave the attributes alone, because they are not longer than 120 characters + they are already aligned. So what I would like to see is instead of a force, make sure they are aligned when on multiline, and put them multiline when the line goes over 120 characters. |
Visual Studio (not Code) formats HTML this way (aligned, but not forced) by default. Would be nice if Code could too. |
Please add the feature so that my html template code wont become extremely long. |
This is highly desired. @cheerypick are you still planning on making a PR for this? |
Not working for me in VSCode. |
@christoferd |
I saw this issue again after I updated the VScode to latest version. Version 1.30.2 on Mac OS High Sierra. It was set to auto and suddenly my code starts wrapping. Tried force aligning and it does not work too. |
@aybhalala @christoferd Please be specific about what you are seeing. Come chat on gitter or open a new issue. |
@bitwiseman Sorry. Just figured out that it was a problem with the Prettier plugin. Thanks for responding. |
Description
I would like to get the combination of the power of :
"wrap-attributes": "force-aligned",
"wrap-line-length": 120
If my line reaches the wrap-line-length, it should wrap the whole line and align them with the previous line.
Input
The code looked like this before beautification:
Expected Output
The code should look like this after beautification with that feature:
The text was updated successfully, but these errors were encountered: