(content, friendlyId string)
| 216 | } |
| 217 | |
| 218 | func 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. |
no test coverage detected