MCPcopy
hub / github.com/writefreely/writefreely / postTitle

Function postTitle

postrender.go:218–232  ·  view source on GitHub ↗
(content, friendlyId string)

Source from the content-addressed store, hash-verified

216}
217
218func postTitle(content, friendlyId string) string {
219 const maxTitleLen = 80
220
221 content = stripHTMLWithoutEscaping(content)
222
223 content = strings.TrimLeftFunc(stripmd.Strip(content), unicode.IsSpace)
224 eol := strings.IndexRune(content, '\n')
225 blankLine := strings.Index(content, "\n\n")
226 if blankLine != -1 && blankLine <= eol && blankLine <= assumedTitleLen {
227 return strings.TrimSpace(content[:blankLine])
228 } else if utf8.RuneCountInString(content) <= maxTitleLen {
229 return content
230 }
231 return friendlyId
232}
233
234// TODO: fix duplicated code from postTitle. postTitle is a widely used func we
235// don't have time to investigate right now.

Callers 1

getSlugFromPostFunction · 0.85

Calls 1

stripHTMLWithoutEscapingFunction · 0.85

Tested by

no test coverage detected