diff --git a/formatters/html/html.go b/formatters/html/html.go index 74db7ff33..164c842d2 100644 --- a/formatters/html/html.go +++ b/formatters/html/html.go @@ -139,17 +139,17 @@ var ( defaultPreWrapper = preWrapper{ start: func(code bool, styleAttr string) string { if code { - return fmt.Sprintf(`
`, styleAttr) + return fmt.Sprintf(`` }, } ) @@ -250,7 +250,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma. } // Start of Line - fmt.Fprint(w, ``, styleAttr) } - return fmt.Sprintf(`
`, styleAttr) + return fmt.Sprintf(`` + return ``, styleAttr) }, end: func(code bool) string { if code { - return `` + return `` } - return ``) // End of CodeLine - fmt.Fprint(w, ``) // End of Line + fmt.Fprint(w, ``) // End of Line } fmt.Fprintf(w, f.preWrapper.End(true)) @@ -454,8 +454,8 @@ func (f *Formatter) styleToCSS(style *chroma.Style) map[chroma.TokenType]string // All rules begin with default rules followed by user provided rules classes[chroma.Line] = `display: flex;` + classes[chroma.Line] classes[chroma.LineNumbers] = lineNumbersStyle + classes[chroma.LineNumbers] - classes[chroma.LineNumbersTable] = `font-family: monospace; font-size: inherit;` + lineNumbersStyle + classes[chroma.LineNumbersTable] - classes[chroma.LineTable] = "border-spacing: 0; padding: 0; margin: 0; border: 0; width: auto; overflow: auto; display: block;" + classes[chroma.LineTable] + classes[chroma.LineNumbersTable] = lineNumbersStyle + classes[chroma.LineNumbersTable] + classes[chroma.LineTable] = "border-spacing: 0; padding: 0; margin: 0; border: 0;" + classes[chroma.LineTable] classes[chroma.LineTableTD] = "vertical-align: top; padding: 0; margin: 0; border: 0;" + classes[chroma.LineTableTD] return classes } diff --git a/formatters/html/html_test.go b/formatters/html/html_test.go index 39575ba3b..346611f76 100644 --- a/formatters/html/html_test.go +++ b/formatters/html/html_test.go @@ -129,7 +129,7 @@ func TestHighlightLines(t *testing.T) { err = f.Format(&buf, styles.Fallback, it) assert.NoError(t, err) - assert.Contains(t, buf.String(), ``) + assert.Contains(t, buf.String(), ``) } func TestLineNumbers(t *testing.T) { @@ -141,7 +141,7 @@ func TestLineNumbers(t *testing.T) { err = f.Format(&buf, styles.Fallback, it) assert.NoError(t, err) - assert.Contains(t, buf.String(), `1echo FOO`) + assert.Contains(t, buf.String(), `1echo FOO`) } func TestPreWrapper(t *testing.T) { @@ -153,7 +153,7 @@ func TestPreWrapper(t *testing.T) { err = f.Format(&buf, styles.Fallback, it) assert.NoError(t, err) - assert.Regexp(t, "\n echo FOO\n\n