Groundskeeper will clean your weedy HTML.
Groundskeeper will clean your weedy HTML.
Via Composer
$ composer require kevintweber/groundskeeper
Here is a simple example:
use Groundskeeper\Groundskeeper;
$groundskeeper = new Groundskeeper(array(
'output' => 'pretty'
));
$groundskeeper->setLogger($myLogger); // Optional: will log changes to your HTML.
$cleanHtml = $groundskeeper->clean($dirtyHtml);
clean-strategy
: Describes how the HTML document will be cleaned.none
, lenient
, standard
, aggressive
; Default: standard
none
- No cleaning will be done.lenient
- Like standard
except no markup will be removed.standard
- Standard compliant HTML will be output. Unfixable malformed HTML will be removed.aggressive
- Like “standard” plus non-standard elements will be removed. (TODO)element-blacklist
: Describes which elements will be removed from the output.indent-spaces
: The number of spaces for indentation when using pretty output.output
: Describes how the HTML will be output.compact
, pretty
; Default: compact
compact
- Will remove all whitespace between elements, and will set indent-spaces
to 0.pretty
- One element per line with indentation. Handy for debugging.type-blacklist
: Describes which token types will be removed from the output.cdata
, comment
, doctype
, element
, php
, text
; Default: cdata,comment
aggressive
cleaning strategy.pretty
output should inline certain elements.Please see CHANGELOG for more information what has changed recently.
$ phpunit
Please see CONTRIBUTING for details.
If you discover any security related issues, please email kevintweber@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.