Java
Lumis Java API via lumis4j including highlighting, language and theme selection, and JVM integration.
Lumis4J is a community-maintained Java runtime from roastedroot. It has its own API and releases. Check the Lumis4J documentation for supported features and version compatibility.
Installation
<dependency>
<groupId>io.roastedroot</groupId>
<artifactId>lumis4j</artifactId>
<version>0.0.7</version>
</dependency>Basic usage
import io.roastedroot.lumis4j.core.Lang;
import io.roastedroot.lumis4j.core.Lumis;
import io.roastedroot.lumis4j.core.Theme;
var lumis = Lumis.builder().build();
var highlighter = lumis.highlighter()
.withLang(Lang.JAVASCRIPT)
.withTheme(Theme.CATPPUCCIN_FRAPPE)
.build();
var html = highlighter.highlight("const x = 1").string();Languages and themes
Languages and themes are available as enum constants:
Lang.RUST
Lang.JAVASCRIPT
Lang.ELIXIR
Lang.PYTHON
Theme.CATPPUCCIN_FRAPPE
Theme.GITHUB_DARK
Theme.CATPPUCCIN_MOCHA
Theme.ONEDARKCustom themes
Generate a theme from a Neovim colorscheme covers JSON generation and source-license considerations. Lumis4J has its own theme API; check its documentation for custom theme support in your version rather than assuming it can load the generated JSON. The recipe also shows how to render HTML with the CLI as a build step.
Formatter support
lumis4j supports the following formatters: TERMINAL, HTML_INLINE, HTML_LINKED, and BBCODE. HTML_INLINE, TERMINAL, and BBCODE support themes; HTML_LINKED is designed for external CSS.
API reference
See the lumis4j GitHub repository for full API documentation.