sdxc-highlight

Tokenizes source code into typed Token arrays for component-based rendering and markdown painting.

5|Updated Feb 2, 2026
One-click install
npx skills add https://github.com/sergiodxa/monorepo --skill sdxc-highlight-sergiodxa
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sdxc-highlight
Source: https://github.com/sergiodxa/monorepo/tree/main/.agents/skills/sdxc-highlight
Command: npx skills add https://github.com/sergiodxa/monorepo --skill sdxc-highlight-sergiodxa

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Syntax highlighters that return markup strings force you to inject HTML into the DOM, which does not fit component-based renderers, inline-styled emails, or parsed markdown documents. This Skill documents @sdxc/highlight, which returns typed Token arrays instead, so code blocks can be rendered as elements, painted inside a markdown walk, or themed through CSS custom properties. ## Core Features & Use Cases - Token-based highlighting: tokenize(code, language) returns Token[] for component rendering, while highlight returns escaped <span> markup for string-based callers. - Markdown integration: The @sdxc/highlight/markdown visitor paints every fenced code block during a Markdown.walk, filling Markdown.Code.tokens synchronously. - Theming and custom grammars: A stylesheet keyed to --highlight-<type> custom properties handles colors, and scan/compose let you write grammars for unsupported languages. - Use Case: While rendering a parsed markdown document as components, spread the highlight visitor into your walk so every code fence is tokenized in the same pass that rewrites links, with no extra async step. ## Quick Start Add @sdxc/highlight as a workspace dependency and use the skill's guidance to tokenize a code string or paint code blocks in a markdown document.

Frequently Asked Questions about sdxc-highlight

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I highlight code as components instead of HTML strings?▼

Use tokenize(code, language) from @sdxc/highlight, which returns a Token array with typed runs like keyword, number, and operator. Map those tokens to your own elements instead of injecting a markup string into the DOM.

How to syntax highlight code blocks in a parsed markdown document?▼

Import the visitor from @sdxc/highlight/markdown and spread it into your Markdown.walk handlers. Its code handler paints each fenced block synchronously, filling the tokens field on Markdown.Code in the same pass as other rewrites.

What happens when highlighting an unsupported language?▼

Unknown languages do not throw. tokenize resolves aliases like ts, sh, yml, and gql to their grammars, and a language with no grammar yields a single plain token containing the entire input.

Can I write a custom grammar for a language it does not ship?▼

Yes, use the scan and compose functions with the Grammar and Rule types. Rule order sets priority, matches use the sticky flag, nesting uses push and pop modes, and unmatched text accumulates into plain tokens.

How do I theme the highlighted code colors?▼

Load @sdxc/highlight/styles.css, which defines one rule per token type reading a --highlight-<type> custom property with light and dark defaults. The stylesheet sets only color; padding, borders, and fonts belong to your own rules.