Skip to content

Commit

Permalink
Fix(adapters): 修复 a 标签中的相对链接转换失败
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Nov 27, 2024
1 parent f0cfd68 commit 3a68340
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion layouts/partials/adapters/projects.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@
{{- /* Convert Hugo shortcodes to markdown plain text */ -}}
{{- $markdown = replace $markdown "{{<" "{{?{}<" -}}
{{- /* Convert relative links to absolute links in the README content */ -}}
{{- $replacement := printf "$1[$2](%v$4)" (printf "https://raw.githubusercontent.com/%v/refs/heads/%v/$3" $repoInfo.full_name $repoInfo.default_branch) -}}
{{- $replacement := printf "$1[$2](%v$3$4)" (printf "https://raw.githubusercontent.com/%v/refs/heads/%v" $repoInfo.full_name $repoInfo.default_branch) -}}
{{- /* Oops! Lookahead regular lookup is not supported in Golang, e.g `(?!http)` */ -}}
{{- $markdown = replaceRE `([!]?)\[(.*?)\]\(([/|\./].*).*?(\s+".*?")?\)` $replacement $markdown -}}
{{- $replacement = printf `<a$1 href="%v$2"$3>$4</a>` (printf "https://raw.githubusercontent.com/%v/refs/heads/%v" $repoInfo.full_name $repoInfo.default_branch) -}}
{{- $markdown = replaceRE `<a(.*?) href="([/|\./].*).*?"(.*?)>(.*?)</a>` $replacement $markdown -}}
{{- $content := dict
"mediaType" "text/markdown"
"value" $markdown
Expand Down

0 comments on commit 3a68340

Please sign in to comment.