From 9031c268c95aa30ff8e3ee1305ecea0624f50e1a Mon Sep 17 00:00:00 2001
From: nate smith
Date: Tue, 30 Apr 2024 21:52:20 -0700
Subject: [PATCH] bugfixes
---
cutup/cutup.go | 4 ++--
cutup/cutup_test.go | 5 +++++
templates/index.tmpl | 10 +++++-----
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/cutup/cutup.go b/cutup/cutup.go
index 24aa8f2..21937e1 100644
--- a/cutup/cutup.go
+++ b/cutup/cutup.go
@@ -139,7 +139,7 @@ func worker(opts CutupOpts, paths <-chan string, sources chan<- string) {
}
}
for i, r := range text {
- if v := shouldBreak(phraseBuff, r); v > 0 {
+ if v := shouldBreak(phraseBuff, r); v >= 0 {
if len(phraseBuff) > 0 {
phraseBuff = phraseBuff[0 : len(phraseBuff)-v]
}
@@ -198,7 +198,7 @@ const maxSuffixLen = 8 // magic number based on longest suffix
func shouldBreak(phraseBuff []byte, r rune) int {
if ok := phraseMarkers[r]; ok {
- return 1
+ return 0
}
if r != ' ' {
diff --git a/cutup/cutup_test.go b/cutup/cutup_test.go
index ce2700c..231fc7a 100644
--- a/cutup/cutup_test.go
+++ b/cutup/cutup_test.go
@@ -82,6 +82,11 @@ func Test_shouldBreak(t *testing.T) {
args: args{[]byte("whether good or"), ' '},
expected: 2,
},
+ {
+ name: "phrase marker",
+ args: args{[]byte("whither good"), ';'},
+ expected: 1,
+ },
// TODO test phrasemarkers
}
diff --git a/templates/index.tmpl b/templates/index.tmpl
index a7d5cd3..3ee7569 100644
--- a/templates/index.tmpl
+++ b/templates/index.tmpl
@@ -121,18 +121,18 @@ a {
-
-
+
+
gutenberg
, THE ENTIRE ENGLISH CONTENT OF PROJECT GUTENBERG. IT IS UNABRIDGED: BE WARNED.
-
+
THE AUTHOR OF THIS SOFT WARE IS ~VILMIBM.
-
+