speciale spaties -> gewone spaties

This commit is contained in:
Peter Kleiweg
2026-03-02 21:41:13 +01:00
parent a94b190108
commit fd750a8d47
10 changed files with 72 additions and 31 deletions

View File

@@ -57,10 +57,10 @@ func main() {
var item Item
x(xml.Unmarshal(b, &item))
for _, cat := range item.Cats {
_, err = fmt.Fprintf(fp, "##META text cat = %s\n", cat)
_, err = fmt.Fprintf(fp, "##META text cat = %s\n", fixSpace(cat))
x(err)
}
_, err = fp.WriteString(addEnd(item.Title))
_, err = fp.WriteString(addEnd(fixSpace(item.Title)))
x(err)
doc, err := gokogiri.ParseHtml([]byte(`<html><body>` + item.Text + `</body></html>`))
x(err)
@@ -73,7 +73,7 @@ func main() {
pp, err := root.Search(`//body//p[not(.//a[contains(@href,"reportersonline.nl/support")])]`)
x(err)
for _, p := range pp {
_, err = fp.WriteString(addEnd(p.Content()))
_, err = fp.WriteString(addEnd(fixSpace(p.Content())))
x(err)
}
x(err)
@@ -100,3 +100,7 @@ func addEnd(s string) string {
}
return s + ".\n"
}
func fixSpace(s string) string {
return strings.Join(strings.Fields(s), " ")
}