summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-05-21 11:13:02 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-05-21 11:31:29 +1000
commit3eed99716105481dffddc9a74db0d444a9c469a2 (patch)
tree22a7ec053c0a9d82b6af8a09d2f60fdf249c6840 /pkg
parent526d8a8a7630a963bf5ff64b553f233264d63d65 (diff)
Update cheatsheet
Now that we're using the angle-bracket syntax everywhere for consistency, we need to escape the angle brackets in the markdown of the cheatsheets.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/cheatsheet/generate.go25
-rw-r--r--pkg/i18n/english.go2
2 files changed, 20 insertions, 7 deletions
diff --git a/pkg/cheatsheet/generate.go b/pkg/cheatsheet/generate.go
index ee2538c1f..ec2c84dbd 100644
--- a/pkg/cheatsheet/generate.go
+++ b/pkg/cheatsheet/generate.go
@@ -12,6 +12,7 @@ import (
"fmt"
"log"
"os"
+ "strings"
"github.com/jesseduffield/generics/maps"
"github.com/jesseduffield/generics/slices"
@@ -183,6 +184,8 @@ func getHeader(binding *types.Binding, tr *i18n.TranslationSet) header {
func formatSections(tr *i18n.TranslationSet, bindingSections []*bindingSection) string {
content := fmt.Sprintf("# Lazygit %s\n", tr.Keybindings)
+ content += fmt.Sprintf("\n%s\n", italicize(tr.KeybindingsLegend))
+
for _, section := range bindingSections {
content += formatTitle(section.title)
content += "<pre>\n"
@@ -200,13 +203,21 @@ func formatTitle(title string) string {
}
func formatBinding(binding *types.Binding) string {
+ result := fmt.Sprintf(" <kbd>%s</kbd>: %s", escapeAngleBrackets(keybindings.LabelFromKey(binding.Key)), binding.Description)
if binding.Alternative != "" {
- return fmt.Sprintf(
- " <kbd>%s</kbd>: %s (%s)\n",
- keybindings.LabelFromKey(binding.Key),
- binding.Description,
- binding.Alternative,
- )
+ result += fmt.Sprintf(" (%s)", binding.Alternative)
}
- return fmt.Sprintf(" <kbd>%s</kbd>: %s\n", keybindings.LabelFromKey(binding.Key), binding.Description)
+ result += "\n"
+
+ return result
+}
+
+func escapeAngleBrackets(str string) string {
+ result := strings.ReplaceAll(str, ">", "&gt;")
+ result = strings.ReplaceAll(result, "<", "&lt;")
+ return result
+}
+
+func italicize(str string) string {
+ return fmt.Sprintf("_%s_", str)
}
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index ea34ae022..ed2191508 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -368,6 +368,7 @@ type TranslationSet struct {
LcStartSearch string
Panel string
Keybindings string
+ KeybindingsLegend string
LcRenameBranch string
LcSetUnsetUpstream string
NewGitFlowBranchPrompt string
@@ -1039,6 +1040,7 @@ func EnglishTranslationSet() TranslationSet {
LcStartSearch: "start search",
Panel: "Panel",
Keybindings: "Keybindings",
+ KeybindingsLegend: "Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b",
LcRenameBranch: "rename branch",
LcSetUnsetUpstream: "set/unset upstream",
NewBranchNamePrompt: "Enter new branch name for branch",