1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-02-15 13:33:12 +02:00

feat: add MustNewXMLStyle

This commit is contained in:
Alec Thomas 2022-11-02 15:40:25 +11:00
parent c263f6fa19
commit ebba7013b3
2 changed files with 10 additions and 1 deletions

View File

@ -230,6 +230,15 @@ func NewXMLStyle(r io.Reader) (*Style, error) {
return style, dec.Decode(style)
}
// MustNewXMLStyle is like NewXMLStyle but panics on error.
func MustNewXMLStyle(r io.Reader) *Style {
style, err := NewXMLStyle(r)
if err != nil {
panic(err)
}
return style
}
// NewStyle creates a new style definition.
func NewStyle(name string, entries StyleEntries) (*Style, error) {
return NewStyleBuilder(name).AddAll(entries).Build()

View File

@ -1,7 +1,7 @@
package styles
import (
"embed" // Imported for side-effects.
"embed"
"io/fs"
"sort"