Try using this code (it allows you to use <i> , <b> and <del> ):
<?php $html = '<b>Inline <del>context <div>No block allowed <great going </div></del></b>'; function escapeEveryOther(&$v, $k) { if($k % 2 == 0) { $v = htmlspecialchars($v); } } $parts = preg_split('`(</?(?:b|i|del)>)`is', $html, -1, PREG_SPLIT_DELIM_CAPTURE); array_walk($parts, 'escapeEveryOther'); $html = implode('', $parts);
and then pass $html via HTMLPurifier to fix inconsistent opening and closing tags.
source share