diff --git a/.gitignore b/.gitignore index cb9380e..6f40a17 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bombadillo *.asciinema +*.swp diff --git a/client.go b/client.go index c97e4b0..4b31efb 100644 --- a/client.go +++ b/client.go @@ -980,6 +980,7 @@ func (c *client) handleGemini(u Url) { case 2: // Success if capsule.MimeMaj == "text" || (c.Options["showimages"] == "true" && capsule.MimeMaj == "image") { + u.Mime = capsule.MimeMin pg := MakePage(u, capsule.Content, capsule.Links) pg.FileType = capsule.MimeMaj pg.WrapContent(c.Width-1, (c.Options["theme"] == "color")) diff --git a/gemini/gemini.go b/gemini/gemini.go index db02ca5..526aca6 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -361,6 +361,7 @@ func parseGemini(b, currentUrl string) (string, []string) { links := make([]string, 0, 10) inPreBlock := false + spacer := " " outputIndex := 0 for i, ln := range splitContent { @@ -371,7 +372,7 @@ func parseGemini(b, currentUrl string) (string, []string) { alt := strings.TrimSpace(ln) if len(alt) > 3 { alt = strings.TrimSpace(alt[3:]) - splitContent[outputIndex] = fmt.Sprintf("[ %s ]", alt) + splitContent[outputIndex] = fmt.Sprintf("%s[ALT][ %s ]", spacer, alt) outputIndex++ } } else if isPreBlockDeclaration { @@ -401,7 +402,12 @@ func parseGemini(b, currentUrl string) (string, []string) { if inPreBlock && (BlockBehavior == "alt" || BlockBehavior == "neither") { continue } - splitContent[outputIndex] = ln + var leader, tail string = "", "" + if len(ln) > 0 && ln[0] == '#' { + leader = "\033[1m" + tail = "\033[0m" + } + splitContent[outputIndex] = fmt.Sprintf("%s%s%s%s", spacer, leader, ln, tail) outputIndex++ } } diff --git a/gopher/gopher.go b/gopher/gopher.go index fbe579f..adf36e9 100644 --- a/gopher/gopher.go +++ b/gopher/gopher.go @@ -144,7 +144,8 @@ func parseMap(text string) (string, []string) { } else { link := buildLink(line[2], line[3], string(line[0][0]), line[1]) links = append(links, link) - linktext := fmt.Sprintf("(%s) %2d %s", getType(string(line[0][0])), len(links), title) + linkNum := fmt.Sprintf("[%d]",len(links)) + linktext := fmt.Sprintf("%s %5s %s", getType(string(line[0][0])), linkNum, title) splitContent[i] = linktext } } diff --git a/page.go b/page.go index ad44ab2..d4ed745 100644 --- a/page.go +++ b/page.go @@ -72,11 +72,17 @@ func (p *Page) WrapContent(width int, color bool) { } width = min(width, 100) counter := 0 - spacer := " " + spacer := "" var content strings.Builder var esc strings.Builder escape := false content.Grow(len(p.RawContent)) + + if p.Location.Mime == "1" { // gopher document + spacer = " " + } else if strings.HasSuffix(p.Location.Mime, "gemini") { //gemini document + spacer = " " + } for _, ch := range []rune(p.RawContent) { if escape { if color { @@ -125,10 +131,8 @@ func (p *Page) WrapContent(width int, color bool) { } else { content.WriteRune('\n') counter = 0 - if p.Location.Mime == "1" { - content.WriteString(spacer) - counter += len(spacer) - } + content.WriteString(spacer) + counter += len(spacer) content.WriteRune(ch) counter++ }