【问题标题】:cleditor content riddled with <span> tags充满 <span> 标签的 cleditor 内容
【发布时间】:2012-04-08 19:40:49
【问题描述】:

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

然而,它似乎随机地决定在我的内容中插入&lt;span class="Apple-style-span"&gt;

我在 Google 上做了一个快速搜索,找不到任何关于 cleditor 的内容,但显然 ckeditor 有一个 similar 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>

提前致谢,

【问题讨论】:

    标签: javascript cleditor


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-13
      • 2012-11-03
      • 2020-04-17
      • 2019-09-03
      相关资源
      最近更新 更多