Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions docs/language-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ These optional entry points connect language labels to the definitions you impor
```ts
import { tokenize, render } from '@vortexlabs/kirari/core'
import { createRegistry } from '@vortexlabs/kirari/registry'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { typescript } from '@vortexlabs/kirari/languages/typescript'
import { python } from '@vortexlabs/kirari/languages/python'
import { javascript, typescript, python } from '@vortexlabs/kirari/languages'

const registry = createRegistry([javascript, typescript, python])
const source = 'const answer: number = 42'
Expand Down Expand Up @@ -51,9 +49,7 @@ Custom language names work without extra configuration, including as filename ex
import { tokenize, render } from '@vortexlabs/kirari/core'
import { createRegistry } from '@vortexlabs/kirari/registry'
import { createMarkdown } from '@vortexlabs/kirari/markdown'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { python } from '@vortexlabs/kirari/languages/python'
import { json } from '@vortexlabs/kirari/languages/json'
import { javascript, python, json } from '@vortexlabs/kirari/languages'

const markdown = createMarkdown(createRegistry([javascript, python, json]))
const source = '# Example\n```js\nconst answer = 42\n```\n'
Expand Down
2 changes: 1 addition & 1 deletion docs/streaming.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ classifications, so patches replace a suffix instead of blindly appending tokens

```ts
import { render, type Token } from '@vortexlabs/kirari/core'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { javascript } from '@vortexlabs/kirari/languages'
import { createTokenStream, type TokenPatch } from '@vortexlabs/kirari/stream'

const stream = createTokenStream(javascript)
Expand Down
8 changes: 4 additions & 4 deletions packages/kirari/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ JSX and TSX have separate definitions, including markup and embedded expressions

```ts
import { highlight } from '@vortexlabs/kirari'
import { tsx } from '@vortexlabs/kirari/languages/tsx'
import { tsx } from '@vortexlabs/kirari/languages'

const html = highlight('<Button disabled={busy}>{label}</Button>', { language: tsx })
```
Expand All @@ -61,7 +61,7 @@ For a Python-only bundle, import the language-independent core:

```ts
import { tokenize, render } from '@vortexlabs/kirari/core'
import { python } from '@vortexlabs/kirari/languages/python'
import { python } from '@vortexlabs/kirari/languages'

const html = render(tokenize('answer = 42', python))
```
Expand Down Expand Up @@ -162,7 +162,7 @@ These features use separate entrypoints and are absent from the default bundle:

```ts
import { tokenize } from '@vortexlabs/kirari/core'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { javascript } from '@vortexlabs/kirari/languages'
import { renderDecorated } from '@vortexlabs/kirari/decorations'
import { createRegistry } from '@vortexlabs/kirari/registry'
import { createMarkdown } from '@vortexlabs/kirari/markdown'
Expand Down Expand Up @@ -203,7 +203,7 @@ highlights Markdown source; the Rehype plugin integrates with document rendering

```ts
import { highlight } from '@vortexlabs/kirari'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { javascript } from '@vortexlabs/kirari/languages'
import type { Language } from '@vortexlabs/kirari'

