Documentation
¶
Index ¶
Constants ¶
const ( Table chroma.TokenType = 9000 + iota TableHeader TableRow TableRowAlt StrongEmph CodeSpan )
Variables ¶
var ( GlamourDark = ChromaStyleFromConfig("glamour-dark", glamourstyles.DarkStyleConfig) GlamourLight = ChromaStyleFromConfig("glamour-light", glamourstyles.LightStyleConfig) GlamourDracula = ChromaStyleFromConfig("glamour-dracula", glamourstyles.DraculaStyleConfig) GlamourTokyoNight = ChromaStyleFromConfig("glamour-tokyo-night", glamourstyles.TokyoNightStyleConfig) GlamourPink = ChromaStyleFromConfig("glamour-pink", glamourstyles.PinkStyleConfig) )
Glamour themes converted from github.com/charmbracelet/glamour/styles.
var Pulumi = styles.Register(chroma.MustNewStyle("pulumi", chroma.StyleEntries{ chroma.Text: "#d7d7d7", chroma.Error: "#d75f5f", chroma.Comment: "#afafaf", chroma.Keyword: "#af87af", chroma.Operator: "#5fafd7", chroma.Punctuation: "#d7afff", chroma.Name: "#d7d7d7", chroma.NameAttribute: "#d7d7d7", chroma.NameClass: "#d7d7d7", chroma.NameConstant: "#d7d7d7", chroma.NameDecorator: "#d7d7d7", chroma.NameException: "#d7d7d7", chroma.NameFunction: "#d7d7d7", chroma.NameOther: "#d7d7d7", chroma.NameTag: "#d7d7d7", chroma.LiteralNumber: "#87ffaf", chroma.Literal: "#00d7af", chroma.LiteralDate: "#00d7af", chroma.LiteralString: "#ffaf5f", chroma.LiteralStringEscape: "#5f5f87", chroma.GenericDeleted: "#d75f5f", chroma.GenericEmph: "italic", chroma.GenericHeading: "#d787af bold", chroma.GenericInserted: "#5f875f", chroma.GenericStrong: "bold", StrongEmph: "bold italic", chroma.GenericSubheading: "#d787af", chroma.GenericUnderline: "underline", CodeSpan: "#d7d7d7 bg:#303030", Table: "bg:#121212", TableHeader: "#d787af", TableRowAlt: "bg:#323232", }))
Functions ¶
func AutoTheme ¶
AutoTheme returns GlamourDark or GlamourLight depending on the terminal's background color. It queries stdin/stdout to detect whether the terminal has a dark background, matching the behavior of glamour's "auto" style.
func ChromaStyleFromConfig ¶
func ChromaStyleFromConfig(name string, cfg ansi.StyleConfig) *chroma.Style
ChromaStyleFromConfig converts a glamour ansi.StyleConfig into a *chroma.Style registered under the given name. This produces the same format used by the renderer's WithTheme option.
Types ¶
type StyleEntry ¶
type StyleEntry struct {
Colour color.Color
Background color.Color
Bold Trilean
Italic Trilean
Underline Trilean
}
StyleEntry defines the visual style for a single token type.
func (StyleEntry) IsZero ¶
func (e StyleEntry) IsZero() bool
IsZero returns true if all fields are at their zero/nil/Pass values.
type Theme ¶
type Theme struct {
// contains filtered or unexported fields
}
Theme maps token types to style entries.
func FromStyleConfig ¶
func FromStyleConfig(cfg ansi.StyleConfig) *Theme
FromStyleConfig converts a glamour ansi.StyleConfig into a *Theme.
Chroma syntax-highlighting entries are applied first (lower priority), then structural markdown fields are overlaid on top.
func NewTheme ¶
func NewTheme(entries map[TokenType]StyleEntry) *Theme
NewTheme creates a new Theme from a map of token types to style entries.
func (*Theme) Get ¶
func (t *Theme) Get(token TokenType) StyleEntry
Get returns the style entry for the given token type, inheriting from parent token types (sub-category, category, Text, Background) as needed. This matches chroma's Style.Get behavior.
type TokenType ¶
type TokenType int
TokenType identifies a syntactic element for styling purposes. Values match chroma.TokenType so that a simple cast converts between them.
const ( Keyword TokenType = 1000 + iota KeywordConstant KeywordDeclaration KeywordNamespace KeywordPseudo KeywordReserved KeywordType )
Keywords.
const ( Name TokenType = 2000 + iota NameAttribute NameBuiltin NameBuiltinPseudo NameClass NameConstant NameDecorator NameEntity NameException NameFunction NameFunctionMagic NameKeyword NameLabel NameNamespace NameOperator NameOther NamePseudo NameProperty NameTag )
Names.
const ( LiteralString TokenType = 3100 + iota LiteralStringAffix LiteralStringAtom LiteralStringBacktick LiteralStringBoolean LiteralStringChar LiteralStringDelimiter LiteralStringDoc LiteralStringDouble LiteralStringEscape LiteralStringHeredoc )
Strings.