mirror of
https://github.com/alecthomas/chroma.git
synced 2025-07-17 01:22:22 +02:00
[html formatter] Add option to let users provide custom CSS styles
Example: WithCustomCSS(map[chroma.TokenType]string{chroma.Line: `display: inline;`})
This commit is contained in:
committed by
Alec Thomas
parent
7cc13cf232
commit
7d779408db
@ -108,6 +108,18 @@ func TestTableLineNumberNewlines(t *testing.T) {
|
||||
</span>`)
|
||||
}
|
||||
|
||||
func TestWithCustomCSS(t *testing.T) {
|
||||
f := New(WithClasses(false), WithCustomCSS(map[chroma.TokenType]string{chroma.Line: `display: inline;`}))
|
||||
it, err := lexers.Get("bash").Tokenise(nil, "echo FOO")
|
||||
assert.NoError(t, err)
|
||||
|
||||
var buf bytes.Buffer
|
||||
err = f.Format(&buf, styles.Fallback, it)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Regexp(t, `<span style="display:flex;display:inline;"><span><span style=".*">echo</span> FOO</span></span>`, buf.String())
|
||||
}
|
||||
|
||||
func TestWrapLongLines(t *testing.T) {
|
||||
f := New(WithClasses(false), WrapLongLines(true))
|
||||
it, err := lexers.Get("go").Tokenise(nil, "package main\nfunc main()\n{\nprintln(\"hello world\")\n}\n")
|
||||
|
Reference in New Issue
Block a user