1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-06-15 19:15:24 +00:00

🐛 Fix heading and link styling when color is disabled

This commit is contained in:
makeworld 2020-06-24 12:01:09 -04:00
parent 5056bd303d
commit bd6daa5a3c
2 changed files with 26 additions and 12 deletions

View File

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

View File

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