-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[header] Support header comments so line breaks properly #1664
Conversation
For now looking for feedback only. Depending on feedback will adjust tests as needed. |
This is ready for review. Basic idea here is license header comments used in html pages. The current jsoup will not line break after the comment thus the block start is at end of the header comment which is not correct. To avoid touching other comments, this addresses only when 'accum' is empty and thus start of the file processing when pretty print is turned on. An existing toString test already runs full pretty print and was able to be adjusted to confirm this test while keeping all other existing tests intact. |
@jhy Could you look at this one? |
You can see this saved item Saved https://try.jsoup.org/~pWWgM1Tq8l3YM1WTm8Fftq5ziv4, look at the header as it buts up against the docttype. It should line break which this one attempts to fix and does work. |
…print License headers will be comments at start of html. Pretty print today does not line break when it writes it thus it is not properly pretty printed. This patch looks for usage of pretty print and fact that 'accum' is empty to ensure the proper line break.
rebased, still not fixed until this commit |
@jhy Finally got back to properly confirm, this worked as expected. This also seemed to fix another issue I had not noticed previously where I ended up with 2 license headers. Anyway, thank you! |
context: formatter-maven-plugin
Issue: Many files come with copyright headers in the files. The html parser for pretty printing with jsoup treats this header comment incorrectly and ends up adding the html tag at end of --> on same line. I'm not sure the fix I have here is appropriate but it did solve the issue.
As with before you can see this with this file here.