From 3762b65a8b625fed9482368af9eb004e47efd535 Mon Sep 17 00:00:00 2001 From: offends Date: Mon, 25 Aug 2025 19:39:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=84=9A=E6=9C=AC=E9=81=97?= =?UTF-8?q?=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- builder.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/builder.sh b/builder.sh index 2cb6f58..648fc84 100644 --- a/builder.sh +++ b/builder.sh @@ -86,6 +86,30 @@ function Replace_Url() { done } +function Replace_Url() { + SEND_INFO "------------ 开始替换 Gitee 链接为 Blog 链接 ------------" + + # 使用更精确的匹配模式,处理包含中文和其他特殊字符的URL + grep -r 'https://gitee.com/offends/' --include="*.md" . | while read -r line; do + file=$(echo "$line" | awk -F ':' '{print $1}') + + # 一次性完成所有替换操作 + sed -i ' + # 处理标准格式的Gitee链接 + s|https://gitee.com/offends/\([^/]*\)/blob/main/\(.*\)\.md|https://blog.offends.cn/\1/\2.html|g + s|https://gitee.com/offends/\([^/]*\)/blob/main/\(.*\)\.md#\(.*\)|https://blog.offends.cn/\1/\2.html#\3|g + + # 额外处理可能遗漏的.md后缀 + s|\(https://blog.offends.cn/[^)]*\)\.md|\1.html|g + s|\.md#|.html#|g + s|\.md$|.html|g + s|\.md)|.html)|g + ' "$file" + done + + SEND_INFO "------------ 替换完成 ------------" +} + function All() { SEND_INFO "开始构建......" Clean_File