Fix TableElement not inheriting style from parent

This commit is contained in:
Christian Muehlhaeuser
2019-12-17 12:54:10 +01:00
parent fb6c5cdab8
commit 92cf159a89
+4 -3
View File
@@ -49,10 +49,11 @@ func (e *TableElement) Render(w io.Writer, ctx RenderContext) error {
},
}
ctx.table.styleWriter = NewStyleWriter(ctx, iw, rules.StylePrimitive)
style := bs.With(rules.StylePrimitive)
ctx.table.styleWriter = NewStyleWriter(ctx, iw, style)
renderText(w, bs.Current().Style.StylePrimitive, rules.BlockPrefix)
renderText(ctx.table.styleWriter, rules.StylePrimitive, rules.Prefix)
renderText(ctx.table.styleWriter, style, rules.Prefix)
ctx.table.writer = tablewriter.NewWriter(ctx.table.styleWriter)
return nil
}
@@ -74,7 +75,7 @@ func (e *TableElement) Finish(w io.Writer, ctx RenderContext) error {
ctx.table.writer.Render()
ctx.table.writer = nil
renderText(ctx.table.styleWriter, rules.StylePrimitive, rules.Suffix)
renderText(ctx.table.styleWriter, ctx.blockStack.With(rules.StylePrimitive), rules.Suffix)
renderText(ctx.table.styleWriter, ctx.blockStack.Current().Style.StylePrimitive, rules.BlockSuffix)
return ctx.table.styleWriter.Close()
}