fix text breaking by lines
parent
a4d83d3b95
commit
2b246d789d
|
@ -46,12 +46,18 @@ func textContent(s string) string {
|
|||
if node.Type == html.TextNode {
|
||||
data := strings.Trim(node.Data, "\r\n")
|
||||
if data != "" {
|
||||
w.WriteString(data + "\n")
|
||||
w.WriteString(data)
|
||||
}
|
||||
}
|
||||
for c := node.FirstChild; c != nil; c = c.NextSibling {
|
||||
extractText(c, w)
|
||||
}
|
||||
if node.Type == html.ElementNode {
|
||||
name := strings.ToLower(node.Data)
|
||||
if name == "br" {
|
||||
w.WriteString("\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
extractText(doc, &buf)
|
||||
return buf.String()
|
||||
|
|
|
@ -5,10 +5,8 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -309,7 +307,7 @@ func (c *Client) StreamingPublic(ctx context.Context) (chan Event, error) {
|
|||
}
|
||||
if err == nil {
|
||||
name := ""
|
||||
s := bufio.NewScanner(io.TeeReader(resp.Body, os.Stdout))
|
||||
s := bufio.NewScanner(resp.Body)
|
||||
for s.Scan() {
|
||||
line := s.Text()
|
||||
token := strings.SplitN(line, ":", 2)
|
||||
|
|
Loading…
Reference in New Issue