7 "github.com/charmbracelet/glamour/v2"
8 "github.com/charmbracelet/glamour/v2/ansi"
11// lipglossColorToHex converts a color.Color to hex string
12func lipglossColorToHex(c color.Color) string {
13 r, g, b, _ := c.RGBA()
14 return fmt.Sprintf("#%02x%02x%02x", r>>8, g>>8, b>>8)
17// Helper functions for style pointers
18func boolPtr(b bool) *bool { return &b }
19func stringPtr(s string) *string { return &s }
20func uintPtr(u uint) *uint { return &u }
22// returns a glamour TermRenderer configured with the current theme
23func GetMarkdownRenderer(width int) *glamour.TermRenderer {
25 r, _ := glamour.NewTermRenderer(
26 glamour.WithStyles(t.S().Markdown),
27 glamour.WithWordWrap(width),
32// returns a glamour TermRenderer with no colors (plain text with structure)
33func GetPlainMarkdownRenderer(width int) *glamour.TermRenderer {
34 r, _ := glamour.NewTermRenderer(
35 glamour.WithStyles(PlainMarkdownStyle()),
36 glamour.WithWordWrap(width),
41// PlainMarkdownStyle returns a glamour style config with no colors
42func PlainMarkdownStyle() ansi.StyleConfig {
44 bgColor := stringPtr(lipglossColorToHex(t.BgBaseLighter))
45 fgColor := stringPtr(lipglossColorToHex(t.FgMuted))
46 return ansi.StyleConfig{
47 Document: ansi.StyleBlock{
48 StylePrimitive: ansi.StylePrimitive{
50 BackgroundColor: bgColor,
53 BlockQuote: ansi.StyleBlock{
54 StylePrimitive: ansi.StylePrimitive{
56 BackgroundColor: bgColor,
59 IndentToken: stringPtr("│ "),
62 LevelIndent: defaultListIndent,
64 Heading: ansi.StyleBlock{
65 StylePrimitive: ansi.StylePrimitive{
69 BackgroundColor: bgColor,
73 StylePrimitive: ansi.StylePrimitive{
78 BackgroundColor: bgColor,
82 StylePrimitive: ansi.StylePrimitive{
85 BackgroundColor: bgColor,
89 StylePrimitive: ansi.StylePrimitive{
92 BackgroundColor: bgColor,
96 StylePrimitive: ansi.StylePrimitive{
99 BackgroundColor: bgColor,
103 StylePrimitive: ansi.StylePrimitive{
106 BackgroundColor: bgColor,
110 StylePrimitive: ansi.StylePrimitive{
113 BackgroundColor: bgColor,
116 Strikethrough: ansi.StylePrimitive{
117 CrossedOut: boolPtr(true),
119 BackgroundColor: bgColor,
121 Emph: ansi.StylePrimitive{
122 Italic: boolPtr(true),
124 BackgroundColor: bgColor,
126 Strong: ansi.StylePrimitive{
129 BackgroundColor: bgColor,
131 HorizontalRule: ansi.StylePrimitive{
132 Format: "\n--------\n",
134 BackgroundColor: bgColor,
136 Item: ansi.StylePrimitive{
139 BackgroundColor: bgColor,
141 Enumeration: ansi.StylePrimitive{
144 BackgroundColor: bgColor,
146 Task: ansi.StyleTask{
147 StylePrimitive: ansi.StylePrimitive{
149 BackgroundColor: bgColor,
154 Link: ansi.StylePrimitive{
155 Underline: boolPtr(true),
157 BackgroundColor: bgColor,
159 LinkText: ansi.StylePrimitive{
162 BackgroundColor: bgColor,
164 Image: ansi.StylePrimitive{
165 Underline: boolPtr(true),
167 BackgroundColor: bgColor,
169 ImageText: ansi.StylePrimitive{
170 Format: "Image: {{.text}} →",
172 BackgroundColor: bgColor,
174 Code: ansi.StyleBlock{
175 StylePrimitive: ansi.StylePrimitive{
179 BackgroundColor: bgColor,
182 CodeBlock: ansi.StyleCodeBlock{
183 StyleBlock: ansi.StyleBlock{
184 StylePrimitive: ansi.StylePrimitive{
186 BackgroundColor: bgColor,
188 Margin: uintPtr(defaultMargin),
191 Table: ansi.StyleTable{
192 StyleBlock: ansi.StyleBlock{
193 StylePrimitive: ansi.StylePrimitive{
195 BackgroundColor: bgColor,
199 DefinitionDescription: ansi.StylePrimitive{
202 BackgroundColor: bgColor,
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list