Skip to content

Problems with html template tag #2258

Closed

Description

@efMss24

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();

Activity

  1. self-assigned this
    on Jan 14, 2025
  2. added
    bugA confirmed bug, that we should fix
    on Jan 14, 2025
  3. added this to the 1.19.1 milestone on Jan 14, 2025
  4. added
    fixedAn {bug|improvement} that has been {fixed|implemented}
    on Jan 14, 2025
  5. jhy commented on Jan 14, 2025

    @jhy
    Owner

    Thanks, well spotted! Fixed.

  6. added a commit that references this issue on Jan 14, 2025
    72fb596
  7. efMss24 commented on Feb 21, 2025

    @efMss24
    Author

    Thank you for the quick response and fix. Can you tell us a date when the version 1.19.1 will be released?

  8. jhy commented on Mar 4, 2025

    @jhy
    Owner

    Thank you for the quick response and fix. Can you tell us a date when the version 1.19.1 will be released?

    Today!

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

Metadata

Metadata

Assignees

Labels

bugA confirmed bug, that we should fixfixedAn {bug|improvement} that has been {fixed|implemented}

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions