Use the Drupal module GeSHi Filter for syntax highlighting

The Drupal module GeSHi Filter offers you a convenient way to display different code on your website (php, html, css, js, etc.). The GeShi Filter module provides a filter for source code syntax highlighting for a wide range of languages. At the time of this writing the GeSHi library supports highlighting for more than 200 programming languages and configuration syntaxes.

Important notes:

  • It is highly recommended to have a look at the README.txt of the module before starting with the installation and configuration
  • To make it work properly, the "Filter processing order" within the text formats used must be fine-tuned. As it seems there is no clear answer as to why, since the elements can be very different. In our experience the elements "Convert URLs into links", "Correct faulty and chopped off HTML" and "Convert line breaks into HTML" must come after "GeSHi filter" in the listed order. As it seems "Convert line breaks into HTML (i.e. and )" should be the last entry.
  • Valuable information regarding the configuration can be found in the tutorial Highlight Code With GeSHi Filter In Drupal 7
  • Using Drupal 7.33 and GeSHi Filter 7.x-1.2 there is a problem with the configuration of languages. One can see the enabled and disabled languages, but if one tries to change them, they data isn't written to the database. Workaround: Manual editing of table drup_variable in database. Just add the entries geshifilter_language_enabled_GESHI-LANGUAGE-CODE and geshifilter_language_tags_GESHI-LANGUAGE-CODE for the GESHI-LANGUAGE-CODEs you want to enable. Use the same content/structure as for an already enabled GESHI-LANGUAGE-CODEs.
  • PROBLEMS using PRE: Major issue with this method is that all right angle brackets must be HTML escaped, eg all < must be replaced with their HTML name "&lt". This will ensure correct rendering. Thus its recommended to replace PRE for example with CODE.

Drupal themes to be compared