From 61d864540140f463a183e187e4211c258bd518bf Mon Sep 17 00:00:00 2001 From: makeworld Date: Fri, 10 Dec 2021 11:52:15 -0500 Subject: [PATCH] Fix color appearing in no color mode Fixes #278 --- CHANGELOG.md | 6 ++++++ amfora.go | 2 +- renderer/renderer.go | 12 ++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35d999d..2b2b73e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/amfora.go b/amfora.go index e916f91..20cab0b 100644 --- a/amfora.go +++ b/amfora.go @@ -16,7 +16,7 @@ import ( ) var ( - version = "v1.9.1" + version = "v1.9.2" commit = "unknown" builtBy = "unknown" ) diff --git a/renderer/renderer.go b/renderer/renderer.go index 32b7b41..21ecf46 100644 --- a/renderer/renderer.go +++ b/renderer/renderer.go @@ -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