mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🐛 Repeated escaping in preview area when searching for matching doc blocks https://github.com/siyuan-note/siyuan/issues/10219
This commit is contained in:
parent
c68396a687
commit
a9092ce18d
2 changed files with 10 additions and 3 deletions
|
|
@ -1298,12 +1298,15 @@ func stringQuery(query string) string {
|
||||||
func markReplaceSpan(n *ast.Node, unlinks *[]*ast.Node, keywords []string, markSpanDataType string, luteEngine *lute.Lute) bool {
|
func markReplaceSpan(n *ast.Node, unlinks *[]*ast.Node, keywords []string, markSpanDataType string, luteEngine *lute.Lute) bool {
|
||||||
text := n.Content()
|
text := n.Content()
|
||||||
if ast.NodeText == n.Type {
|
if ast.NodeText == n.Type {
|
||||||
text = util.EscapeHTML(text)
|
escapedText := util.EscapeHTML(text)
|
||||||
escapedKeywords := make([]string, len(keywords))
|
escapedKeywords := make([]string, len(keywords))
|
||||||
for i, keyword := range keywords {
|
for i, keyword := range keywords {
|
||||||
escapedKeywords[i] = util.EscapeHTML(keyword)
|
escapedKeywords[i] = util.EscapeHTML(keyword)
|
||||||
}
|
}
|
||||||
text = search.EncloseHighlighting(text, escapedKeywords, search.GetMarkSpanStart(markSpanDataType), search.GetMarkSpanEnd(), Conf.Search.CaseSensitive, false)
|
hText := search.EncloseHighlighting(escapedText, escapedKeywords, search.GetMarkSpanStart(markSpanDataType), search.GetMarkSpanEnd(), Conf.Search.CaseSensitive, false)
|
||||||
|
if hText != escapedText {
|
||||||
|
text = hText
|
||||||
|
}
|
||||||
n.Tokens = gulu.Str.ToBytes(text)
|
n.Tokens = gulu.Str.ToBytes(text)
|
||||||
if bytes.Contains(n.Tokens, []byte(search.MarkDataType)) {
|
if bytes.Contains(n.Tokens, []byte(search.MarkDataType)) {
|
||||||
linkTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions)
|
linkTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,11 @@ func RemoveElem[T any](s []T, index int) []T {
|
||||||
}
|
}
|
||||||
|
|
||||||
func EscapeHTML(s string) string {
|
func EscapeHTML(s string) string {
|
||||||
if strings.ContainsAny(s, "<>\"'") {
|
if strings.Contains(s, "&") {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.ContainsAny(s, "<>\"'&") {
|
||||||
return html.EscapeString(s)
|
return html.EscapeString(s)
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue