🎨 Support replacing inline tags with plain text https://github.com/siyuan-note/siyuan/issues/11238

This commit is contained in:
Daniel 2025-04-13 17:13:15 +08:00
parent 6757da9122
commit 1b98f43be7
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -947,7 +947,13 @@ func replaceNodeTextMarkTextContent(n *ast.Node, method int, keyword, escapedKey
replacement = strings.TrimSuffix(replacement, "#")
} else { // 将标签转换为纯文本
if "tag" == n.TextMarkType { // 没有其他类型,仅是标签时直接转换
n.InsertBefore(&ast.Node{Type: ast.NodeText, Tokens: []byte(n.TextMarkTextContent)})
content := n.TextMarkTextContent
if strings.Contains(content, escapedKey) {
content = strings.ReplaceAll(content, escapedKey, replacement)
} else if strings.Contains(content, keyword) {
content = strings.ReplaceAll(content, keyword, replacement)
}
n.InsertBefore(&ast.Node{Type: ast.NodeText, Tokens: []byte(content)})
n.TextMarkTextContent = ""
return
}