lang-html

HTML language support for the CodeMirror code editor, with autocompletion, folding, and nested CSS/JS parsing.

Library
npm
v6.4.12
36 stars
MIT License

Repository Health

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

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
86 /100 Excellent
Architecture 85
Code Quality 85
Innovation 90
Learning Curve 70

@codemirror/lang-html is the official HTML language package for CodeMirror 6. It wires the Lezer HTML parser into CodeMirror as an LRLanguage, adding syntax-aware indentation, code folding, bracket matching, and context-aware autocompletion for tags and attributes.

Beyond plain HTML, the package transparently embeds the JavaScript and CSS language packages so that the contents of <script> and <style> blocks (including TypeScript, JSX, and JSON script types) are parsed and highlighted with their own grammars. A single html() call returns a ready-to-use LanguageSupport extension, and options let you register additional nested languages, extra tags, and custom attributes.

What You Get

  • An html() factory that returns a configured CodeMirror LanguageSupport extension in one call
  • Context-aware completion for HTML tags, attributes, and attribute values via htmlCompletionSource
  • Automatic insertion of closing tags as you type > or / through the autoCloseTags extension
  • Nested parsing of JavaScript, TypeScript, JSX, JSON, and CSS inside <script> and <style> tags

Common Use Cases

  • Building an in-browser HTML editor or template editor with rich highlighting and completion
  • Adding an HTML editing mode to a CodeMirror-based IDE, CMS, or documentation tool
  • Editing HTML fragments or email templates with embedded inline CSS and JavaScript

Under The Hood

Architecture

The core lives in src/html.ts, which defines an LRLanguage (htmlPlain) built on the @lezer/html parser and augmented with indentNodeProp, foldNodeProp, and bracketMatchingHandle node properties for indentation, folding, and tag matching. The exported htmlLanguage wraps this parser with configureNesting, mixing in nested NestedLang and NestedAttr definitions so <script>/<style> bodies and style/event attributes are parsed by the CSS and JavaScript grammars. The html() function assembles a LanguageSupport from the language plus the autocompletion source, autoCloseTags input handler, and the JavaScript/CSS support extensions, selecting a parser dialect based on matchClosingTags/selfClosingTags config.

Tech Stack

Written entirely in TypeScript and published as dual ESM/CJS with type declarations. It depends on the CodeMirror 6 packages (@codemirror/language, @codemirror/state, @codemirror/view, @codemirror/autocomplete, @codemirror/lang-css, @codemirror/lang-javascript) and the Lezer parsers (@lezer/html, @lezer/common, @lezer/css). Building is handled by @codemirror/buildhelper via the cm-buildhelper script.

Code Quality

The codebase is small and focused (html.ts plus a large complete.ts tag/attribute spec table) with thorough /// doc comments that also generate the README API reference. Types are precise (TagSpec, NestedLang, NestedAttr) and there is a dedicated test file (test/test-complete.ts) exercising completion behavior via cm-runtests.

API Design The public surface is deliberately minimal and ergonomic: a single html(config) function covers the common case, while htmlCompletionSource, htmlCompletionSourceWith, htmlLanguage, and autoCloseTags are exported for finer control. Configuration options are well-named and documented inline, keeping the required boilerplate to a single extension entry in an editor’s setup.

Used by 37 apps in this directory

Go
51%
AGPL 3.0

listmonk

Blogging · Marketing

23,944

High-performance, self-hosted newsletter and mailing list manager packaged as a single binary with built-in analytics, transactional messaging, and multi-channel delivery.

View details
90
Repo Health
74
Technical
64
Dependency
Built with
Go 51%
JavaScript 22%
HTML 20%
Updated 5 days ago
Clojure
57%
Other

Metabase

Analytics

49,827

The open-source BI platform that lets anyone ask questions and build dashboards without writing SQL — with an embedded analytics SDK and AI-powered query assistant included.

View details
95
Repo Health
84
Technical
62
Dependency
Built with
Clojure 57%
TypeScript 38%
Updated 5 days ago
Go
67%
MIT

nginx ignition

Developer Tools · Devops

2,141

A modern web UI for nginx that eliminates config file editing with visual virtual hosts, SSL automation, Docker integrations, and real-time traffic analytics.

View details
74
Repo Health
80
Technical
67
Dependency
Built with
Go 67%
TypeScript 28%
Updated 2 weeks ago
TypeScript
99%
Other

NocoBase

Low Code Platforms · No Code Platforms

24,686

Open-source AI + no-code platform that lets coding agents and people collaborate to build business systems fast on proven infrastructure.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
TypeScript 99%
Updated 5 days ago
TypeScript
98%
Other

Novu

Developer Tools

40,195

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 98%
Updated 5 days ago
Go
63%
MIT

Obot

AI Agents · Mcp

1,120

An open-source MCP platform for organizations — host MCP servers, run MCP registries, monitor usage, and build agents and chatbots on top of the Model Context Protocol from one self-hosted deployment.

View details
88
Repo Health
70
Technical
70
Dependency
Built with
Go 63%
Svelte 21%
TypeScript 15%
Updated 6 days ago
TypeScript
99%
Apache 2.0

Onlook

AI Design Tools · Design Tools

26,996

An open-source, AI-first visual editor that lets designers and developers build, style, and deploy React apps directly in code — no handoff required.

View details
63
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 99%
Updated 1 weeks ago
TypeScript
97%
GPL 3.0

OpenKnowledge

Code Editors · Knowledge Management · Note Taking

4,674

A beautiful, local-first markdown IDE that turns any git repo into a live collaborative workspace for humans and AI coding agents like Claude, Codex, and OpenCode.

View details
80
Repo Health
89
Technical
64
Dependency
Built with
TypeScript 97%
Updated 5 days ago
Python
73%
AGPL 3.0

OpenViking

AI Development · AI Memory · Databases

40,705

An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.

View details
85
Repo Health
75
Technical
64
Dependency
Built with
Python 73%
TypeScript 12%
Rust 11%
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