From Blog

X++ syntax highlighting with WP-GeSHi-Highlight

While I was setting up this blog, I installed WP-GeSHi-Highlight for X++ syntax high lighting. I wrote about it here. At the end of that post I wrote that I would edit the CSS of the plugin to make it look more like the X++ Editor.

I make a few small changes, this is what I have come up with so far:

  1. /// <summary>
  2. /// This job is used as an X++ sample (From Wikipedia's Microsoft Dynamics AX page)
  3. /// </summary>
  4. public static void xppTest3(Args _args)
  5. {
  6.     UserInfo userInfo;
  7.     ttsbegin;
  8.     select forupdate userInfo
  9.         where != 'Admin'
  10.            && userInfo.RecId == 1234567890;
  11.     while (userInfo)
  12.     {
  13.         userInfo.enable = NoYes::No;
  14.         userInfo.update();
  15.         next userInfo;
  16.     }
  17.     ttscommit;
  18. }

and this is the same code in the MorfX editor in 2012.
X++ code example

The original CSS produced this result:

I removed the dot from the line numbers and make the numbers turquoise. I also made the line height less. If you by chance use WordPress to write about X++ and have the WP-GeSHi-Highlight plugin, you are welcome to the changes I made to wp-geshi-highlight.css. The changes are small, but it just makes me feel a bit more at home with the way the code is displayed.

X++ syntax highlighting for WordPress

I’m still setting up the blog and was looking for a syntax highlighter plugin for X++. I tried a few highly rated syntax highlighters. Most does not have X++ support, so I tried using C++ and Java. All of the plugins formatted the code nicely and made the comments green, but of course did not make X++ keywords like select and while blue.

I consider X++ to be a niche, so I was surprised to find WP-GeSHi-Highlight that has support for X++. It’s highly customizable with arguments and CSS.

The plugin uses GeSHi highlight system, a .php library for formatting syntax on the web. I saw two other WordPress plugins based on GeSHi, but haven’t tried them yet:
Developer Formatter

It displays X++ code in WordPress like this:

Here’s the same code in the MorfX editor in 2012:
X++ code example

I’m going to try it and see how it goes. I’ll probably also make a few changes to the CSS to see if I can make it look more like the MorfX editor. I’ve noticed that it does not make integers red or comments italics, as you can see above.

UPDATE: I changed the CSS so that it looks a bit more like the MorfX editor. You can download the updated CSS at the end of this post.