♻️ 搜索命中高亮

This commit is contained in:
Liang Ding 2023-02-16 10:41:02 +08:00
parent c56dcead19
commit 7d05f4e8c7
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 20 additions and 6 deletions

View file

@ -17,6 +17,7 @@
package search
import (
"fmt"
"regexp"
"strings"
"unicode/utf8"
@ -99,3 +100,16 @@ func EncloseHighlighting(text string, keywords []string, openMark, closeMark str
}
return
}
const (
MarkDataType = "search-mark"
VirtualBlockRefDataType = "virtual-block-ref"
)
func GetMarkSpanStart(dataType string) string {
return fmt.Sprintf("<span data-type=\"%s\">", dataType)
}
func GetMarkSpanEnd() string {
return "</span>"
}