Something went wrong. Try again.
Kagi Mail CLI client
Something went wrong. Try again.
1234567891011121314151617181920212223package render
import ( "strings" "testing")
func TestHTMLToText(t *testing.T) { in := `<html><body><h1>Title</h1><p>Some <b>bold</b> text.</p><p><a href="https://example.net/x">link</a></p></body></html>` out := HTMLToText(in) for _, want := range []string{"Title", "Some *bold* text.", "link", "https://example.net/x"} { if !strings.Contains(out, want) { t.Errorf("missing %q in %q", want, out) } } if strings.ContainsAny(out, "<>") && !strings.Contains(out, "<https") { t.Errorf("tags left in %q", out) } if out != strings.TrimSpace(out) { t.Errorf("not trimmed: %q", out) }}