Output JSoup without added spaces and line breaks around the elements
With some help from Aleksandr M I solved it in the following way:
doc.outputSettings().indentAmount(0).prettyPrint(false);
A little less nice, but this also seemed to do the trick:
htmlWriter.write(doc.toString().replaceAll(">\\s+",">").replaceAll("\\s+<","<"));