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