Highlight
Highlight is a syntax highlight library that uses Tree-sitter for incredibly quick parsing and highlighting.
Usage
Install the package as a dependency to your project:
sh
bun add @noclaps/highlight
and then import it into your code:
ts
import { highlight, type Theme } from "@noclaps/highlight";
const theme: Theme = {
... // Your theme here
}
const myCode = `
console.log("Hello World");
`
const htmlOutput = highlight(code, "ts", theme);
// <pre>...</pre> HTML output
See the Types documentation for all of the configuration options and types