ref: b791b97ed43150a4be18b5153cf2829f74adc850
parent: f28762979873b8c9de33dd368cb3224c00698c34
author: penny <penny@limitedideas.org>
date: Sun Oct 5 17:05:43 EDT 2025
newline formatting tweaks on new renderer
--- a/format.go
+++ b/format.go
@@ -20,13 +20,11 @@
}
longline := false
- if len(remainder) > width {- longline = true
- }
for len(remainder) > width { if strings.HasPrefix(string(remainder), "\n") {result = append(result, '\n')
+ longline = true
remainder = remainder[1:]
continue
}
@@ -50,6 +48,7 @@
if breakPos > 0 {result = append(result, remainder[:breakPos]...)
result = append(result, '\n')
+ longline = true
remainder = remainder[breakPos+1:]
continue
}
@@ -57,10 +56,12 @@
if remainder[width-1] == ' ' {result = append(result, remainder[:width-1]...)
result = append(result, '\n')
+ longline = true
remainder = remainder[width:] // Consume the space
} else if remainder[width-1] == '-' {result = append(result, remainder[:width]...)
result = append(result, '\n')
+ longline = true
remainder = remainder[width:] // Consume the hyphen
} else if remainder[width-1] != ' ' {result = append(result, remainder[:width-1]...)
@@ -78,7 +79,7 @@
if strings.HasSuffix(string(result), "\n") {result = result[:len(result)-1]
}
- //Put a newline at the end if status takes multiple lines
+ //Put an extra newline at the end if status takes multiple lines
if longline {result = append(result, '\n')
}
--- a/mastodon.go
+++ b/mastodon.go
@@ -230,10 +230,10 @@
func (hc *Hellclient) RenderPostPlaintext(post *mastodon.Status, ref postref) (selectedPost *mastodon.Status, plaintext string) { if post.Reblog != nil {selectedPost = post.Reblog
- plaintext = fmt.Sprintf("$username Reblogged %s> $boostuser $boostcontent $boosted_media_descriptions", ref.ref)+ plaintext = fmt.Sprintf("$username Reblogged %s> $boostuser $boostcontent $boosted_media_descriptions", ref.prefix + ref.ref) } else {selectedPost = post
- plaintext = fmt.Sprintf("%s> $username $content $media_descriptions", ref.ref)+ plaintext = fmt.Sprintf("%s> $username $content $media_descriptions", ref.prefix + ref.ref)}
formatter := &StatusFormatter{hc: hc, status: post, postContext: &ref}templater := newStatusTemplateRenderer(formatter)
--- a/notifications.go
+++ b/notifications.go
@@ -71,12 +71,12 @@
func (hc *Hellclient) RenderNotificationsArray(notifications []*mastodon.Notification) []string {var noticeTexts []string
status := func(Notification *mastodon.Notification, plaintext string) {- notification := fmt.Sprintf("[%s] from <%s>: %s\n", Notification.Type, Notification.Account.Acct, plaintext)+ notification := fmt.Sprintf("[%s] from <%s>: %s", Notification.Type, Notification.Account.Acct, plaintext)noticeTexts = append(noticeTexts, hyphenate(notification))
}
other := func(Notification *mastodon.Notification) {- notification := fmt.Sprintf("[%s] from <%s>\n", Notification.Type, Notification.Account.Acct)+ notification := fmt.Sprintf("[%s] from <%s>", Notification.Type, Notification.Account.Acct)noticeTexts = append(noticeTexts, hyphenate(notification))
}
--- a/pages.go
+++ b/pages.go
@@ -188,7 +188,7 @@
noticeArray := noticeData.hc.RenderNotificationsArray(notices)
var itemArray []PageItem
for i := range noticeArray {- item := makePageItem(noticeArray[i] + "\n")
+ item := makePageItem(noticeArray[i])
itemArray = append(itemArray, item)
}
noticeData.page.MinID = ""
--- a/renderer.go
+++ b/renderer.go
@@ -48,9 +48,6 @@
}
sb.WriteString("🖼️")}
- if len(status.MediaAttachments) > 0 {- sb.WriteString("\n")- }
return sb.String()
}
--- a/templater.go
+++ b/templater.go
@@ -39,5 +39,5 @@
return fmt.Sprintf("[%%KEY_NOT_FOUND:%s]", key)}
- return hyphenate(os.Expand(template, expandMap)), nil
+ return hyphenate(os.Expand(template, expandMap)) + "\n", nil
}
--
⑨