Skip to content

Instantly share code, notes, and snippets.

View parzibyte's full-sized avatar
💻
Coding

Parzibyte parzibyte

💻
Coding
View GitHub Profile
@hubgit
hubgit / html-purifier-strict.php
Created August 18, 2010 15:21
strict purification of HTML using HTMLPurifier
<?php
$url = 'http://en.wikipedia.org/wiki/1,1,1-Trichloroethane'; // example
$config = HTMLPurifier_Config::createDefault();
$config->set('URI.Base', $url); // set the base URL (overrides a <base element in the HTML head?)
$config->set('URI.MakeAbsolute', true); // make all URLs absolute using the base URL set above
$config->set('AutoFormat.RemoveEmpty', true); // remove empty elements
$config->set('HTML.Doctype', 'XHTML 1.0 Strict'); // valid XML output (?)
$config->set('HTML.AllowedElements', array('p', 'div', 'a', 'br', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'ul', 'ol', 'li', 'b', 'i'));