Highlight Language
Language catalog and helpers for Highlight.js language identifiers.
Provides synchronous access to all 190+ supported languages (all), a curated subset of popular languages for quick-access pickers and chips (primary), support validation (isSupported), alias normalization (canonicalName), and file extension mapping (fromExtension).
This is a convenience helper for discoverability and UI tooling. The language parameter used by dev.hossain.highlight.ui.SyntaxHighlightedCode and HighlightEngine.highlight remains a plain String, so callers can still pass any Highlight.js language name directly.
Usage
// Synchronous check if a language or alias is supported
val supported = HighlightLanguage.isSupported("kt") // true
// Resolve an alias to its canonical Highlight.js grammar name
val canonical = HighlightLanguage.canonicalName("kt") // "kotlin"
// Populate a language picker or filter chips
val pickers = HighlightLanguage.primary // ["kotlin", "java", "python", ...]
// Map a file extension to a language identifier
val language = HighlightLanguage.fromExtension("kt") ?: "plaintext"
SyntaxHighlightedCode(
code = snippet,
language = language,
theme = rememberTomorrowLightTheme(),
)Functions
Resolves a language identifier, alias, or file extension to its canonical Highlight.js grammar name.
Returns the Highlight.js language identifier for a file extension.
Checks whether the specified language identifier, alias, or file extension is supported.