Syntax Highlighting : All About the Colorful Snippets


Syntax Highlighting is a method for coloring certain words and characters in a text depending on their importance in in an piece of code or snippet. If you are new to for blogging purpose, you might have seen in some websites, colored texts for PHP, , etc. languages and markups are used. So how these colored things appears and why we basically need them ? To explain this, here is the article on Syntax Highlighting.

 

Basics of Syntax Highlighting

 

Syntax highlighting is mainly used in text editors, like we previously we wrote about gedit for editing excellent documents, program and configuration files. Syntax Highlighting is based on language elements.

Syntax highlighting improves the readability and clears the structures in the text separating comments from the actual code and it also indicates typographical mistakes more quickly, because in many cases only typo creates the problem.

Wilfred Hansen, in 1969 first used practical Syntax Highlighter in the code editor Emily.

 

Resources and Information on Syntax Highlighting

 

Syntax Highlighting in Text Editors 

 

Windows, a great malware proof Operating System, has no Syntax Highlighting software shipped by default. However, most free UNIX like Operating System has basic text editors with Syntax Highlighting feature. Even, stripped down server OS versions of Linux has Syntax Highlighting feature, in our recent on Installing OpenPanel on Rackspace Cloud Server, we have used nano, a Text Editor which works in Command Line Interface (CLI) :

 

Syntax Highlighting in Nano

 

Gedit is one of the most powerful Syntax Highlighting text Editor.

 

Syntax Highlighting in web browser 

 

In most modern web browsers, like Opera, Mozilla Firefox, Google Chrome, Safari etc. has very good Syntax Highlighting feature while using the development related tools.

Please do not think that the fastest web browser named Internet Explorer has no Syntax Highlighting feature from the corollary that  Microsoft Windows by default has no Syntax Highlighting . It has a decade old Syntax Highlighting . That is better than having nothing like Notepad.


 

Syntax Highlighting in Web CMS like WordPress, Joomla!

 

GeSHi is a PHP based Generic Syntax Highlighter, which has been used in various Plugins. WP-Syntax is an age old WordPress Plugin that uses GeSHi.

 

Example of Syntax Highlighting

 

If I write this :

 

<?php

/**

* Example of Syntax Highlighting

*/

if ( !defined(‘WP_LOAD_IMPORTERS’) && !defined(‘DOING_CRON’) )
return;

require_once ABSPATH . ‘wp-admin/includes/import.php’;
require_once ABSPATH . ‘wp-admin/includes/admin.php’;

 

It is not possible to understand which is code part and which is not. But if I use WordPress default <pre> tag, it somewhat looks better :

 

<?php
/**
 * Example of Syntax Highlighting
 */
if ( !defined('WP_LOAD_IMPORTERS') && !defined('DOING_CRON') )
 return;
require_once ABSPATH . 'wp-admin/includes/import.php';
require_once ABSPATH . 'wp-admin/includes/admin.php';

 

Look now :

 

<?php
/**
 * Example of Syntax Highlighting
 */
if ( !defined('WP_LOAD_IMPORTERS') && !defined('DOING_CRON') )
 return;
require_once ABSPATH . 'wp-admin/includes/import.php';
require_once ABSPATH . 'wp-admin/includes/admin.php';

There are advanced Syntax Highlighting plugin and scripts which helps to see the code as plain text, copy in one click or print.
Signature


Incoming search terms:

Syntax Highlighting
0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.
About Abhishek

Abhishek Ghosh is an Orthopedic Surgeon, Inventor with 216 Patents, Current editor of The Customize Windows Media Group. You can follow and know more about Dr. +Abhishek Ghosh on Google Plus and follow on Twitter as @AbhishekCTRL.

Speak Your Mind

*