HTML Purifier - how keep css "margin-left: calc(25%)"

443 Views Asked by At

I'm using HTML purifier in a wysiwyg editor and inline css rule like "margin-left: calc(25%);" is being removed. If the rule is "margin-left: 25%;" it is not removed, however this rule is set automatically by the editor.

I dont know how config the HTML purifier to not remove the margin if it has a calc function.

If it matters, I'm using Yii2 and \yii\helpers\HtmlPurifier https://www.yiiframework.com/doc/api/2.0/yii-helpers-htmlpurifier that uses HTML Purifier (http://htmlpurifier.org)

I also tried to keep all inline css with following code, but nothing has changed.

    $model->msg_email = \yii\helpers\HtmlPurifier::process($model->msg_email, function ($config) {
        $config->set('CSS.Trusted', true); // allow any css
        $config->set('Filter.ExtractStyleBlocks.TidyImpl', false);
    });

Ps.: I tagged csstidy because could be some config in it.(internally used from HTML Purifier)

0

There are 0 best solutions below