MCPcopy Index your code
hub / github.com/apache/answer / cutLongTitle

Function cutLongTitle

pkg/htmltext/htmltext.go:98–109  ·  view source on GitHub ↗
(title string)

Source from the content-addressed store, hash-verified

96}
97
98func cutLongTitle(title string) string {
99 maxBytes := 150
100 if len(title) <= maxBytes {
101 return title
102 }
103
104 truncated := title[:maxBytes]
105 for len(truncated) > 0 && !utf8.ValidString(truncated) {
106 truncated = truncated[:len(truncated)-1]
107 }
108 return truncated
109}
110
111// FetchExcerpt return the excerpt from the HTML string
112func FetchExcerpt(html, trimMarker string, limit int) (text string) {

Callers 2

UrlTitleFunction · 0.85
TestCutLongTitleFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestCutLongTitleFunction · 0.68