tipsy / j2html

Java to HTML generator. Enjoy typesafe HTML generation.
https://j2html.com/
Apache License 2.0
765 stars 136 forks source link

Config.cssMinifier.minify strips last character from each selector #85

Closed ylexus closed 7 years ago

ylexus commented 7 years ago

j2html 1.2.0. To reproduce, run this:

        System.out.println(Config.cssMinifier.minify("body {\n" +
                "    font-family: verdana, geneva, sans-serif;\n" +
                "    font-size: 90%\n" +
                "}\n" +
                "table {\n" +
                "    border: 1px solid black;\n" +
                "    border-collapse: collapse;\n" +
                "    font-size: 90%\n" +
                "}\n" +
                "th {\n" +
                "    text-align: left\n" +
                "}\n" +
                "th,td {\n" +
                "    vertical-align: text-top\n" +
                "}\n" +
                "td.unresolved {\n" +
                "    color: red\n" +
                "}\n" +
                "td.resolved {\n" +
                "    color: green\n" +
                "}\n" +
                "th, td {\n" +
                "    padding: 0.2em;\n" +
                "    text-align: left\n" +
                "}\n" +
                "td.odd, th.odd {\n" +
                "    background-color: #f2f2f2\n" +
                "}"));

which yields in body{font-family:verdana,geneva,sans-serif;font-size:90}table{border:1px solid black;border-collapse:collapse;font-size:90}th{text-align:lef}th,td{vertical-align:text-to}td.unresolved{color:re}td.resolved{color:gree}th,td{padding:0.2em;text-align:lef}td.odd,th.odd{background-color:#f2f2f}

Note last character of each selector is trimmed.

tipsy commented 7 years ago

@ylexus I guess the minifier assumes there is a semi-colon there.

tipsy commented 7 years ago

Seems it's an issue with CSSMin: https://github.com/barryvan/CSSMin/issues/20

tipsy commented 7 years ago

body{font-family:verdana,geneva,sans-serif;font-size:90%}table{border:1px solid black;border-collapse:collapse;font-size:90%}th{text-align:left}th,td{vertical-align:text-top}td.unresolved{color:red}td.resolved{color:green}th,td{padding:0.2em;text-align:left}td.odd,th.odd{background-color:#f2f2f2}

tipsy commented 7 years ago

Fixed in https://github.com/tipsy/j2html/commit/4288924f8f322ec5fc707d20b82629bdcba4ac42

tipsy commented 7 years ago

Released as part of 1.2.1

<dependency>
    <groupId>com.j2html</groupId>
    <artifactId>j2html</artifactId>
    <version>1.2.1</version>
</dependency>

http://search.maven.org/#artifactdetails%7Ccom.j2html%7Cj2html%7C1.2.1%7Cjar