Highlight code and syntax with Prettify

Docs does not include any server-side support for syntax highlighting, but it's easy to include on a per-site basis. We recommend using a JavaScript module called Prettify.


Open your Docs site settings and scroll to the bottom of the page. In the Custom code section, paste the following code into the Insert <head> Code textarea:

<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>

We include the default Prettify stylesheet, but you can alternatively use your own CSS or one of their themes.

Add class="prettyprint" to any <pre> or <code> tags to enable syntax highlighting. You can also enable language hints and line numbering using classes that are covered in the Prettify Getting Started documentation.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.