0

Java コードを使用して HTML ページを縮小しようとしています。https://code.google.com/archive/p/htmlcompressor/を使用して圧縮を行っています。

これが私の縮小方法です:

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

ただし、これは、html にあるインライン css を縮小しません。たとえば、次のタグの場合:

<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;">

これは HtmlCompressor を使用して縮小できますか? そうでない場合、それを行う他のライブラリはありますか?

4

1 に答える 1