From 5135b82370b91d80e977162f6063bef73cdf0287 Mon Sep 17 00:00:00 2001 From: cnspray Date: Fri, 6 Mar 2020 14:47:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=8C=E5=BD=93=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E5=8F=AA=E6=9C=89=E4=B8=80=E8=A1=8C=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=AD=A3=E5=88=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/markdown.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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(//, "");