CAL Syntax Highlighter for WordPress
This website like 20% of all new websites and blogs is run on the WordPress platform, as the subject is Dynamics NAV it helps to add code that could be copied and pasted, Dynamics NAV uses the C/AL Language (Client/server Application Language) otherwise known as CSide which stands for Client Server Integrated Environment.
There are a number of Syntax Highlighter plugins available for WordPress but no support for the C/AL Language, this means when code examples are added to posts the Syntax Highlighting is often coloured wrong, having done a little WordPress and php coding for my own projects I have created a Plugin to extend the Syntax Highlighter Evolved plugin by Alex Mills.
To use this Plugin you will need a WordPress website where you can load plugins, install the Syntax Highlighter Evolved Plugin, download and install my plugin “syntaxhighlighter-evolved-cside-brush” from the WordPress plugins or downloaded from the end of this post, then you are ready to go.
Load Plugins
Plugins > Add New, enter syntaxhighlighter into the searchbox Install and Activate the Syntax Highlighter Evolved Plugin by Alex Mills.
From the Plugins Menu upload, or Search for “syntaxhighlighter cside”, Install and Activate my Plugin which can also be downloaded from the end of this post.
Then you will have two plugins activated.
Using the Syntax Highlighter
The older versions of Navision did not have Syntax Highlighting just plain black text, the later versions have blue keywords and brown text within single quotes.
Indentation and Comments
In Dynamics NAV the Indentation is not a real TAB but a double space, when the C/AL code is pasted and saved it will lose the indentation, it is a shame but I have to save the post as draft and add the indentation to the code manually with spaces.
I have also coloured the Block comments, this feature I feed is missing in Dynamics NAV.
Syntax Highligher without the C/AL, Cside Plugin
CLEAR(PrinterSelection); IF NOT PrinterSelection.GET(USERID,ReportID) THEN IF NOT PrinterSelection.GET('',ReportID) THEN IF NOT PrinterSelection.GET(USERID,0) THEN IF PrinterSelection.GET('',0) THEN; EXIT(PrinterSelection."Printer Name");
With Shortcode cal, nav, navision, cside
//Comment String Example //Comment Block Example { IF NOT PrinterSelection.GET(USERID,ReportID) THEN IF NOT PrinterSelection.GET('',ReportID) THEN } CLEAR(PrinterSelection); IF NOT PrinterSelection.GET(USERID,ReportID) THEN IF NOT PrinterSelection.GET('',ReportID) THEN IF NOT PrinterSelection.GET(USERID,0) THEN IF PrinterSelection.GET('',0) THEN; EXIT(PrinterSelection."Printer Name");
With Language (Cside) and Title
CLEAR(PrinterSelection); IF NOT PrinterSelection.GET(USERID,ReportID) THEN IF NOT PrinterSelection.GET('',ReportID) THEN IF NOT PrinterSelection.GET(USERID,0) THEN IF PrinterSelection.GET('',0) THEN; EXIT(PrinterSelection."Printer Name");
With Language (Cside) ,Title and Collapsed Box
Click Title to Expand.
EXIT('GB Dynamics NAV 7.1');