mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 18:03:07 +08:00
🎨 Improve tag escaping
This commit is contained in:
parent
1d4380bb75
commit
b6bd34ce32
@ -328,7 +328,7 @@ func labelTags() (ret map[string]Tags) {
|
|||||||
|
|
||||||
tagSpans := sql.QueryTagSpans("")
|
tagSpans := sql.QueryTagSpans("")
|
||||||
for _, tagSpan := range tagSpans {
|
for _, tagSpan := range tagSpans {
|
||||||
label := tagSpan.Content
|
label := util.UnescapeHTML(tagSpan.Content)
|
||||||
if _, ok := ret[label]; ok {
|
if _, ok := ret[label]; ok {
|
||||||
ret[label] = append(ret[label], &Tag{})
|
ret[label] = append(ret[label], &Tag{})
|
||||||
} else {
|
} else {
|
||||||
|
@ -95,7 +95,7 @@ func EncloseHighlighting(text string, keywords []string, openMark, closeMark str
|
|||||||
if splitWords {
|
if splitWords {
|
||||||
wordBoundary = lex.IsASCIILetterNums(gulu.Str.ToBytes(k)) // Improve virtual reference split words https://github.com/siyuan-note/siyuan/issues/7833
|
wordBoundary = lex.IsASCIILetterNums(gulu.Str.ToBytes(k)) // Improve virtual reference split words https://github.com/siyuan-note/siyuan/issues/7833
|
||||||
}
|
}
|
||||||
k = regexp.QuoteMeta(k)
|
k = regexp.QuoteMeta(util.EscapeHTML(k))
|
||||||
re += "("
|
re += "("
|
||||||
if wordBoundary {
|
if wordBoundary {
|
||||||
re += "\\b"
|
re += "\\b"
|
||||||
@ -110,10 +110,10 @@ func EncloseHighlighting(text string, keywords []string, openMark, closeMark str
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
re += ")"
|
re += ")"
|
||||||
ret = text
|
ret = util.EscapeHTML(text)
|
||||||
|
|
||||||
if reg, err := regexp.Compile(re); err == nil {
|
if reg, err := regexp.Compile(re); err == nil {
|
||||||
ret = reg.ReplaceAllStringFunc(text, func(s string) string { return openMark + util.EscapeHTML(s) + closeMark })
|
ret = reg.ReplaceAllStringFunc(ret, func(s string) string { return openMark + s + closeMark })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 搜索结果预览包含转义符问题 Search results preview contains escape character issue https://github.com/siyuan-note/siyuan/issues/9790
|
// 搜索结果预览包含转义符问题 Search results preview contains escape character issue https://github.com/siyuan-note/siyuan/issues/9790
|
||||||
|
Loading…
Reference in New Issue
Block a user