diff --git a/internal/merge.go b/internal/merge.go index e4ae80b..5c98061 100644 --- a/internal/merge.go +++ b/internal/merge.go @@ -93,28 +93,30 @@ func merge(base, doc *html.Node) (out *html.Node) { footer := findRec(body, atom.Footer) main := findRec(body, atom.Main) - if header == nil { - header = createElement(atom.Header) - body.InsertBefore(header, body.FirstChild) - } + // TODO: merge attributes + for { n := findRec(newBody, atom.Header) if n == nil { break } + if header == nil { + header = createElement(atom.Header) + body.InsertBefore(header, body.FirstChild) + } reparentChildren(header, n) n.Parent.RemoveChild(n) } - if footer == nil { - footer = createElement(atom.Header) - body.InsertBefore(footer, body.FirstChild) - } for { n := findRec(newBody, atom.Footer) if n == nil { break } + if footer == nil { + footer = createElement(atom.Header) + body.InsertBefore(footer, body.FirstChild) + } reparentChildren(footer, n) n.Parent.RemoveChild(n) }