Let users define a prefix & suffix for style elements

This commit is contained in:
Christian Muehlhaeuser
2019-11-26 22:39:39 +01:00
parent 425d236a44
commit 730f9bd2fb
2 changed files with 10 additions and 0 deletions
+8
View File
@@ -31,6 +31,14 @@ func (e *BaseElement) Render(w io.Writer, node *bf.Node, tr *TermRenderer) error
fmt.Fprintf(w, "%s", e.Token)
return nil
}
if rules.Prefix != "" {
fmt.Fprintf(w, "%s", rules.Prefix)
}
defer func() {
if rules.Suffix != "" {
fmt.Fprintf(w, "%s", rules.Suffix)
}
}()
out := aurora.Reset(e.Token)
if rules.Color != "" {
+2
View File
@@ -47,6 +47,8 @@ type ElementStyle struct {
Inverse bool `json:"inverse"`
Blink bool `json:"blink"`
Theme string `json:"theme"`
Prefix string `json:"prefix"`
Suffix string `json:"suffix"`
}
func keyToType(key string) (StyleType, error) {