cleditor内容充斥着<span>标签</span>

时间:2012-03-27 11:59:08

标签: javascript cleditor

我在WordPress插件中使用cleditor作为我的富文本编辑器。

然而,似乎是随机的,它决定将<span class="Apple-style-span">插入我的内容。

我做了一个快速的Google,找不到cleditor的任何内容,但显然ckeditorsimilar bug on Webkit browsers - 我网站上的两位内容作者都使用Google Chrome。这是logged as a bug with webkit

有没有人知道如何解决此问题,而不是在保存或查看内容时执行PHP str_replace

以下是输出示例:

<h2 id="notes" class="profile_notes">Notes</h2>
<p>
    <span class="Apple-style-span" style="background-color: rgb(255, 255, 255); ">
        <div>
            This species is assigned the codes A220, A221 and A222 under the DATZ 'A' number system with these referring to similar-looking, possibly conspecific, populations. These differ in some aspects of colour pattern, particularly the orientation of the caudal-fin markings which may be horizontal, vertical, or somewhere inbetween.
        </div>
        <div>
            <br>
        </div>
        <div>
            One population displays an orange colouration on the belly and is sometimes referred to as A. mendezi 'orange' (A222) while another known as A. sp. 'fork-band' or 'gabelband' and collected in the rio Jaú may also represent a form of A. mendezi.
        </div>
        <div>
            <span class="Apple-style-span" style="background-color: rgb(255, 255, 255); ">
                <br>
            </span>
        </div>
            Apistogramma&nbsp;is...
        </div>
    </span>
</p>

提前致谢,

1 个答案:

答案 0 :(得分:1)

这是在javascript中调用execcommand时出现的“功能”(在不同的浏览器中显示不同的结果),在http://www.quirksmode.org/dom/execCommand.html

中有用地汇总

我不知道这是否可以在浏览器中被规避,但我对此表示怀疑。最好的方法是使用lxml或BeautifulSoup删除后端中的“违规”HTML类。