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

multiple <html> <body> #246

Open
ducktype opened this issue Jan 26, 2024 · 1 comment
Open

multiple <html> <body> #246

ducktype opened this issue Jan 26, 2024 · 1 comment

Comments

@ducktype
Copy link

ducktype commented Jan 26, 2024

Parsing html with multiple html and body tags is inconsistent with the resulting dom tree compared to html5 browsers

@akne1234
Copy link

akne1234 commented Jun 14, 2024

Same problem here...

My Sample HTML:
$str = '<h1>Hello Dompdf</h1><div><span>nice</span></div>'

Correct test with DomDocument created by my own:
$dom = new DOMDocument("1.0", $encoding);
$dom->preserveWhiteSpace = true;
$dom->loadHTML($str);
echo htmlspecialchars($dom->saveHTML());

=> Correct result:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"></head><body><h1>Hello Dompdf</h1><div><span>nice</span></div></body></html>

Problem with your HTML5 class:
$dom = $html5->loadHTML($str);
...
$doc->loadHTML($html5->saveHTML($dom), LIBXML_NOWARNING | LIBXML_NOERROR);

=> Wrong result with multiple html tags:
<!DOCTYPE html> <html><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><html><h1>Hello Dompdf<html><div><html><span>nice</span></html></div></html></h1></html></html>

Maybe html5 loadHTML creates wrong DomDocument-Object?

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