@@ 2,7 2,9 @@ package main
import (
"bytes"
+ "fmt"
"html/template"
+ "strings"
"github.com/yuin/goldmark"
)
@@ 19,7 21,12 @@ func (p Post) Render() template.HTML {
// #post -> post
func (p Post) BuildReply() string {
- // naive solution: prefix everything with '> '
- // User [@username](/u/username) wrote in [#n](/post/n)...
- return p.Content
+ var out bytes.Buffer
+ // TODO link to post
+ out.Write([]byte(fmt.Sprintf("[@%s](/u/%s) wrote:\n", p.Author.Username, p.Author.Username)))
+ for _, line := range strings.Split(p.Content, "\n") {
+ out.Write([]byte("> "))
+ out.Write([]byte(line))
+ }
+ return out.String()
}