From 845e87b52113e3722c197597b577128913ba0317 Mon Sep 17 00:00:00 2001 From: bratekarate Date: Wed, 2 Oct 2024 21:43:42 +0200 Subject: [PATCH] fix: add dirty hack to avoid white background. --- main.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 821423f..a18bf9b 100644 --- a/main.go +++ b/main.go @@ -73,10 +73,22 @@ func highlight(w io.Writer, source, lexer, style string) error { if err != nil { return err } + + /* HACK: If background color is white, set to a reasonable, light grey + * default. */ + if s.Get(chroma.Background).Background.String() == "#ffffff" { + senr := s.Get(chroma.Background) + senr.Background = chroma.ParseColour("#f6f8fa"); + s, err = s.Builder().AddEntry(chroma.Background, senr).Build(); + if err != nil { + return err + } + } + return f.Format(w, s, it) } -const Version = "0.1" +const Version = "0.1.2" func main() { css := flag.String("css", "", "Path to a CSS import to include at the beginning of the output")