Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

refactor(htmltext): FetchExcerpt delegates to FetchRangedExcerpt

Octobugd8ab71fd0fcb
diff --git a/pkg/htmltext/htmltext.go b/pkg/htmltext/htmltext.go
index df8866ca..459f7a13 100644
--- a/pkg/htmltext/htmltext.go
+++ b/pkg/htmltext/htmltext.go
@@ -125,20 +125,7 @@ func cutLongTitle(title string) string {
// FetchExcerpt return the excerpt from the HTML string
func FetchExcerpt(html, trimMarker string, limit int) (text string) {
- if len(html) == 0 {
- text = html
- return
- }
-
- text = ClearText(html)
- runeText := []rune(text)
- if len(runeText) <= limit {
- text = string(runeText)
- return
- }
-
- text = string(runeText[0:limit]) + trimMarker
- return
+ return FetchRangedExcerpt(html, trimMarker, 0, limit)
}
// findFirstMatchedWord returns the first matched word and its index