Skip to content

Commit

Permalink
Fix color appearing in no color mode
Browse files Browse the repository at this point in the history
Fixes #278
  • Loading branch information
makew0rld committed Dec 10, 2021
1 parent 48d83d1 commit 61d8645
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.9.2] - 2021-12-10
### Fixed
- Preformatted text color showing even when `color = false` (bug since v1.8.0 at least) (#278)
- Link numbers and link text in color even when `color = false` (regression in v1.9.0) (#278)


## [1.9.1] - 2021-12-08
### Fixed
- Deadlock when loading an invalid `about:` URL (#277)
Expand Down
2 changes: 1 addition & 1 deletion amfora.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

var (
version = "v1.9.1"
version = "v1.9.2"
commit = "unknown"
builtBy = "unknown"
)
Expand Down
12 changes: 8 additions & 4 deletions renderer/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ func convertRegularGemini(s string, numLinks, width int, proxied bool) (string,

wrappedLink = wrapLine(linkText, width,
strings.Repeat(" ", indent)+
`["`+strconv.Itoa(num-1)+`"]`+linkTag,
`["`+strconv.Itoa(num-1)+`"]`,
`[::-][""]`,
false, // Don't indent the first line, it's the one with link number
)

wrappedLink[0] = `[::b][` + strconv.Itoa(num) + "[][::-]" + spacing +
`["` + strconv.Itoa(num-1) + `"]` + linkTag +
`["` + strconv.Itoa(num-1) + `"]` +
wrappedLink[0] + `[::-][""]`
}
}
Expand Down Expand Up @@ -341,8 +341,12 @@ func RenderGemini(s string, width int, proxied bool) (string, []string) {
// Lines are modified below to always end with \r\n
buf = strings.TrimSuffix(buf, "\r\n")

rendered += fmt.Sprintf("[%s]", config.GetColorString("preformatted_text")) +
buf + fmt.Sprintf("[%s:%s:-]\r\n", config.GetColorString("regular_text"), config.GetColorString("bg"))
if viper.GetBool("a-general.color") {
rendered += fmt.Sprintf("[%s]", config.GetColorString("preformatted_text")) +
buf + fmt.Sprintf("[%s:%s:-]\r\n", config.GetColorString("regular_text"), config.GetColorString("bg"))
} else {
rendered += buf + "\r\n"
}
}

// processRegular processes non-preformatted sections
Expand Down

0 comments on commit 61d8645

Please sign in to comment.