Optimize clearMD() logic.

This commit is contained in:
Kenshin 2018-08-24 15:10:57 +08:00
parent a4b627fa53
commit 014ea8abab

View File

@ -119,9 +119,12 @@ function md2enml( result ) {
* Clear Html to MD, erorr <tag>
*
* @param {string} convert string
* @param {boolen} header
*
* @return {string} format string
*/
function clearMD( str ) {
str = `> 本文由 [简悦 SimpRead](http://ksria.com/simpread/) 转码, 原文地址 ${ window.location.href } \r\n\r\n ${str}`;
function clearMD( str, header = true ) {
header && ( str = `> 本文由 [简悦 SimpRead](http://ksria.com/simpread/) 转码, 原文地址 ${ window.location.href } \r\n\r\n ${str}` );
str = str.replace( /<\/?(ins|font|span|div|canvas|noscript|fig\w+)[ -\w*= \w=\-.:&\/\/?!;,%+()#'"{}\u4e00-\u9fa5]*>/ig, "" )
.replace( /sr-blockquote/ig, "blockquote" )
.replace( /<\/?style[ -\w*= \w=\-.:&\/\/?!;,+()#"\S]*>/ig, "" )