mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-06 08:57:14 -04:00
Automatically apply custom chroma theme when set in style
This commit is contained in:
@@ -63,6 +63,8 @@ func (e *CodeBlockElement) Render(w io.Writer, ctx RenderContext) error {
|
||||
}
|
||||
theme := rules.Theme
|
||||
|
||||
if rules.Chroma != nil {
|
||||
theme = "charm"
|
||||
styles.Register(chroma.MustNewStyle("charm",
|
||||
chroma.StyleEntries{
|
||||
chroma.Text: chromaStyle(rules.Chroma.Text),
|
||||
@@ -97,6 +99,7 @@ func (e *CodeBlockElement) Render(w io.Writer, ctx RenderContext) error {
|
||||
chroma.GenericSubheading: chromaStyle(rules.Chroma.GenericSubheading),
|
||||
chroma.Background: chromaStyle(rules.Chroma.Background),
|
||||
}))
|
||||
}
|
||||
|
||||
iw := &indent.Writer{
|
||||
Indent: indentation + margin,
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ type StyleBlock struct {
|
||||
type StyleCodeBlock struct {
|
||||
StyleBlock
|
||||
Theme string `json:"theme"`
|
||||
Chroma struct {
|
||||
Chroma *struct {
|
||||
Text StylePrimitive `json:"text"`
|
||||
Error StylePrimitive `json:"error"`
|
||||
Comment StylePrimitive `json:"comment"`
|
||||
|
||||
Reference in New Issue
Block a user