mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-06 08:57:14 -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() {
|
switch node.Kind() {
|
||||||
// Document
|
// Document
|
||||||
case ast.KindDocument:
|
case ast.KindDocument:
|
||||||
|
e := &BlockElement{
|
||||||
|
Block: &bytes.Buffer{},
|
||||||
|
Style: ctx.styles.Document,
|
||||||
|
Margin: true,
|
||||||
|
}
|
||||||
return Element{
|
return Element{
|
||||||
Renderer: &DocumentElement{},
|
Renderer: e,
|
||||||
Finisher: &DocumentElement{},
|
Finisher: e,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Heading
|
// Heading
|
||||||
|
|||||||
Reference in New Issue
Block a user