|  Download StyleParserThis PHP class reduces download overhead by excluding unused CSS classes. IntroductionStyleParseranalyses an HTML string and identifies the CSS styles being used. It then injects the corresponding classes from your own custom library directly back into the HTML<style>tag. If there is no<style>tag it will create one.
 StyleParserincludes an optional, responsive utility library that provides all the reusable classes you need to build a site using a simple and intuitive syntax. This utility library uses thedata-utilattribute, instead of the standardclassattribute, in order to keep utilities separate from your own custom classes. You can change the attribute by editingconfig.ini.
 Usage
Instantiate StyleParser:
$styleParser = new StyleParser();
Parse HTML:
$html = '<html>...</html>';
$modifiedHtml = $styleParser->parse($html);
Customisation:
- Modify configuration files to tailor the styling behaviour.
 Configuration FilesPlease note that classes must be written using PHP .inisyntax inside the config files, and not standard CSS syntax. 
`config.ini` for general settings.
`root.ini` for root styles whiach are applied globally.
`elements.ini` for standard CSS elements (e.g. `div`).
`custom.ini` for custom classes (e.g. `header-hero`).
`utilities.ini` for built-in utility attributes (e.g. `row(lc)s+`).
`resolutions.ini` for built-in utility media query resolutions.
 Dependencies
PHP: Requires PHP 7.0 or later.
DOMDocument: Uses the `DOMDocument` class for HTML parsing.
 Error HandlingThe class throws a RuntimeExceptionif parsing any configuration file fails. It is essential to handle this exception appropriately in your application. LicenseThis project is licensed under the MIT License. AcknowledgmentsFeel free to contribute, report issues, or suggest improvements! |