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
Copy file name to clipboardExpand all lines: README.md
+14-16Lines changed: 14 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ The resulting CSS document structure can be manipulated prior to being output.
33
33
34
34
#### Charset
35
35
36
-
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.
36
+
The charset option will only be used if the CSS file does not contain an `@charset` declaration. 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.
37
37
38
38
```php
39
39
$settings = \Sabberworm\CSS\Settings::create()
@@ -69,29 +69,26 @@ The resulting data structure consists mainly of five basic types: `CSSList`, `Ru
69
69
70
70
#### CSSList
71
71
72
-
`CSSList` represents a generic CSS container, most likely containing declaration blocks (rule sets with a selector), but it may also contain at-rules, charset declarations, etc.`CSSList` has the following concrete subtypes:
72
+
`CSSList` represents a generic CSS container, most likely containing declaration blocks (rule sets with a selector), but it may also contain at-rules, charset declarations, etc.
73
73
74
-
*`Document` – representing the root of a CSS file.
75
-
*`MediaQuery` – represents a subsection of a `CSSList` that only applies to an output device matching the contained media query.
76
-
77
-
To access the items stored in a `CSSList` – like the document you got back when calling `$parser->parse()` –, use `getContents()`, then iterate over that collection and use instanceof to check whether you’re dealing with another `CSSList`, a `RuleSet`, a `Import` or a `Charset`.
74
+
To access the items stored in a `CSSList` – like the document you got back when calling `$parser->parse()` –, use `getContents()`, then iterate over that collection and use `instanceof` to check whether you’re dealing with another `CSSList`, a `RuleSet`, a `Import` or a `Charset`.
78
75
79
76
To append a new item (selector, media query, etc.) to an existing `CSSList`, construct it using the constructor for this class and use the `append($oItem)` method.
80
77
81
78
#### RuleSet
82
79
83
80
`RuleSet` is a container for individual rules. The most common form of a rule set is one constrained by a selector. The following concrete subtypes exist:
84
81
85
-
*`AtRuleSet` – for generic at-rules which do not match the ones specifically mentioned like`@import`, `@charset` or `@media`. A common example for this is `@font-face`.
82
+
*`AtRuleSet` – for generic at-rules for generic at-rules which are not covered by specific classes, i.e., not`@import`, `@charset` or `@media`. A common example for this is `@font-face`.
86
83
*`DeclarationBlock` – a `RuleSet` constrained by a `Selector`; contains an array of selector objects (comma-separated in the CSS) as well as the rules to be applied to the matching elements.
87
84
88
85
Note: A `CSSList` can contain other `CSSList`s (and `Import`s as well as a `Charset`), while a `RuleSet` can only contain `Rule`s.
89
86
90
-
If you want to manipulate a `RuleSet`, use the methods `addRule(Rule $rule)`, `getRules()` and `removeRule($rule)` (which accepts either a `Rule`instance or a rule name; optionally suffixed by a dash to remove all related rules).
87
+
If you want to manipulate a `RuleSet`, use the methods `addRule(Rule $rule)`, `getRules()` and `removeRule($rule)` (which accepts either a `Rule` or a rule name; optionally suffixed by a dash to remove all related rules).
91
88
92
89
#### Rule
93
90
94
-
`Rule`s just have a key (the rule) and a value. These values are all instances of a `Value`.
91
+
`Rule`s just have a string key (the rule) and a `Value`.
95
92
96
93
#### Value
97
94
@@ -100,21 +97,22 @@ If you want to manipulate a `RuleSet`, use the methods `addRule(Rule $rule)`, `g
100
97
*`Size` – consists of a numeric `size` value and a unit.
101
98
*`Color` – colors can be input in the form #rrggbb, #rgb or schema(val1, val2, …) but are always stored as an array of ('s' => val1, 'c' => val2, 'h' => val3, …) and output in the second form.
102
99
*`CSSString` – this is just a wrapper for quoted strings to distinguish them from keywords; always output with double quotes.
103
-
*`URL` – URLs in CSS; always output in URL("") notation.
100
+
*`URL` – URLs in CSS; always output in `URL("")` notation.
101
+
102
+
There is another abstract subclass of `Value`, `ValueList`: A `ValueList` represents a lists of `Value`s, separated by some separation character (mostly `,`, whitespace, or `/`).
104
103
105
-
There is another abstract subclass of `Value`, `ValueList`. A `ValueList` represents a lists of `Value`s, separated by some separation character (mostly `,`, whitespace, or `/`). There are two types of `ValueList`s:
104
+
There are two types of `ValueList`s:
106
105
107
-
*`RuleValueList` – The default type, used to represent all multi-valued rules like `font: bold 12px/3 Helvetica, Verdana, sans-serif;` (where the value would be a whitespace-separated list of the primitive value `bold`, a slash-separated list and a comma-separated list).
106
+
*`RuleValueList` – The default type, used to represent all multivalued rules like `font: bold 12px/3 Helvetica, Verdana, sans-serif;` (where the value would be a whitespace-separated list of the primitive value `bold`, a slash-separated list and a comma-separated list).
108
107
*`CSSFunction` – A special kind of value that also contains a function name and where the values are the function’s arguments. Also handles equals-sign-separated argument lists like `filter: alpha(opacity=90);`.
109
108
110
109
#### Convenience methods
111
110
112
-
There are a few convenience methods on Document to ease finding, manipulating and deleting rules:
111
+
There are a few convenience methods on `Document` to ease finding, manipulating and deleting rules:
113
112
114
-
*`getAllDeclarationBlocks()` – does what it says; no matter how deeply nested your selectors are. Aliased as `getAllSelectors()`.
115
-
*`getAllRuleSets()` – does what it says; no matter how deeply nested your rule sets are.
113
+
*`getAllDeclarationBlocks()` – does what it says; no matter how deeply nested the selectors are. Aliased as `getAllSelectors()`.
114
+
*`getAllRuleSets()` – does what it says; no matter how deeply nested the rule sets are.
116
115
*`getAllValues()` – finds all `Value` objects inside `Rule`s.
117
-
*`getSelectorsBySpecificity(int: $specificity)` - finds all selectors with the requested specificity. `$specificity` is an integer with `1` being the highest specificity value. The method behaves just like `getAllDeclarationBlocks()` if no parameter is passed.
0 commit comments