From 0f383ad5b4d4f4a4b4e83eb98a2ec045a0f509c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=A6=E9=82=A6=E9=82=A6=E9=82=A6?= <15622356989@163.com> Date: Mon, 21 Apr 2025 20:13:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=A4=96=E9=93=BE?= =?UTF-8?q?=E8=A2=AB=E8=BD=AC=E4=B9=89=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/docs/single.html | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/layouts/docs/single.html b/layouts/docs/single.html index fc7ec57dd..78f563ee1 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -1,9 +1,19 @@ {{ define "main" }}
- {{ $pt := (replace .Content ".md\"" ".html\"") }} - {{ $pt1 := (replace $pt ".md#" ".html#") }} - {{ $st := (replace $pt1 "‘" "'") }} - {{ $ot := (replace $st "’" "'") }} - {{- $ot | safeHTML -}} + {{ $content := .Content }} + {{ $links := findRE `(href|src)=(["'])([^"']+)(\.md)(["'])` $content }} + {{ range $links }} + {{ $link := . }} + {{ $attr := index (findRE `(href|src)` $link) 0 }} + {{ $quote := index (findRE `(["'])` $link) 0 }} + {{ $path := index (findRE `(href|src)=(["'])([^"']+)(\.md)(["'])` $link) 0 | replaceRE `(href|src)=(["'])` "" | replaceRE `(\.md)(["'])` "" }} + {{ if not (or (hasPrefix $path "http://") (hasPrefix $path "https://")) }} + {{ $newLink := printf "%s=%s%s.html%s" $attr $quote $path $quote }} + {{ $content = replace $content $link $newLink }} + {{ end }} + {{ end }} + {{ $pt := replace $content "‘" "'" }} + {{ $ot := replace $pt "’" "'" }} + {{- $ot | safeHTML -}}
{{ end }} \ No newline at end of file -- Gitee