use of com.helger.css.reader.errorhandler.DoNothingCSSParseErrorHandler in project ph-css by phax.
the class CSSReader30SpecialFuncTest method testReadWithBOM.
@Test
public void testReadWithBOM() {
final String sCSSBase = "/* comment */.class{color:red}.class{color:blue}";
for (final EUnicodeBOM eBOM : EUnicodeBOM.values()) {
final Charset aDeterminedCharset = eBOM.getCharset();
if (aDeterminedCharset != null) {
final CascadingStyleSheet aCSS = CSSReader.readFromStream(new ByteArrayInputStreamProvider(ArrayHelper.getConcatenated(eBOM.getAllBytes(), sCSSBase.getBytes(aDeterminedCharset))), aDeterminedCharset, ECSSVersion.CSS30, new DoNothingCSSParseErrorHandler());
assertNotNull("Failed to read with BOM " + eBOM, aCSS);
assertEquals(".class{color:red}.class{color:blue}", new CSSWriter(ECSSVersion.CSS30, true).getCSSAsString(aCSS));
}
}
}
use of com.helger.css.reader.errorhandler.DoNothingCSSParseErrorHandler 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));
}
Aggregations