From 48a11ab6d77f1f76593c5b741be44875833d32ae Mon Sep 17 00:00:00 2001 From: Niko Abeler Date: Thu, 1 Dec 2022 19:37:13 +0100 Subject: [PATCH] fix note rendering --- post.go | 6 +++--- post_test.go | 6 ++---- renderer.go | 2 +- renderer_test.go | 8 +++++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/post.go b/post.go index 3c51153..08961c0 100644 --- a/post.go +++ b/post.go @@ -168,7 +168,7 @@ func (post *Post) Content() []byte { return data } -func (post *Post) RenderedContent() bytes.Buffer { +func (post *Post) RenderedContent() string { data := post.Content() // trim yaml block @@ -204,7 +204,7 @@ func (post *Post) RenderedContent() bytes.Buffer { panic(err) } - return buf + return buf.String() } @@ -366,7 +366,7 @@ func (post *Post) ScanForLinks() error { // this could be done in markdown parsing, but I don't want to // rely on goldmark for this (yet) postHtml := post.RenderedContent() - links, _ := post.user.repo.Parser.ParseLinksFromString(postHtml.String()) + links, _ := post.user.repo.Parser.ParseLinksFromString(postHtml) // add reply url if set if post.Meta().Reply.Url != "" { links = append(links, post.Meta().Reply.Url) diff --git a/post_test.go b/post_test.go index 4d83654..67b30a9 100644 --- a/post_test.go +++ b/post_test.go @@ -80,8 +80,7 @@ func TestNoRawHTMLIfDisallowedByRepo(t *testing.T) { content += "\n" os.WriteFile(post.ContentFile(), []byte(content), 0644) html := post.RenderedContent() - html_str := html.String() - assertions.AssertNotContains(t, html_str, "\n" os.WriteFile(post.ContentFile(), []byte(content), 0644) html := post.RenderedContent() - html_str := html.String() - assertions.AssertContains(t, html_str, "