Ich versuche, eine HTML-Seite über meinen Java-Code zu minimieren. Ich verwende https://code.google.com/archive/p/htmlcompressor/, um die Komprimierung durchzuführen.Wie Inline-CSS in einem HTML-Format mit HtmlCompressor zu minimieren?
Hier ist meine Methode für minification:
public static String minifyHtml(String html) {
HtmlCompressor htmlCompressor = new HtmlCompressor();
htmlCompressor.setRemoveSurroundingSpaces(HtmlCompressor.ALL_TAGS);
htmlCompressor.setPreserveLineBreaks(false);
htmlCompressor.setCompressCss(true);
return htmlCompressor.compress(document.toString());
}
Dies gilt jedoch nicht minify die Inline-CSS, die ich in den HTML-Code haben. Zum Beispiel für den folgenden Tag:
<div class="content" style="font-family: Helvetica,sans-serif,Lucida Sans Unicode; font-size: 12pt; font-weight: normal; font-style: normal; text-decoration: none; color: rgb(0,0,0); background-color: transparent; margin-top: 0.0pt; margin-bottom: 0.0pt; text-indent: 0.0in; margin-left: 0.0in; margin-right: 0.0in; text-align: left; border-style: none; border-width: 0.0pt; border-color: rgb(0,0,0); padding: 0.0pt; white-space: pre-wrap;">
Kann dies die HtmlCompressor verwenden werden minimiert? Wenn nicht, gibt es dann noch eine andere Bibliothek?