HighlightLanguage

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(),
)

Properties

Link copied to clipboard

Uppercase alias for all to match common constant naming conventions.

Link copied to clipboard

Complete list of all supported language identifiers in alphabetical order.

Link copied to clipboard

Uppercase alias for primary to match common constant naming conventions.

Link copied to clipboard

Curated primary languages for quick-access pickers, filter chips, and editors.

Functions

Link copied to clipboard
fun canonicalName(nameOrAlias: String): String?

Resolves a language identifier, alias, or file extension to its canonical Highlight.js grammar name.

Link copied to clipboard
fun fromExtension(extension: String): String?

Returns the Highlight.js language identifier for a file extension.

Link copied to clipboard
fun isSupported(language: String): Boolean

Checks whether the specified language identifier, alias, or file extension is supported.