Skip to content

Commit

Permalink
Keeps the <bookmarks> tag in <head> during cleanup 🚧
Browse files Browse the repository at this point in the history
…as it is a non-standard header tag only supported by _flying saucer_.

OX-10783
  • Loading branch information
jakobvogel committed Sep 15, 2024
1 parent 2dfc2f7 commit 0cb2925
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ public boolean generate(Generator generator, OutputStream out) throws Exception
private String cleanHtml(String html) {
Document document = Jsoup.parse(html);

// the parser is very strict in terms of what elements are accepted within the <head> element, and it does not
// know about additional valid elements like <bookmarks> that are valid for flying saucer; we need to move them
// back from the <body> to the <head> element
document.select("body > bookmarks").forEach(bookmarks -> {
document.head().appendChild(bookmarks);
});

// in theory, the following two lines should be possible with a single CSS selector; however, in practice, Jsoup
// does not select the style elements correctly when attempting that
document.select("script").remove();
Expand Down

0 comments on commit 0cb2925

Please sign in to comment.