Welcome! » Log In » Create A New Profile

HTML5 Support?

Posted by Peter Nguyen 
Peter Nguyen
HTML5 Support?
April 24, 2010 01:45AM

Hi,

when will HTML Purifier support HTML5? For example tags like , and end tags without slashes e.g. ?

Re: HTML5 Support?
April 24, 2010 01:51AM

Sometime in the distant future, when I have time and inclination to put in the dev work to make it happen... (do you want to help?!)

Peter Nguyen
Re: HTML5 Support?
May 06, 2010 04:09AM

Yes, I would love to help. How do we start?

Re: HTML5 Support?
May 06, 2010 04:21AM

The first step is implementing the HTML5 parsing algorithm. I've done part of the work in html5lib, but of late the parser there has fallen out of date, and needs to be updated with the spec.

Then we need to make HTML Purifier use the html5lib parser. There's also a show-stopper bug, which is that there doesn't seem to be a good way of passing around XML namespace information from DOM.

Benjamin "balupton" Lupton
Re: HTML5 Support?
June 13, 2010 12:12AM

I too would like HTML5 support.

I'm already using the PH5P lexer as indicated I should use in the changelogs if I wanted HTML5 support, but alas it does not help.

I tried the following, but still no avail.

				$Definition = $Config->getHTMLDefinition(true);
				$Definition->addElement(
					'section',		// name
					'Block',		// content set
					'Flow',			// allowed children
					'Common'		// attribute collection
				);
				$Definition->addElement(
					'header',		// name
					'Block',		// content set
					'Flow',			// allowed children
					'Common'		// attribute collection
				);
Re: HTML5 Support?
June 13, 2010 12:25AM

Can you post your full config? It should be possible to get ad hoc support for HTML5 elements.

Benjamin "balupton" Lupton
Re: HTML5 Support?
June 21, 2010 02:09AM

Hi Ambush,

Here is the configuration being used with HTML Purifier 4.1.1:

	require_once(HTMLPURIFIER_PATH.'/HTMLPurifier.auto.php');
	require_once(HTMLPURIFIER_PATH.'/HTMLPurifier/Lexer/PH5P.php');
				$Config = HTMLPurifier_Config::createDefault();
				$Config->set('HTML.AllowedAttributes', null);
				$Config->set('AutoFormat.AutoParagraph', false);
				$Config->set('AutoFormat.Linkify', false);
				$Config->set('Core.LexerImpl', 'PH5P');
				$Purifier = HTMLPurifier::getInstance();
				$value = $Purifier->purify($value, $Config);

This will work fine, however it will turn:

<section class="section" id="step1">
<h1>1. Modifying nav.json</h1>
...

into:

<h1>1. Modifying nav.json</h1>
...

so it will strip all the html5 elements.

Hence my attempt to add them, via the configuration in my previous message.

Re: HTML5 Support?
June 22, 2010 07:08PM

Where are you loading the custom definition? Could you copy and paste your code verbatim?

Sorry, you do not have permission to post/reply in this forum.