From cb482ac9dc64b27f2f8cceaf6dc3e2b438a30dca Mon Sep 17 00:00:00 2001
From: Eltrac <45323514+BigCoke233@users.noreply.github.com>
Date: Fri, 24 Jan 2020 15:46:53 +0800
Subject: =?UTF-8?q?=F0=9F=93=96=20Add:=20=E7=AB=A0=E8=8A=82=E9=93=BE?=
=?UTF-8?q?=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
libs/Contents.php | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
(limited to 'libs/Contents.php')
diff --git a/libs/Contents.php b/libs/Contents.php
index a9510d6..a196c5d 100644
--- a/libs/Contents.php
+++ b/libs/Contents.php
@@ -25,11 +25,15 @@ class Contents
$text = preg_replace('/
/s','
',$text);
//LazyLoad
$text = preg_replace('/
/','
',$text);
-
+
+ //章节链接
+ $reg='/\(.*?)\<\/h.*?\>/s';
+ $text = preg_replace_callback($reg, array('Contents', 'parseHeaderCallback'), $text);
+
//气泡
$text = preg_replace('/\[bubble\](.*?)\[\/bubble\]/s','',$text);
- //阴影
+ //Text Color
$text = preg_replace('/\&\{\"(.*?)\"\|(.*?)\|(.*?)\}/s','${1}',$text);
//ruby
@@ -43,7 +47,7 @@ class Contents
$text = preg_replace('/\[tip type="(.*?)"\](.*?)\[\/tip\]/s','',$text);
//Tip Group
$text = preg_replace('/\[tip\-group\](.*?)\[\/tip\-group\]/s','${1}
',$text);
-
+
//解析友链盒子
$reg = '/\[links\](.*?)\[\/links\]/s';
$rp = '';
@@ -74,6 +78,18 @@ class Contents
* @param string $table 表名, 支持 contents, comments, metas, users
* @return Widget_Abstract
*/
+
+ /**
+ * 为内容中的标题编号
+ */
+ static private $CurrentTocID = 0;
+ static public function parseHeaderCallback($matchs)
+ {
+ // 增加单独标记,否则冲突
+ $id = 'toc_'.(self::$CurrentTocID++);
+ return ''.$matchs[3].'';
+ }
+
public static function widgetById($table, $pkId)
{
$table = ucfirst($table);
--
cgit v1.2.3