Let user pick a syntax color theme in Gold's style config

This commit is contained in:
Christian Muehlhaeuser 2019-11-25 05:57:43 +01:00
commit 67685a4ebe
3 changed files with 11 additions and 2 deletions

View file

@ -18,7 +18,8 @@
"color": "200"
},
"code_block": {
"color": "200"
"color": "200",
"theme": "solarized-dark"
},
"emph": {
"italic": true

View file

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

View file

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