I am needing the code that will allow my users to input centered text and not have htmlpurifier strip it out.
Thanks!
Grabbing half the answer from your(?) HTML Purifier thread:
$config = HTMLPurifier_Config::createDefault();
$config->set('CSS.AllowedProperties', 'text-align');
$purifier = new HTMLPurifier($config);
That's the first step. If you want to disallow anything but center as in that thread, you would change the CSS AttrDef for text-align:
$css = $purifier->getCSSDefinition();
$css->info['text-align'] = new HTMLPurifier_AttrDef_Enum(array('center'));
// should allow text-align:center but not text-align:right or the likes:
$purifier->purify(/* ... */);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With