|
@@ -346,6 +346,7 @@ func ArticleAnnotation(item *models.ArticleListResp) (annotation string) {
|
|
|
doc, _ := goquery.NewDocumentFromReader(strings.NewReader(annotation))
|
|
|
docText := doc.Text()
|
|
|
mapDoc := make(map[int]string)
|
|
|
+ mapSortRepeat := make(map[string]string)
|
|
|
var mapSort []int
|
|
|
p := doc.Find("p")
|
|
|
p.Each(func(tk int, pd *goquery.Selection) {
|
|
@@ -353,8 +354,11 @@ func ArticleAnnotation(item *models.ArticleListResp) (annotation string) {
|
|
|
pdText = strings.Replace(pdText, " ", "", -1)
|
|
|
if pdText != "" {
|
|
|
textLen := strings.Index(docText, pdText)
|
|
|
- mapDoc[(strings.Index(docText, pdText))] = pdText
|
|
|
- mapSort = append(mapSort, textLen)
|
|
|
+ if mapSortRepeat[strconv.Itoa(textLen)] == "" {
|
|
|
+ mapDoc[(strings.Index(docText, pdText))] = pdText
|
|
|
+ mapSort = append(mapSort, textLen)
|
|
|
+ mapSortRepeat[strconv.Itoa(textLen)] = strconv.Itoa(textLen)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
li := doc.Find("li")
|
|
@@ -363,8 +367,11 @@ func ArticleAnnotation(item *models.ArticleListResp) (annotation string) {
|
|
|
liText = strings.Replace(liText, " ", "", -1)
|
|
|
if liText != "" {
|
|
|
textLen := strings.Index(docText, liText)
|
|
|
- mapDoc[(strings.Index(docText, liText))] = strconv.Itoa(tk+1) + "." + liText
|
|
|
- mapSort = append(mapSort, textLen)
|
|
|
+ if mapSortRepeat[strconv.Itoa(textLen)] == "" {
|
|
|
+ mapDoc[(strings.Index(docText, liText))] = strconv.Itoa(tk+1) + "." + liText
|
|
|
+ mapSort = append(mapSort, textLen)
|
|
|
+ mapSortRepeat[strconv.Itoa(textLen)] = strconv.Itoa(textLen)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
|
|
@@ -374,8 +381,11 @@ func ArticleAnnotation(item *models.ArticleListResp) (annotation string) {
|
|
|
ulText = strings.Replace(ulText, " ", "", -1)
|
|
|
if ulText != "" {
|
|
|
textLen := strings.Index(docText, ulText)
|
|
|
- mapDoc[(strings.Index(docText, ulText))] = ulText
|
|
|
- mapSort = append(mapSort, textLen)
|
|
|
+ if mapSortRepeat[strconv.Itoa(textLen)] == "" {
|
|
|
+ mapDoc[(strings.Index(docText, ulText))] = ulText
|
|
|
+ mapSort = append(mapSort, textLen)
|
|
|
+ mapSortRepeat[strconv.Itoa(textLen)] = strconv.Itoa(textLen)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
if len(mapSort) == 0 {
|