From 19082e4759c53b07bb3196c1a22243aa0413dab0 Mon Sep 17 00:00:00 2001 From: BigCoke233 Date: Sat, 28 Mar 2020 14:43:18 +0800 Subject: =?UTF-8?q?=F0=9F=98=95=20Perf:=20=E6=97=A0=E4=BC=A4=E5=A4=A7?= =?UTF-8?q?=E9=9B=85=E7=9A=84=E5=B0=8F=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/Contents.php | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'libs') diff --git a/libs/Contents.php b/libs/Contents.php index 51d97a6..37b2555 100644 --- a/libs/Contents.php +++ b/libs/Contents.php @@ -13,22 +13,13 @@ class Contents $text = empty($last) ? $data : $last; if ($widget instanceof Widget_Archive) { //ParseOther - $text = Contents::parseEmo(Contents::parsePrism(Contents::parseImages(Contents::parseHeadings(Contents::parseTextColor(Contents::parseRuby(Contents::parseTip(Contents::parseLink($text)))))))); + $text = Contents::parseEmo(Contents::parseCode(Contents::parseImages(Contents::parseHeadings(Contents::parseTextColor(Contents::parseRuby(Contents::parseTip(Contents::parseLink($text)))))))); //LazyLoad $text = preg_replace('//','',$text); } return $text; } - /** - * 解析 Prism - */ - static public function parsePrism($text){ - //未定义的代码语言视为 html - $text = preg_replace('/
/s','
',$text);
-		return $text;
-	}
-	
 	/**
 	 *  解析图片
 	 */
@@ -39,16 +30,6 @@ class Contents
 		return $text;
     }
 	
-	/**
-	 *  解析章节链接
-	 */ 
-	static public function parseHeadings($text){
-		$reg='/\(.*?)\<\/h.*?\>/s';
-        $text = preg_replace_callback($reg, array('Contents', 'parseHeaderCallback'), $text);
-		
-		return $text;
-	}
-	
 	/**
 	 *  解析 Text-Color
 	 */
@@ -165,9 +146,26 @@ class Contents
         }
 	}
 	
+	/**
+	 * 解析代码块
+	 */
+    static public function parseCode($text) {
+		$text = preg_replace('/
/s','
',$text);
+		return $text;
+	}
 	
 	//从这里开始的代码来自 熊猫小A (https://imalan.cn)
 	 
+	/**
+	 *  解析章节链接
+	 */ 
+	static public function parseHeadings($text){
+		$reg='/\(.*?)\<\/h.*?\>/s';
+        $text = preg_replace_callback($reg, array('Contents', 'parseHeaderCallback'), $text);
+		
+		return $text;
+	}
+	 
 	/**
      * 为内容中的标题编号
      */
-- 
cgit v1.2.3