WP-GeSHi-Highlight — syntax highlighting via clean, small, and valid (X)HTML

plugin banner

Fast syntax highlighting for many languages. Clean, small, and valid (X)HTML. Highly&easily configurable.

Author:Dr. Jan-Philip Gehrcke (profile at wordpress.org)
WordPress version required:3.0
WordPress version tested:6.2
Plugin version:1.4.3
Added to WordPress repository:22-11-2010
Last updated:30-04-2023
Rating, %:82
Rated by:9
Plugin URI:https://gehrcke.de/wp-geshi-highlight
Total downloads:30 552
Active installs:600+
plugin download
Click to start download

Live demo

• Highlights:

  • Supports 259 languages.
  • Server-side. Saves bandwidth, latency, and battery compared to client-side rendering.
  • Near-zero load on the backend. With a caching solution this does not affect your page load time at all.
  • Line numbering. If you want to (no vertical displacements between code line and line number).
  • Default style was tested with more than 20 themes, including Twenty Ten to Fifteen, and tweaked based on a bunch of user feedback.
  • If you’d like to tweak the style: just provide your own CSS file. Styles are highly & easily configurable.
  • Per-block styles: each code block on a single page can be styled on its own (if that is something you would liked to do).
  • Clean, small and valid HTML output.
  • Well-documented source code using modern WordPress API calls.
  • I have maintained this plugin for several years and I plan to continue to provide support.
  • Based on GeSHi, a reliable and well-established PHP highlighting engine, used by popular community forum applications such as phpBB or wiki applications such as Dokuwiki or MediaWiki.

WP-GeSHi-Highlight works as a drop-in replacement for WP-Syntax, which does not seem to be maintained anymore (as of 2015). Make the switch, it should just work (let me know how it went)!

• Usage:

WordPress 5 users: for now I have tested this plugin only with the Classical Editor. Gutenberg is not yet supported (it may work though, let me know).

Recommendation: use the “Text” (raw) editor. Do not use the “Visual” editor. Switching between both may corrupt the contents of your code blocks.

In the text editor insert code blocks as pre blocks, and use the lang argument to define the language of the code snippet:

<pre lang="language">

A short example for the bash language:

<pre lang="bash">
    $ dd if=/dev/zero of=image.ext3 bs=1M count=10000 oflag=append conv=notrunc

Publish/preview, and have a look at the result!

Also check out the reference documentation for all available options. You can find it on the plugin’s website. Note that more usage examples can be found on the demo website.

• Issues:

A bunch of websites have used this plugin for years, and it seems to serve its purpose well. If you find an issue please let me know: drop a mail or leave a comment.

• Theme compatibility of the default style sheet:

The default style sheet was tested with recent versions of all official themes (Twenty Ten to Twenty Fifteen), and with a large range of non-official themes such as Vantage, Customizr, ColorWay, Zerif Lite, Responsive, Storefront, Virtue, evolve, Make, Sparkling, Spacious, Enigma, Sydney, Point, Interface, SinglePage.

Certain themes might define styles with a high specificity that negatively affect the visual code block appearance. It is difficult to impossible to anticipate all these cases in advance, so I expect this to happen in rare cases (the past has proven that these things happen). So, I need you to look out for these situations, and please report them!