Code Prettify

Component ID

1089064

Component name

Code Prettify

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

This module attempts to provide the easiest and most general way of getting code syntax highlighting on a Drupal site, using the Google code prettify javascript library.

Combined with the use of the included input filter, it provides a number of key benefits:

  • No need for special embedded markup in your content
  • Automatic-language detection
  • Easily customised appearance via css
  • Good cross browser compatibility and wide usage (powers code.google.com and stackoverflow.com)
  • Works nicely with markdown
  • Virtually no configuration or fiddling required

Usage

Turn on the module. Add a class of 'pretty-print' to any code or pre tags you wish to have highlighted. Optionally, you can enable the included input filter, and Code Prettify will apply the class for you behind the scenes; leaving you to ensure your code is wrapped in...wait for it, <code> tags!

If you're writing your content in markdown, place this input filter after it, and it will act on the code tags automatically generated by markdown, leaving you with super clean and tidy content.