GitHub supports readme files with markdown formatting. Markdown has an option to show text as source code, by wrapping it in ```.
Today I learned, that the GitHub markdown renderer knows a lot of programming languages. I just made a file that pretty prints C++ and CMake code.
Using it is easy. You just put ```cpp or ```cmake at the start, instead of just the 3 opening apostrophes.