optimize code
This commit is contained in:
parent
ee9ba3fcf0
commit
63591899bb
|
@ -61,7 +61,13 @@ func InitDigestCache() {
|
|||
if len(c.DigestTagOccupyNum) <= 1 {
|
||||
return c
|
||||
}
|
||||
c.specialSolve = map[string]digest.SpecialSolveConf{}
|
||||
c.specialSolve = ParseDigestConf(c)
|
||||
return c
|
||||
}, "digestConfig")
|
||||
}
|
||||
|
||||
func ParseDigestConf(c DigestConfig) map[string]digest.SpecialSolveConf {
|
||||
specialSolve := map[string]digest.SpecialSolveConf{}
|
||||
for _, item := range c.DigestTagOccupyNum {
|
||||
tags := strings.Split(strings.ReplaceAll(item.Tag, " ", ""), "<")
|
||||
for _, tag := range tags {
|
||||
|
@ -99,9 +105,8 @@ func InitDigestCache() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
c.specialSolve[tag] = digest.SpecialSolveConf{
|
||||
specialSolve[tag] = digest.SpecialSolveConf{
|
||||
Num: item.Num,
|
||||
ChuckOvered: item.ChuckOvered,
|
||||
EscapeCharacter: ec,
|
||||
|
@ -109,8 +114,7 @@ func InitDigestCache() {
|
|||
}
|
||||
}
|
||||
}
|
||||
return c
|
||||
}, "digestConfig")
|
||||
return specialSolve
|
||||
}
|
||||
|
||||
func RemoveWpBlock(s string) string {
|
||||
|
|
|
@ -26,8 +26,6 @@ type SpecialSolve struct {
|
|||
ChuckOvered bool
|
||||
}
|
||||
|
||||
var selfCloseTags = html.GetSelfCloseTags()
|
||||
|
||||
func StripTags(content, allowTag string) string {
|
||||
content = strings.Trim(content, " \t\n\r\000\x0B")
|
||||
content = strings.Replace(content, "]]>", "]]>", -1)
|
||||
|
@ -78,7 +76,7 @@ func Html(content string, limit int) (string, string) {
|
|||
tagIn = false
|
||||
continue
|
||||
}
|
||||
if tagIn == false && ru[i] != '\n' {
|
||||
if tagIn == false {
|
||||
end++
|
||||
}
|
||||
}
|
||||
|
@ -111,6 +109,7 @@ func CustomizeHtml(content string, limit int, m map[string]SpecialSolveConf) (st
|
|||
runeTotal := len(runeContent)
|
||||
l, r := '<', '>'
|
||||
i := -1
|
||||
selfCloseTags := html.GetSelfCloseTags()
|
||||
var currentTag, parentTag string
|
||||
var allTags = []string{"<top>"}
|
||||
var tag []rune
|
||||
|
|
Loading…
Reference in New Issue
Block a user