From c053f1e04ffb0fb89743cc7bc5154efaf6e8a0bf Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 14 Apr 2026 10:10:50 +0300 Subject: Add HTML OutputFormat and report API support (ask task 03) - Add FormatHTML with parse/string and HTMLReporter on existing report path - Emit minimal HTML document with escaped title, description, and pre table - Daemon /report sets text/html Content-Type for HTML format - Integration fixtures and tests for HTML Made-with: Cursor --- internal/daemon/daemon.go | 2 ++ internal/daemon/daemon_test.go | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'internal/daemon') diff --git a/internal/daemon/daemon.go b/internal/daemon/daemon.go index a7de45f..13e7311 100644 --- a/internal/daemon/daemon.go +++ b/internal/daemon/daemon.go @@ -156,6 +156,8 @@ func reportContentType(f goprecords.OutputFormat) string { return "text/markdown; charset=utf-8" case goprecords.FormatGemtext: return "text/gemini; charset=utf-8" + case goprecords.FormatHTML: + return "text/html; charset=utf-8" default: return "text/plain; charset=utf-8" } diff --git a/internal/daemon/daemon_test.go b/internal/daemon/daemon_test.go index 9f25ca3..87b3dd8 100644 --- a/internal/daemon/daemon_test.go +++ b/internal/daemon/daemon_test.go @@ -91,6 +91,28 @@ func TestReportQueryAliases(t *testing.T) { } } +func TestReportHTMLContentType(t *testing.T) { + fixtures := filepath.Join("..", "..", "fixtures") + srv := httptest.NewServer(Handler(fixtures)) + defer srv.Close() + res, err := http.Get(srv.URL + "/report?OutputFormat=HTML&limit=2") + if err != nil { + t.Fatal(err) + } + defer res.Body.Close() + if res.StatusCode != http.StatusOK { + t.Fatalf("status %d", res.StatusCode) + } + if ct := res.Header.Get("Content-Type"); ct != "text/html; charset=utf-8" { + t.Fatalf("Content-Type %q", ct) + } + b, _ := io.ReadAll(res.Body) + body := string(b) + if !strings.Contains(body, "") || !strings.Contains(body, "
") {
+		t.Fatalf("expected HTML body, got %q", body)
+	}
+}
+
 func TestReportGemtextContentType(t *testing.T) {
 	fixtures := filepath.Join("..", "..", "fixtures")
 	srv := httptest.NewServer(Handler(fixtures))
-- 
cgit v1.2.3