refactor: external render (#38885)

make the "command variable replacement" more accurate and
OS-independent, add a test for it.
This commit is contained in:
wxiaoguang
2026-08-13 03:30:26 +08:00
committed by GitHub
parent 8161479fde
commit 53d7d3f053
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]
}