From bd6daa5a3c3e20a936f003ffb1ecc887aa0557c9 Mon Sep 17 00:00:00 2001 From: makeworld Date: Wed, 24 Jun 2020 12:01:09 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20heading=20and=20link=20sty?= =?UTF-8?q?ling=20when=20color=20is=20disabled?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ renderer/renderer.go | 36 ++++++++++++++++++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2fa950..44399cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bottom bar is not in focus after clicking Enter - Badly formed links on pages can no longer crash the browser - Disabling color in config affects UI elements (#16) +- Keep bold for headings even with color disabled +- Don't make whole link text bold when color is disabled ## [1.0.0] - 2020-06-18 diff --git a/renderer/renderer.go b/renderer/renderer.go index 6d33e28..c621d62 100644 --- a/renderer/renderer.go +++ b/renderer/renderer.go @@ -29,17 +29,29 @@ func convertRegularGemini(s string, numLinks int, width int) (string, []string) for i := range lines { lines[i] = strings.TrimRight(lines[i], " \r\t\n") - if strings.HasPrefix(lines[i], "#") && viper.GetBool("a-general.color") { - + if strings.HasPrefix(lines[i], "#") { // Headings - if strings.HasPrefix(lines[i], "###") { - lines[i] = "[fuchsia::b]" + lines[i] + "[-::-]" - } - if strings.HasPrefix(lines[i], "##") { - lines[i] = "[lime::b]" + lines[i] + "[-::-]" - } - if strings.HasPrefix(lines[i], "#") { - lines[i] = "[red::b]" + lines[i] + "[-::-]" + if viper.GetBool("a-general.color") { + if strings.HasPrefix(lines[i], "###") { + lines[i] = "[fuchsia::b]" + lines[i] + "[-::-]" + } + if strings.HasPrefix(lines[i], "##") { + lines[i] = "[lime::b]" + lines[i] + "[-::-]" + } + if strings.HasPrefix(lines[i], "#") { + lines[i] = "[red::b]" + lines[i] + "[-::-]" + } + } else { + // Just bold, no colors + if strings.HasPrefix(lines[i], "###") { + lines[i] = "[::b]" + lines[i] + "[::-]" + } + if strings.HasPrefix(lines[i], "##") { + lines[i] = "[::b]" + lines[i] + "[::-]" + } + if strings.HasPrefix(lines[i], "#") { + lines[i] = "[::b]" + lines[i] + "[::-]" + } } // Links @@ -84,8 +96,8 @@ func convertRegularGemini(s string, numLinks int, width int) (string, []string) } } else { // No colours allowed - lines[i] = `[::b][` + strconv.Itoa(numLinks+len(links)) + "[] " + - `["` + strconv.Itoa(numLinks+len(links)-1) + `"]` + linkText + `[""][-]` + lines[i] = `[::b][` + strconv.Itoa(numLinks+len(links)) + "[][::-] " + + `["` + strconv.Itoa(numLinks+len(links)-1) + `"]` + linkText + `[""]` } // Lists