mirror of
https://github.com/alecthomas/chroma.git
synced 2025-07-01 00:35:06 +02:00
Combine HTML formatting functions.
This commit is contained in:
@ -1,14 +1,29 @@
|
||||
package html
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/alecthomas/chroma/lexers"
|
||||
"github.com/alecthomas/chroma/styles"
|
||||
)
|
||||
|
||||
func TestCompressStyle(t *testing.T) {
|
||||
style := "color: #888888; background-color: #faffff"
|
||||
actual := compressStyle(style)
|
||||
expected := "color:#888;background-color:#faffff"
|
||||
require.Equal(t, expected, actual)
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
func BenchmarkHTMLFormatter(b *testing.B) {
|
||||
formatter := New()
|
||||
writer, err := formatter.Format(ioutil.Discard, styles.Fallback)
|
||||
assert.NoError(b, err)
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
err = lexers.Go.Tokenise(nil, "package main\nfunc main()\n{\nprintln(`hello world`)\n}\n", writer)
|
||||
assert.NoError(b, err)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user