A small PHP update to GeSHi


The faithful old GeSHi Syntax Highlighter hasn't seen an update in a many a long year. It's a tried and trusted way to do server-side code highlighting - turning a myriad of programming languages into beautiful HTML & CSS.

A few weeks ago, I noticed someone had proposed an update to its HTML rendering. The changes were mostly adding in new element names.

PHP has been updated several times since GeSHi was last updated, so I thought I'd do the same. Here's an update to the PHP highlighter.

Getting all the current PHP functions was fairly simple:

 PHP$functions = get_defined_functions();
$builtInFunctions = $functions['internal'];
sort($builtInFunctions);
foreach ( $builtInFunctions as $key => $value ) {
   echo "'{$value}', "; 
}

Now I'm wondering if there's a better code highlighter. Here's what I'm looking for:

  • Server-side. I don't want to clutter the web with JavaScript.
  • PHP only. I don't want to add something more complicated to my tech stack.
  • WordPress for preference (but not blocks-only). Although I can build around a library.
  • Accessible colours. GeSHi's style-sheet doesn't always meet WCAG.
  • Actively maintained. If it hasn't been updated in 2 years, it's probably broken.
  • Somewhat hackable. I like to add a bit of semantic fluff around the output.

Any thoughts?


Share this post on…

What links here from around this blog?

  1. The HTML5 Logo.Using Tempest Highlight with WordPress

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

See allowed HTML elements: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <p> <pre> <br> <img src="" alt="" title="" srcset="">