refactor: external render (#38885) (#38898)

Backport #38885 by @wxiaoguang

make the "command variable replacement" more accurate and
OS-independent, add a test for it.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot
2026-08-12 23:17:39 -07:00
committed by GitHub
co-authored by wxiaoguang
parent 1c92062c69
commit 88b56d408d
5 changed files with 60 additions and 27 deletions
+1
View File
@@ -64,6 +64,7 @@ func RenderMarkup(ctx *context.Base, ctxRepo *context.Repository, mode, text, ur
treePath = path.Dir(filePath) // it is "doc" if filePath is "doc/CHANGE.md"
refPath = strings.Join(fields[3:], "/") // it is "branch/features/feat-12/doc"
refPath = strings.TrimSuffix(refPath, "/"+treePath) // now we get the correct branch path: "branch/features/feat-12"
refPath = util.PathEscapeSegments(refPath)
} else if fields = strings.SplitN(repoLinkPath, "/", 3); len(fields) == 2 {
repoOwnerName, repoName = fields[0], fields[1]
}