欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

Ueditor 中 pre的空格会转换成nbsp

获取编辑器的内容

var str = UE.getEditor('container').getContent();

Ueditor中pre块部分会出现换行后,无法用正则表达式识别代码块的问题。

解决方案:用br去替换换行

str = str.replace(/[\r\n]/g, "<br />");

Ueditor中<pre></pre>里面的空格会转换成&nbsp问题

解决方案:用空格去替换&nbsp;

str = str.replace(/&nbsp;/g, " ");

<pre></pre>中没有被转义&nbsp的空格

str = str.replace(/^\s\s*/, '').replace(/\s\s*$/, '')

每次打开编辑器时,点击html,发现ueditor总是在文本前后增加<p><br>。这个问题我已经解决了,分享下经验。并非是ueditor的问题,而是代码中编辑器内容前后各有回车,ueditor将这2个回车自动转换为<p></p><br/>的形式了,如:

<script id="context" name="context" type="text/plain"> ${absKnows.context} </script>

正确的写法应该是:

<script id="context" name="context" type="text/plain">${absKnows.context}</script>

来自 https://jingyan.baidu.com/article/d7130635c7896313fdf47511.html

普通分类: