mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
Basic table removal rule
This commit is contained in:
parent
9a826bbe6f
commit
49d2596fc6
3 changed files with 43 additions and 0 deletions
|
@ -335,3 +335,34 @@ func parseMarkdown(entryContent string) string {
|
|||
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
func removeTables(entryContent string) string {
|
||||
doc, err := goquery.NewDocumentFromReader(strings.NewReader(entryContent))
|
||||
if err != nil {
|
||||
return entryContent
|
||||
}
|
||||
|
||||
var table *goquery.Selection
|
||||
|
||||
for {
|
||||
table = doc.Find("table").First()
|
||||
|
||||
if table.Length() == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
td := table.Find("td").First()
|
||||
|
||||
if td.Length() == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
tdHtml, _ := td.Html()
|
||||
|
||||
table.Parent().AppendHtml(tdHtml)
|
||||
table.Remove()
|
||||
}
|
||||
|
||||
output, _ := doc.Find("body").First().Html()
|
||||
return output
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue