summaryrefslogtreecommitdiffstats
path: root/pkg/cheatsheet/generate.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/cheatsheet/generate.go')
-rw-r--r--pkg/cheatsheet/generate.go21
1 files changed, 8 insertions, 13 deletions
diff --git a/pkg/cheatsheet/generate.go b/pkg/cheatsheet/generate.go
index 205abf7cb..27667e686 100644
--- a/pkg/cheatsheet/generate.go
+++ b/pkg/cheatsheet/generate.go
@@ -14,7 +14,6 @@ import (
"fmt"
"log"
"os"
- "strings"
"github.com/jesseduffield/generics/maps"
"github.com/jesseduffield/lazycore/pkg/utils"
@@ -191,11 +190,11 @@ func formatSections(tr *i18n.TranslationSet, bindingSections []*bindingSection)
for _, section := range bindingSections {
content += formatTitle(section.title)
- content += "<pre>\n"
+ content += "| Key | Action | Info |\n"
+ content += "|-----|--------|-------------|\n"
for _, binding := range section.bindings {
content += formatBinding(binding)
}
- content += "</pre>\n"
}
return content
@@ -206,19 +205,15 @@ 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)
+ action := keybindings.LabelFromKey(binding.Key)
+ description := binding.Description
if binding.Alternative != "" {
- result += fmt.Sprintf(" (%s)", binding.Alternative)
+ action += fmt.Sprintf(" (%s)", binding.Alternative)
}
- result += "\n"
- return result
-}
-
-func escapeAngleBrackets(str string) string {
- result := strings.ReplaceAll(str, ">", "&gt;")
- result = strings.ReplaceAll(result, "<", "&lt;")
- return result
+ // Use backticks for keyboard keys. Two backticks are needed with an inner space
+ // to escape a key that is itself a backtick.
+ return fmt.Sprintf("| `` %s `` | %s | %s |\n", action, description, binding.Tooltip)
}
func italicize(str string) string {