mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-01 14:37:28 -04:00
Drop redundant DocumentElement
This commit is contained in:
-39
@@ -1,39 +0,0 @@
|
||||
package gold
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
)
|
||||
|
||||
type DocumentElement struct {
|
||||
}
|
||||
|
||||
func (e *DocumentElement) Render(w io.Writer, ctx RenderContext) error {
|
||||
rules := ctx.styles.Document
|
||||
|
||||
be := BlockElement{
|
||||
Block: &bytes.Buffer{},
|
||||
Style: rules,
|
||||
}
|
||||
ctx.blockStack.Push(be)
|
||||
|
||||
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.styles.Document
|
||||
|
||||
mw := NewMarginWriter(ctx, w, rules)
|
||||
_, err := mw.Write(bs.Current().Block.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
renderText(mw, rules.StylePrimitive, rules.Suffix)
|
||||
|
||||
bs.Current().Block.Reset()
|
||||
bs.Pop()
|
||||
|
||||
return nil
|
||||
}
|
||||
+7
-2
@@ -32,9 +32,14 @@ func (tr *TermRenderer) NewElement(node ast.Node, source []byte) Element {
|
||||
switch node.Kind() {
|
||||
// Document
|
||||
case ast.KindDocument:
|
||||
e := &BlockElement{
|
||||
Block: &bytes.Buffer{},
|
||||
Style: ctx.styles.Document,
|
||||
Margin: true,
|
||||
}
|
||||
return Element{
|
||||
Renderer: &DocumentElement{},
|
||||
Finisher: &DocumentElement{},
|
||||
Renderer: e,
|
||||
Finisher: e,
|
||||
}
|
||||
|
||||
// Heading
|
||||
|
||||
Reference in New Issue
Block a user