From 92cf159a89da976f1ca6319852bf179f6b77a155 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 17 Dec 2019 12:54:10 +0100 Subject: [PATCH] Fix TableElement not inheriting style from parent --- ansi/table.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ansi/table.go b/ansi/table.go index e77ec5c..0cc49be 100644 --- a/ansi/table.go +++ b/ansi/table.go @@ -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() }