summaryrefslogtreecommitdiffstats
path: root/libs/Contents.php
diff options
context:
space:
mode:
Diffstat (limited to 'libs/Contents.php')
-rw-r--r--libs/Contents.php38
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;