Command line client for Write.as https://write.as/apps/cli
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

20 行
407 B

  1. package posts
  2. import (
  3. "strings"
  4. )
  5. func ExtractTitle(content string) (title string, body string) {
  6. if hashIndex := strings.Index(content, "# "); hashIndex == 0 {
  7. eol := strings.IndexRune(content, '\n')
  8. // First line should start with # and end with \n
  9. if eol != -1 {
  10. body = strings.TrimLeft(content[eol:], " \t\n\r")
  11. title = content[len("# "):eol]
  12. return
  13. }
  14. }
  15. body = content
  16. return
  17. }