mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-24 16:10:54 +00:00
35fa192838
Fixes #9932 Fixes #9931
37 lines
723 B
Go
37 lines
723 B
Go
package helpers
|
|
|
|
import (
|
|
"sort"
|
|
|
|
"github.com/alecthomas/chroma/v2/lexers"
|
|
"github.com/gohugoio/hugo/docshelper"
|
|
)
|
|
|
|
// This is is just some helpers used to create some JSON used in the Hugo docs.
|
|
func init() {
|
|
docsProvider := func() docshelper.DocProvider {
|
|
var chromaLexers []any
|
|
|
|
sort.Sort(lexers.GlobalLexerRegistry.Lexers)
|
|
|
|
for _, l := range lexers.GlobalLexerRegistry.Lexers {
|
|
|
|
config := l.Config()
|
|
|
|
lexerEntry := struct {
|
|
Name string
|
|
Aliases []string
|
|
}{
|
|
config.Name,
|
|
config.Aliases,
|
|
}
|
|
|
|
chromaLexers = append(chromaLexers, lexerEntry)
|
|
|
|
}
|
|
|
|
return docshelper.DocProvider{"chroma": map[string]any{"lexers": chromaLexers}}
|
|
}
|
|
|
|
docshelper.AddDocProviderFunc(docsProvider)
|
|
}
|