forked from sloum/bombadillo
Adds spacing to gemini docs to normalize the formatting with gopher docs
This commit is contained in:
parent
97b74ea767
commit
01d071e510
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -977,6 +977,7 @@ func (c *client) handleGemini(u Url) {
|
||||||
case 2:
|
case 2:
|
||||||
// Success
|
// Success
|
||||||
if capsule.MimeMaj == "text" || (c.Options["showimages"] == "true" && capsule.MimeMaj == "image") {
|
if capsule.MimeMaj == "text" || (c.Options["showimages"] == "true" && capsule.MimeMaj == "image") {
|
||||||
|
u.Mime = capsule.MimeMin
|
||||||
pg := MakePage(u, capsule.Content, capsule.Links)
|
pg := MakePage(u, capsule.Content, capsule.Links)
|
||||||
pg.FileType = capsule.MimeMaj
|
pg.FileType = capsule.MimeMaj
|
||||||
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color"))
|
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color"))
|
||||||
|
|
Binary file not shown.
|
@ -361,6 +361,7 @@ func parseGemini(b, currentUrl string) (string, []string) {
|
||||||
links := make([]string, 0, 10)
|
links := make([]string, 0, 10)
|
||||||
|
|
||||||
inPreBlock := false
|
inPreBlock := false
|
||||||
|
spacer := " "
|
||||||
|
|
||||||
outputIndex := 0
|
outputIndex := 0
|
||||||
for i, ln := range splitContent {
|
for i, ln := range splitContent {
|
||||||
|
@ -371,7 +372,7 @@ func parseGemini(b, currentUrl string) (string, []string) {
|
||||||
alt := strings.TrimSpace(ln)
|
alt := strings.TrimSpace(ln)
|
||||||
if len(alt) > 3 {
|
if len(alt) > 3 {
|
||||||
alt = strings.TrimSpace(alt[3:])
|
alt = strings.TrimSpace(alt[3:])
|
||||||
splitContent[outputIndex] = fmt.Sprintf("[ %s ]", alt)
|
splitContent[outputIndex] = fmt.Sprintf("%s[ALT][ %s ]", spacer, alt)
|
||||||
outputIndex++
|
outputIndex++
|
||||||
}
|
}
|
||||||
} else if isPreBlockDeclaration {
|
} else if isPreBlockDeclaration {
|
||||||
|
@ -401,7 +402,12 @@ func parseGemini(b, currentUrl string) (string, []string) {
|
||||||
if inPreBlock && (BlockBehavior == "alt" || BlockBehavior == "neither") {
|
if inPreBlock && (BlockBehavior == "alt" || BlockBehavior == "neither") {
|
||||||
continue
|
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++
|
outputIndex++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
page.go
10
page.go
|
@ -72,7 +72,8 @@ func (p *Page) WrapContent(width int, color bool) {
|
||||||
}
|
}
|
||||||
width = min(width, 100)
|
width = min(width, 100)
|
||||||
counter := 0
|
counter := 0
|
||||||
spacer := " "
|
gopherspacer := " "
|
||||||
|
geminispacer := " "
|
||||||
var content strings.Builder
|
var content strings.Builder
|
||||||
var esc strings.Builder
|
var esc strings.Builder
|
||||||
escape := false
|
escape := false
|
||||||
|
@ -126,8 +127,11 @@ func (p *Page) WrapContent(width int, color bool) {
|
||||||
content.WriteRune('\n')
|
content.WriteRune('\n')
|
||||||
counter = 0
|
counter = 0
|
||||||
if p.Location.Mime == "1" {
|
if p.Location.Mime == "1" {
|
||||||
content.WriteString(spacer)
|
content.WriteString(gopherspacer)
|
||||||
counter += len(spacer)
|
counter += len(gopherspacer)
|
||||||
|
} else if strings.HasSuffix(p.Location.Mime, "gemini") {
|
||||||
|
content.WriteString(geminispacer)
|
||||||
|
counter += len(geminispacer)
|
||||||
}
|
}
|
||||||
content.WriteRune(ch)
|
content.WriteRune(ch)
|
||||||
counter++
|
counter++
|
||||||
|
|
Loading…
Reference in New Issue