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

Space inserted around custom elements when pretty-printing #1852

Closed
jochenberger opened this issue Oct 27, 2022 · 2 comments
Closed

Space inserted around custom elements when pretty-printing #1852

jochenberger opened this issue Oct 27, 2022 · 2 comments
Assignees
Labels
Milestone

Comments

@jochenberger
Copy link

For the following input

<foo>
  <bar />
</foo>

the following output is generated

<html>
 <head></head>
 <body>
  <foo>
   <bar /> 
  </foo>
 </body>
</html>

For some reason, there is a space after the <bar /> element.
This space is not added if I omit the newline after the <bar /> in the input or if I use regular HTML elements like div.

Here's a repro as a Groovy script:

@Grab('org.jsoup:jsoup:1.15.3')
import org.jsoup.Jsoup

def input = '''\
                <foo>
                  <bar/>
                </foo>'''.stripIndent()

assert Jsoup.parse(input).toString() == '''\
                <html>
                 <head></head>
                 <body>
                  <foo>
                   <bar />
                  </foo>
                 </body>
                </html>'''.stripIndent()
@jochenberger
Copy link
Author

If I add more than one bar element, only the last one gets an additional space appended.

@jochenberger jochenberger changed the title Space inserted aroung custom elements when pretty-printing Space inserted around custom elements when pretty-printing Oct 27, 2022
@jhy jhy closed this as completed in 9e5869b Jan 5, 2023
@jhy jhy added the fixed label Jan 5, 2023
@jhy jhy added this to the 1.15.4 milestone Jan 5, 2023
@jhy jhy self-assigned this Jan 5, 2023
@jhy
Copy link
Owner

jhy commented Jan 5, 2023

Thanks. Looked to be only if a self-closed element with a following newline is inside a custom element.

Fixed!

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

No branches or pull requests

2 participants