Javascript CKEditor插入<;q>;总之<;p>;

Javascript CKEditor插入<;q>;总之<;p>;,javascript,html,ckeditor,Javascript,Html,Ckeditor,我正在一个中应用CKEditor,内容如下: <q> <p>this is paragraph one.</p> <p>this is paragraph two.</p> </q> 这是第一段 这是第二段 所以,我想引用所有这些段落。但是,当我应用CKEditor时,上面的HTML将在以下HTML中转换: <q> <p><q>this is paragraph one.</q

我正在一个
中应用CKEditor,内容如下:

<q>
<p>this is paragraph one.</p>
<p>this is paragraph two.</p>
</q>

这是第一段

这是第二段

所以,我想引用所有这些段落。但是,当我应用CKEditor时,上面的HTML将在以下HTML中转换:

<q>
<p><q>this is paragraph one.</q></p>
<p><q>this is paragraph two.</q></p>
</q>

这是第一段

这是第二段

这是我创建CKEditor实例的函数:

function create_ckeditor_instance(comment) {
    comment = '<q>' + comment.trim() + '</q>';

    var html = '<textarea rows="5" cols="80" id="reply-textarea">';
    html += comment;
    html += "</textarea>";

    $('reply-comment-wrapper').html(html);

    CKEDITOR.replace('reply-textarea');

    CKEDITOR.instances['reply-textarea'].on('instanceReady', function (event) {
      var range = CKEDITOR.instances['reply-textarea'].createRange();
      range.moveToPosition( range.root, CKEDITOR.POSITION_BEFORE_END );
      CKEDITOR.instances['reply-textarea'].getSelection().selectRanges( [ range ] );
      CKEDITOR.instances['reply-textarea'].focus();
    });

}
function create\u ckeditor\u实例(注释){
comment=''+comment.trim()+'';
var html='';
html+=注释;
html+=“”;
$('reply-comment-wrapper').html(html);
CKEDITOR.replace('reply-textarea');
CKEDITOR.instances['reply-textarea'].on('instancerady',函数(事件){
var range=CKEDITOR.instances['reply-textarea'].createRange();
range.moveToPosition(range.root、CKEDITOR.POSITION\u在\u结束之前);
CKEDITOR.instances['reply-textarea'].getSelection().selectRanges([range]);
CKEDITOR.instances['reply-textarea'].focus();
});
}
我的问题是,如何避免CKEditor的这种行为

的内容模型是,但元素是,并且从那时起不是
的有效子元素

您需要使用

外部的
在我看来像是一个bug,但我不能在这里复制它,使用当前版本的CKEditor

但它被转化为:

<p><q>this is paragraph one.</q></p>
<p><q>this is paragraph two.</q></p>
这是第一段

这是第二段

是正确的,因为围绕这两个
包装
会产生无效的代码。

的内容模型是,但元素是,因此不是
的有效子元素

您需要使用

外部的
在我看来像是一个bug,但我不能在这里复制它,使用当前版本的CKEditor

但它被转化为:

<p><q>this is paragraph one.</q></p>
<p><q>this is paragraph two.</q></p>
这是第一段

这是第二段


是正确的,因为在这两个
周围包装
会产生无效的代码。

很好,当我使用比预期更好的一切时!!:D@VitorLuis需要注意的是:CKEditor无法处理(至少上次我检查时)like
,而在HTML5中使用
测试是有效的,当我使用的一切都比预期的好时,CKEditor也会对您的示例中的like进行同样的处理,将其转换为
测试
,而在HTML5中,让
测试测试是有效的,在您的示例中,CKEditor对like做了相同的处理,将其转换为
测试