# Highlight

Whether `language` has a grammar here.

- Registry name: `highlight` (`@candor/highlight`)
- Tier: Free (MIT). No licence key needed.
- Docs: https://candor.themethodic.com/docs/highlight

## Install

```bash
npx candor-ui add highlight
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/highlight`.

## Functions

### canHighlight

```ts
canHighlight(language: string)
```

Whether `language` has a grammar here.

### tokenize

```ts
tokenize(text: string, language: string)
```

The text split into typed tokens; their texts joined give back the input exactly.

## Types

### TokenType

A small syntax highlighter for code an agent shows: it splits text into typed tokens (keyword, string, comment…), and Payload renders each as a span. The output is text, never HTML, so nothing in the code can run or inject markup. It covers the languages agents show most (JS/TS, Python, SQL, JSON, shell, YAML, CSS, HTML/XML, Go, Rust, Java, C) in a few kilobytes; anything else comes back as one plain token.

```ts
"keyword" | "string" | "number" | "comment" | "function" | "property" | "type" | "tag" | "variable" | "operator" | "plain"
```

### Token

```ts
{ type: TokenType; text: string }
```

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
