You can download and use it for free. But don't delete the copyright notice. You can read terms of the license.
YES if there is no answer in this Guide and if you are ready to share some informations such as : your configuration (platform Win *nix mac, PHP version, PEAR packages installed) and perharps your script.
You can report it with the bug tracker at PEAR.
CSS (an acronym for Cascading Style Sheets) is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
HTML_CSS is a PEAR package that provides methods for handling stylesheet declarations.
Version 1.0.0 does not offers yet methods to validate a style sheet.
PEAR (an acronym for PHP Extension and Application Repository) is a framework and distribution system for reusable PHP components.
Don't forget to read also the PEAR Manual and PEAR FAQ.
Yes it is. First, you need to download package PEAR::HTML_Common version 1.2 or greater.
Extract content (Common.php file) in same directory HTML/ as CSS.php file.
Last, you should create your own error handler, or disable it. See chapter Error Handler for details.
With previous release than 1.1.0 it was not possible because HTML_CSS::getStyle() require at least an existing property, or it will return HTML_CSS_ERROR_NO_ELEMENT_PROPERTY.
With new function HTML_CSS::grepStyle() of version 1.1.0, it's now possible.
01: <?php 02: require_once 'HTML/CSS.php'; 03: 04: function myErrorHandler() 05: { 06: return PEAR_ERROR_PRINT; // always print all error messages 07: } 08: 09: $styles = ' 10: h1, h2, h3, h4 { padding: 1em; } 11: .highlight p, .highlight ul { margin-left: .5em; } 12: #main p, #main ul { padding-top: 1em; } 13: '; 14: 15: $prefs = array( 16: 'push_callback' => 'myErrorHandler', 17: ); 18: $attribs = null; 19: 20: $css = new HTML_CSS($attribs, $prefs); 21: $css->parseString($styles); 22: 23: $css->getStyle('.highlight p', 'color'); 24: 25: $styles = $css->grepStyle('/highlight/', '/^color$/'); 26: echo '<pre>'; var_dump($styles); echo '</pre>'; 27: ?> |
Custom error handler is defined to allow script to continue (print message), when HTML_CSS::getStyle() will raise error at line 23.
Stylesheet used is :
h1, h2, h3, h4 { padding: 1em; } .highlight p, .highlight ul { margin-left: .5em; } #main p, #main ul { padding-top: 1em; } |
While HTML_CSS::getStyle() will raise error (printed by custom error handler), line 25 will return an empty array with no error raised.
Reason : color property does not exist for .highlight p class selector.