about summary refs log tree commit diff stats
path: root/cmd
diff options
context:
space:
mode:
authorAlan Pearce2024-04-18 11:33:54 +0200
committerAlan Pearce2024-04-18 11:33:54 +0200
commit100034677d2b4c4678c050ab08889b581c889840 (patch)
treef3192ca68bb59b410a8de85fb442e39ff2d73213 /cmd
parent1ecd1a5fad10bd3b8b5f88198b8331a40e7814cf (diff)
downloadwebsite-100034677d2b4c4678c050ab08889b581c889840.tar.lz
website-100034677d2b4c4678c050ab08889b581c889840.tar.zst
website-100034677d2b4c4678c050ab08889b581c889840.zip
make self-closing tags void
Diffstat (limited to 'cmd')
-rw-r--r--cmd/build/build.go16
1 files changed, 11 insertions, 5 deletions
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("<!doctype html>\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("<!doctype html>\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) {