This commit is contained in:
Daniel 2024-12-16 22:04:43 +08:00
parent 3bd2debf4c
commit f3853ee842
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -592,7 +592,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
return ast.WalkContinue
}
replaceNodeTokens(n, method, keyword, replacement, r)
replaceNodeTokens(n, method, keyword, strings.TrimSpace(replacement), r)
case ast.NodeLinkText:
if !replaceTypes["imgText"] {
return ast.WalkContinue
@ -673,11 +673,11 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
if replaceTypes["aHref"] {
if 0 == method {
if strings.Contains(n.TextMarkAHref, keyword) {
n.TextMarkAHref = strings.ReplaceAll(n.TextMarkAHref, keyword, replacement)
n.TextMarkAHref = strings.ReplaceAll(n.TextMarkAHref, keyword, strings.TrimSpace(replacement))
}
} else if 3 == method {
if nil != r && r.MatchString(n.TextMarkAHref) {
n.TextMarkAHref = r.ReplaceAllString(n.TextMarkAHref, replacement)
n.TextMarkAHref = r.ReplaceAllString(n.TextMarkAHref, strings.TrimSpace(replacement))
}
}
}