ref: cc7e785c8e24ddf31409fdefaf3eb26b7b90bbbf
parent: e5b736cb7f152d66efcc2c8b5e33f372dd8db2f5
author: penny <penny@limitedideas.org>
date: Tue Aug 5 18:27:37 EDT 2025
one more edge case for hyphens
--- a/format.go
+++ b/format.go
@@ -3,27 +3,26 @@
import (
"strings"
- //"github.com/chzyer/readline"
+ "github.com/chzyer/readline"
)
func hyphenate(input string) string {width := readline.GetScreenWidth()
- result, remainder := hyphenateline(input, width)
+ remainder := input
var cresult string
var result string
- for len([]rune(remainder)) > width-1 {+ for len([]rune(remainder)) > width-2 {cresult, remainder = hyphenateline(remainder, width)
result += cresult
- if len([]rune(cresult)) == width-1 {- if(!strings.HasSuffix(cresult, " ")) {- result += "-"
- } else {- result += "\n"
- }
- }
-
- }
+ if len([]rune(cresult)) == width-1 {+ if !strings.HasSuffix(cresult, " ") && !strings.HasPrefix(remainder, " ") {+ result += "-"
+ } else {+ result += "\n"
+ }
+ }
+ }
return result + remainder
}
--
⑨