zidane-ui/ code/ tokens
import { … } from 'zidane-ui/code/tokens'ui/src/code/tokens.ts
Functions#
highlightToTokensFunction#
Code highlighting for a host that draws code itself (the phone, in native text): the same
highlighter and themes as the kit's code blocks (@pierre/highlights), giving lines of styled
runs instead of HTML. It runs where WebAssembly does (a web view), so it is an entry of its own:
that page loads this and nothing else.
function highlightToTokens(
code: string,
lang: string,
themeId: string,
): Promise<CodeTokens | null>Parameters
| Name | Type | Description |
|---|---|---|
| code | string | The code. |
| lang | string | A language name or alias, such as |
| themeId | string | A bundled code theme id ( |
Returns
Promise<CodeTokens | null>The runs, or null for a language with no lexer or an unknown theme.
Interfaces#
CodeRunInterface#
One styled run of a line: its text, its color (#rrggbb, absent: the theme's text), bold and italic.
interface CodeRunProperties
| Name | Type | Description |
|---|---|---|
| bold? | true | Drawn bold. |
| color? | string | Its color, |
| italic? | true | Drawn italic. |
| text | string | The run's text. |
CodeTokensInterface#
Code as lines of styled runs, and the theme's text and background colors.
interface CodeTokensProperties
| Name | Type | Description |
|---|---|---|
| bg? | string | The theme's background color. |
| fg? | string | The theme's text color. |
| lines | CodeRun[][] | Each line's runs, in order. |
Re-exports#
These names are documented on the entry point that owns them.