Use TrueColor color profile as default

Users can override the desired profile by calling WithColorProfile.
This commit is contained in:
Christian Muehlhaeuser
2020-02-10 14:28:08 +01:00
parent a2997cbe4a
commit 8d4e3f0692
12 changed files with 59 additions and 46 deletions
+12 -1
View File
@@ -7,6 +7,7 @@ import (
"io/ioutil"
"os"
"github.com/muesli/termenv"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/parser"
@@ -60,7 +61,8 @@ func NewTermRenderer(options ...TermRendererOption) (*TermRenderer, error) {
),
),
ansiOptions: ansi.Options{
WordWrap: 80,
WordWrap: 80,
ColorProfile: termenv.TrueColor,
},
}
for _, o := range options {
@@ -87,6 +89,15 @@ func WithBaseURL(baseURL string) TermRendererOption {
}
}
// WithColorProfile sets the TermRenderer's color profile
// (TrueColor / ANSI256 / ANSI).
func WithColorProfile(profile termenv.Profile) TermRendererOption {
return func(tr *TermRenderer) error {
tr.ansiOptions.ColorProfile = profile
return nil
}
}
// WithStandardStyle sets a TermRenderer's styles with a standard (builtin)
// style.
func WithStandardStyle(style string) TermRendererOption {