-
Notifications
You must be signed in to change notification settings - Fork 114
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
HTML5 Tools + Drupal 7 + HTML5 PHP breaks </address> tag #109
Comments
@sylus Can you point me to the code using If you look in I'm curious where this is happening. |
Hey thanks for the response! :) We are using a patch to get html5_tools to work with html5-php from this issue: http://drupal.org/node/2415305 When looking at the markup for the body field in devel I see the following: value (String, 40 characters ) <address>Testing address tag</address>
...
safe_value (String, 39 characters ) <address>Testing address tag So it is only the safe_value which has the issue and gets called by the following: function html5_tools_filter_info() {
...
$filters['filter_html5corrector'] = array(
'title' => t('Correct faulty and chopped off HTML5'),
'process callback' => '_html5_tools_filter_htmlcorrector',
'weight' => 10,
);
...
} /**
* Implements callback_filter_process().
*
* Scans the input and makes sure that HTML tags are properly closed.
*/
function _html5_tools_filter_htmlcorrector($text) {
return html5_tools_filter_dom_serialize(html5_tools_filter_dom_load($text));
} function html5_tools_filter_dom_serialize($dom_document) {
$body_node = $dom_document->getElementsByTagName('body')->item(0);
$body_content = '';
foreach ($body_node->getElementsByTagName('script') as $node) {
filter_dom_serialize_escape_cdata_element($dom_document, $node);
}
foreach ($body_node->getElementsByTagName('style') as $node) {
filter_dom_serialize_escape_cdata_element($dom_document, $node, '/*', '*/');
}
$html5 = html5_tools_get_html5_instance();
foreach ($body_node->childNodes as $child_node) {
$body_content .= $html5->saveHTML($child_node);
}
return preg_replace('|<([^> ]*)/>|i', '<$1 />', $body_content);
} function html5_tools_filter_dom_load($text) {
$html5 = html5_tools_get_html5_instance();
$text = <<<EOL
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>$text</body>
</html>
EOL;
$dom_document = $html5->loadHTML($text);
return $dom_document;
} If i don't use that filter then the issues goes away. Hope this helps! |
I believe I have reduced it down to this:
Where $body_content is returned as: <address>Example
<video src="http://www.google.com"> </video> Noticably the video gets fixed but address isn't. |
When I changed the following: "address" => 89, // NORMAL | VOID_TAG | AUTOCLOSE_P | BLOCK_TAG to "address" => 65, // NORMAL | BLOCK_TAG I then got correct output. <address>Example</address>
<video src="http://www.google.com"> </video> |
Looking at the spec for address I see that neither the start or end tag can be omitted. I'm not sure why @sylus Do you want to update this on master and the 2.x branch or shall I? I'm always open to PRs. "address" => 65, // NORMAL | BLOCK_TAG |
Thanks a bunch submitted a P.R. ^_^ |
Version 2.2.1 has been released with this fix included. Thanks for the contribution. |
Thank you for the awesomeness that is html5-php :) |
It seems when using HTML5 Tools + HTML5 PHP for Drupal 7 that address tags are broken.
We originally added the HTML5 PHP library to fix issues with video tags which worked. Except now it has been proven when saving a piece of content with the opening + closing address tags that the closing tags get removed on node render. CKEditor source view shows the close address tag as still present. On node view and inspect page source the closing address tag is removed.
Was wondering if had any ideas about this? ^_^
The text was updated successfully, but these errors were encountered: