Replace the "Limit allowed HTML tags" and "Correct faulty and chopped off markup" filters with versions that are HTML5 aware.

This is needed for modules that are using, for instance, user-defined attributes (data-whatever) or HTML5 tags. embed_external needs this, and I'm sure other modules could use it as well.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cweagans’s picture

Status: Active » Needs review
FileSize
21.77 KB
joseph.olstad’s picture

Great work Cweagans, I had a quick look at the patch, it's using the masterminds html5 library, this is good. I'm assuming that we install the masterminds library into sites/all/libraries ?

I'll try to have a closer look at this patch next week and try it out.

Thanks again for the hard work and for sharing! So happy :)

cweagans’s picture

Yeah, it should live in sites/all/library/html5-php.

Note that the unit test for this removes the XHTML test cases and CDATA-related things. I also added tests for checking html5 tags and user-defined attributes.

Dave Reid’s picture

+++ b/html5_tools.admin.inc
@@ -94,6 +94,12 @@ function html5_tools_admin_settings() {
+  $form['html5_tools_overrides']['html5_tools_replace_filters'] = array(
+    '#type' => 'checkbox',
+    '#default_value' => variable_get('html5_tools_replace_filters', 1),
+    '#title' => t('Replace core text filters with HTML5-aware versions'),
+    '#description' => t('HTML5 Tools implements versions of the HTML Corrector filter and the Limit Allowed HTML Tags filter that are HTML5-aware.'),
+  );

Because this constitutes such a large change to the behaviors of filters, I would propose this variable is disabled by default. Our site is using this patch and encountered several errors in the process due to xautoload and not finding the right html5-php library classes that we have yet to be able to resolve. It would be nice if this module didn't suddenly take over the entire filter system.

sylus’s picture

I have made the minor change that Dave Reid requested which incidentally works well for me since am adding a custom patch to just make a whole new filter linked to a different text formatter. So can keep both alongside each other so can transition slowly.

This is now in Drupal 8 though am not sure whether there were concerns about html5-php not being a validating parser though I think there was mitigations.

Incidentally I did also have the xautoload + html5-php not being detected properly for a bit but some cache clears / debugging seemed to resolve it. Might be a race condition between xautoload and libraries_load?

Aside from that agreed thanks for the work!

dimaro’s picture

Update to run the tests.

Upps sorry for this coment, wrong issue.

sylus’s picture

I wanted instead of altering the default Drupal input filters to add two additional ones that could be used for a more phased approach. Attaching patch with minor addition of html5_tools_filter_info().

natew’s picture

Re-spin of #7 as I was running into issues applying this to 1.3