8000 GitHub - zdunecki/lighter: The syntax highlighter used by Code Hike.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

zdunecki/lighter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The syntax highlighter used by Code Hike.

Usage

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:

[
  [
    { "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

For more theme colors (like line number foreground, selection background, etc.):

import { getThemeColors } from "@code-hike/lighter";

const themeColors = await getThemeColors("material-darker");

Credits

  • Using vscode-oniguruma for highlighting
  • Heavily inspired by Shiki and adapted to Code Hike needs.
  • Some more inspiration from starry-night
  • Grammars and some themes come from Shiki, which pulls them from different sources.

About

The syntax highlighter used by Code Hike.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 51.4%
  • TypeScript 47.9%
  • CSS 0.7%
0