P
P
po472021-06-02 11:57:48
Yii
po47, 2021-06-02 11:57:48

How to disable span tag/allow only p tag via HtmlPurifier?

The text for the block on the site is filled through the admin panel, where it is possible to edit the text styles. In my case, I would like it not to be displayed. Now the text on the page looks like this:

<p>
<span style="font-size:24pt;"> текст </span>
</p>


Tried
<?php HtmlPurifier::process($text->getText(), function ($config) {
                                            $config->getHTMLDefinition(true)->addAttribute('p', 'class', 'Text');
                                        });?>


Does not work.
What are the solutions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
po47, 2021-06-03
@po47

We solved the problem with a regular expression:
preg_replace('/\s?style=["][^"]*"\s?/i', ' ', $text)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question