分页: 1 / 1

phpbb论坛语法高亮插件o0johntam0o产生空白行的解决方法

发表于 : 周六 10月 18, 2025 1:09 am
BG6RSH
该插件会自动为代码添加一个空行;如果原代码有一空行,则它会在原来的基础上增加1个空行。经过查找需要修改一下“\ext\o0johntam0o\codeboxplus\event\main_listener.php”文件中的第99行内容:
  1. // 修改前
  2. return $this->codebox_template(preg_replace('#\<br\\s*/?\>#msi', "\n", $arg[3]), $arg[1], $arg[2], $post_id, ++$part);
  3. // 修改后
  4. return $this->codebox_template(preg_replace('#\<br\\s*/?\>#msi', "", $arg[3]), $arg[1], $arg[2], $post_id, ++$part);

Re: phpbb论坛语法高亮插件o0johntam0o产生空白行的解决方法

发表于 : 周六 10月 18, 2025 1:14 am
BG6RSH
GeSHi 旧版用了 PHP 8 已经废弃的 create_function(),运行时爆致命错。修改/ext/o0johntam0o/codeboxplus/includes/geshi/geshi.php文件,手工改第 4746 行(以及后面若干行)
原旧代码:
  1.         if (!$recursed) {
  2.             $list = preg_replace('#\(\?\:(.)\)\?#', '\1?', $list);
  3.             static $callback_2;
  4.             if (!isset($callback_2)) {
  5.                 $callback_2 = create_function('$matches', 'return "[" . str_replace("|", "", $matches[1]) . "]";');
  6.             }
  7.             $list = preg_replace_callback('#\(\?\:((?:.\|)+.)\)#', $callback_2, $list);
  8.         }
修改后的代码:
  1. if (!$recursed) {
  2.     // 1. 把 (?:a|b|c) 改写成 [abc]
  3.     $list = preg_replace('#\(\?\:(.)\)\?#', '\1?', $list);
  4.  
  5.     static $callback_2;
  6.     if (!isset($callback_2)) {
  7.         $callback_2 = function ($matches) {
  8.             return '[' . str_replace('|', '', $matches[1]) . ']';
  9.         };
  10.     }
  11.     $list = preg_replace_callback('#\(\?\:((?:.\|)+.)\)#', $callback_2, $list);
  12. }