optimize code and fix bug
This commit is contained in:
parent
9af2257650
commit
a8d1dcdd5b
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/fthvgb1/wp-go/cache/cachemanager"
|
||||
"github.com/fthvgb1/wp-go/cache/reload"
|
||||
"github.com/fthvgb1/wp-go/helper"
|
||||
"github.com/fthvgb1/wp-go/helper/maps"
|
||||
str "github.com/fthvgb1/wp-go/helper/strings"
|
||||
"github.com/fthvgb1/wp-go/plugin/digest"
|
||||
"github.com/fthvgb1/wp-go/safety"
|
||||
|
@ -74,12 +75,10 @@ func ParseDigestConf(c DigestConfig) map[string]digest.SpecialSolveConf {
|
|||
if tag == "" {
|
||||
continue
|
||||
}
|
||||
ec := make(map[rune]digest.SpecialSolve)
|
||||
specialTags := make(map[string]digest.SpecialSolve)
|
||||
tag = str.Join("<", tag)
|
||||
var ec map[rune]digest.SpecialSolve
|
||||
var specialTags map[string]digest.SpecialSolve
|
||||
if len(item.EscapeCharacter) > 0 {
|
||||
ec = make(map[rune]digest.SpecialSolve)
|
||||
specialTags = make(map[string]digest.SpecialSolve)
|
||||
for _, esc := range item.EscapeCharacter {
|
||||
for _, i := range esc.Character {
|
||||
s := []rune(i)
|
||||
|
@ -106,12 +105,21 @@ func ParseDigestConf(c DigestConfig) map[string]digest.SpecialSolveConf {
|
|||
}
|
||||
}
|
||||
}
|
||||
specialSolve[tag] = digest.SpecialSolveConf{
|
||||
Num: item.Num,
|
||||
ChuckOvered: item.ChuckOvered,
|
||||
EscapeCharacter: ec,
|
||||
Tags: specialTags,
|
||||
v, ok := specialSolve[tag]
|
||||
if !ok {
|
||||
specialSolve[tag] = digest.SpecialSolveConf{
|
||||
Num: item.Num,
|
||||
ChuckOvered: item.ChuckOvered,
|
||||
EscapeCharacter: ec,
|
||||
Tags: specialTags,
|
||||
}
|
||||
continue
|
||||
}
|
||||
v.Num = item.Num
|
||||
v.ChuckOvered = item.ChuckOvered
|
||||
v.EscapeCharacter = maps.Merge(v.EscapeCharacter, ec)
|
||||
v.Tags = maps.Merge(v.Tags, specialTags)
|
||||
specialSolve[tag] = v
|
||||
}
|
||||
}
|
||||
return specialSolve
|
||||
|
|
|
@ -184,17 +184,17 @@ func CustomizeHtml(content string, limit int, m map[string]SpecialSolveConf) (st
|
|||
}
|
||||
currentTags := allTags[len(allTags)-1]
|
||||
mm, ok := m[currentTags]
|
||||
if !ok {
|
||||
if !ok || len(mm.EscapeCharacter) < 1 {
|
||||
count++
|
||||
} else if len(mm.EscapeCharacter) > 0 {
|
||||
if n, ok := mm.EscapeCharacter[runeContent[i]]; ok {
|
||||
if (count+n.Num) > limit && n.ChuckOvered {
|
||||
break
|
||||
}
|
||||
count += n.Num
|
||||
} else {
|
||||
count++
|
||||
continue
|
||||
}
|
||||
if n, ok := mm.EscapeCharacter[runeContent[i]]; ok {
|
||||
if (count+n.Num) > limit && n.ChuckOvered {
|
||||
break
|
||||
}
|
||||
count += n.Num
|
||||
} else {
|
||||
count++
|
||||
}
|
||||
}
|
||||
if i > runeTotal {
|
||||
|
|
Loading…
Reference in New Issue
Block a user