https://github.com/code-hike/lighter
The syntax highlighter used by Code Hike.
https://github.com/code-hike/lighter
syntax-highlighting
Last synced: 6 months ago
JSON representation
The syntax highlighter used by Code Hike.
- Host: GitHub
- URL: https://github.com/code-hike/lighter
- Owner: code-hike
- Created: 2022-12-15T15:24:36.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-31T17:55:46.000Z (about 1 year ago)
- Last Synced: 2025-06-18T22:14:19.474Z (7 months ago)
- Topics: syntax-highlighting
- Language: JavaScript
- Homepage: https://lighter-codehike.vercel.app
- Size: 5.74 MB
- Stars: 97
- Watchers: 3
- Forks: 10
- Open Issues: 5
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
The syntax highlighter used by Code Hike.
## Usage
```js
import { highlight } from "@code-hike/lighter";
const { lines, style } = await highlight(
/* code */ "print('hello')",
/* lang */ "py",
/* theme */ "github-dark"
);
// base foreground and background
const { color, background } = style;
console.log(lines);
```
Output:
```json
[
[
{ "style": { "color": "#79C0FF" }, "content": "print" },
{ "style": { "color": "#C9D1D9" }, "content": "(" },
{ "style": { "color": "#A5D6FF" }, "content": "'hello'" },
{ "style": { "color": "#C9D1D9" }, "content": ")" }
]
]
```
For **dark/light theme support with CSS** see [#25](https://github.com/code-hike/lighter/pull/25)
For more theme colors (like line number foreground, selection background, etc.):
```js
import { getThemeColors } from "@code-hike/lighter";
const themeColors = await getThemeColors("material-darker");
```
## Credits
- Using [vscode-oniguruma](https://github.com/microsoft/vscode-oniguruma) for highlighting
- **Heavily inspired by [Shiki](https://github.com/shikijs/shiki)** and adapted to Code Hike needs.
- Some more inspiration from [starry-night](https://github.com/wooorm/starry-night)
- Grammars and some themes come from [Shiki](https://github.com/shikijs/shiki), which pulls them from different sources.
```
```