Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing end head tag </head> from file... #96

Open
paquette-codes opened this issue Jan 21, 2024 · 1 comment
Open

removing end head tag </head> from file... #96

paquette-codes opened this issue Jan 21, 2024 · 1 comment

Comments

@paquette-codes
Copy link

What is this feature about (expected vs actual behaviour)?

when using $html->minify($htmlstring) and/or with other methods, it keep removing the tag from the string... resulting on a wrong html structure.

How can I reproduce it?

try this html:

<!DOCTYPE html>
<html lang="en">
<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
this is a test
</body>
</html>
@manofstrong
Copy link

A hacky workaround to handle this; for future people facing the same issue; use reflection to ensure the private optional_end_tags array is empty.

                $htmlMin = new HtmlMin();

                $reflection = new \ReflectionClass($htmlMin);

                $property = $reflection->getProperty('optional_end_tags');

                $property->setAccessible(true);

                $property->setValue($htmlMin, []);

                $minified_html = $htmlMin->minify($original_html);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants