From 100034677d2b4c4678c050ab08889b581c889840 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 18 Apr 2024 11:33:54 +0200 Subject: make self-closing tags void --- cmd/build/build.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'cmd/build') diff --git a/cmd/build/build.go b/cmd/build/build.go index 1983e3c..0436c20 100644 --- a/cmd/build/build.go +++ b/cmd/build/build.go @@ -25,6 +25,7 @@ import ( "github.com/antchfx/xmlquery" "github.com/antchfx/xpath" mapset "github.com/deckarep/golang-set/v2" + iohelper "github.com/jf-tech/go-corelib/ios" "github.com/pkg/errors" "github.com/yuin/goldmark" "github.com/yuin/goldmark/extension" @@ -153,13 +154,18 @@ func layout(filename string, config config.Config, pageTitle string) (*goquery.D } func renderHTML(doc *goquery.Document) io.Reader { - r, w := io.Pipe() + r := bytes.NewBufferString("\n") + // hello go? HTML 5 does not have self-closing tags + replacer := iohelper.NewBytesReplacingReader(r, []byte("/>"), []byte(" >")) + + // TODO: return errors to main thread go func() { - w.Write([]byte("\n")) - goquery.Render(w, doc.Children()) - defer w.Close() + err := goquery.Render(r, doc.Children()) + if err != nil { + slog.Error("error rendering html", "error", err) + } }() - return r + return replacer } func renderPost(post Post, config config.Config) (r io.Reader, err error) { -- cgit 1.4.1