From 3975667bafcbf6ef90ef95c1e8b1022a238d55cf Mon Sep 17 00:00:00 2001 From: ohmyga <40896676+bakaomg@users.noreply.github.com> Date: Sun, 18 Apr 2021 15:40:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=94=20=E5=B0=86=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E4=BB=A3=E7=A0=81=E9=AB=98=E4=BA=AE=E9=A2=84=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E4=BA=A4=E7=BB=99=E5=90=8E=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (说白了兼容性问题,偷懒交给后端解析) --- core/libs/Comments.php | 4 ++-- core/libs/Contents.php | 14 +++++++++++++- static/js/castle.js | 12 ++---------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/core/libs/Comments.php b/core/libs/Comments.php index fc414b5..908b160 100644 --- a/core/libs/Comments.php +++ b/core/libs/Comments.php @@ -1,7 +1,7 @@
- getParent(); echo preg_replace('#]*>#','', Castle_Contents::parseOwO(Castle_ShortCode::parseAll($this->content))); ?> + getParent(); echo Castle_Contents::code(preg_replace('#]*>#','', Castle_Contents::parseOwO(Castle_ShortCode::parseAll($this->content)))); ?>
diff --git a/core/libs/Contents.php b/core/libs/Contents.php index bf33da3..8dbf1d8 100644 --- a/core/libs/Contents.php +++ b/core/libs/Contents.php @@ -1,7 +1,7 @@ ([\\s\\S]*?)<\/code>/i'; + $rp = '
${2}
'; + $new = preg_replace($reg, $rp, $text); + + return $new; + } + /** * 文章阅读数 * diff --git a/static/js/castle.js b/static/js/castle.js index b2d6238..5f07099 100644 --- a/static/js/castle.js +++ b/static/js/castle.js @@ -7,7 +7,7 @@ \_____| \__,_| |___/ \__| |_| \___| ---------------------------------------- * Castle's JavaScript - * Last Update: 2021/04/13 [0.9.6] + * Last Update: 2021/04/18 [0.9.6.1] * Author: ohmyga (https://ohmyga.cn) * GitHub: https://github.com/bakaomg/castle-Typecho-Theme/ * LICENSE: GPL V3 (https://www.gnu.org/licenses/gpl-3.0.html) @@ -978,14 +978,6 @@ var CastlePost = { //代码高亮 highLight: function () { - // 为评论区的代码高亮补全样式 - $$('code[class^="lang"]:not(pre code)').each(function (key, item) { - let child = item; - let parent = document.createElement("pre"); - child.parentNode.replaceChild(parent, child); - parent.appendChild(child); - }); - $$("pre code").each(function (key, item) { if (item.classList.contains("hljs") === false) { $$(this).html("
  1. " + $$(this).html().replace(/\n/g, "\n
  2. ") + "\n
"); @@ -1450,7 +1442,7 @@ var CastleComments = { if (next[0] == null) { return node; } - if (next.hasClass("moe-comments-list-box") == false) { + if (next.hasClass("moe-comments-list-box") === false) { return node; } nextNodeList = next.children(".moe-comments-box");