Release to master 2.4.0 #217
4
page.go
4
page.go
|
@ -142,6 +142,10 @@ func (p *Page) WrapContent(width, maxWidth int, color bool) {
|
||||||
if counter+(j-i) <= width+1 && !(j == i && counter == width+1) {
|
if counter+(j-i) <= width+1 && !(j == i && counter == width+1) {
|
||||||
content.WriteRune(ch)
|
content.WriteRune(ch)
|
||||||
counter++
|
counter++
|
||||||
|
} else if ch == ' ' || ch == '\t' {
|
||||||
|
// we want to wrap and write this char, but it's a space. eat it to prevent the next line from
|
||||||
|
// having a leading whitespace because of our wrapping
|
||||||
|
counter++
|
||||||
} else {
|
} else {
|
||||||
content.WriteRune('\n')
|
content.WriteRune('\n')
|
||||||
counter = 0
|
counter = 0
|
||||||
|
|
33
page_test.go
33
page_test.go
|
@ -52,10 +52,10 @@ func Test_WrapContent_Wrapped_Line_Length(t *testing.T) {
|
||||||
"01 345 789 123456789 123456789 123456789 123456789\n",
|
"01 345 789 123456789 123456789 123456789 123456789\n",
|
||||||
[]string{
|
[]string{
|
||||||
"01 345 789",
|
"01 345 789",
|
||||||
" 123456789",
|
"123456789 ",
|
||||||
" 123456789",
|
"123456789 ",
|
||||||
" 123456789",
|
"123456789 ",
|
||||||
" 123456789",
|
"123456789",
|
||||||
"",
|
"",
|
||||||
},
|
},
|
||||||
args{
|
args{
|
||||||
|
@ -65,14 +65,29 @@ func Test_WrapContent_Wrapped_Line_Length(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Long line wrapped to 10 columns",
|
"Long line wrapped to 10 columns, leading spaces omitted when wrapping",
|
||||||
"0123456789 123456789 123456789 123456789 123456789\n",
|
"0123456789 123456789 123456789 123456789 123456789\n",
|
||||||
[]string{
|
[]string{
|
||||||
"0123456789",
|
"0123456789",
|
||||||
" 123456789",
|
"123456789 ",
|
||||||
" 123456789",
|
"123456789 ",
|
||||||
" 123456789",
|
"123456789 ",
|
||||||
" 123456789",
|
"123456789",
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
args{
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Intentional leading spaces aren't trimmed",
|
||||||
|
"01 345\n 789 123456789\n",
|
||||||
|
[]string{
|
||||||
|
"01 345",
|
||||||
|
" 789 ",
|
||||||
|
"123456789",
|
||||||
"",
|
"",
|
||||||
},
|
},
|
||||||
args{
|
args{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user