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

Problems with html template tag #2258

Closed
efMss24 opened this issue Jan 13, 2025 · 1 comment
Closed

Problems with html template tag #2258

efMss24 opened this issue Jan 13, 2025 · 1 comment
Assignees
Labels
bug Confirmed bug that we should fix fixed
Milestone

Comments

@efMss24
Copy link

efMss24 commented Jan 13, 2025

If we parse the following html

<ul>
    <li>Value 1</li>
    <li>Value 2
       <template id="template-1">
          <li>Template 1 Value 1</li>
          <li>Template 1 Value 2</li>
       </template>
    </li>
    <li>Value 3</li>
</ul>

we get the following Output:

<ul>
<li>Value 1</li>
<li>Value 2 
<template id="template-1">
</template>
</li>
<li>Template 1 Value 1</li>
<li>Template 1 Value 2</li>
<li>Value 3</li>
</ul>

The template-tag is empty and all the contents are added after the tag. We would expect the content of this tag is optimized but remains inside the tag.

We use following OutputSettings:

outputSettings.syntax(Document.OutputSettings.Syntax.html);
outputSettings.escapeMode(Entities.EscapeMode.extended);
outputSettings.prettyPrint(true);
outputSettings.charset(StandardCharsets.UTF_8);
outputSettings.outline(true);
outputSettings.indentAmount(0);

For parsing we use:

Document htmlDocument = Jsoup.parse(htmlString);
String htmlOutput = htmlDocument.outputSettings(outputSettings).toString();
@jhy jhy self-assigned this Jan 14, 2025
@jhy jhy added the bug Confirmed bug that we should fix label Jan 14, 2025
@jhy jhy added this to the 1.19.1 milestone Jan 14, 2025
@jhy jhy closed this as completed in 72fb596 Jan 14, 2025
@jhy jhy added the fixed label Jan 14, 2025
@jhy
Copy link
Owner

jhy commented Jan 14, 2025

Thanks, well spotted! Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug that we should fix fixed
Projects
None yet
Development

No branches or pull requests

2 participants