-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Fix class attributes not counting towards attribute wrapping #503
Fix class attributes not counting towards attribute wrapping #503
Conversation
please update the PR, but I still need to find time to analyze this PR/fix |
It looks like this also affects the So do we also need to implement this for |
You are correct that ID's have the same issue. I added a test and expanded the same fix to cover ID attributes.
As an aside, what would be a kosher way to add tests that will currently fail because of a bug? Use the An example is that the attribute wrapping classes will fail with |
It's a pleasure to work with you because you think ahead 😸 I need to have a look into this
However for the third options, I welcome you in #167 🐱 |
I will merge this now and then do some dependency updates |
Thanks for the kind words and for fast-tracking a new release. This should be good for now 🙏 |
Issue
There are a few issues with the
pugClassNotation: 'attribute'
option that resolve themselves with multiple repeated runs (one run to convert from literals to attributes with broken formatting, another run to fix the formatting) but one issue persists.Classes are not counted to
numNormalAttributes
when deciding if the attributes should be wrapped as perpugWrapAttributesThreshold
. This causes lines not to wrap as expected if they have class attributes.Input with
pugWrapAttributesThreshold: 1
andpugClassNotation: 'attribute'
:Output:
Expected output:
Fix
I added an extra check to the code path for classes that manually adds +1 to
numNormalAttributes
if classes were defined as attributes and they are not explicitly forced to be converted to literals.Test
I added two new tests (better naming welcome) demonstrating correct wrapping when both
pugClassNotation
andpugWrapAttributesThreshold
have been set. I left the tests simple as more complex setups like mixed literal + attribute classes will hit formatting bugs that should not be in the scope of this PR.