Document posts.ExtractTitle func

This commit is contained in:
Matt Baer
2019-05-30 10:12:34 -04:00
parent 1f29da565f
commit 46304124ec
+2
View File
@@ -4,6 +4,8 @@ import (
"strings" "strings"
) )
// ExtractTitle takes the given raw post text and returns a title, if explicitly
// provided, and a body.
func ExtractTitle(content string) (title string, body string) { func ExtractTitle(content string) (title string, body string) {
if hashIndex := strings.Index(content, "# "); hashIndex == 0 { if hashIndex := strings.Index(content, "# "); hashIndex == 0 {
eol := strings.IndexRune(content, '\n') eol := strings.IndexRune(content, '\n')