diff --git a/bin/gmi2html/gmi2html.go b/bin/gmi2html/gmi2html.go index d253967..c0266e9 100644 --- a/bin/gmi2html/gmi2html.go +++ b/bin/gmi2html/gmi2html.go @@ -22,7 +22,10 @@ func runApp() error { return err } - html := gmi2html.Gmi2html(string(data), "") + html, err := gmi2html.Gmi2html(string(data), "") + if err != nil { + return err + } _, err = fmt.Fprintf(os.Stdout, "%s", html) if err != nil { return err diff --git a/gmi2html.go b/gmi2html.go index 1e2de68..5dc3b27 100644 --- a/gmi2html.go +++ b/gmi2html.go @@ -12,7 +12,7 @@ import ( // Based on https://geminiprotocol.net/docs/gemtext-specification.gmi // Gmi2html converts Gemini text to HTML with proper escaping and wraps it in a container with typography-focused CSS -func Gmi2html(text string, title string) string { +func Gmi2html(text string, title string) (string, error) { content := convertGeminiContent(text) // Handle any template errors with container @@ -26,10 +26,10 @@ func Gmi2html(text string, title string) string { }) if err != nil { fmt.Printf("Error executing container template: %s\n", err) - return "" + return "", err } - return buffer.String() + return buffer.String(), nil } // convertGeminiContent converts Gemini text to HTML with proper escaping diff --git a/gmi2html_test.go b/gmi2html_test.go index bb82ffc..214fc79 100644 --- a/gmi2html_test.go +++ b/gmi2html_test.go @@ -61,7 +61,7 @@ func TestConvertGeminiContent(t *testing.T) { func TestGmi2html(t *testing.T) { sample := "# Hello Gemini\n\nThis is a test document.\n\n=> https://gemini.circumlunar.space/ Project Gemini" - result := Gmi2html(sample, "Gemini Test") + result, _ := Gmi2html(sample, "Gemini Test") // Check that it contains the expected elements if !strings.Contains(result, "Gemini Test") { diff --git a/templates.go b/templates.go index 84e9938..5e9d2b1 100644 --- a/templates.go +++ b/templates.go @@ -51,7 +51,8 @@ body { color: var(--text-color); /* background-color: var(--bg-color); */ max-width: 34rem; - margin: 0 auto; + /* margin: 0 auto; */ + margin-left: 2rem; padding: 1rem 1rem; font-size: 16px; text-align: justify;