コード例 #1
0
  public String process(String css) {
    CascadingStyleSheet cascadingStyleSheet =
        CSSReader.readFromString(
            css,
            CCharset.CHARSET_UTF_8_OBJ,
            ECSSVersion.CSS30,
            new DoNothingCSSParseErrorHandler());

    processRules(cascadingStyleSheet.getAllRules());

    return _cssWriter.getCSSAsString(cascadingStyleSheet);
  }
コード例 #2
0
  protected String formatCss(String css) {
    CascadingStyleSheet cascadingStyleSheet =
        CSSReader.readFromString(
            css,
            CCharset.CHARSET_UTF_8_OBJ,
            ECSSVersion.CSS30,
            new DoNothingCSSParseErrorHandler());

    CSSWriterSettings cssWriterSettings = new CSSWriterSettings(ECSSVersion.CSS30, false);

    cssWriterSettings.setOptimizedOutput(false);
    cssWriterSettings.setRemoveUnnecessaryCode(Boolean.TRUE);

    CSSWriter cssWriter = new CSSWriter(cssWriterSettings);

    return cssWriter.getCSSAsString(cascadingStyleSheet);
  }