Skip to content
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

Please expose maxPaddingWidth in two ways #1653

Closed
hazendaz opened this issue Oct 15, 2021 · 4 comments · Fixed by #1655
Closed

Please expose maxPaddingWidth in two ways #1653

hazendaz opened this issue Oct 15, 2021 · 4 comments · Fixed by #1655
Milestone

Comments

@hazendaz
Copy link
Contributor

hazendaz commented Oct 15, 2021

Hi,

I work with the formatter-maven-plugin and ever since 1.14.1, we have been unable to upgrade as it seriously corrupted pretty formatted html. After deep diving this, I finally found the cause. So I think the change basically breaks pretty formatting in most cases. Our example is rather simple, you cna find it here ->

test
resource

We keep the hash of what the prior formatter was producing (namely 1.13.1) that is on our master now. If it changes during an upgrade, it should be some improvement. In this case its rather corrupted by lack of proper whitespace. It further doesn't line break on the header any longer (not solved on this ticket).

After reviewing all the code changes and a lot of debuging, I have gotten to the StringUtil change here. Specifically line 75 (width = Math.min(width, maxPaddingWidth);) or line 128 in your lastest master.

After looking at what formatted for us, it was clear it was 30 characters as that is set preventing proper nesting to occur. So I cloned this repo and commented out that line then ran against that. The result was more of what we expected. A few tags were shortened where possible (but note that header line break from star slash comment didn't change). This is far more acceptable to us given our user base and fact that jsoup is vulnerable I believe a couple times now.

This is clearly internal code of jsoup and not intended for external exposure based on the package naming but I feel we need this exposed with 2 options. The first option, completely disable it so it works like it did before as that is rather critical as we are formatting source code to be committed to repos. The second option would simply to allow some sizing. So I think something like -1 to mean no limit and then configurable to whatever a user might want.

I don't might writing the code to expose that out but wanted to run this full diagnostic of the issue by your team first before attempting to do so.

@jhy
Copy link
Owner

jhy commented Oct 16, 2021

Hi -- this sounds like a good feature to add. I'd be happy to review a PR if you want to go ahead with it. Something like adding a maxPadding parameter to Document.OutputSettings, with it defaulting to the current default, and -1 to disable.

@hazendaz
Copy link
Contributor Author

@jhy Raised PR #1655 for review.

@jhy jhy closed this as completed in #1655 Oct 21, 2021
@jhy jhy added this to the 1.15.1 milestone Oct 21, 2021
@hazendaz
Copy link
Contributor Author

Thanks @jhy When might we see this next release?

@jhy
Copy link
Owner

jhy commented Nov 2, 2021

@hazendaz I don't have a specific timeframe in mind, and do have a few other pieces I want to add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants