summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorEltrac Koalar <hi@guhub.cn>2022-08-26 14:20:16 +0800
committerEltrac Koalar <hi@guhub.cn>2022-08-26 14:20:16 +0800
commit97b29e6ffd85a679fd65519ee17ce3ce54cd43b6 (patch)
tree9fa614b89dba0b1121da9e676f7058d6a04eaf1f /libs
parente0c4d1c47a347f9ad3e3bc85a50821914a89cf21 (diff)
:put_litter_in_its_place: Remove: 移除 Pangu.php
因为需要这个功能的人不多,就算需要,那些需要的人大部分也已经养成手打空格的习惯了(比如我
Diffstat (limited to 'libs')
-rw-r--r--libs/Matcha.php3
-rw-r--r--libs/Pangu.php112
2 files changed, 1 insertions, 114 deletions
diff --git a/libs/Matcha.php b/libs/Matcha.php
index 3d28ff9..ef49b0b 100644
--- a/libs/Matcha.php
+++ b/libs/Matcha.php
@@ -1,6 +1,5 @@
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
-require_once("Pangu.php");
/**
* Matcha.php
* 处理主题显示的内容
@@ -264,7 +263,7 @@ class Matcha
{
$text = empty($last) ? $data : $last;
if ($widget instanceof Widget_Archive) {
- $text = Matcha::lazyLoad(pangu($text));
+ $text = Matcha::lazyLoad($text);
}
return $text;
}
diff --git a/libs/Pangu.php b/libs/Pangu.php
deleted file mode 100644
index e17667b..0000000
--- a/libs/Pangu.php
+++ /dev/null
@@ -1,112 +0,0 @@
-<?php
-/**
- * pangu.php
- * https://github.com/kunr/pangu.php
- *
- * Copyright (c) 2015 Rakume Hayashi
- * Licensed under the MIT License
- */
-
-function pangu($text) {
- $cjk = '' .
- '\x{2e80}-\x{2eff}' .
- '\x{2f00}-\x{2fdf}' .
- '\x{3040}-\x{309f}' .
- '\x{30a0}-\x{30ff}' .
- '\x{3100}-\x{312f}' .
- '\x{3200}-\x{32ff}' .
- '\x{3400}-\x{4dbf}' .
- '\x{4e00}-\x{9fff}' .
- '\x{f900}-\x{faff}';
-
- $patterns = array(
- 'cjk_quote' => array(
- '([' . $cjk . '])(["\'])',
- '$1 $2'
- ),
-
- 'quote_cjk' => array(
- '(["\'])([' . $cjk . '])',
- '$1 $2'
- ),
-
- 'fix_quote' => array(
- '(["\']+)(\s*)(.+?)(\s*)(["\']+)',
- '$1$3$5'
- ),
-
- 'cjk_hash' => array(
- '([' . $cjk . '])(#(\S+))',
- '$1 $2'
- ),
-
- 'hash_cjk' => array(
- '((\S+)#)([' . $cjk . '])',
- '$1 $3'
- ),
-
- 'cjk_operator_ans' => array(
- '([' . $cjk . '])([A-Za-zΑ-Ωα-ω0-9])([\+\-\*\/=&\\|<>])',
- '$1 $2 $3'
- ),
-
- 'ans_operator_cjk' => array(
- '([\+\-\*\/=&\\|<>])([A-Za-zΑ-Ωα-ω0-9])([' . $cjk . '])',
- '$1 $2 $3'
- ),
-
- 'bracket' => array(
- array(
- '([' . $cjk . '])([<\[\{\(]+(.*?)[>\]\}\)]+)([' . $cjk . '])',
- '$1 $2 $4'
- ),
-
- array(
- 'cjk_bracket' => array(
- '([' . $cjk . '])([<>\[\]\{\}\(\)])',
- '$1 $2'
- ),
-
- 'bracket_cjk' => array(
- '([<>\[\]\{\}\(\)])([' . $cjk . '])',
- '$1 $2'
- )
- )
- ),
-
- 'fix_bracket' => array(
- '([<\[\{\(]+)(\s*)(.+?)(\s*)([>\]\}\)]+)',
- '$1$3$5'
- ),
-
- 'cjk_ans' => array(
- '([' . $cjk . '])([A-Za-zΑ-Ωα-ω0-9`@&%\=\$\^\*\-\+\\/|\\\])',
- '$1 $2'
- ),
-
- 'ans_cjk' => array(
- '([A-Za-zΑ-Ωα-ω0-9`~!%&=;\|\,\.\:\?\$\^\*\-\+\/\\\])([' . $cjk . '])',
- '$1 $2'
- )
- );
-
- foreach ($patterns as $key => $value) {
- if ($key === 'bracket') {
- $old = $text;
- $new = preg_replace('/' . $value[0][0] . '/iu', $value[0][1], $text);
- $text = $new;
-
- if ($old === $new) {
- foreach ($value[1] as $val) {
- $text = preg_replace('/' . $val[0] . '/iu', $val[1], $text);
- }
- }
-
- continue;
- }
-
- $text = preg_replace('/' . $value[0] . '/iu', $value[1], $text);
- }
-
- return $text;
-} \ No newline at end of file