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 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
specialSolve[tag] = digest.SpecialSolveConf{
|
v, ok := specialSolve[tag]
|
||||||
Num: item.Num,
|
if !ok {
|
||||||
ChuckOvered: item.ChuckOvered,
|
specialSolve[tag] = digest.SpecialSolveConf{
|
||||||
EscapeCharacter: ec,
|
Num: item.Num,
|
||||||
Tags: specialTags,
|
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
|
return specialSolve
|
||||||
|
|
|
@ -184,17 +184,17 @@ 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 (count+n.Num) > limit && n.ChuckOvered {
|
if n, ok := mm.EscapeCharacter[runeContent[i]]; ok {
|
||||||
break
|
if (count+n.Num) > limit && n.ChuckOvered {
|
||||||
}
|
break
|
||||||
count += n.Num
|
|
||||||
} else {
|
|
||||||
count++
|
|
||||||
}
|
}
|
||||||
|
count += n.Num
|
||||||
|
} else {
|
||||||
|
count++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if i > runeTotal {
|
if i > runeTotal {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user