fromCss

fun fromCss(cssText: String, name: String, backgroundColor: Color? = null, defaultTextColor: Color? = null): HighlightTheme

Custom theme from raw Highlight.js CSS text.

Use this when you fetch or generate CSS at runtime rather than bundling it as an asset.

val css = // ... fetch from network or build programmatically
val theme = HighlightTheme.fromCss(
cssText = css,
name = "my-runtime-theme",
)

Return

A HighlightTheme whose color map is lazily parsed from cssText.

Parameters

cssText

Raw Highlight.js-compatible CSS text.

name

Display name for the theme.

backgroundColor

Optional explicit background color known ahead of time. When provided, this color is available immediately without waiting for CSS parsing.

defaultTextColor

Optional explicit default text color known ahead of time. When provided, this color is available immediately without waiting for CSS parsing.