from Asset
Custom theme loaded from a Highlight.js CSS file in the app's assets/ folder.
This is the recommended way for app developers to ship additional themes. Download any .css file from the Highlight.js styles directory, place it in src/main/assets/, and reference it here.
// src/main/assets/themes/github.css ← place the CSS here
val theme = HighlightTheme.fromAsset(
context = context,
assetPath = "themes/github.css",
name = "github",
)
HighlightThemeProvider(lightHighlightTheme = theme, ...) { ... }Note: loading is lazy - the CSS is parsed on first use, not at factory-call time. The provided context is defensively normalized to applicationContext before being retained by the lazy theme provider.
Return
A HighlightTheme whose color map is lazily parsed from assetPath.
Parameters
Any Context; normalized to applicationContext internally.
Path within assets/ to the Highlight.js CSS file (e.g. "themes/github.css").
Display name for the theme.
Throws
if the asset file is found but contains no parseable color rules (e.g. it is empty or uses only unsupported CSS properties).
if the asset file cannot be opened (missing or unreadable). This exception is also thrown lazily, on first use of the theme.