mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-01 06:18:49 +01:00
🎨 Support replacing inline tags with plain text https://github.com/siyuan-note/siyuan/issues/11238
This commit is contained in:
parent
6757da9122
commit
1b98f43be7
1 changed files with 7 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue