Skip to content

Commit

Permalink
Only use if masterminds/html5 is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
bytestream committed Jul 6, 2020
1 parent 725b49f commit 1bf6318
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@
"php": "~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0",
"ext-dom": "*",
"ext-libxml": "*",
"masterminds/html5": "^2.7",
"symfony/css-selector": "^3.4.32 || ^4.3.5 || ^5.0"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.2.0",
"slevomat/coding-standard": "^4.0.0",
"squizlabs/php_codesniffer": "^3.5.1"
},
"suggest": {
"masterminds/html5": "Use instead of PHP's built-in DOMDocument for HTML5 support."
},
"autoload": {
"psr-4": {
"Pelago\\Emogrifier\\": "src/"
Expand Down
3 changes: 2 additions & 1 deletion src/HtmlProcessor/AbstractHtmlProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ private function ensureExistenceOfBodyElement(): void
*/
private function isHtml5(string $html): bool
{
return \strspn($html, " \t\r\n") === \stripos($html, '<!doctype html>');
return \strspn($html, " \t\r\n") === \stripos($html, '<!doctype html>')
&& class_exists(HTML5::class);
}

/**
Expand Down

0 comments on commit 1bf6318

Please sign in to comment.