const projectJavaScript: Language = {
Expand Down
4 changes: 2 additions & 2 deletions packages/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Requires React 19. Kirari is a peer dependency.

```tsx
import { Code } from '@vortexlabs/kirari-react'
import { typescript } from '@vortexlabs/kirari/languages/typescript'
import { typescript } from '@vortexlabs/kirari/languages'
import '@vortexlabs/kirari/theme.css'

export const CodeExample = () => (
Expand Down Expand Up @@ -63,7 +63,7 @@ Line numbers are CSS:

import { Code } from '@vortexlabs/kirari-react'
import { useTokenStream } from '@vortexlabs/kirari-react/stream'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { javascript } from '@vortexlabs/kirari/languages'
import '@vortexlabs/kirari/theme.css'

export const StreamExample = () => {
Expand Down
7 changes: 3 additions & 4 deletions packages/rehype/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeStringify from 'rehype-stringify'
import rehypeKirari from '@vortexlabs/kirari-rehype'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { typescript } from '@vortexlabs/kirari/languages/typescript'
import { javascript, typescript } from '@vortexlabs/kirari/languages'

const processor = unified()
.use(remarkParse)
Expand Down Expand Up @@ -59,7 +58,7 @@ Pass the same plugin to the MDX compiler's `rehypePlugins` option:
```ts
import { compile } from '@mdx-js/mdx'
import rehypeKirari from '@vortexlabs/kirari-rehype'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { javascript } from '@vortexlabs/kirari/languages'

const markdown = '```js\nconst answer = 42\n```'
const compiled = await compile(markdown, {
Expand Down Expand Up @@ -123,7 +122,7 @@ The `lineClassName` callback can append your own classes:

```ts
import type { Options } from '@vortexlabs/kirari-rehype'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { javascript } from '@vortexlabs/kirari/languages'

const options = {
languages: [javascript],
Expand Down
1 change: 1 addition & 0 deletions sites/docs/content/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Returns escaped HTML from readonly tokens. Custom classes append to Kirari’s s
| `@vortexlabs/kirari/decorations` | [renderDecorated](/docs/decorations/), Decoration, DecoratedRenderOptions |
| `@vortexlabs/kirari/registry` | [createRegistry](/docs/markdown/), LanguageRegistry |
| `@vortexlabs/kirari/markdown` | [createMarkdown(registry)](/docs/markdown/) |
| `@vortexlabs/kirari/languages` | Every language definition as a named export |
| `@vortexlabs/kirari/languages/*` | One named language definition |
| `@vortexlabs/kirari/theme.css` | Optional theme, driven by CSS variables |
| `@vortexlabs/kirari-rehype` | [Optional Markdown and MDX plugin](/docs/rehype/), Options |
Expand Down
2 changes: 1 addition & 1 deletion sites/docs/content/grammars.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Extend definitions with your own rules and categories.
Copy a definition and put your rules first. Each rule matches at the current source position; earlier rules win.

```js
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { javascript } from '@vortexlabs/kirari/languages'
import type { Language } from '@vortexlabs/kirari'

const projectJavaScript: Language = {
Expand Down
102 changes: 52 additions & 50 deletions sites/docs/content/languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,62 @@ Import from `/core` to ship only Python. The main entry always bundles JavaScrip

```js
import { tokenize, render } from '@vortexlabs/kirari/core'
import { python } from '@vortexlabs/kirari/languages/python'
import { python } from '@vortexlabs/kirari/languages'

const html = render(tokenize('print("Hello, world!")', python))
```

| Language | Import |
| Language | Export |
| --- | --- |
| C | `@vortexlabs/kirari/languages/c` |
| C# | `@vortexlabs/kirari/languages/csharp` |
| C++ | `@vortexlabs/kirari/languages/cpp` |
| Clojure | `@vortexlabs/kirari/languages/clojure` |
| CSS | `@vortexlabs/kirari/languages/css` |
| Dart | `@vortexlabs/kirari/languages/dart` |
| Diff | `@vortexlabs/kirari/languages/diff` |
| Dockerfile | `@vortexlabs/kirari/languages/dockerfile` |
| Dotenv | `@vortexlabs/kirari/languages/dotenv` |
| Elixir | `@vortexlabs/kirari/languages/elixir` |
| GLSL | `@vortexlabs/kirari/languages/glsl` |
| Go | `@vortexlabs/kirari/languages/go` |
| GraphQL | `@vortexlabs/kirari/languages/graphql` |
| Groovy | `@vortexlabs/kirari/languages/groovy` |
| HCL | `@vortexlabs/kirari/languages/hcl` |
| HTML | `@vortexlabs/kirari/languages/html` |
| INI | `@vortexlabs/kirari/languages/ini` |
| Java | `@vortexlabs/kirari/languages/java` |
| JavaScript | `@vortexlabs/kirari/languages/javascript` |
| JSON | `@vortexlabs/kirari/languages/json` |
| JSONC | `@vortexlabs/kirari/languages/jsonc` |
| JSX | `@vortexlabs/kirari/languages/jsx` |
| Julia | `@vortexlabs/kirari/languages/julia` |
| Kotlin | `@vortexlabs/kirari/languages/kotlin` |
| Lua | `@vortexlabs/kirari/languages/lua` |
| Makefile | `@vortexlabs/kirari/languages/makefile` |
| Markdown | `@vortexlabs/kirari/languages/markdown` |
| Nginx | `@vortexlabs/kirari/languages/nginx` |
| PHP | `@vortexlabs/kirari/languages/php` |
| Plain text | `@vortexlabs/kirari/languages/plaintext` |
| PowerShell | `@vortexlabs/kirari/languages/powershell` |
| Protocol Buffers | `@vortexlabs/kirari/languages/protobuf` |
| Python | `@vortexlabs/kirari/languages/python` |
| R | `@vortexlabs/kirari/languages/r` |
| Ruby | `@vortexlabs/kirari/languages/ruby` |
| Rust | `@vortexlabs/kirari/languages/rust` |
| Scala | `@vortexlabs/kirari/languages/scala` |
| Shell | `@vortexlabs/kirari/languages/shell` |
| SQL | `@vortexlabs/kirari/languages/sql` |
| Svelte | `@vortexlabs/kirari/languages/svelte` |
| Swift | `@vortexlabs/kirari/languages/swift` |
| TOML | `@vortexlabs/kirari/languages/toml` |
| TSX | `@vortexlabs/kirari/languages/tsx` |
| TypeScript | `@vortexlabs/kirari/languages/typescript` |
| Vue | `@vortexlabs/kirari/languages/vue` |
| XML | `@vortexlabs/kirari/languages/xml` |
| YAML | `@vortexlabs/kirari/languages/yaml` |
| Zig | `@vortexlabs/kirari/languages/zig` |
| C | `c` |
| C# | `csharp` |
| C++ | `cpp` |
| Clojure | `clojure` |
| CSS | `css` |
| Dart | `dart` |
| Diff | `diff` |
| Dockerfile | `dockerfile` |
| Dotenv | `dotenv` |
| Elixir | `elixir` |
| GLSL | `glsl` |
| Go | `go` |
| GraphQL | `graphql` |
| Groovy | `groovy` |
| HCL | `hcl` |
| HTML | `html` |
| INI | `ini` |
| Java | `java` |
| JavaScript | `javascript` |
| JSON | `json` |
| JSONC | `jsonc` |
| JSX | `jsx` |
| Julia | `julia` |
| Kotlin | `kotlin` |
| Lua | `lua` |
| Makefile | `makefile` |
| Markdown | `markdown` |
| Nginx | `nginx` |
| PHP | `php` |
| Plain text | `plaintext` |
| PowerShell | `powershell` |
| Protocol Buffers | `protobuf` |
| Python | `python` |
| R | `r` |
| Ruby | `ruby` |
| Rust | `rust` |
| Scala | `scala` |
| Shell | `shell` |
| SQL | `sql` |
| Svelte | `svelte` |
| Swift | `swift` |
| TOML | `toml` |
| TSX | `tsx` |
| TypeScript | `typescript` |
| Vue | `vue` |
| XML | `xml` |
| YAML | `yaml` |
| Zig | `zig` |

Every definition is a named export of `@vortexlabs/kirari/languages`; bundlers keep only the ones you import. Without a bundler, import one file instead, such as `@vortexlabs/kirari/languages/python`.

JSX and TSX are separate definitions. Use `hcl` for Terraform and `shell` for common shell syntax. These are lexical grammars, not compiler parsers.
3 changes: 1 addition & 2 deletions sites/docs/content/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ Build a registry from the languages you import, then pass it to `createMarkdown`
import { tokenize, render } from '@vortexlabs/kirari/core'
import { createRegistry } from '@vortexlabs/kirari/registry'
import { createMarkdown } from '@vortexlabs/kirari/markdown'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { json } from '@vortexlabs/kirari/languages/json'
import { javascript, json } from '@vortexlabs/kirari/languages'

const registry = createRegistry([javascript, json])
registry.resolve(' JS ') // javascript
Expand Down
4 changes: 2 additions & 2 deletions sites/docs/content/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ npm install @vortexlabs/kirari @vortexlabs/kirari-react

```tsx
import { Code } from '@vortexlabs/kirari-react'
import { typescript } from '@vortexlabs/kirari/languages/typescript'
import { typescript } from '@vortexlabs/kirari/languages'
import '@vortexlabs/kirari/theme.css'

const source = 'const answer: number = 42'
Expand All @@ -36,7 +36,7 @@ Text children join the way React renders text, so `{value}` interpolation works;
'use client'
import { Code } from '@vortexlabs/kirari-react'
import { useTokenStream } from '@vortexlabs/kirari-react/stream'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { javascript } from '@vortexlabs/kirari/languages'

export const StreamedCode = () => {
const { tokens, write, end } = useTokenStream(javascript)
Expand Down
4 changes: 2 additions & 2 deletions sites/docs/content/rehype.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeStringify from 'rehype-stringify'
import rehypeKirari from '@vortexlabs/kirari-rehype'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { javascript } from '@vortexlabs/kirari/languages'

const processor = unified()
.use(remarkParse)
Expand All @@ -35,7 +35,7 @@ Pass the languages you need; labels like `js` resolve via the registry. Nothing
```js
import { compile } from '@mdx-js/mdx'
import rehypeKirari from '@vortexlabs/kirari-rehype'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { javascript } from '@vortexlabs/kirari/languages'

const markdown = '```js\nconst answer = 42\n```'
const compiled = await compile(markdown, {
Expand Down
2 changes: 1 addition & 1 deletion sites/docs/content/streaming.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Apply token patches as source chunks arrive.
```ts
import { render } from '@vortexlabs/kirari/core'
import { createTokenStream } from '@vortexlabs/kirari/stream'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { javascript } from '@vortexlabs/kirari/languages'
import type { Token } from '@vortexlabs/kirari/core'
import type { TokenPatch } from '@vortexlabs/kirari/stream'

Expand Down
2 changes: 1 addition & 1 deletion sites/docs/src/components/code/ThemeCard/ThemeCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styles from './ThemeCard.module.css'
import { highlight } from '@vortexlabs/kirari'
import { typescript } from '@vortexlabs/kirari/languages/typescript'
import { typescript } from '@vortexlabs/kirari/languages'
import { HighlightedCode } from '@/components/code/HighlightedCode'
import type * as Types from './ThemeCard.types'

Expand Down
2 changes: 1 addition & 1 deletion sites/docs/src/features/compare/Compare/Compare.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styles from './Compare.module.css'
import type { CSSProperties } from 'react'
import { highlight } from '@vortexlabs/kirari'
import { typescript } from '@vortexlabs/kirari/languages/typescript'
import { typescript } from '@vortexlabs/kirari/languages'
import {
alternatives,
features,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { highlight } from '@vortexlabs/kirari'
import { css } from '@vortexlabs/kirari/languages/css'
import { typescript } from '@vortexlabs/kirari/languages/typescript'
import { css, typescript } from '@vortexlabs/kirari/languages'
import { languageEntries } from '@/lib/languages'
import { docsPath, routes } from '@/lib/navigation'
import { site } from '@/lib/site'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import styles from './StreamDemo.module.css'
import { useCallback, useEffect, useRef, useState } from 'react'
import { gsap } from 'gsap'
import { highlight, render, type Token } from '@vortexlabs/kirari'
import { typescript } from '@vortexlabs/kirari/languages/typescript'
import { typescript } from '@vortexlabs/kirari/languages'
import { createTokenStream } from '@vortexlabs/kirari/stream'
import { streamSample } from './StreamDemo.constants'
import { reducedMotion } from '@/client/motion'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import styles from './Playground.module.css'
import { useRouter } from 'next/navigation'
import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { tokenize, render, tokenTypes, type Token } from '@vortexlabs/kirari/core'
import { css } from '@vortexlabs/kirari/languages/css'
import { javascript } from '@vortexlabs/kirari/languages/javascript'
import { tsx } from '@vortexlabs/kirari/languages/tsx'
import { css, javascript, tsx } from '@vortexlabs/kirari/languages'
import { languageEntries } from '@/lib/languages'
import { animateIn } from '@/client/motion'
import { usageCode } from './Playground.utilities'
Expand Down
Loading
Loading