mirror of
https://github.com/alecthomas/chroma.git
synced 2025-07-01 00:35:06 +02:00
Add support for line numbers.
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/alecthomas/chroma"
|
||||
"github.com/alecthomas/chroma/lexers"
|
||||
"github.com/alecthomas/chroma/styles"
|
||||
)
|
||||
@ -27,3 +28,26 @@ func BenchmarkHTMLFormatter(b *testing.B) {
|
||||
assert.NoError(b, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitTokensIntoLines(t *testing.T) {
|
||||
in := []*chroma.Token{
|
||||
{Value: "hello", Type: chroma.NameKeyword},
|
||||
{Value: " world\nwhat?\n", Type: chroma.NameKeyword},
|
||||
{Type: chroma.EOF},
|
||||
}
|
||||
expected := [][]*chroma.Token{
|
||||
[]*chroma.Token{
|
||||
{Type: chroma.NameKeyword, Value: "hello"},
|
||||
{Type: chroma.NameKeyword, Value: " world\n"},
|
||||
},
|
||||
[]*chroma.Token{
|
||||
{Type: chroma.NameKeyword, Value: "what?\n"},
|
||||
},
|
||||
[]*chroma.Token{
|
||||
{Type: chroma.NameKeyword},
|
||||
{Type: chroma.EOF},
|
||||
},
|
||||
}
|
||||
actual := splitTokensIntoLines(in)
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
Reference in New Issue
Block a user