This commit is contained in:
Peter Kleiweg
2026-06-05 16:05:46 +02:00
parent efa301cc4a
commit a76fa21584
12 changed files with 645 additions and 38 deletions

View File

@@ -24,8 +24,6 @@ var (
x = e.ExitErr
reYearWeek = regexp.MustCompile(`^2[0-9][0-9][0-9]\.[0-5][0-9]$`)
reEM = regexp.MustCompile(`::EM::.*?::/EM::`)
reTitle = regexp.MustCompile(`^\p{Lu}`)
)
func main() {
@@ -68,7 +66,7 @@ func main() {
x(fmt.Fprintf(fp, "##META text tag = %s\n", t))
}
x(fp.WriteString(u.AddEnd(u.FixSpace(item.Title))))
doc, err := gokogiri.ParseHtml([]byte(`<html><body>` + em1(u.HtmlFixString(item.Text)) + `</body></html>`))
doc, err := gokogiri.ParseHtml([]byte(`<html><body>` + u.HtmlFixString(item.Text) + `</body></html>`))
x(err)
root := doc.Root()
pp, err := root.Search(`//body/p`)
@@ -76,26 +74,9 @@ func main() {
for _, p := range pp {
s := p.Content()
if !strings.Contains(s, "verscheen eerst op Tzum.") {
x(fp.WriteString(em2(u.AddEnd(u.FixSpace(p.Content())))))
x(fp.WriteString(u.AddEnd(u.FixSpace(p.Content()))))
}
}
x(fp.Close())
}
}
func em1(s string) string {
return strings.ReplaceAll(
strings.ReplaceAll(s, "<em>", " ::EM::"),
"</em>",
"::/EM:: ")
}
func em2(s string) string {
return reEM.ReplaceAllStringFunc(s, func(s1 string) string {
s1 = s1[6 : len(s1)-7]
if reTitle.MatchString(s1) {
return `"` + s1 + `"`
}
return s1
})
}