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 runtime and @lumis-sh/themes for bundled themes.
cargo add lumis
def deps do
[
{:lumis, "~> 0.3"}
]
end
<dependency>
<groupId>io.roastedroot</groupId>
<artifactId>lumis4j</artifactId>
<version>0.0.7</version>
</dependency>
cargo install lumis-cli
The installed binary is lumis.
<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.
- 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.