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