plgg-highlight
v0.0.3
Published
Zero-dep TS/TSX/JS/JSX/JSON syntax highlighting for plgg-md's Highlighter seam, tokenizing code with an in-house plgg-parser grammar (no typescript dependency) into classified plgg-view Html<never> spans; alias-normalizes the fence language and falls back
Readme
plgg-highlight
UNSTABLE - Experimental study work. Part of the plgg monorepo.
Syntax highlighting with zero dependencies, built from
scratch on plgg. It fills
plgg-md's Highlighter seam for the
TypeScript family — TS / TSX / JS / JSX / JSON — by tokenizing
the source with an in-house plgg-parser
grammar, emitting classified plgg-view
Html<never> spans. Anything it can't highlight falls back to
an escaped <pre><code> block.
Why this package exists
plgg-md renders code fences through a Highlighter seam but
stays language-agnostic itself. plgg-highlight supplies that
seam with an in-house parser — no highlight.js, no shiki,
and (since the plgg-parser migration) no typescript
dependency either:
plgg ── plgg-md ── plgg-highlight
(Highlighter seam) └── plgg-parser TS grammarHow it's organized
- Lang — alias-normalizes a fence language (
ts,tsx,js,jsx,json) to a tokenizer mode; an unknown language selects the fallback. - Token — a
plgg-parsergrammar walks the source into classified tokens (context-tracking/for regex vs. division), preserving trivia so the tokens round-trip to the exact input. - Render — folds those tokens into
plgg-viewHtml<never>spans, degrading to an escaped<pre><code>block when no language matches.
Conventions
as/any/ts-ignoreare prohibited (see rootCLAUDE.md).- No runtime dependency beyond the plgg family;
typescriptis a dev-dependency for type-checking only, so highlighting adds nothing to a consumer's install. - After editing a
file:-linked dependency's source, rebuild itsdistor this package won't see new exports.
