CSSdoc has been designed to be as simple to use as possible, but with enough configuration options to control the output more closely.
CSSdoc is configured only through the minify and output options, there is not other configuration.
CSS can be loaded in two ways, either from a string, or from a stream:
$css = '#test {
font-weight: bold;
color: red;
}'; // can be a snippet
$charset = mb_internal_encoding(); // UTF-8?
$doc = new \hexydec\css\cssdoc();
if ($doc->load($html, $charset)) {
// do something
}
$url = 'https://github.githubassets.com/assets/github-12ad3ce380b8369cc49199a0e1805f6c.css';
$context = stream_context_create([
'http' => [
'user-agent' => 'My CSS Bot 1.0 (Mozilla Compatible)',
'timeout' => 10
]
]);
$doc = new \hexydec\css\cssdoc();
if ($doc->open($url, $context, $error)) {
// do something
} else {
trigger_error('Could not parse CSS: '.$error, E_USER_WARNING);
}
For more information, see the API documentation for the load()
method and the open()
method.