diff --git a/internal/format/format.go b/internal/format/format.go index 12813a0..f06edce 100644 --- a/internal/format/format.go +++ b/internal/format/format.go @@ -36,6 +36,15 @@ func FormatHtml2Text(htmlText string, width, leftPadding int) string { return wrapped } +func FormatText(plainText string, width, leftPadding int) string { + wrapped, _ := text.WrapLeftPadded( + GreenTextIt(strings.ReplaceAll(plainText, "\r\n", "\n")), + width, + leftPadding, + ) + return wrapped +} + func Min(a, b int) int { if a < b { return a diff --git a/internal/lobsters/fetch.go b/internal/lobsters/fetch.go index 6ad3777..7e7ba42 100644 --- a/internal/lobsters/fetch.go +++ b/internal/lobsters/fetch.go @@ -26,7 +26,7 @@ func Fetch(rawUrl, userAgent string, timeout time.Duration) (*Thread, error) { thread := Thread{} thread.op = Op{ createdAt: gjson.Get(jsonRaw, "created_at").Time(), - message: gjson.Get(jsonRaw, "description").String(), + message: gjson.Get(jsonRaw, "description_plain").String(), nComments: int(gjson.Get(jsonRaw, "comment_count").Int()), score: int(gjson.Get(jsonRaw, "score").Int()), self: rawUrl, @@ -41,7 +41,7 @@ func Fetch(rawUrl, userAgent string, timeout time.Duration) (*Thread, error) { thread.insert(Comment{ createdAt: comment.Get("created_at").Time(), id: comment.Get("short_id").String(), - message: comment.Get("comment").String(), + message: comment.Get("comment_plain").String(), parent: comment.Get("parent_comment").String(), score: int(comment.Get("score").Int()), thread: &thread, diff --git a/internal/lobsters/format.go b/internal/lobsters/format.go index 221cdaa..f49ad59 100644 --- a/internal/lobsters/format.go +++ b/internal/lobsters/format.go @@ -25,7 +25,7 @@ func (o Op) String() (ret string) { } ret += fmt.Sprintf( "\n%s\n\n", - format.FormatHtml2Text(o.message, o.thread.LineWidth, o.thread.LeftPadding), + format.FormatText(o.message, o.thread.LineWidth, o.thread.LeftPadding), ) ret += fmt.Sprintf( "%s - %s \n\n\n", @@ -45,7 +45,7 @@ func (c Comment) String() (ret string) { ) - rightPadding ret += fmt.Sprintf( "%s\n", - format.FormatHtml2Text(c.message, lineWidth, leftPadding+extraLeft), + format.FormatText(c.message, lineWidth, leftPadding+extraLeft), ) ret += strings.Repeat(" ", leftPadding) ret += ">>"