HTML净化器清除p标

HTML净化器清除p标

出于某种原因html净化器清除p标记。当p在span标记内时发生。
例如:

<span class=\"large gray content_text article_text\">
<p>111111</p>
<p>222222</p>
<p>333333</p>
</span>

输出:
<span>111111

2222222

3333333</span>

我的htmlpurifier配置:
$config = HTMLPurifier_Config::createDefault();
$config -> set('Core.Encoding', 'UTF-8');
$config -> set('HTML.Doctype', 'XHTML 1.0 Transitional');
$config -> set('HTML.TidyLevel','none');
$config -> set('HTML.Allowed', 'p, a[href|rel], span[style], img[src|style], object[height|width|data], param[name|value|allowscriptaccess|allowfullscreen|height|width], br, strong, em');
$config -> set('CSS.AllowedProperties', 'font-weight, font-style, text-decoration, color, width, height');
$config -> set('HTML.SafeObject', 'true');
$config -> set('Output.FlashCompat', 'true');
$config -> set('HTML.FlashAllowFullScreen', 'true');
$schemes = array('http' => true, 'https' => true);
$config -> set('URI.AllowedSchemes', $schemes);
$purifier = new HTMLPurifier($config);
$content = $purifier -> purify($content);

最佳答案

<span>是内联元素,在其中放置块级标记是不正确的。
使用<p>而不是<div>

关于php - HTML净化器清除p标签,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7104689/

10-12 13:35