Fix color appearing in no color mode

Fixes #278
This commit is contained in:
makeworld 2021-12-10 11:52:15 -05:00
parent 48d83d13d2
commit 61d8645401
3 changed files with 15 additions and 5 deletions

View File

@ -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)

View File

@ -16,7 +16,7 @@ import (
)
var (
version = "v1.9.1"
version = "v1.9.2"
commit = "unknown"
builtBy = "unknown"
)

View File

@ -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] + `[::-][""]`
}
}
@ -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