Last active
December 13, 2021 11:15
-
-
Save marcus-at-localhost/a0baec722aefe68cf019bc31f120c3ac to your computer and use it in GitHub Desktop.
[Replace tags with HTML Purifier] http://htmlpurifier.org/ #dom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// include HTMLPurifier.php | |
$config = HTMLPurifier_Config::createDefault(); | |
$config->set('AutoFormat.RemoveEmpty', true); | |
$config->set('AutoFormat.AutoParagraph', true); | |
$config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true); | |
$config->set('CSS.AllowedProperties', array()); | |
$config->set('HTML.ForbiddenAttributes', array('*@class')); | |
// tag transformation | |
$def = $config->getHTMLDefinition(true); | |
$def->info_tag_transform['h2'] = new HTMLPurifier_TagTransform_Simple('strong'); | |
$purifier = new HTMLPurifier($config); | |
$content = $purifier->purify($content); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment