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
The charset is used only if no @charset declaration is found in the CSS file. UTF-8 is the default, so you won’t have to create a settings object at all if you don’t intend to change that.
22
+
new Sabberworm\CSS\Parser($sText);
26
23
27
24
To read a file, for example, you’d do the following:
28
25
@@ -31,12 +28,28 @@ To read a file, for example, you’d do the following:
31
28
32
29
The resulting CSS document structure can be manipulated prior to being output.
33
30
34
-
### Strict parsing
31
+
### Options
32
+
33
+
#### Charset
34
+
35
+
The charset option is used only if no @charset declaration is found in the CSS file. UTF-8 is the default, so you won’t have to create a settings object at all if you don’t intend to change that.
To have the parser choke on invalid rules, supply a Sabberworm\CSS\Settings object:
40
+
#### Strict parsing
41
+
42
+
To have the parser choke on invalid rules, supply a thusly configured Sabberworm\CSS\Settings object:
37
43
38
44
$oCssParser = new Sabberworm\CSS\Parser(file_get_contents('somefile.css'), Sabberworm\CSS\Settings::create()->beStrict());
39
45
46
+
#### Disable multibyte functions
47
+
48
+
To achieve faster parsing, you can choose to have PHP-CSS-Parser use regular string functions instead of `mb_*` functions. This should work fine in most cases, even for UTF-8 files, as all the multibyte characters are in string literals. Still it’s not recommended to use this with input you have no control over as it’s not thoroughly covered by test cases.
The resulting data structure consists mainly of five basic types: `CSSList`, `RuleSet`, `Rule`, `Selector` and `Value`. There are two additional types used: `Import` and `Charset` which you won’t use often.
0 commit comments