From 6844c6e3481e450aa05a8c01bc1ef98bf84a1f60 Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Sun, 26 May 2024 03:09:47 +0100 Subject: [PATCH] checkpoint: use Content instead of Text Content from Mastodon statuses are not converted to plain text server side unfortunately so it needs to be done client side. Display messages from the Content field and run the content through the StripHTMLTags function before printing. --- internal/model/status.go | 2 +- internal/model/timeline.go | 4 ++-- internal/utilities/utilities.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/model/status.go b/internal/model/status.go index 29dd695..1bc22e7 100644 --- a/internal/model/status.go +++ b/internal/model/status.go @@ -182,7 +182,7 @@ func (s Status) String() string { utilities.DisplayNameFormat(s.Account.DisplayName), s.Account.Username, utilities.HeaderFormat("CONTENT:"), - utilities.WrapLines(s.Text, "\n ", 80), + utilities.WrapLines(s.Content, "\n ", 80), utilities.HeaderFormat("STATUS ID:"), s.ID, utilities.HeaderFormat("CREATED AT:"), diff --git a/internal/model/timeline.go b/internal/model/timeline.go index 7f3480f..5b8ee26 100644 --- a/internal/model/timeline.go +++ b/internal/model/timeline.go @@ -16,11 +16,11 @@ func (t Timeline) String() string { separator := "────────────────────────────────────────────────────────────────────────────────" - builder.WriteString(t.Name + "\n" + separator + "\n") + builder.WriteString(utilities.HeaderFormat(t.Name) + "\n\n") for _, status := range t.Statuses { builder.WriteString(utilities.DisplayNameFormat(status.Account.DisplayName) + " (@" + status.Account.Username + ")\n\n") - builder.WriteString(utilities.WrapLines(status.Text, "\n", 80) + "\n\n") + builder.WriteString(utilities.WrapLines(utilities.StripHTMLTags(status.Content), "\n", 80) + "\n\n") builder.WriteString(utilities.FieldFormat("ID:") + " " + status.ID + "\t" + utilities.FieldFormat("Created at:") + " " + utilities.FormatTime(status.CreatedAt) + "\n") builder.WriteString(separator + "\n") } diff --git a/internal/utilities/utilities.go b/internal/utilities/utilities.go index d3fc812..31daf69 100644 --- a/internal/utilities/utilities.go +++ b/internal/utilities/utilities.go @@ -43,7 +43,7 @@ func StripHTMLTags(text string) string { case html.ErrorToken: return builder.String() case html.TextToken: - text := token.Token().String() + text := token.Token().Data builder.WriteString(text) case html.StartTagToken: tag := token.Token().String()