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
|
theme := rules.Theme
|
||||||
|
|
||||||
|
if rules.Chroma != nil {
|
||||||
|
theme = "charm"
|
||||||
styles.Register(chroma.MustNewStyle("charm",
|
styles.Register(chroma.MustNewStyle("charm",
|
||||||
chroma.StyleEntries{
|
chroma.StyleEntries{
|
||||||
chroma.Text: chromaStyle(rules.Chroma.Text),
|
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.GenericSubheading: chromaStyle(rules.Chroma.GenericSubheading),
|
||||||
chroma.Background: chromaStyle(rules.Chroma.Background),
|
chroma.Background: chromaStyle(rules.Chroma.Background),
|
||||||
}))
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
iw := &indent.Writer{
|
iw := &indent.Writer{
|
||||||
Indent: indentation + margin,
|
Indent: indentation + margin,
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ type StyleBlock struct {
|
|||||||
type StyleCodeBlock struct {
|
type StyleCodeBlock struct {
|
||||||
StyleBlock
|
StyleBlock
|
||||||
Theme string `json:"theme"`
|
Theme string `json:"theme"`
|
||||||
Chroma struct {
|
Chroma *struct {
|
||||||
Text StylePrimitive `json:"text"`
|
Text StylePrimitive `json:"text"`
|
||||||
Error StylePrimitive `json:"error"`
|
Error StylePrimitive `json:"error"`
|
||||||
Comment StylePrimitive `json:"comment"`
|
Comment StylePrimitive `json:"comment"`
|
||||||
|
|||||||
Reference in New Issue
Block a user