Tzum: <em>Titel</em> -> "Titel"
This commit is contained in:
@@ -24,6 +24,8 @@ var (
|
|||||||
x = e.ExitErr
|
x = e.ExitErr
|
||||||
|
|
||||||
reYearWeek = regexp.MustCompile(`^2[0-9][0-9][0-9]\.[0-5][0-9]$`)
|
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() {
|
func main() {
|
||||||
@@ -66,7 +68,7 @@ func main() {
|
|||||||
x(fmt.Fprintf(fp, "##META text tag = %s\n", t))
|
x(fmt.Fprintf(fp, "##META text tag = %s\n", t))
|
||||||
}
|
}
|
||||||
x(fp.WriteString(u.AddEnd(u.FixSpace(item.Title))))
|
x(fp.WriteString(u.AddEnd(u.FixSpace(item.Title))))
|
||||||
doc, err := gokogiri.ParseHtml([]byte(`<html><body>` + u.HtmlFixString(item.Text) + `</body></html>`))
|
doc, err := gokogiri.ParseHtml([]byte(`<html><body>` + em1(u.HtmlFixString(item.Text)) + `</body></html>`))
|
||||||
x(err)
|
x(err)
|
||||||
root := doc.Root()
|
root := doc.Root()
|
||||||
pp, err := root.Search(`//body/p`)
|
pp, err := root.Search(`//body/p`)
|
||||||
@@ -74,9 +76,26 @@ func main() {
|
|||||||
for _, p := range pp {
|
for _, p := range pp {
|
||||||
s := p.Content()
|
s := p.Content()
|
||||||
if !strings.Contains(s, "verscheen eerst op Tzum.") {
|
if !strings.Contains(s, "verscheen eerst op Tzum.") {
|
||||||
x(fp.WriteString(u.AddEnd(u.FixSpace(p.Content()))))
|
x(fp.WriteString(em2(u.AddEnd(u.FixSpace(p.Content())))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x(fp.Close())
|
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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user