diff --git a/static/js/markdown.js b/static/js/markdown.js index 8276faec..80b6f94a 100644 --- a/static/js/markdown.js +++ b/static/js/markdown.js @@ -439,6 +439,10 @@ $(function () { //对html进行预处理 function firstfilter(str) { + //处理一下html,忽略从WORD粘贴时特殊情况下尾部乱码 + if (/()/gi.test(str)) { + str = str.match(/()/gi)[0]; + } //去掉头部描述 return str.replace(/[\s\S]*<\/head>/gi, "") //去掉注释 @@ -508,8 +512,9 @@ $(function () { } if (!//i.test(a) && !/(rowspan|colspan)/i.test(a)) { //没有表头,将第一行作为表头 - const firstrow = "" + a.match(/[\s\S]*?(?=)/i)[0] + ""; - a = a.replace(/[\s\S]*?(?=)/i, "") + //修复,当表格只有一行时,正则错误 + const firstrow = "
" + a.match(/[\s\S]*?(<\/tr>)/i)[0] + ""; + a = a.replace(/[\s\S]*?(<\/tr>)/i, "") .replace(/
/, firstrow); } else if (//i.test(a) && /(rowspan|colspan)/i.test(a)) { a=a.replace(//, "");