Codebase list golang-github-jaytaylor-html2text / 01ec452
Properly trim white space of text nodes Mike McCrary authored 5 years ago J. Elliot Taylor committed 4 years ago
2 changed file(s) with 5 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
398398 if ctx.isPre {
399399 data = node.Data
400400 } else {
401 data = strings.Trim(spacingRe.ReplaceAllString(node.Data, " "), " ")
401 data = strings.TrimSpace(spacingRe.ReplaceAllString(node.Data, " "))
402402 }
403403 return ctx.emit(data)
404404
668668 "Test 1<div>Test 2</div> <div>Test 3</div>Test 4",
669669 "Test 1\nTest 2\nTest 3\nTest 4",
670670 },
671 {
672 "Test 1<div>&nbsp;Test 2&nbsp;</div>",
673 "Test 1\nTest 2",
674 },
671675 }
672676
673677 for _, testCase := range testCases {