At the time of this writing the best option for adding syntax highlighting to doce inside a google doc is NOT by creating you code in a separate website or program and copying that into the google doc and hoping that it retains the color/formatting of the previous editor.
But now we have an Add On right inside Google Docs that will do this for us. Here is a quick tutorial on how to make that work.
Step 1) Create a Google doc and write some text, then write some code, then right some more text. Leaving a clear seperation between each. Save the doc.
Step 2) Go to Addons and search for “Code Pretty” and install the Addon.
Step 3) Highlight just the code portion. Go to the Addons tab and Select: Code Pretty > Format Selection
After you apply the highlighting, the document will look as follows:
Like Bub Rub and Lil Sis would say.. “That’s it and that’s all!, we do it for decorations man!”