Search in sources :

Example 16 with LoggingCSSParseErrorHandler

use of com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler 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));
}
Also used : CascadingStyleSheet(com.helger.css.decl.CascadingStyleSheet) IReadableResource(com.helger.commons.io.resource.IReadableResource) CSSWriter(com.helger.css.writer.CSSWriter) CSSReaderSettings(com.helger.css.reader.CSSReaderSettings) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) LoggingCSSParseErrorHandler(com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler) Test(org.junit.Test)

Example 17 with LoggingCSSParseErrorHandler

use of com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler in project ph-css by phax.

the class Issue4Test method testIssue4.

@Test
public void testIssue4() {
    final IReadableResource aRes = new ClassPathResource("testfiles/css30/good/issue4.css");
    assertTrue(aRes.exists());
    final CascadingStyleSheet aCSS = CSSReader.readFromStream(aRes, StandardCharsets.UTF_8, ECSSVersion.CSS30, new LoggingCSSParseErrorHandler());
    assertNotNull(aCSS);
    if (false)
        System.out.println(new CSSWriter(ECSSVersion.CSS30).getCSSAsString(aCSS));
}
Also used : CascadingStyleSheet(com.helger.css.decl.CascadingStyleSheet) IReadableResource(com.helger.commons.io.resource.IReadableResource) CSSWriter(com.helger.css.writer.CSSWriter) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) LoggingCSSParseErrorHandler(com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler) Test(org.junit.Test)

Example 18 with LoggingCSSParseErrorHandler

use of com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler in project ph-css by phax.

the class Issue8Test method testIssue8.

@Test
public void testIssue8() {
    final IReadableResource aRes = new ClassPathResource("testfiles/css30/good/issue8.css");
    assertTrue(aRes.exists());
    final CascadingStyleSheet aCSS = CSSReader.readFromStream(aRes, StandardCharsets.UTF_8, ECSSVersion.CSS30, new LoggingCSSParseErrorHandler());
    assertNotNull(aCSS);
    assertEquals(1, aCSS.getStyleRuleCount());
    final CSSStyleRule aStyleRule = aCSS.getStyleRuleAtIndex(0);
    assertNotNull(aStyleRule);
    assertEquals(4, aStyleRule.getDeclarationCount());
}
Also used : CascadingStyleSheet(com.helger.css.decl.CascadingStyleSheet) CSSStyleRule(com.helger.css.decl.CSSStyleRule) IReadableResource(com.helger.commons.io.resource.IReadableResource) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) LoggingCSSParseErrorHandler(com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler) Test(org.junit.Test)

Example 19 with LoggingCSSParseErrorHandler

use of com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler in project ph-css by phax.

the class IssueGC18Test method testIssue18.

@Test
public void testIssue18() {
    final IReadableResource aRes = new ClassPathResource("testfiles/css30/good/issue-gc-18.css");
    assertTrue(aRes.exists());
    final CascadingStyleSheet aCSS = CSSReader.readFromStream(aRes, StandardCharsets.UTF_8, ECSSVersion.CSS30, new LoggingCSSParseErrorHandler());
    assertNotNull(aCSS);
    if (false)
        System.out.println(new CSSWriter(ECSSVersion.CSS30).getCSSAsString(aCSS));
}
Also used : CascadingStyleSheet(com.helger.css.decl.CascadingStyleSheet) IReadableResource(com.helger.commons.io.resource.IReadableResource) CSSWriter(com.helger.css.writer.CSSWriter) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) LoggingCSSParseErrorHandler(com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler) Test(org.junit.Test)

Aggregations

CascadingStyleSheet (com.helger.css.decl.CascadingStyleSheet)19 LoggingCSSParseErrorHandler (com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler)19 Test (org.junit.Test)16 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)12 IReadableResource (com.helger.commons.io.resource.IReadableResource)12 CSSWriter (com.helger.css.writer.CSSWriter)12 CSSReaderSettings (com.helger.css.reader.CSSReaderSettings)9 File (java.io.File)4 FileSystemRecursiveIterator (com.helger.commons.io.file.FileSystemRecursiveIterator)3 CollectingCSSParseErrorHandler (com.helger.css.reader.errorhandler.CollectingCSSParseErrorHandler)3 CSSWriterSettings (com.helger.css.writer.CSSWriterSettings)2 Charset (java.nio.charset.Charset)2 ECSSVersion (com.helger.css.ECSSVersion)1 CSSDeclaration (com.helger.css.decl.CSSDeclaration)1 CSSExpressionMemberTermURI (com.helger.css.decl.CSSExpressionMemberTermURI)1 CSSImportRule (com.helger.css.decl.CSSImportRule)1 CSSStyleRule (com.helger.css.decl.CSSStyleRule)1 ICSSTopLevelRule (com.helger.css.decl.ICSSTopLevelRule)1 DefaultCSSUrlVisitor (com.helger.css.decl.visit.DefaultCSSUrlVisitor)1 LoggingCSSParseExceptionCallback (com.helger.css.handler.LoggingCSSParseExceptionCallback)1