@lezer/highlight

Syntax highlighting framework that maps Lezer parse trees to styleable highlighting tags

Library
npm
v1.2.4
41 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
23 /100 Needs Attention
Development Activity 8
Maintenance 0
Community 16
Maturity 56
Momentum 12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
75 /100 Good
Architecture 85
Code Quality 78
Innovation 82
Learning Curve 55

@lezer/highlight is the syntax highlighting layer of the Lezer parser system used by CodeMirror. It defines a mostly closed vocabulary of highlighting tags, lets language packages associate tree nodes with those tags, and provides highlighters that turn tagged nodes into CSS classes or inline styles.

Rather than matching raw token strings, it works over structured Lezer parse trees, so highlighting stays consistent across languages and themes. It ships as a tiny, dependency-light TypeScript library that powers highlighting for every CodeMirror 6 language mode.

What You Get

  • A closed, extensible vocabulary of highlighting tags (tags) shared across all Lezer languages
  • styleTags to associate syntax tree node types with highlighting tags in a language grammar
  • tagHighlighter and the ready-made classHighlighter for turning tags into CSS classes
  • highlightTree and highlightCode to walk a parse tree and emit styled ranges or DOM
  • Tag modifiers and inheritance so themes can fall back from specific to general tags

Common Use Cases

  • Adding syntax highlighting to a CodeMirror 6 editor via a language package
  • Authoring a new Lezer language mode that exposes highlighting metadata
  • Rendering static, highlighted code snippets outside an editor with highlightCode
  • Building custom editor themes that map highlighting tags to CSS classes

Under The Hood

Architecture - The entire library lives in a single src/highlight.ts module built around a Tag class whose instances form a specificity-ordered set of parent tags, with Modifier instances lazily generating modified tags and caching them via a power-set of parent configurations. styleTags compiles a selector spec into a Rule linked list stored on nodes through a ruleNodeProp NodeProp; highlightTree and highlightCode then drive a HighlightBuilder that walks the tree with a TreeCursor, resolves the active tags via getStyleTags, and calls a Highlighter to emit class names for each styled range. Tech Stack - Written in TypeScript targeting both ESM and CommonJS (dist/index.js and dist/index.cjs), its only runtime dependency is @lezer/common for tree and NodeProp primitives, and it builds with @marijn/buildtool and TypeScript 5. Code Quality - The code is dense but carefully commented with /// doc comments feeding the generated API reference, uses precise readonly types and internal markers, and favors small pure helpers (sameArray, powerSet); there is no test directory in the repository, so correctness relies on the broader Lezer/CodeMirror integration suite rather than local unit tests. API Design - The public surface is small and composable - tags, styleTags, tagHighlighter/classHighlighter, and highlightTree/highlightCode - with a closed tag vocabulary and inheritance that lets themes cover many languages with minimal boilerplate, though understanding the tag/modifier model takes some reading of the reference docs.

Used by 47 apps in this directory

TypeScript
95%
MIT

Actual

Invoicing Finance

29,186

Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.

View details
93
Repo Health
85
Technical
73
Dependency
Built with
TypeScript 95%
Updated 4 days ago
Python
67%
Apache 2.0

Agent Control

AI Agents

314

An open-source runtime control plane for AI agents — define safety guardrails once, apply them across agents built on LangChain, CrewAI, Google ADK, or AWS Strands, and update controls without redeploying code.

View details
74
Repo Health
71
Technical
67
Dependency
Built with
Python 67%
TypeScript 32%
Updated 4 days ago
TypeScript
95%
Apache 2.0

AionUi

AI Agents · Productivity

33,179

Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.

View details
85
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 95%
Updated 3 weeks ago
Python
89%
Apache 2.0

Apache Airflow

Data Engineering

46,995

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
64
Dependency
Built with
Python 89%
Updated 4 days ago
Vue
43%
MIT

Alexandrie

Collaboration · Knowledge Management · Note Taking

2,777

The open-source, offline-first Notion, Obsidian & Confluence alternative with multi-tenant teams, OIDC/SSO, and one-command Docker deployment.

View details
86
Repo Health
73
Technical
74
Dependency
Built with
Vue 43%
TypeScript 41%
Go 13%
Updated 1 weeks ago
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

52,202

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
89
Repo Health
84
Technical
70
Dependency
Built with
TypeScript 99%
Updated 4 days ago
Ruby
61%
GPL 2.0

Discourse

Community

47,915

Open-source community platform with dynamic trust levels, real-time chat, and a powerful plugin architecture for self-hosted forums.

View details
89
Repo Health
89
Technical
67
Dependency
Built with
Ruby 61%
JavaScript 32%
Updated 4 days ago
Java
34%
Apache 2.0

Enso

Analytics · Data Engineering · Low Code Platforms

7,441

A visual and textual programming platform for data prep and analysis where the node graph and the underlying Enso code are always perfectly in sync, built by an Alteryx co-founder on a GraalVM engine.

View details
59
Repo Health
90
Technical
61
Dependency
Built with
Java 34%
TypeScript 27%
Scala 26%
Updated 1 months ago
TypeScript
64%
Other

Epicenter

Developer Tools · Knowledge Management · Note Taking

4,808

A local-first monorepo led by Whispering, an open-source speech-to-text app, built on an MIT toolkit that turns your data into plain Markdown and SQLite files you own instead of a database you rent.

View details
88
Repo Health
90
Technical
64
Dependency
Built with
TypeScript 64%
HTML 13%
Svelte 13%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers