mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-02-28 05:32:52 +00:00
🐛 无法替换包含 HTML 转义的代码内容 https://github.com/siyuan-note/siyuan/issues/6476
This commit is contained in:
@@ -207,6 +207,17 @@ func FindReplace(keyword, replacement string, ids []string) (err error) {
|
||||
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte(keyword), []byte(replacement))
|
||||
}
|
||||
case ast.NodeTextMark:
|
||||
if n.IsTextMarkType("code") {
|
||||
escapedKey := html.EscapeString(keyword)
|
||||
if strings.Contains(n.TextMarkTextContent, escapedKey) {
|
||||
n.TextMarkTextContent = strings.ReplaceAll(n.TextMarkTextContent, escapedKey, replacement)
|
||||
}
|
||||
} else {
|
||||
if bytes.Contains(n.Tokens, []byte(keyword)) {
|
||||
n.TextMarkTextContent = strings.ReplaceAll(n.TextMarkTextContent, keyword, replacement)
|
||||
}
|
||||
}
|
||||
|
||||
if strings.Contains(n.TextMarkTextContent, keyword) {
|
||||
n.TextMarkTextContent = strings.ReplaceAll(n.TextMarkTextContent, keyword, replacement)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user