How to add syntax highlighting to code as a user types in realtime with vanilla JavaScript
On Monday, I shared a new interactive Code Sandbox I had built using vanilla JavaScript, and explained how I live render code into an iframe.
Today, I wanted to share how I syntax highlight code as the user types in real time.
Let’s dig in!
The one simple trick that makes this work! I tried a bunch of things to get this to work, but the trick that made it happen ended up being stupidly simple.