glamour icon indicating copy to clipboard operation
glamour copied to clipboard

document margin is only applied if color is also present

Open anicolao opened this issue 2 years ago • 1 comments

To reproduce:

cp styles/light.json /tmp
vi /tmp/light.json # remove color line from document block at top of file
glow -s /tmp/light.json ANYFILE.md

The output of glow should have a two space margin. The margin appears only before lines which have colour in them, like headers, and not before other lines.

anicolao avatar Feb 03 '22 20:02 anicolao

The following hack does work around the problem:

diff --git a/ansi/margin.go b/ansi/margin.go
index e039783..4e1992f 100644
--- a/ansi/margin.go
+++ b/ansi/margin.go
@@ -29,10 +29,10 @@ func NewMarginWriter(ctx RenderContext, w io.Writer, rules StyleBlock) *MarginWr
 	}
 
 	pw := padding.NewWriterPipe(w, bs.Width(ctx), func(wr io.Writer) {
-		renderText(w, ctx.options.ColorProfile, rules.StylePrimitive, " ")
+		renderText(w, ctx.options.ColorProfile, rules.StylePrimitive, "\u200b ")
 	})
 
-	ic := " "
+	ic := "\u200b "
 	if rules.IndentToken != nil {
 		ic = *rules.IndentToken
 	}

anicolao avatar Feb 03 '22 22:02 anicolao