(str)
| 565 | |
| 566 | //对html进行预处理 |
| 567 | function firstfilter(str) { |
| 568 | //处理一下html,忽略从WORD粘贴时特殊情况下尾部乱码 |
| 569 | if (/(<html[\s\S]*<\/html>)/gi.test(str)) { |
| 570 | str = str.match(/(<html[\s\S]*<\/html>)/gi)[0]; |
| 571 | } |
| 572 | //去掉头部描述 |
| 573 | return str.replace(/<head>[\s\S]*<\/head>/gi, "") |
| 574 | //去掉注释 |
| 575 | .replace(/<!--[\s\S]*?-->/ig, "") |
| 576 | //去掉隐藏元素 |
| 577 | .replace(/<([a-z0-9]*)[^>]*\s*display:none[\s\S]*?><\/\1>/gi, ''); |
| 578 | } |
| 579 | |
| 580 | |
| 581 | //去除冗余属性和标签 |