Turn code blocks into interactive explanations.
CodeGloss adds clickable, token-level annotations and connection arcs to fenced code blocks. One remark plugin, one Web Component, every framework.
npm install codegloss1function fibonacci(n) {2 const memo = {};34 function fib(k) {5 if (k <= 1) return k;6 if (memo[k]) return memo[k];7 memo[k] = fib(k - 1) + fib(k - 2);8 return memo[k];9 }1011 return fib(n);12}
Interactive Annotations
Click any highlighted token to reveal an explanation. Annotations are defined in JSON alongside your code — no custom syntax to learn.
Connection Arcs
Draw visual arcs between related annotations. Gutter lines connect concepts with click-to-explain popovers.
MDX Native
Write fenced code blocks with a `codegloss` tag. The remark plugin detects them and emits CodeGloss components at build time.
Why CodeGloss?
Code comments are static and invisible to readers skimming a tutorial. CodeGloss annotations are interactive — readers click what they don't understand and skip what they already know.
A single Web Component under the hood, with thin wrappers for React, Vue, and Svelte. Works with any markdown pipeline via a remark plugin, or drop the custom element into plain HTML.
Define annotations in a JSON block alongside the fenced code. Your source stays clean, and annotations can be updated without touching the code itself.
Quick start
npm install codeglossimport createMdx from '@next/mdx';
import remarkCodegloss from 'codegloss/remark';
const withMdx = createMdx({
options: {
remarkPlugins: [remarkCodegloss],
},
});```js codegloss fibonacci.js
function fibonacci(n) {
const memo = {};
// ...
}
```
```json annotations
{
"annotations": [{
"id": "a1",
"token": "memo",
"line": 1,
"occurrence": 0,
"title": "Cache",
"text": "Stores computed values."
}]
}
```