From 3f941ddff48e9238c6385a8b7d408555d39cadbe Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Wed, 20 Sep 2017 20:25:47 +1000 Subject: [PATCH] Correctly add styles for line numbers and line highlights when inling. Fixes #7. Fixes #9. --- formatters/html/html.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/formatters/html/html.go b/formatters/html/html.go index 48c1604..bdf78cb 100644 --- a/formatters/html/html.go +++ b/formatters/html/html.go @@ -78,7 +78,7 @@ func (f *Formatter) Format(w io.Writer, style *chroma.Style) (func(*chroma.Token }, nil } -func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []*chroma.Token) error { +func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []*chroma.Token) error { // nolint: gocyclo // We deliberately don't use html/template here because it is two orders of magnitude slower (benchmarked). // // OTOH we need to be super careful about correct escaping... @@ -115,10 +115,10 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []*chroma } } if highlight { - fmt.Fprintf(w, "") + fmt.Fprintf(w, "", f.styleAttr(css, chroma.LineHighlight)) } if f.lineNumbers { - fmt.Fprintf(w, "%*d", lineDigits, line+1) + fmt.Fprintf(w, "%*d", f.styleAttr(css, chroma.LineNumbers), lineDigits, line+1) } for _, token := range tokens {