1package common
 2
 3import (
 4	"github.com/charmbracelet/colorprofile"
 5	gansi "github.com/charmbracelet/glamour/v2/ansi"
 6	"github.com/charmbracelet/glamour/v2/styles"
 7)
 8
 9// DefaultColorProfile is the default color profile used by the SSH server.
10var DefaultColorProfile = colorprofile.ANSI256
11
12func strptr(s string) *string {
13	return &s
14}
15
16// StyleConfig returns the default Glamour style configuration.
17func StyleConfig() gansi.StyleConfig {
18	noColor := strptr("")
19	s := styles.DarkStyleConfig
20	// This fixes an issue with the default style config. For example
21	// highlighting empty spaces with red in Dockerfile type.
22	s.CodeBlock.Chroma.Error.BackgroundColor = noColor
23	return s
24}
25
26// StyleRenderer returns a new Glamour renderer.
27func StyleRenderer() gansi.RenderContext {
28	return StyleRendererWithStyles(StyleConfig())
29}
30
31// StyleRendererWithStyles returns a new Glamour renderer.
32func StyleRendererWithStyles(styles gansi.StyleConfig) gansi.RenderContext {
33	return gansi.NewRenderContext(gansi.Options{
34		Styles: styles,
35	})
36}