MCPcopy Index your code
hub / github.com/devongovett/tree-sitter-highlight

github.com/devongovett/tree-sitter-highlight @v1.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1.0 ↗ · + Follow
10 symbols 13 edges 4 files 0 documented · 0% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

tree-sitter-highlight

A syntax highlighter for Node.js powered by Tree Sitter. Written in Rust.

Usage

The following will output HTML:

const treeSitter = require('tree-sitter-highlight');

treeSitter.highlight('const foo = "hi";', treeSitter.Language.JS);
// => '<span class="source">...</span>'

You can also output a HAST AST, which is useful for integrating with Markdown or MDX processors (e.g. Remark).

treeSitter.highlightHast('const foo = "hi";', treeSitter.Language.JS);
// => {type: 'element', children: [...]}

Themes

The output HTML will contain CSS class names for various tokens. These will depend on the language, but there are several common names used across languages. Here is a basic example theme:

.keyword {
  color: purple;
}

.function {
  color: blue;
}

.type {
  color: pink;
}

.string {
  color: green;
}

.number {
  color: brown;
}

.operator {
  color: gray;
}

.comment {
  color: lightgray;
}

Inspect the generated output HTML and design your CSS accordingly.

License

MIT

Core symbols most depended-on inside this repo

add_highlight_names
called by 11
build.rs
highlight_config
called by 4
src/lib.rs
main
called by 0
build.rs
from_name
called by 0
src/lib.rs
highlight
called by 0
src/lib.rs
highlight_hast
called by 0
src/lib.rs

Shape

Function 4
Class 3
Method 2
Enum 1

Languages

Rust100%

Modules by API surface

src/lib.rs8 symbols
build.rs2 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add tree-sitter-highlight \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page