func sanitizeText(s string, newlineSemi bool) []byte {
	out := make([]byte, 0, len(s))
	prevWhite := false
	for _, r := range s {
		if newlineSemi && r == '\n' && len(out) > 0 {
			out = append(out, ';')
			prevWhite = true
			continue
		}
		if unicode.IsSpace(r) {
			if len(out) > 0 {
				prevWhite = true
			}
			continue
		}
		if prevWhite {
			out = append(out, ' ')
			prevWhite = false
		}
		out = append(out, string(r)...)
	}
	// Remove final space, any full stops and any final semicolon
	// we might have added.
	out = bytes.TrimRightFunc(out, func(r rune) bool {
		return r == '.' || r == ' ' || r == ';'
	})
	return out
}
// sanitizeText tries to make the given string easier to read when presented
// as a single line. It squashes each run of white space into a single
// space, trims leading and trailing white space and trailing full
// stops. If newlineSemi is true, any newlines will be replaced with a
// semicolon.
sanitizeText tries to make the given string easier to read when presented
as a single line. It squashes each run of white space into a single
space, trims leading and trailing white space and trailing full
stops. If newlineSemi is true, any newlines will be replaced with a
semicolon.
// sanitizeText tries to make the given string easier to read when presented // as a single line . It squashes each run of white space into a single // space trims leading and trailing white space and trailing full // stops . If newlineSemi is true any newlines will be replaced with a // semicolon .
func sanitizeText(s string, newlineSemi bool) []byte {
	out := make([]byte, 0, len(s))
	prevWhite := false
	for _, r := range s {
		if newlineSemi && r == '\n' && len(out) > 0 {
			out = append(out, ';')
			prevWhite = true
			continue
		}
		if unicode.IsSpace(r) {
			if len(out) > 0 {
				prevWhite = true
			}
			continue
		}
		if prevWhite {
			out = append(out, ' ')
			prevWhite = false
		}
		out = append(out, string(r)...)
	}
	out = bytes.TrimRightFunc(out, func(r rune) bool {
		return r == '.' || r == ' ' || r == ';'
	})
	return out
}
func sanitizeText ( s string , newlineSemi bool ) [ ] byte { out := make ( [ ] byte , 0 , len ( s ) ) prevWhite := false for _ , r := range s { if newlineSemi && r == '\n' && len ( out ) > 0 { out = append ( out , ';' ) prevWhite = true continue } if unicode . IsSpace ( r ) { if len ( out ) > 0 { prevWhite = true } continue } if prevWhite { out = append ( out , ' ' ) prevWhite = false } out = append ( out , string ( r ) ... ) } out = bytes . TrimRightFunc ( out , func ( r rune ) bool { return r == '.' || r == ' ' || r == ';' } ) return out }
sanitizeText tries to make the given string easier to read when presented
as a single line.
sanitizeText tries to make the given string easier to read when presented as a single line .
// Remove final space, any full stops and any final semicolon // we might have added.