diff options
| author | BigCoke233 <hi@guhub.cn> | 2020-03-28 14:43:18 +0800 |
|---|---|---|
| committer | BigCoke233 <hi@guhub.cn> | 2020-03-28 14:43:18 +0800 |
| commit | 19082e4759c53b07bb3196c1a22243aa0413dab0 (patch) | |
| tree | e1d8a89aa4f2e7cc4435ac85ad987ae2f23a6dbb | |
| parent | aff8a7fb73da5d4e768f5b3b9b61278df2d32352 (diff) | |
😕 Perf: 无伤大雅的小改动
| -rw-r--r-- | libs/Contents.php | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/libs/Contents.php b/libs/Contents.php index 51d97a6..37b2555 100644 --- a/libs/Contents.php +++ b/libs/Contents.php @@ -13,7 +13,7 @@ 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('/<img (.*?)src(.*?)(\/)?>/','<img $1src="/usr/themes/Miracles/images/loading/'.$load_image.'.gif" data-original$2 />',$text); } @@ -21,15 +21,6 @@ class Contents } /** - * 解析 Prism - */ - static public function parsePrism($text){ - //未定义的代码语言视为 html - $text = preg_replace('/<pre><code>/s','<pre><code class="language-html">',$text); - return $text; - } - - /** * 解析图片 */ static public function parseImages($text){ @@ -40,16 +31,6 @@ class Contents } /** - * 解析章节链接 - */ - static public function parseHeadings($text){ - $reg='/\<h([2-3])(.*?)\>(.*?)\<\/h.*?\>/s'; - $text = preg_replace_callback($reg, array('Contents', 'parseHeaderCallback'), $text); - - return $text; - } - - /** * 解析 Text-Color */ static public function parseTextColor($text){ @@ -165,10 +146,27 @@ class Contents } } + /** + * 解析代码块 + */ + static public function parseCode($text) { + $text = preg_replace('/<pre><code>/s','<pre><code class="language-html">',$text); + return $text; + } //从这里开始的代码来自 熊猫小A (https://imalan.cn) /** + * 解析章节链接 + */ + static public function parseHeadings($text){ + $reg='/\<h([2-3])(.*?)\>(.*?)\<\/h.*?\>/s'; + $text = preg_replace_callback($reg, array('Contents', 'parseHeaderCallback'), $text); + + return $text; + } + + /** * 为内容中的标题编号 */ static private $CurrentTocID = 0; |
