mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-05 08:27:18 -04:00
Decode style JSON into a typed struct
This commit is contained in:
+4
-4
@@ -9,7 +9,7 @@ type DocumentElement struct {
|
||||
}
|
||||
|
||||
func (e *DocumentElement) Render(w io.Writer, ctx RenderContext) error {
|
||||
rules := ctx.style[Document]
|
||||
rules := ctx.styles.Document
|
||||
|
||||
be := BlockElement{
|
||||
Block: &bytes.Buffer{},
|
||||
@@ -17,20 +17,20 @@ func (e *DocumentElement) Render(w io.Writer, ctx RenderContext) error {
|
||||
}
|
||||
ctx.blockStack.Push(be)
|
||||
|
||||
renderText(ctx.blockStack.Current().Block, rules, rules.Prefix)
|
||||
renderText(ctx.blockStack.Current().Block, rules.StylePrimitive, rules.Prefix)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *DocumentElement) Finish(w io.Writer, ctx RenderContext) error {
|
||||
bs := ctx.blockStack
|
||||
rules := ctx.style[Document]
|
||||
rules := ctx.styles.Document
|
||||
|
||||
mw := NewMarginWriter(ctx, w, rules)
|
||||
_, err := mw.Write(bs.Current().Block.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
renderText(mw, rules, rules.Suffix)
|
||||
renderText(mw, rules.StylePrimitive, rules.Suffix)
|
||||
|
||||
bs.Current().Block.Reset()
|
||||
bs.Pop()
|
||||
|
||||
Reference in New Issue
Block a user