more consistent error messages

master
magical 2021-11-16 06:24:03 +00:00
parent 6e5ef58613
commit 3de81ba65c
1 changed files with 4 additions and 4 deletions

View File

@ -69,13 +69,13 @@ func Merge(base, doc io.Reader) (merged string, assets *Assets, _ error) {
func merge(base, doc *html.Node) (out *html.Node) {
out, err := html.Parse(strings.NewReader("<!doctype html><html><head></head><body></body></html>"))
if err != nil {
panic("mergehtml: internal error: " + err.Error())
panic("merge: internal error: " + err.Error())
}
// TODO: title
html := find(out, atom.Html)
if html == nil {
log.Panicf("no <html> in %v", out)
log.Panicf("merge: no <html> in %v", out)
}
head := find(html, atom.Head)
reparentChildren(head, find(find(base, atom.Html), atom.Head))
@ -83,12 +83,12 @@ func merge(base, doc *html.Node) (out *html.Node) {
body := find(html, atom.Body)
if body == nil {
log.Panicf("no <body> in %v", html)
log.Panicf("merge: no <body> in %v", html)
}
baseBody := find(find(base, atom.Html), atom.Body)
newBody := find(find(doc, atom.Html), atom.Body)
reparentChildren(body, baseBody)
header := findRec(body, atom.Header)
footer := findRec(body, atom.Footer)
main := findRec(body, atom.Main)