package main import ( "fmt" "html" "net/url" "strings" "git.sr.ht/~adnano/go-gemini" ) func textToHTML(reqUrl *url.URL, text gemini.Text) string { var b strings.Builder var pre bool var list bool for _, l := range text { if _, ok := l.(gemini.LineListItem); ok { if !list { list = true fmt.Fprint(&b, "
\n", altText) } else { fmt.Fprint(&b, "\n") } } else { fmt.Fprint(&b, "\n") } case gemini.LinePreformattedText: text := string(l.(gemini.LinePreformattedText)) fmt.Fprintf(&b, "%s\n", html.EscapeString(text)) case gemini.LineHeading1: text := string(l.(gemini.LineHeading1)) fmt.Fprintf(&b, "%s
\n", html.EscapeString(text)) case gemini.LineHeading2: text := string(l.(gemini.LineHeading2)) fmt.Fprintf(&b, "%s
\n", html.EscapeString(text)) case gemini.LineHeading3: text := string(l.(gemini.LineHeading3)) fmt.Fprintf(&b, "%s
\n", html.EscapeString(text)) case gemini.LineListItem: text := string(l.(gemini.LineListItem)) fmt.Fprintf(&b, "
%s\n", html.EscapeString(text)) case gemini.LineText: text := string(l.(gemini.LineText)) if text == "" { fmt.Fprint(&b, "
%s
\n", html.EscapeString(text)) } } } if pre { fmt.Fprint(&b, "\n") } if list { fmt.Fprint(&b, "\n") } return b.String() } // Convert a Gemini link to a proxy link func proxyLink() { }