diff --git a/formatters/html/html_test.go b/formatters/html/html_test.go index ac1fbf1..48ef5b3 100644 --- a/formatters/html/html_test.go +++ b/formatters/html/html_test.go @@ -44,9 +44,6 @@ func TestSplitTokensIntoLines(t *testing.T) { { {Type: chroma.NameKeyword, Value: "what?\n"}, }, - { - {Type: chroma.NameKeyword}, - }, } actual := chroma.SplitTokensIntoLines(in) assert.Equal(t, expected, actual) diff --git a/iterator.go b/iterator.go index f540372..814b1f4 100644 --- a/iterator.go +++ b/iterator.go @@ -64,5 +64,12 @@ func SplitTokensIntoLines(tokens []Token) (out [][]Token) { if len(line) > 0 { out = append(out, line) } + // Strip empty trailing token line. + if len(out) > 0 { + last := out[len(out)-1] + if len(last) == 1 && last[0].Value == "" { + out = out[:len(out)-1] + } + } return }