Initial support for some unicode line endings
This commit is contained in:
parent
97b74ea767
commit
388218a5b6
4
page.go
4
page.go
|
@ -91,8 +91,8 @@ func (p *Page) WrapContent(width int, color bool) {
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ch == '\n' {
|
if ch == '\n' || ch == '\u0085' || ch == '\u2028' || ch == '\u2029' {
|
||||||
content.WriteRune(ch)
|
content.WriteRune('\n')
|
||||||
counter = 0
|
counter = 0
|
||||||
} else if ch == '\t' {
|
} else if ch == '\t' {
|
||||||
if counter+4 < width {
|
if counter+4 < width {
|
||||||
|
|
20
page_test.go
20
page_test.go
|
@ -61,6 +61,26 @@ func Test_WrapContent_Wrapped_Line_Length(t *testing.T) {
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Unicode line endings that should not wrap",
|
||||||
|
"LF\u000A" +
|
||||||
|
"CR+LF\u000D\u000A" +
|
||||||
|
"NEL\u0085" +
|
||||||
|
"LS\u2028" +
|
||||||
|
"PS\u2029",
|
||||||
|
[]string{
|
||||||
|
"LF",
|
||||||
|
"CR+LF",
|
||||||
|
"NEL",
|
||||||
|
"LS",
|
||||||
|
"PS",
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
args{
|
||||||
|
10,
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue