Is there a way to "print" to pdf, html, or similar a copy of the code with syntax highlighting?

You may use pygments
https://pygments.org/demo/
Copy and paste your code and get the html file or use it within LaTeX to get pdf.

2 Likes