You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Java CSS 2 and CSS 3 parser and builder. This version supersedes phloc-css.
8
-
The Maven plugin to compress CSS files at build time is located in sub-project ph-csscompress-maven-plugin and described further down.
7
+
Java-based CSS 3 parser and builder.
8
+
The Maven plugin to compress CSS files at build time is located in sub-module `ph-csscompress-maven-plugin` and described further down.
9
9
10
-
ph-css has no logic for applying CSS onto HTML elements. This page shows some basic code examples that can be used to use the library. All snippets are free for any use.
10
+
`ph-css` has no logic for applying CSS onto HTML elements. This page shows some basic code examples that can be used to use the library. All snippets are free for any use.
11
11
12
-
ph-css and ph-csscompress-maven-plugin are both licensed under the **Apache 2.0 license**.
12
+
`ph-css` and `ph-csscompress-maven-plugin` are both licensed under the **Apache 2.0 license**.
13
13
14
-
ph-css is used as a part of [Apache JMeter 3](https://github.com/apache/jmeter) :)
14
+
`ph-css` is used as a part of [Apache JMeter 3](https://github.com/apache/jmeter) :)
15
15
16
16
# Maven usage
17
17
@@ -25,7 +25,7 @@ Add the following to your pom.xml to use this artifact, replacing `x.y.z` with t
25
25
</dependency>
26
26
```
27
27
28
-
To build ph-css from source, Maven 3.0.4 is required. Any Maven version below does **NOT** work!
28
+
To build `ph-css` from source, Maven 3.x is required. Any Maven version below does **NOT** work!
29
29
30
30
# Documentation
31
31
@@ -39,16 +39,17 @@ Please look at my personal [Coding Styleguide](https://github.com/phax/meta/blob
39
39
40
40
A complete stylesheet is represented as an instance of `com.helger.css.decl.CascadingStyleSheet`. There is no difference between CSS 2.1 and CSS 3.0 instances. The class `com.helger.css.decl.CascadingStyleSheet` contains all top-level rules that may be present in a CSS:
* Any other unknown rules (`@foo`) - `com.helger.css.decl.CSSUnknownRule`
52
53
53
54
## CSS reading
54
55
@@ -66,10 +67,10 @@ Since v3.8.2 the class `com.helger.css.reader.CSSReaderSettings` is present and
66
67
### Recoverable Errors
67
68
ph-css differentiates between recoverable errors and unrecoverable errors. An example for a recoverable error is e.g. an `@import` rule in the wrong place or a missing closing bracket within a style declaration. For recoverable errors a special handler interface `com.helger.css.reader.errorhandler.ICSSParseErrorHandler` is present. You can pass an implementation of this error handler to the CSS reader (see above). The following implementations are present by default (all residing in package `com.helger.css.reader.errorhandler`):
68
69
69
-
*`DoNothingCSSParseErrorHandler` - silently ignoring all recoverable errors
70
-
*`LoggingCSSParseErrorHandler` - logging all recoverable errors to an SLF4J logger
71
-
*`ThrowingCSSParseErrorHandler` - throws a `com.helger.css.parser.ParseException` in case of a recoverable error which is afterwards handled by the unrecoverable error handler (see below). This can be used to enforce handling only 100% valid CSS files. This is the default setting, if no error handler is specified during reading.
72
-
*`CollectingCSSParseErrorHandler` - collects all recoverable errors into a list of `com.helger.css.reader.errorhandler.CSSParseError` instances for later evaluation.
70
+
*`DoNothingCSSParseErrorHandler` - silently ignoring all recoverable errors
71
+
*`LoggingCSSParseErrorHandler` - logging all recoverable errors to an SLF4J logger
72
+
*`ThrowingCSSParseErrorHandler` - throws a `com.helger.css.parser.ParseException` in case of a recoverable error which is afterwards handled by the unrecoverable error handler (see below). This can be used to enforce handling only 100% valid CSS files. This is the default setting, if no error handler is specified during reading.
73
+
*`CollectingCSSParseErrorHandler` - collects all recoverable errors into a list of `com.helger.css.reader.errorhandler.CSSParseError` instances for later evaluation.
73
74
74
75
Some error handlers can be nested so that a combination of a logging handler and a collecting handler can easily be achieved like:
75
76
@@ -85,8 +86,8 @@ Both `CSSReader` and `CSSReaderDeclarationList` have the possibility to define a
85
86
86
87
In case of an unrecoverable error, the underlying parser engine of JavaCC throws a `com.helger.css.parser.ParseException`. This exception contains all the necessary information on where the error occurred. In case of such an unrecoverable error, the result of the reading will always be `null` and the exception is not automatically propagated to the caller. To explicitly get notified when such a parse error occurs, the handler interface `com.helger.css.handler.ICSSParseExceptionCallback` is available. The available implementations are (all residing in package `com.helger.css.handler`):
87
88
88
-
*`DoNothingCSSParseExceptionHandler` - silently ignore all unrecoverable errors
89
-
*`LoggingCSSParseExceptionHandler` - log all unrecoverable errors to an SLF4J logger
89
+
*`DoNothingCSSParseExceptionHandler` - silently ignore all unrecoverable errors
90
+
*`LoggingCSSParseExceptionHandler` - log all unrecoverable errors to an SLF4J logger
90
91
91
92
As there is at most one unrecoverable error per parse there is no collecting implementation of an `ICSSParseExceptionCallback` available. If it is desired to propagate the Exception to the caller you need to implement your own `ICSSParseExceptionCallback` subclass that throws an unchecked exception (one derived from `RuntimeException`). Example:
92
93
@@ -146,7 +147,7 @@ All of these shorthand properties are registered in class `CSSShortHandRegistry`
0 commit comments