Skip to content

Commit

Permalink
blocko.isEmpty: Use xhtml.Children
Browse files Browse the repository at this point in the history
  • Loading branch information
earthboundkid committed May 20, 2024
1 parent 4f6e9d4 commit c10b2de
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions internal/blocko/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,16 @@ var inlineElements = map[atom.Atom]bool{
}

func isEmpty(n *html.Node) bool {
root := n
for n := range xhtml.All(n) {
if n == root {
continue
}
switch n.Type {
for c := range xhtml.Children(n) {
switch c.Type {
case html.TextNode:
s := strings.ReplaceAll(n.Data, "\n", " ")
s := strings.ReplaceAll(c.Data, "\n", " ")
s = strings.TrimSpace(s)
if s == "" {
continue
}
case html.ElementNode:
if inlineElements[n.DataAtom] {
if inlineElements[c.DataAtom] {
continue
}
}
Expand Down

0 comments on commit c10b2de

Please sign in to comment.