Search documentation

↑↓ to move↵ to open

kirari

Reference

API reference

Core functions, optional entry points, and their options.

A small API for the straightforward case, with optional entry points when you need more.

highlight(source, options?)

Returns an escaped HTML fragment. Options accept a language definition, a token-to-class classes map, and a className(token) callback. JavaScript is the default.

tokenize(source, language?)

Returns Token[] with type, value, start, and end. The main @vortexlabs/kirari entry defaults to JavaScript; @vortexlabs/kirari/core requires an explicit language.

render(tokens, options?)

Returns escaped HTML from readonly tokens. Custom classes append to Kirari’s standard classes. Rendering does not mutate tokens.

ImportWhat you get
@vortexlabs/kirariAll three core functions, with JavaScript defaults
@vortexlabs/kirari/coretokenize, render, token types; no default language
@vortexlabs/kirari/streamcreateTokenStream, TokenStream, TokenPatch
@vortexlabs/kirari/decorationsrenderDecorated, Decoration, DecoratedRenderOptions
@vortexlabs/kirari/registrycreateRegistry, LanguageRegistry
@vortexlabs/kirari/markdowncreateMarkdown(registry)
@vortexlabs/kirari/languages/*One named language definition
@vortexlabs/kirari/theme.cssOptional theme, driven by CSS variables
@vortexlabs/kirari-rehypeOptional Markdown and MDX plugin, Options

Core TypeScript types include Token, TokenType, Language, Rule, RenderOptions, and HighlightOptions. Import optional APIs and their types from their own entry points.