Updating the blog tool set today, I got a little tired of the vanilla code commands.


<pre><code></code></pre>

There has to be a better way, and of course there is.

I settled on Prism Syntax Highlighter Plugin that is available from the wordpress plugins search –

Prism Syntax Highlighter

Prism Syntax Highlighter for WordPress

http://prismjs.com/

It installs in a few simple steps:

1. Install the plugin via the wordpress plugins menu. Search for it, click install and done.

2. Go to the prismjs.com website and download the javascript and the theme css file. Just select the boxes for the code you want prism to be able to highlight. I also clicked the line numbers and show language plugin. http://prismjs.com/download.html

3. Open up an ftp session and go to /wp-content/uploads/. Create a folder called “prism” and upload the script and css file from step 2. While you’re in ftp – change the permission of these two files to 744 – owner full rights, group read, everyone read. FileZilla ftp client does this seamlessly.

4. Now you’re basically set. You can edit the css file to change colors and all that, but lets look at some example code.

Example 1:

Calling the module – data-language calls the show language plugin.    class=”language-xxx” calls the language.   I have languages such as bash, html, powershell installed from the checkboxes in step 2.


<pre class="data-language"><code class="language-powershell">
...sample code...
</code></pre>

Result:


Import-AzurePublishSettingsFile  
Get-Date -Format "DD/MM/YYYY HH:MM"

Example 1:

Calling the module – line-numbers to show the line numbers module.


<pre class="line-numbers"><code class="language-bash">
...sample code...
</code></pre>

Result:


#Bash_Profile
# ii: display useful host related information
# -------------------------------------------------------------------
ii() {
echo -e "\nYou are logged on ${RED}$HOST"
echo -e "\nAdditional information:$NC " ; uname -a
echo -e "\n${RED}Users logged on:$NC " ; w -h
echo -e "\n${RED}Current date :$NC " ; date
echo -e "\n${RED}Machine stats :$NC " ; uptime
#echo -e "\n${RED}DNS Configuration:$NC " ; scutil --dns
echo
}