Code Blocks

Syntax Highlighting

Options for including code blocks with syntax highlighting on your website include:

The Nift documentation covers syntax highlighting code blocks on your site using Google Code Prettify. Using Google Code Prettify on your site is as simple as adding the following code to the head of each page:

<!-- uses google-code-prettify for syntax highlighting 
	 see https://github.com/google/code-prettify for more info -->
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js">
</script>

See here for a gallery of themes for Google Code Prettify.

Note the examples on this site are using the included pre.css file.

If your code blocks with the template you use do not have nice margins (eg. overlap the text above or below) then try modifying margin-top and margin-bottom in the included pre.css file.

See the Google code prettifier README for supported languages and other relevant information.

Also see the basic usage tutorial for a better idea of how to nicely display code blocks.