Skip to content

Commit 61d8645

Browse files
committed
Fix color appearing in no color mode
Fixes #278
1 parent 48d83d1 commit 61d8645

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.9.2] - 2021-12-10
8+
### Fixed
9+
- Preformatted text color showing even when `color = false` (bug since v1.8.0 at least) (#278)
10+
- Link numbers and link text in color even when `color = false` (regression in v1.9.0) (#278)
11+
12+
713
## [1.9.1] - 2021-12-08
814
### Fixed
915
- Deadlock when loading an invalid `about:` URL (#277)

amfora.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
var (
19-
version = "v1.9.1"
19+
version = "v1.9.2"
2020
commit = "unknown"
2121
builtBy = "unknown"
2222
)

renderer/renderer.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ func convertRegularGemini(s string, numLinks, width int, proxied bool) (string,
231231

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

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

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

348352
// processRegular processes non-preformatted sections

0 commit comments

Comments
 (0)