2018-04-02 02:49:54 -04:00
|
|
|
package helpers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sort"
|
|
|
|
|
2022-05-26 06:17:10 -04:00
|
|
|
"github.com/alecthomas/chroma/v2/lexers"
|
2018-04-02 02:49:54 -04:00
|
|
|
"github.com/gohugoio/hugo/docshelper"
|
|
|
|
)
|
|
|
|
|
|
|
|
// This is is just some helpers used to create some JSON used in the Hugo docs.
|
|
|
|
func init() {
|
2020-03-20 11:34:53 -04:00
|
|
|
docsProvider := func() docshelper.DocProvider {
|
2022-03-17 17:03:27 -04:00
|
|
|
var chromaLexers []any
|
2018-04-02 02:49:54 -04:00
|
|
|
|
2022-05-26 06:17:10 -04:00
|
|
|
sort.Sort(lexers.GlobalLexerRegistry.Lexers)
|
2018-04-02 02:49:54 -04:00
|
|
|
|
2022-05-26 06:17:10 -04:00
|
|
|
for _, l := range lexers.GlobalLexerRegistry.Lexers {
|
2018-04-02 02:49:54 -04:00
|
|
|
|
|
|
|
config := l.Config()
|
|
|
|
|
|
|
|
lexerEntry := struct {
|
|
|
|
Name string
|
|
|
|
Aliases []string
|
|
|
|
}{
|
|
|
|
config.Name,
|
2022-05-26 06:17:10 -04:00
|
|
|
config.Aliases,
|
2018-04-02 02:49:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
chromaLexers = append(chromaLexers, lexerEntry)
|
|
|
|
|
|
|
|
}
|
2020-03-20 11:34:53 -04:00
|
|
|
|
2022-03-17 17:03:27 -04:00
|
|
|
return docshelper.DocProvider{"chroma": map[string]any{"lexers": chromaLexers}}
|
2018-04-02 02:49:54 -04:00
|
|
|
}
|
|
|
|
|
2020-03-20 11:34:53 -04:00
|
|
|
docshelper.AddDocProviderFunc(docsProvider)
|
2018-04-02 02:49:54 -04:00
|
|
|
}
|