首页 > 其他 > 详细

KindEditor自动过滤首行缩进和全角空格的解决方法

时间:2018-08-14 00:50:40      阅读:296      评论:0      收藏:0      [点我收藏+]

KindEditor 4.1.11:
kindeditor-all.js 文件中大致第752行:

/(\s*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"‘<>]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+=‘[^‘]*‘))*)(\/)?>(\s*)/g;

kindeditor-all-min.js 文件中通过/(\s*)搜索:

var h=/(\s*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"‘<>]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+=‘[^‘]*‘))*)(\/)?>(\s*)/g

赋值的正则表达式替换为:

/([\f\n\r\t\v]*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"‘<>]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+=‘[^‘]*‘))*)(\/)?>([ \f\n\r\t\v]*)/g

简单来说,就是把第一个和最后一个 \s 替换成 [ \f\n\r\t\v]

 

KindEditor 4.1.10:

kindeditor.js 文件的第754行:

var re = /(\s*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"‘<>]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+=‘[^‘]*‘))*)(\/)?>(\s*)/g;

改为

var re = /([ \f\n\r\t\v]*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"‘<>]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+=‘[^‘]*‘))*)(\/)?>([ \f\n\r\t\v]*)/g;

 

KindEditor自动过滤首行缩进和全角空格的解决方法

原文:https://www.cnblogs.com/dudumao/p/9471896.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!