Displaying Code in WordPress

I often have the need to display code within this blog – whether it’s JavaScript, PHP, XHTML or something else.

There are many plugins available that will display any such code in a nice manner – usually with syntax highlighting – but, as yet, I’ve been unable to find one that doesn’t fulfil my requirements. And personally, I don’t think my requirements are that much.

Showing the code in a fixed font, with a decent line wrapping facility and the ability to display spaces and/or tabs, I don’t think, is a big list of needs. That list doesn’t even include the ubiquitous syntax highlighting.

In the end I created a half-arsed version of my own. In fact, it’s not even a plugin – just simply some CSS for displaying the code in reasonable manner. Unfortunately, it doesn’t get around the line wrapping problem.

So, imagine my surprise to come across a plugin the other day that seemed to resolve all these problems. And it does Syntax Highlighting. I had some initial problems, which involved me having to move my aforementioned CSS, and then, with no further testing, I started busily converting my posts to the new system. Note, me specifically mentioning my lack of testing. Because, yes, after changing lots of pages and posts, I realised that it wouldn’t work with spaced or tabs, so all lines of code were aligned down the left hand side of the screen. Bah. And I can’t find a solution, so I’m in the process of putting it all back to how it was.

If ANYBODY knows a plugin that will do what I’m after, then please let me know!

Talk to me!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from David Artiss

Subscribe now to keep reading and get access to the full archive.

Continue reading