speciale spaties -> gewone spaties
This commit is contained in:
@@ -220,7 +220,7 @@ func doArticle(filename string, url string, title string, tags []string, labels
|
||||
x(err)
|
||||
} else {
|
||||
for _, tag := range tags {
|
||||
_, err = fmt.Fprintf(&buf, "##META text cat = %s\n", tag)
|
||||
_, err = fmt.Fprintf(&buf, "##META text cat = %s\n", fixSpace(tag))
|
||||
x(err)
|
||||
}
|
||||
}
|
||||
@@ -229,12 +229,12 @@ func doArticle(filename string, url string, title string, tags []string, labels
|
||||
x(err)
|
||||
} else {
|
||||
for _, label := range labels {
|
||||
_, err = fmt.Fprintf(&buf, "##META text label = %s\n", label)
|
||||
_, err = fmt.Fprintf(&buf, "##META text label = %s\n", fixSpace(label))
|
||||
x(err)
|
||||
}
|
||||
}
|
||||
|
||||
_, err = buf.WriteString(clean(title))
|
||||
_, err = buf.WriteString(addEnd(fixSpace(title)))
|
||||
x(err)
|
||||
|
||||
fouten := make([]string, 0)
|
||||
@@ -243,7 +243,7 @@ func doArticle(filename string, url string, title string, tags []string, labels
|
||||
pp, err := root.Search(`//div[@data-sentry-component="ArticleHeading"]//p[contains(@class,"prose-article-body-r")]`)
|
||||
x(err)
|
||||
for _, p := range pp {
|
||||
_, err = fmt.Fprint(&buf, clean(p.Content()))
|
||||
_, err = fmt.Fprint(&buf, addEnd(fixSpace(p.Content())))
|
||||
x(err)
|
||||
found = true
|
||||
}
|
||||
@@ -259,7 +259,7 @@ func doArticle(filename string, url string, title string, tags []string, labels
|
||||
`//div[@data-sentry-component="ArticleTitle"]//h2`)
|
||||
x(err)
|
||||
for _, p := range pp {
|
||||
_, err = fmt.Fprint(&buf, clean(p.Content()))
|
||||
_, err = fmt.Fprint(&buf, addEnd(fixSpace(p.Content())))
|
||||
x(err)
|
||||
found = true
|
||||
}
|
||||
@@ -299,8 +299,8 @@ func doArticle(filename string, url string, title string, tags []string, labels
|
||||
return true
|
||||
}
|
||||
|
||||
func clean(s string) string {
|
||||
s = strings.Join(strings.Fields(s), " ")
|
||||
func addEnd(s string) string {
|
||||
s = strings.TrimSpace(s)
|
||||
n := len(s)
|
||||
if n == 0 {
|
||||
return ""
|
||||
@@ -318,3 +318,7 @@ func clean(s string) string {
|
||||
}
|
||||
return s + ".\n"
|
||||
}
|
||||
|
||||
func fixSpace(s string) string {
|
||||
return strings.Join(strings.Fields(s), " ")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user