Move chroma style settings to separate struct

This commit is contained in:
Christian Muehlhaeuser
2019-12-15 00:08:11 +01:00
parent da222f957c
commit ed99f8a844
2 changed files with 65 additions and 63 deletions
+31 -31
View File
@@ -45,37 +45,37 @@ func (e *CodeBlockElement) Render(w io.Writer, ctx RenderContext) error {
styles.Register(chroma.MustNewStyle("charm", styles.Register(chroma.MustNewStyle("charm",
chroma.StyleEntries{ chroma.StyleEntries{
chroma.Text: chromaColor(rules.Text), chroma.Text: chromaColor(rules.Chroma.Text),
chroma.Error: chromaColor(rules.Error), chroma.Error: chromaColor(rules.Chroma.Error),
chroma.Comment: chromaColor(rules.Comment), chroma.Comment: chromaColor(rules.Chroma.Comment),
chroma.CommentPreproc: chromaColor(rules.CommentPreproc), chroma.CommentPreproc: chromaColor(rules.Chroma.CommentPreproc),
chroma.Keyword: chromaColor(rules.Keyword), chroma.Keyword: chromaColor(rules.Chroma.Keyword),
chroma.KeywordReserved: chromaColor(rules.KeywordReserved), chroma.KeywordReserved: chromaColor(rules.Chroma.KeywordReserved),
chroma.KeywordNamespace: chromaColor(rules.KeywordNamespace), chroma.KeywordNamespace: chromaColor(rules.Chroma.KeywordNamespace),
chroma.KeywordType: chromaColor(rules.KeywordType), chroma.KeywordType: chromaColor(rules.Chroma.KeywordType),
chroma.Operator: chromaColor(rules.Operator), chroma.Operator: chromaColor(rules.Chroma.Operator),
chroma.Punctuation: chromaColor(rules.Punctuation), chroma.Punctuation: chromaColor(rules.Chroma.Punctuation),
chroma.Name: chromaColor(rules.Name), chroma.Name: chromaColor(rules.Chroma.Name),
chroma.NameBuiltin: chromaColor(rules.NameBuiltin), chroma.NameBuiltin: chromaColor(rules.Chroma.NameBuiltin),
chroma.NameTag: chromaColor(rules.NameTag), chroma.NameTag: chromaColor(rules.Chroma.NameTag),
chroma.NameAttribute: chromaColor(rules.NameAttribute), chroma.NameAttribute: chromaColor(rules.Chroma.NameAttribute),
chroma.NameClass: chromaColor(rules.NameClass), chroma.NameClass: chromaColor(rules.Chroma.NameClass),
chroma.NameConstant: chromaColor(rules.NameConstant), chroma.NameConstant: chromaColor(rules.Chroma.NameConstant),
chroma.NameDecorator: chromaColor(rules.NameDecorator), chroma.NameDecorator: chromaColor(rules.Chroma.NameDecorator),
chroma.NameException: chromaColor(rules.NameException), chroma.NameException: chromaColor(rules.Chroma.NameException),
chroma.NameFunction: chromaColor(rules.NameFunction), chroma.NameFunction: chromaColor(rules.Chroma.NameFunction),
chroma.NameOther: chromaColor(rules.NameOther), chroma.NameOther: chromaColor(rules.Chroma.NameOther),
chroma.Literal: chromaColor(rules.Literal), chroma.Literal: chromaColor(rules.Chroma.Literal),
chroma.LiteralNumber: chromaColor(rules.LiteralNumber), chroma.LiteralNumber: chromaColor(rules.Chroma.LiteralNumber),
chroma.LiteralDate: chromaColor(rules.LiteralDate), chroma.LiteralDate: chromaColor(rules.Chroma.LiteralDate),
chroma.LiteralString: chromaColor(rules.LiteralString), chroma.LiteralString: chromaColor(rules.Chroma.LiteralString),
chroma.LiteralStringEscape: chromaColor(rules.LiteralStringEscape), chroma.LiteralStringEscape: chromaColor(rules.Chroma.LiteralStringEscape),
chroma.GenericDeleted: chromaColor(rules.GenericDeleted), chroma.GenericDeleted: chromaColor(rules.Chroma.GenericDeleted),
chroma.GenericEmph: chromaColor(rules.GenericEmph), chroma.GenericEmph: chromaColor(rules.Chroma.GenericEmph),
chroma.GenericInserted: chromaColor(rules.GenericInserted), chroma.GenericInserted: chromaColor(rules.Chroma.GenericInserted),
chroma.GenericStrong: chromaColor(rules.GenericStrong), chroma.GenericStrong: chromaColor(rules.Chroma.GenericStrong),
chroma.GenericSubheading: chromaColor(rules.GenericSubheading), chroma.GenericSubheading: chromaColor(rules.Chroma.GenericSubheading),
chroma.Background: chromaColor(rules.Background), chroma.Background: chromaColor(rules.Chroma.Background),
})) }))
iw := &IndentWriter{ iw := &IndentWriter{
+34 -32
View File
@@ -37,38 +37,40 @@ type StyleBlock struct {
type StyleCodeBlock struct { type StyleCodeBlock struct {
StyleBlock StyleBlock
Theme string `json:"theme"` Theme string `json:"theme"`
Text StylePrimitive `json:"text"` Chroma struct {
Error StylePrimitive `json:"error"` Text StylePrimitive `json:"text"`
Comment StylePrimitive `json:"comment"` Error StylePrimitive `json:"error"`
CommentPreproc StylePrimitive `json:"comment_preproc"` Comment StylePrimitive `json:"comment"`
Keyword StylePrimitive `json:"keyword"` CommentPreproc StylePrimitive `json:"comment_preproc"`
KeywordReserved StylePrimitive `json:"keyword_reserved"` Keyword StylePrimitive `json:"keyword"`
KeywordNamespace StylePrimitive `json:"keyword_namespace"` KeywordReserved StylePrimitive `json:"keyword_reserved"`
KeywordType StylePrimitive `json:"keyword_type"` KeywordNamespace StylePrimitive `json:"keyword_namespace"`
Operator StylePrimitive `json:"operator"` KeywordType StylePrimitive `json:"keyword_type"`
Punctuation StylePrimitive `json:"punctuation"` Operator StylePrimitive `json:"operator"`
Name StylePrimitive `json:"name"` Punctuation StylePrimitive `json:"punctuation"`
NameBuiltin StylePrimitive `json:"name_builtin"` Name StylePrimitive `json:"name"`
NameTag StylePrimitive `json:"name_tag"` NameBuiltin StylePrimitive `json:"name_builtin"`
NameAttribute StylePrimitive `json:"name_attribute"` NameTag StylePrimitive `json:"name_tag"`
NameClass StylePrimitive `json:"name_class"` NameAttribute StylePrimitive `json:"name_attribute"`
NameConstant StylePrimitive `json:"name_constant"` NameClass StylePrimitive `json:"name_class"`
NameDecorator StylePrimitive `json:"name_decorator"` NameConstant StylePrimitive `json:"name_constant"`
NameException StylePrimitive `json:"name_exception"` NameDecorator StylePrimitive `json:"name_decorator"`
NameFunction StylePrimitive `json:"name_function"` NameException StylePrimitive `json:"name_exception"`
NameOther StylePrimitive `json:"name_other"` NameFunction StylePrimitive `json:"name_function"`
Literal StylePrimitive `json:"literal"` NameOther StylePrimitive `json:"name_other"`
LiteralNumber StylePrimitive `json:"literal_number"` Literal StylePrimitive `json:"literal"`
LiteralDate StylePrimitive `json:"literal_date"` LiteralNumber StylePrimitive `json:"literal_number"`
LiteralString StylePrimitive `json:"literal_string"` LiteralDate StylePrimitive `json:"literal_date"`
LiteralStringEscape StylePrimitive `json:"literal_string_escape"` LiteralString StylePrimitive `json:"literal_string"`
GenericDeleted StylePrimitive `json:"generic_deleted"` LiteralStringEscape StylePrimitive `json:"literal_string_escape"`
GenericEmph StylePrimitive `json:"generic_emph"` GenericDeleted StylePrimitive `json:"generic_deleted"`
GenericInserted StylePrimitive `json:"generic_inserted"` GenericEmph StylePrimitive `json:"generic_emph"`
GenericStrong StylePrimitive `json:"generic_strong"` GenericInserted StylePrimitive `json:"generic_inserted"`
GenericSubheading StylePrimitive `json:"generic_subheading"` GenericStrong StylePrimitive `json:"generic_strong"`
Background StylePrimitive `json:"background"` GenericSubheading StylePrimitive `json:"generic_subheading"`
Background StylePrimitive `json:"background"`
} `json:"chroma"`
} }
type StyleList struct { type StyleList struct {