A developer shares a discovery made while using an AI coding agent to build an interactive widget. The agent produced code that used a little-known KaTeX feature — the `\htmlData` command — which attaches data attributes to individual `<span>` elements in rendered math. Unlike MathJax, which outputs a single `<svg>`, KaTeX renders each element in its own `<span>`, making it possible to bind DOM events to specific parts of a math expression. The post reflects on the value of pausing to study AI-generated code you don't fully understand, as it can reveal patterns and techniques you'd otherwise miss.
153.3K Impressions1 Comment