Document 360: #1 Knowledge Base Software
Stay updated
Keep current with the latest trends in technical communication by subscribing to the I'd Rather Be Writing newsletter. 5,400+ subscribers

Search results

Document 360: #1 Knowledge Base Software

Adding Syntax Highlighting to Code Examples Online and in Microsoft Word

by Tom Johnson on Apr 4, 2013 •
categories: technical-writing

If you're integrating code examples into your technical documentation, a couple of tools can help with this. If you have an online output, you can use Code Prettify (see its Drupal version or WordPress version or regular HTML page version). This module/plugin applies syntax highlighting to your code so that it's more readable.


I usually replace the angle brackets with their character symbol equivalents (< and > for less than and greater than). If you leave in the angle brackets, the Prettify plugin sometimes has issues.

To get the same syntax highlighting in Microsoft Word, copy your program code into this online form to create the syntax highlight. Then paste it into Word. if you have a one-liner, add a second line to retain the number when copying and pasting, and then remove the extra line number once it's in Word.

You want the numbers in Word, by the way, because you're usually explaining what each of the line numbers means.

If you have a JSON response and want to keep the formatting clean, use something like Chrome's Advanced Rest Client app to format the JSON into readable code. Then manually copy this into your web page and apply the Prettify plugin's syntax highlight.


Update: For integrating Code Prettify with Flare, see this post from Jenny Watson.

follow us in feedly