mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-09 09:49:09 +02:00
Let user pick a syntax color theme in Gold's style config
This commit is contained in:
parent
51ffc0d1ad
commit
67685a4ebe
3 changed files with 11 additions and 2 deletions
|
|
@ -18,7 +18,8 @@
|
|||
"color": "200"
|
||||
},
|
||||
"code_block": {
|
||||
"color": "200"
|
||||
"color": "200",
|
||||
"theme": "solarized-dark"
|
||||
},
|
||||
"emph": {
|
||||
"italic": true
|
||||
|
|
|
|||
9
gold.go
9
gold.go
|
|
@ -427,7 +427,14 @@ func (tr *TermRenderer) RenderNode(w io.Writer, node *bf.Node, entering bool) bf
|
|||
|
||||
for _, f := range e.Fragments {
|
||||
if node.Type == bf.CodeBlock {
|
||||
err := quick.Highlight(w, f.Token, string(node.CodeBlockData.Info), "terminal16m", "monokai")
|
||||
theme := "monokai"
|
||||
if rules, ok := tr.style[f.Style]; ok {
|
||||
if len(rules.Theme) > 0 {
|
||||
theme = rules.Theme
|
||||
}
|
||||
}
|
||||
|
||||
err := quick.Highlight(w, f.Token, string(node.CodeBlockData.Info), "terminal16m", theme)
|
||||
if err == nil {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
1
style.go
1
style.go
|
|
@ -46,6 +46,7 @@ type ElementStyle struct {
|
|||
Overlined bool `json:"overlined"`
|
||||
Inverse bool `json:"inverse"`
|
||||
Blink bool `json:"blink"`
|
||||
Theme string `json:"theme"`
|
||||
}
|
||||
|
||||
func keyToType(key string) (StyleType, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue