WyriHaximus / HtmlCompress

MIT License
78 stars 17 forks source link

Feature request: extend API to allow setting options on HtmlMin + to add patterns #86

Open abuyoyo opened 4 years ago

abuyoyo commented 4 years ago

Introduce compressor() method to HtmlCompressor interface. This will allow direct access to HtmlMin API.

$parser = \WyriHaximus\HtmlCompress\Factory::construct();
$htmlMinInstance = $parser->compressor();
$htmlMinInstance->doRemoveHttpPrefixFromAttributes();
$htmlMinInstance->doMakeSameDomainsLinksRelative(['example.com']);
$compressedHtml = $parser->compress($sourceHtml);

Introduce patterns() method to HtmlCompressor interface. Introduce add(PatternInterface $pattern) method to Patterns class. This will allow usage such as this:

$parser = \WyriHaximus\HtmlCompress\Factory::construct();
$patterns = $parser->patterns();
$patterns->add(CustomPatternThatImplementsPatternInterface);
$compressedHtml = $parser->compress($sourceHtml);