Handle preformatted content.
This commit is contained in:
parent
11f9d440bf
commit
1d6bcf551c
|
@ -90,8 +90,13 @@ func main() {
|
|||
if meta == "text/gemini" {
|
||||
// Handle Gemini map
|
||||
links = make([]string, 0, 100)
|
||||
preformatted := false
|
||||
for _, line := range strings.Split(body, "\n") {
|
||||
if strings.HasPrefix(line, "=>") {
|
||||
if strings.HasPrefix(line, "```") {
|
||||
preformatted = !preformatted
|
||||
} else if preformatted {
|
||||
fmt.Println(line)
|
||||
} else if strings.HasPrefix(line, "=>") {
|
||||
line = line[2:]
|
||||
bits := strings.Fields(line)
|
||||
parsedLink, err := url.Parse(bits[0])
|
||||
|
@ -108,6 +113,9 @@ func main() {
|
|||
links = append(links, link)
|
||||
fmt.Printf("[%d] %s\n", len(links), label)
|
||||
} else {
|
||||
// This should really be wrapped, but there's
|
||||
// no easy support for this in Go's standard
|
||||
// library
|
||||
fmt.Println(line)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue