Installation
Pick the runtime you want to use first. The highlighting concepts stay the same across all of them.
- JavaScript
- Rust
- Elixir
- Java
- CLI
- Browsers / CDN
npm install @lumis-sh/lumis @lumis-sh/themes
Use @lumis-sh/lumis for the per-language WASM runtime and
@lumis-sh/themes for bundled themes. Node.js, Bun, Deno, and browsers use the
same runtime model.
cargo add lumis
def deps do
[
{:lumis, "~> 0.3"}
]
end
<dependency>
<groupId>io.roastedroot</groupId>
<artifactId>lumis4j</artifactId>
<version>0.0.7</version>
</dependency>
npx @lumis-sh/cli --help
For a global install:
npm install -g @lumis-sh/cli
The installed binary is lumis. Rust users can also install from crates.io with cargo install lumis-cli.
<script type="module">
import {highlight} from 'https://esm.sh/@lumis-sh/lumis';
import {htmlInline} from 'https://esm.sh/@lumis-sh/lumis/formatters';
import javascript from 'https://esm.sh/@lumis-sh/lumis/langs/javascript';
import dracula from 'https://esm.sh/@lumis-sh/themes/dracula';
const html = await highlight(
'const x = 1',
htmlInline({language: javascript, theme: dracula})
);
document.getElementById('output').innerHTML = html;
</script>
Notes
- JavaScript loads parser WASM files at runtime. By default they come from a CDN. See WASM and CDN.
- Elixir also loads missing root and injected parser WASM on demand and caches verified bytes locally.
- For local JavaScript parser assets from npm, install per-language packages such as
@lumis-sh/wasm-rustor bundle packages such as@lumis-sh/wasm-bundle-web. - The CLI caches parsers and custom themes in a local data directory.