From 09fe4f3bdbc460c480c3ea5b6f1c829aab9db965 Mon Sep 17 00:00:00 2001 From: neveler <55753029+neveler@users.noreply.github.com> Date: Mon, 8 Dec 2025 19:35:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Alert=20=E5=89=8D=E7=BC=80?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=B6=E4=BC=9A=E9=81=BF=E5=85=8D=E7=A0=B4?= =?UTF-8?q?=E5=9D=8F=20HTML=20=E7=BB=93=E6=9E=84=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#372)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _multiplayer/feedback.md | 5 ----- _plugins/auto-alert.rb | 15 +++++++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/_multiplayer/feedback.md b/_multiplayer/feedback.md index 684e5a9..41425a2 100644 --- a/_multiplayer/feedback.md +++ b/_multiplayer/feedback.md @@ -9,13 +9,8 @@ contributors: ## Terracotta | 陶瓦联机 - > [!TIP] -> > 欢迎您填写反馈表单。 - 我们注意到了 EasyTier 项目。它提供了一种简单、安全、去中心化的异地组网方案,足以承载 Minecraft 的联机需求。 在 EasyTier 开发团队的帮助下,我们决定重新在启动器内提供联机服务。 diff --git a/_plugins/auto-alert.rb b/_plugins/auto-alert.rb index ee0d1b8..bb8ce96 100644 --- a/_plugins/auto-alert.rb +++ b/_plugins/auto-alert.rb @@ -15,14 +15,17 @@ Jekyll::Hooks.register [:pages, :documents], :post_convert do |doc| next unless first_child next unless first_child.name == "p" - text = first_child.text.downcase + inner_html = first_child.inner_html.downcase # 遍历所有 alert 类型 alert_type.each do |type, data| + prefix = "[!#{type}]" + prefix_with_newline = "#{prefix}\n" + # 情况一:完整匹配 [!type] 形式
[!NOTE]
- if text == "[!#{type}]" + if inner_html == prefix # 将 alert 类型对应的 class 加入 blockquote - item['class'] = [item['class'], data["class_name"]].compact.join(" ") + item["class"] = [item["class"], data["class_name"]].compact.join(" ") # 将替换为
[!NOTE]\n\n other content
- elsif text.start_with? "[!#{type}]\n" + elsif inner_html.start_with? prefix_with_newline # 将 alert 类型对应的 class 加入 blockquote - item['class'] = [item['class'], data["class_name"]].compact.join(" ") + item["class"] = [item["class"], data["class_name"]].compact.join(" ") # 在原段落前插入标题[!NOTE]\n\n other content
first_child.add_previous_sibling "\n other content
- first_child.content = first_child.content.sub(/\A#{Regexp.escape("[!#{type}]\n")}/i, "") + first_child.inner_html = first_child.inner_html[prefix_with_newline.length..-1] || "" break end end