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

Add masterminds/html5 #210

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bytestream
Copy link

This PR adds optional usage of masterminds/html5 similar to the implementation in symfony/dom-crawler. This resolves some quirks when saving HTML documents with DOMDocument for example an anchor wrapping a table <a><table></table></a> becomes <table></table><a></a>

Opt-in usage - pass true to the constructor argument. This differs to symfony/dom-crawler for the sake of backwards compatibility i.e. users who already have masterminds/html5 as a project dependency

$cssToInlineStyles = new CssToInlineStyles(true);

Closes #195

*/
protected function parseHtml5($html)
{
$this->isHtml5Document = strspn($html, " \t\r\n") === stripos($html, '<!doctype html>');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks wrong to me. It is still using the HTML5 parser even when this is false

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way I implemented is the same as symfony/dom-crawler. It did seem a little odd to me. I'll change it if you want?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking at an old version. I've updated it 👍

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

Successfully merging this pull request may close these issues.

Use HTML5 parser instead of DOMDocument
2 participants