added support for language, topic, and preset acquisition and detection functions

This commit is contained in:
2025-07-19 11:47:25 +08:00
parent 5783f40de7
commit 43d4349293
12 changed files with 988 additions and 499 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/alecthomas/chroma/v2"
"github.com/alecthomas/chroma/v2/lexers"
"github.com/alecthomas/chroma/v2/styles"
)
// LanguageDetector provides enhanced language detection capabilities
@@ -168,6 +169,21 @@ func (ld *LanguageDetector) GetSupportedLanguages() []string {
return lexers.Names(false) // false means don't include aliases
}
// GetSupportedThemes returns a list of all supported themes
func (ld *LanguageDetector) GetSupportedThemes() []string {
var themes []string
for name := range styles.Registry {
themes = append(themes, name)
}
return themes
}
// IsThemeSupported checks if a theme is supported
func (ld *LanguageDetector) IsThemeSupported(theme string) bool {
_, exists := styles.Registry[strings.ToLower(theme)]
return exists
}
// IsLanguageSupported checks if a language is supported
func (ld *LanguageDetector) IsLanguageSupported(language string) bool {
lexer := lexers.Get(language)