- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/format/texthelper.php
- Класс: Bitrix\Crm\Format\TextHelper
- Вызов: TextHelper::convertHtmlToBbCode
static function convertHtmlToBbCode($html)
{
$html = strval($html);
if($html === '')
{
return '';
}
$allow = [
'ANCHOR' => 'Y',
'BIU' => 'Y',
'IMG' => 'Y',
'QUOTE' => 'Y',
'CODE' => 'N',
'FONT' => 'Y',
'LIST' => 'Y',
'SMILES' => 'Y',
'NL2BR' => 'Y',
'VIDEO' => 'Y',
'TABLE' => 'Y',
'ALIGN' => 'Y',
'P' => 'Y',
'CUT_ANCHOR' => 'Y',
];
$result = (new \CTextParser())->convertHTMLToBB($html, $allow);
// \CTextParser leaves some html tags, escaping them instead of removing/transforming them
// remove those remaining tags, and escape the result for backwards compatibility
return htmlspecialcharsbx(strip_tags(htmlspecialcharsback($result)));
}