A syntax highlighting library that uses Tree-sitter for incredibly quick parsing and highlighting.
Install the package as a dependency to your project:
bun add @noclaps/highlight
and then import it into your code:
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