10 gemini "git.sr.ht/~adnano/go-gemini"
14 ErrNoTitle = errors.New(`no title found`)
16 title1 = regexp.MustCompile(`^#[^#]`)
17 title2 = regexp.MustCompile(`^##[^#]`)
18 title3 = regexp.MustCompile(`^###`)
21 func geminiTitle(url string) (string, error) {
22 client := gemini.Client{}
23 ctx := context.Background()
24 resp, err := client.Get(ctx, url)
28 defer resp.Body.Close()
30 if resp.Status != 20 || !strings.HasPrefix(resp.Meta, "text/gemini") {
36 scanner := bufio.NewScanner(resp.Body)
38 line := scanner.Text()
41 case title1.MatchString(line):
43 case title2.MatchString(line) && t2 == "":
45 case title3.MatchString(line) && t3 == "":