Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10669938
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
669 B
Subscribers
None
View Options
diff --git a/posts/parse.go b/posts/parse.go
index 85d0c4d..b082a05 100644
--- a/posts/parse.go
+++ b/posts/parse.go
@@ -1,19 +1,21 @@
package posts
import (
"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) {
if hashIndex := strings.Index(content, "# "); hashIndex == 0 {
eol := strings.IndexRune(content, '\n')
// First line should start with # and end with \n
if eol != -1 {
body = strings.TrimLeft(content[eol:], " \t\n\r")
title = content[len("# "):eol]
return
}
}
body = content
return
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, May 16, 6:32 PM (6 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3240361
Attached To
rWC Write.as Web Core
Event Timeline
Log In to Comment