The basic technique I use to do syntax highlighting for my talk slides has two steps:
I use this technique a lot when I'm preparing my talks! For an example of a whole presentation built with this technique you can check this slide deck.
To make it easier to follow, you can find here the step-by-step instructions. At the bottom of the page you'll also find an animated GIF showing you how I do this.





Pretty simple and saves you a LOT of trouble if you try to do syntax highlighting by hand... Which I did! It was painful. Finally, just because I can, here is the whole process in an animated GIF:

That's it for now! Stay tuned and I'll see you around!
Every Monday, you'll get a Python deep dive that unpacks a topic with analogies, diagrams, and code examples so you can write clearer, faster, and more idiomatic code.