mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-20 19:10:49 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
29d959c18c
@ -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…
Reference in New Issue
Block a user