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.

3m read timeFrom koaning.io
Post cover image
Table of contents
Details of KatexMeta observation
153.3K Impressions1 Comment