Skip to content

Instantly share code, notes, and snippets.

@ctrl-freak
Created September 2, 2011 08:02
Show Gist options
  • Save ctrl-freak/1188139 to your computer and use it in GitHub Desktop.
Save ctrl-freak/1188139 to your computer and use it in GitHub Desktop.
HTML Purifier Configuration
<?
$purifier_config = HTMLPurifier_Config::createDefault();
$purifier_config->set('HTML.AllowedElements', 'p, a, ul, ol, li, h1, h2, h3, h4, h5, h6, br, strong, em, b, i');
$purifier_config->set('HTML.AllowedAttributes', '');
$purifier_config->set('CSS.AllowedProperties', '');
$purifier_config->set('AutoFormat.RemoveEmpty', true);
$purifier_config->set('AutoFormat.AutoParagraph', true);
// May cause problems with empty table cells and headers
$purifier_config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
$purifier = new HTMLPurifier($purifier_config);
$content = $purifier->purify($content);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment