use of com.helger.css.reader.CSSReaderSettings in project ph-css by phax.
the class Issue19Test method testIssue.
@Test
public void testIssue() {
// Multiple errors contained
final IReadableResource aRes = new ClassPathResource("testfiles/css30/bad_but_browsercompliant/issue19.css");
assertTrue(aRes.exists());
final CascadingStyleSheet aCSS = CSSReader.readFromStream(aRes, new CSSReaderSettings().setFallbackCharset(StandardCharsets.UTF_8).setCSSVersion(ECSSVersion.CSS30).setCustomErrorHandler(new LoggingCSSParseErrorHandler()).setBrowserCompliantMode(true));
assertNotNull(aCSS);
if (false)
System.out.println(new CSSWriter(ECSSVersion.CSS30).getCSSAsString(aCSS));
assertEquals(1, aCSS.getRuleCount());
assertEquals(1, aCSS.getStyleRuleCount());
}
use of com.helger.css.reader.CSSReaderSettings in project ph-css by phax.
the class Issue34Test method testIssue.
@Test
@Ignore("TODO")
public void testIssue() {
final String css = ".pen {background-color:red} {* some incorrect block *} .pen {background-color: blue}";
final CSSReaderSettings aSettings = new CSSReaderSettings().setCSSVersion(ECSSVersion.LATEST).setBrowserCompliantMode(true).setCustomErrorHandler(new LoggingCSSParseErrorHandler()).setCustomExceptionHandler(new LoggingCSSParseExceptionCallback());
final CascadingStyleSheet cascadingStyleSheet = CSSReader.readFromStringStream(css, aSettings);
assertNotNull(cascadingStyleSheet);
final CSSWriter writer = new CSSWriter(new CSSWriterSettings(ECSSVersion.LATEST, true));
s_aLogger.info(writer.getCSSAsString(cascadingStyleSheet));
}
use of com.helger.css.reader.CSSReaderSettings in project ph-css by phax.
the class Issue36Test method testIssue.
@Test
public void testIssue() {
final String css = "@media screen and (min-width: 768px) {.section {.\r\n" + " padding: 40px\r\n" + "}\r\n" + "\r\n" + "}";
final CSSReaderSettings aSettings = new CSSReaderSettings().setCSSVersion(ECSSVersion.LATEST).setBrowserCompliantMode(true).setCustomErrorHandler(new DoNothingCSSParseErrorHandler());
final CascadingStyleSheet cascadingStyleSheet = CSSReader.readFromStringStream(css, aSettings);
final CSSWriter writer = new CSSWriter(new CSSWriterSettings(ECSSVersion.LATEST, true));
assertEquals("@media screen and (min-width:768px){.section{}}", writer.getCSSAsString(cascadingStyleSheet));
}
use of com.helger.css.reader.CSSReaderSettings in project ph-css by phax.
the class Issue24Test method testIssue.
@Test
public void testIssue() {
final IReadableResource aRes = new ClassPathResource("testfiles/css30/bad_but_browsercompliant/issue24.css");
assertTrue(aRes.exists());
final CascadingStyleSheet aCSS = CSSReader.readFromStream(aRes, new CSSReaderSettings().setFallbackCharset(StandardCharsets.UTF_8).setBrowserCompliantMode(true).setCustomErrorHandler(new LoggingCSSParseErrorHandler()));
assertNotNull(aCSS);
if (false)
System.out.println(new CSSWriter().getCSSAsString(aCSS));
}
Aggregations