Skip to content

Commit 99ca9c0

Browse files
committed
Improve rendering of posts
1 parent 793f2d2 commit 99ca9c0

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

pkg/posts/post.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,27 @@ func openPost(app *tview.Application, postcuid string, list *tview.List) {
7878
return ""
7979
}(),
8080
)
81+
noresponse := len(singlePost.Post.Responses)
8182
for ind, response := range singlePost.Post.Responses {
8283
writeToTextView(
8384
textView,
84-
fmt.Sprintf("\n%d", ind+1),
85-
fmt.Sprintf("---"),
85+
fmt.Sprintf("\n[green]Response %d/%d[white]", ind+1, noresponse),
86+
fmt.Sprintf("[green]--------------[green]"),
8687
renderTerminal(response.ContentMarkdown),
8788
)
8889
if len(response.Replies) > 0 {
8990
writeToTextView(textView,
90-
"\n\t[green]Replies[white]",
91-
"\t[green]=======[white]",
91+
"\n[yellow]Replies[white]",
92+
"[yellow]=======[white]",
9293
)
94+
noreplies := len(response.Replies)
9395
for indreply, reply := range response.Replies {
9496
writeToTextView(
9597
textView,
96-
fmt.Sprintf("\n\t%d", indreply+1),
97-
fmt.Sprintf("\t---"),
98-
fmt.Sprintf("\tAuthor: %s", reply.Author.Name),
99-
fmt.Sprintf("\t%s", renderTerminal(reply.ContentMarkdown)),
98+
fmt.Sprintf("\n[yellow]Reply %d/%d[white]", indreply+1, noreplies),
99+
fmt.Sprintf("[yellow]~~~~~~~~~~~[white]"),
100+
fmt.Sprintf("Author: %s", reply.Author.Name),
101+
indentMarkdown(renderTerminal(reply.ContentMarkdown), "\t"),
100102
)
101103

102104
}
@@ -135,3 +137,11 @@ func renderTerminal(content string) string {
135137
return out
136138

137139
}
140+
141+
func indentMarkdown(s string, prefix string) string {
142+
// var lines []string
143+
// for _, line := range strings.Split(s, "\n") {
144+
// lines = append(lines, fmt.Sprintf("%s%s", prefix, line))
145+
// }
146+
return fmt.Sprintf("%s%s", prefix, s)
147+
}

0 commit comments

Comments
 (0)