// ToLine behaves line ToText, but also collapses all newlines to a single
// space, so the resulting text is always a single line.
ToLine behaves line ToText, but also collapses all newlines to a single
space, so the resulting text is always a single line.
// ToLine behaves line ToText but also collapses all newlines to a single // space so the resulting text is always a single line .
func ToLine(html string) string {
	if strings.TrimSpace(html) == "" {
		return html
	}
	doc, err := goquery.NewDocumentFromReader(strings.NewReader(html))
	if err != nil {
		return fmt.Sprintf("could not parse document: %v", err.Error())
	}
	var buf bytes.Buffer
	for _, n := range doc.Nodes {
		buf.WriteString(getNodeText(n))
	}
	return strings.TrimSpace(buf.String())
}
func ToLine ( html string ) string { if strings . TrimSpace ( html ) == " " { return html } doc , err := goquery . NewDocumentFromReader ( strings . NewReader ( html ) ) if err != nil { return fmt . Sprintf ( " " , err . Error ( ) ) } var buf bytes . Buffer for _ , n := range doc . Nodes { buf . WriteString ( getNodeText ( n ) ) } return strings . TrimSpace ( buf . String ( ) ) }
ToLine behaves line ToText, but also collapses all newlines to a single
space, so the resulting text is always a single line.
ToLine behaves line ToText but also collapses all newlines to a single space so the resulting text is always a single line .
// Don't return the original HTML, since that might introduce security // risks if we rely on it for XSS escaping.