From f20aeddfdf4ed58a6108de430d364c1e9c75874c Mon Sep 17 00:00:00 2001 From: Skywt2003 Date: Wed, 8 Dec 2021 17:29:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=86=85=20BBCode=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 58 +-------------------------------------------------- 1 file changed, 1 insertion(+), 57 deletions(-) diff --git a/functions.php b/functions.php index 9d5807d..a636068 100644 --- a/functions.php +++ b/functions.php @@ -55,47 +55,8 @@ function themeFields($layout) { } function exContent($content){ - // 短代码提示框,期望用数组的办法一次性实现,但是正则表达式太难了 - // $alertIcons = array('primary' => 'fas fa-info-circle', - // 'success' => 'fas fa-info-circle', - // 'info' => 'fas fa-info-circle', - // 'warning' => 'fa-exclamation-circle', - // 'danger' => 'fas fa-skull-crossbones', - // 'default' => 'fas fa-info-circle', - // 'secondary' => 'fas fa-info-circle'); - - $pattern = '/\[(primary)\](.*?)\[\s*\/\1\s*\]/'; - $replacement = ' - '; - $content = preg_replace($pattern, $replacement, $content); - - $pattern = '/\[(default)\](.*?)\[\s*\/\1\s*\]/'; - $replacement = ' - '; - $content = preg_replace($pattern, $replacement, $content); - - $pattern = '/\[(secondary)\](.*?)\[\s*\/\1\s*\]/'; - $replacement = ' - '; - $content = preg_replace($pattern, $replacement, $content); - - $pattern = '/\[(success)\](.*?)\[\s*\/\1\s*\]/'; - $replacement = ' - '; - $content = preg_replace($pattern, $replacement, $content); + // 文章内短代码 $pattern = '/\[(info)\](.*?)\[\s*\/\1\s*\]/'; $replacement = ' '; $content = preg_replace($pattern, $replacement, $content); - // $pattern = '/\[(alert-(.*?))\](.*?)\[\s*\/\1\s*\]/'; - // $replacement = ' - // '; - // $content = preg_replace($pattern, $replacement, $content); - - // 正则表达式也太难了 。・゜・(ノД`)・゜・。 - // $pattern = '/\[link (.*)\](.*)\[link\]/'; - // $replacement = ' - // $2'; - // $content = preg_replace($pattern, $replacement, $content); - // 文章 TOC 功能 - // [0]: 完整的匹配

conTent

- // [1]: 匹配中的数字 2 - // [2]: 匹配中的内容 conTent if (preg_match_all('/(.*)<\/h\d>/isU', $content, $outarr)){ $toc_out = ""; $minlevel = 6;