Automatically apply custom chroma theme when set in style

This commit is contained in:
Christian Muehlhaeuser
2019-12-16 08:37:31 +01:00
parent 48a98c9d30
commit 5b742594cc
2 changed files with 38 additions and 35 deletions
+3
View File
@@ -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
View File
@@ -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"`