bugfixes
This commit is contained in:
parent
4b497a8185
commit
9031c268c9
@ -139,7 +139,7 @@ func worker(opts CutupOpts, paths <-chan string, sources chan<- string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i, r := range text {
|
for i, r := range text {
|
||||||
if v := shouldBreak(phraseBuff, r); v > 0 {
|
if v := shouldBreak(phraseBuff, r); v >= 0 {
|
||||||
if len(phraseBuff) > 0 {
|
if len(phraseBuff) > 0 {
|
||||||
phraseBuff = phraseBuff[0 : len(phraseBuff)-v]
|
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 {
|
func shouldBreak(phraseBuff []byte, r rune) int {
|
||||||
if ok := phraseMarkers[r]; ok {
|
if ok := phraseMarkers[r]; ok {
|
||||||
return 1
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if r != ' ' {
|
if r != ' ' {
|
||||||
|
@ -82,6 +82,11 @@ func Test_shouldBreak(t *testing.T) {
|
|||||||
args: args{[]byte("whether good or"), ' '},
|
args: args{[]byte("whether good or"), ' '},
|
||||||
expected: 2,
|
expected: 2,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "phrase marker",
|
||||||
|
args: args{[]byte("whither good"), ';'},
|
||||||
|
expected: 1,
|
||||||
|
},
|
||||||
// TODO test phrasemarkers
|
// TODO test phrasemarkers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,18 +121,18 @@ a {
|
|||||||
<a is="about-toggler"></a>
|
<a is="about-toggler"></a>
|
||||||
<a is="theme-toggler"></a>
|
<a is="theme-toggler"></a>
|
||||||
</p>
|
</p>
|
||||||
<p id="about">
|
<div id="about">
|
||||||
<div>
|
<p>
|
||||||
HELLO. THIS IS A <a href="https://github.com/vilmibm/trunkless">SOFT WARE</a> FOR MAKING <a href="https://en.wikipedia.org/wiki/Cut-up_technique">CUT-UP POETRY</a>. THERE ARE A VARIETY OF CORPORA TO CHOOSE FROM:
|
HELLO. THIS IS A <a href="https://github.com/vilmibm/trunkless">SOFT WARE</a> FOR MAKING <a href="https://en.wikipedia.org/wiki/Cut-up_technique">CUT-UP POETRY</a>. THERE ARE A VARIETY OF CORPORA TO CHOOSE FROM:
|
||||||
</div>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><code>gutenberg</code>, THE ENTIRE ENGLISH CONTENT OF <a href="https://gutenberg.org">PROJECT GUTENBERG</a>. IT IS UNABRIDGED: BE WARNED.</li>
|
<li><code>gutenberg</code>, THE ENTIRE ENGLISH CONTENT OF <a href="https://gutenberg.org">PROJECT GUTENBERG</a>. IT IS UNABRIDGED: BE WARNED.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div>
|
<p>
|
||||||
THE AUTHOR OF THIS SOFT WARE IS <a href="https://tilde.town/~vilmibm">~VILMIBM</a>.
|
THE AUTHOR OF THIS SOFT WARE IS <a href="https://tilde.town/~vilmibm">~VILMIBM</a>.
|
||||||
</div>
|
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<button is="poem-resetter"></button>
|
<button is="poem-resetter"></button>
|
||||||
<form is="corpus-picker" style="display:inline">
|
<form is="corpus-picker" style="display:inline">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user